Repository: microsoft/ALAppExtensions
Pull request #28301: [BugFix] "Swiss QR-Bill Incoming Doc" UpdatePurchDocFromIncDoc Don't Override Purchase Field
Author: login: PeterDurrer
Labels: name: processing-PR
description: The PR is currently being reviewed
name: linked
description: Issue is linked to a Azure Boards work item
name: Finance
description: GitHub request for Finance area
Created: 2025-03-03T08:18:44Z | Merged: 2025-03-26T09:00:53Z

<!-- Thank you for submitting a Pull Request. If you're new to contributing to AlAppExtensions please read our pull request guideline below
* https://github.com/microsoft/ALAppExtensions/blob/main/CONTRIBUTING.md
-->
#### Summary <!-- Provide a general summary of your changes -->
Don't Override Purchase Field if empty in QRCode

#### Work Item(s) <!-- Add the issue number here after the #. The issue needs to be open and approved. Submitting PRs with no linked issues or unapproved issues is highly discouraged. -->
Fixes #28300 

Fixes [AB#568198](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/568198)








Linked issue #28300: [Bug]: "Swiss QR-Bill Incoming Doc" UpdatePurchDocFromIncDoc  Override Purchase Fields with empty Values from QRCode
### Describe the issue

If you scan a Swiss Qr Code for a purchase, with empty optional values ??????not filled in the QRCode, these will clear the purchase header values.

### Expected behavior

If you scan a Swiss Qr Code for a purchase, with empty optional values ??????not filled in the QRCode, don't override the purchase header values.

### Steps to reproduce

Open a new Purchase Invoice
Fill the Vendor and Check or Fill the Fields:
    "Posting Description"
    "Payment Reference"
    "Vendor Invoice No."
    "Document Date"

Scan the QR Code (With empty "QR-Bill Unstr. Message","QR-Bill Reference No.","Billing Information")

Check the Fields:
    "Posting Description" --> actual Empty, expected not changed
    "Payment Reference" --> actual Empty, expected not changed
    "Vendor Invoice No." --> actual Empty, expected not changed
    "Document Date" --> actual Empty, expected not changed
 

### Additional context

_No response_

### I will provide a fix for a bug

- [x] I will provide a fix for a bug
Internal work item: [AB#568198](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/568198)
Linked issue comments: user: login: JesperSchulz
created_at: 2025-03-04T14:35:42Z
body: @altotovi, could you triage this one?
author_association: CONTRIBUTOR
user: login: JesperSchulz
created_at: 2025-03-05T12:59:48Z
body: @PeterDurrer, we're unable to triage your issue at the moment. As it is a regulatory requirement, we need specific people to give the "go ahead", but they are currently unavailable. We'll have to get back to you on this one a bit later. Thank you for your patience.
author_association: CONTRIBUTOR
user: login: JesperSchulz
created_at: 2025-03-06T12:11:47Z
body: Luckily I was able to find someone to look into your issue, and it got approved 😊 Please continue your PR!
author_association: CONTRIBUTOR
user: login: PeterDurrer
created_at: 2025-03-26T09:24:34Z
body: @JesperSchulz  thanks for close in which version is this available
author_association: CONTRIBUTOR
user: login: JesperSchulz
created_at: 2025-03-27T14:04:34Z
body: Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 32238.
author_association: CONTRIBUTOR
user: login: JesperSchulz
created_at: 2025-04-04T10:31:29Z
body: @PeterDurrer, normally this would ship with version 27. I'm making an exception though and will backport for release with 26.1. At some point I have to stop making these exceptions though, as the workload is too high.
author_association: CONTRIBUTOR
user: login: PeterDurrer
created_at: 2025-04-04T10:44:23Z
body: > [@PeterDurrer](https://github.com/PeterDurrer), normally this would ship with version 27. I'm making an exception though and will backport for release with 26.1. At some point I have to stop making these exceptions though, as the workload is too high.

@JesperSchulz  Thank you, I understand. But as partners, we can create bug reports in the MS-AL repos. If we can't backport them in the future, I always have to create a ticket in the Microsoft Partner Support Portal. And then you'll have more work developing bug fixes. We can't always wait until the next major release. Can we switch development for events and bug fixes to NextMinor? That would be beneficial for both you and us. BCIdeas, i.e., new features, should continue to be programmed on NextMajor. Would there be a way to do this, for example, with two main branches (main-->NextMajor and main2-->NextMinor)?
author_association: CONTRIBUTOR
user: login: JesperSchulz
created_at: 2025-04-04T10:56:44Z
body: The problem as such only exists for this repository (ALAppExtensions), as it's only a copy of our internal repository for 1st party apps. The changes you provide here, I have to copy to our master branch. If you request a backport, I have to copy it to our release branch too. With all the bookkeeping etc. that sets me back about half an hour. It's fine for a PR or two, but if I would have to backport hundreds of PRs, then that would turn into a considerable time investment.

This is one of the reasons why we initially did not accept extensibility requests as pull requests on GitHub. The process overhead is too large.

For the new repo, being BCApps, you can do backport to the release branch yourself (e.g. releases/26.x). That should help eliminating the bottleneck that is... me 😊
author_association: CONTRIBUTOR
user: login: JesperSchulz
created_at: 2025-04-08T07:27:19Z
body: Ready for release with 26.1.
author_association: CONTRIBUTOR
user: login: JesperSchulz
created_at: 2025-04-08T07:27:30Z
body: Availability update: We will publish a fix for this issue in the next update for release 26.

Build ID to track: 32790.
author_association: CONTRIBUTOR

Diff:
diff --git a/Apps/CH/SwissQRBill/app/src/IncomingDocuments/SwissQRBillIncomingDoc.Codeunit.al b/Apps/CH/SwissQRBill/app/src/IncomingDocuments/SwissQRBillIncomingDoc.Codeunit.al
index 58d786831b..e3b4f1d858 100644
--- a/Apps/CH/SwissQRBill/app/src/IncomingDocuments/SwissQRBillIncomingDoc.Codeunit.al
+++ b/Apps/CH/SwissQRBill/app/src/IncomingDocuments/SwissQRBillIncomingDoc.Codeunit.al
@@ -191,9 +191,12 @@ codeunit 11516 "Swiss QR-Bill Incoming Doc"
             if IncomingDocument."Document Date" <> 0D then
                 Validate("Document Date", IncomingDocument."Document Date");
 
-            Validate("Posting Description", CopyStr(IncomingDocument."Swiss QR-Bill Unstr. Message", 1, MaxStrLen("Posting Description")));
-            Validate("Payment Reference", DelChr(IncomingDocument."Swiss QR-Bill Reference No."));
-            Validate("Vendor Invoice No.", IncomingDocument."Vendor Invoice No.");
+            if IncomingDocument."Swiss QR-Bill Unstr. Message" <> '' then
+                Validate("Posting Description", CopyStr(IncomingDocument."Swiss QR-Bill Unstr. Message", 1, MaxStrLen("Posting Description")));
+            if IncomingDocument."Swiss QR-Bill Reference No." <> '' then
+                Validate("Payment Reference", DelChr(IncomingDocument."Swiss QR-Bill Reference No."));
+            if IncomingDocument."Vendor Invoice No." <> '' then
+                Validate("Vendor Invoice No.", IncomingDocument."Vendor Invoice No.");
 
             "Swiss QR-Bill IBAN" := IncomingDocument."Vendor IBAN";
             "Swiss QR-Bill Currency" := IncomingDocument."Currency Code";
diff --git a/Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al b/Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al
index 2e3010712b..644ab62e60 100644
--- a/Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al
+++ b/Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al
@@ -1505,6 +1505,116 @@ codeunit 148096 "Swiss QR-Bill Test Purchases"
         SwissQRBillTestLibrary.ClearVendor(PurchaseHeader."Buy-from Vendor No.");
     end;
 
+    [Test]
+    [HandlerFunctions('QRBillScanMPH,MessageHandler')]
+    procedure InvoiceScanQRBillWithOptionalInfo()
+    var
+        PurchaseHeader: Record "Purchase Header";
+        VendorNo: Code[20];
+        VendorBankAccountNo: Code[20];
+        QRCodeText: Text;
+        IBAN: Code[50];
+        BillInfo: Text;
+        PurchDocVendorInvNo: Code[35];
+        PurchDocPayRef: Code[50];
+        PurchDocPostingDescr: Text[100];
+        QRBillVendInvNo: Code[50];
+        QRBillPayRef: Code[50];
+        QRBillPostingDescr: Text;
+    begin
+        // [SCENARIO 568198] Scan QR-Bill from Purchase Invoice card when all Billing details are specified.
+        Initialize();
+
+        // [GIVEN] QR-Bill text with Billing Information with Unstructured Message "MSG1", Payment Reference "REF1" and Invoice No. "INV1".
+        IBAN := SwissQRBillTestLibrary.GetRandomIBAN();
+        QRBillPostingDescr := LibraryUtility.GenerateGUID();
+        QRBillPayRef := SwissQRBillTestLibrary.GetRandomQRPaymentReference();
+        QRBillVendInvNo := LibraryUtility.GenerateGUID();
+        BillInfo := 'S1/10/' + QRBillVendInvNo + '/11/231015';
+        SwissQRBillTestLibrary.CreateVendorWithBankAccount(VendorNo, VendorBankAccountNo, IBAN);
+        QRCodeText := SwissQRBillTestLibrary.CreateQRCodeText(IBAN, 123.45, 'CHF', QRBillPayRef, QRBillPostingDescr, BillInfo);
+
+        // [GIVEN] Purchase Invoice with Posting Description "MSG2", Payment Reference "REF2", Vendor Invoice No. "INV2".
+        PurchDocPostingDescr := LibraryUtility.GenerateGUID();
+        PurchDocPayRef := SwissQRBillTestLibrary.GetRandomQRPaymentReference();
+        PurchDocVendorInvNo := LibraryUtility.GenerateGUID();
+        CreatePurchaseHeader(PurchaseHeader, DocumentType::Invoice, VendorNo, false, PurchDocPayRef, PurchDocVendorInvNo, PurchDocPostingDescr);
+
+        // [WHEN] Run scan QR-Bill from Purhchase Invoice card on the given QR-Bill text.
+        LibraryVariableStorage.Enqueue(QRCodeText);
+        ScanToInvoice(PurchaseHeader);
+
+        // [THEN] QR-Bill billing information was set on Purchase Invoice.
+        // [THEN] Posting Description = "MSG1", Payment Reference = "REF1", Vendor Invoice No. = "INV1".
+        Assert.ExpectedMessage(ImportSuccessMsg, LibraryVariableStorage.DequeueText());
+        PurchaseHeader.Get(PurchaseHeader."Document Type", PurchaseHeader."No.");
+        Assert.AreEqual(QRBillPostingDescr, PurchaseHeader."Posting Description", 'Incorrect Posting Description');
+        Assert.AreEqual(QRBillPayRef, PurchaseHeader."Payment Reference", 'Incorrect Payment Reference');
+        Assert.AreEqual(QRBillVendInvNo, PurchaseHeader."Vendor Invoice No.", 'Incorrect Vendor Invoice No.');
+
+        // tear down
+        VoidInvoice(PurchaseHeader);
+        PurchaseHeader.Delete();
+        SwissQRBillTestLibrary.ClearVendor(VendorNo);
+
+        LibraryVariableStorage.AssertEmpty();
+    end;
+
+    [Test]
+    [HandlerFunctions('QRBillScanMPH,MessageHandler')]
+    procedure InvoiceScanQRBillWithoutOptionalInfo()
+    var
+        PurchaseHeader: Record "Purchase Header";
+        VendorNo: Code[20];
+        VendorBankAccountNo: Code[20];
+        QRCodeText: Text;
+        IBAN: Code[50];
+        BillInfo: Text;
+        PurchDocVendorInvNo: Code[35];
+        PurchDocPayRef: Code[50];
+        PurchDocPostingDescr: Text[100];
+        QRBillVendInvNo: Code[50];
+        QRBillPayRef: Code[50];
+        QRBillPostingDescr: Text;
+    begin
+        // [SCENARIO 568198] Scan QR-Bill from Purchase Invoice card when optional Billing details are not specified.
+        Initialize();
+
+        // [GIVEN] QR-Bill text with Billing Information with empty Unstructured Message, Payment Reference and Invoice No..
+        IBAN := SwissQRBillTestLibrary.GetRandomIBAN();
+        QRBillPostingDescr := '';
+        QRBillPayRef := '';
+        QRBillVendInvNo := '';
+        BillInfo := 'S1/10/' + QRBillVendInvNo + '/11/231015';
+        SwissQRBillTestLibrary.CreateVendorWithBankAccount(VendorNo, VendorBankAccountNo, IBAN);
+        QRCodeText := SwissQRBillTestLibrary.CreateQRCodeText(IBAN, 123.45, 'CHF', QRBillPayRef, QRBillPostingDescr, BillInfo);
+
+        // [GIVEN] Purchase Invoice with Posting Description "MSG2", Payment Reference "REF2", Vendor Invoice No. "INV2".
+        PurchDocPostingDescr := LibraryUtility.GenerateGUID();
+        PurchDocPayRef := SwissQRBillTestLibrary.GetRandomQRPaymentReference();
+        PurchDocVendorInvNo := LibraryUtility.GenerateGUID();
+        CreatePurchaseHeader(PurchaseHeader, DocumentType::Invoice, VendorNo, false, PurchDocPayRef, PurchDocVendorInvNo, PurchDocPostingDescr);
+
+        // [WHEN] Run scan QR-Bill from Purhchase Invoice card on the given QR-Bill text.
+        LibraryVariableStorage.Enqueue(QRCodeText);
+        ScanToInvoice(PurchaseHeader);
+
+        // [THEN] QR-Bill billing information was not overridden in Purchase Invoice with empty values.
+        // [THEN] Posting Description = "MSG2", Payment Reference = "REF2", Vendor Invoice No. = "INV2".
+        Assert.ExpectedMessage(ImportSuccessMsg, LibraryVariableStorage.DequeueText());
+        PurchaseHeader.Get(PurchaseHeader."Document Type", PurchaseHeader."No.");
+        Assert.AreEqual(PurchDocPostingDescr, PurchaseHeader."Posting Description", 'Incorrect Posting Description');
+        Assert.AreEqual(PurchDocPayRef, PurchaseHeader."Payment Reference", 'Incorrect Payment Reference');
+        Assert.AreEqual(PurchDocVendorInvNo, PurchaseHeader."Vendor Invoice No.", 'Incorrect Vendor Invoice No.');
+
+        // tear down
+        VoidInvoice(PurchaseHeader);
+        PurchaseHeader.Delete();
+        SwissQRBillTestLibrary.ClearVendor(VendorNo);
+
+        LibraryVariableStorage.AssertEmpty();
+    end;
+
     local procedure Initialize()
     begin
         LibraryVariableStorage.Clear();
@@ -1567,6 +1677,16 @@ codeunit 148096 "Swiss QR-Bill Test Purchases"
         PurchaseHeader.Modify();
     end;
 
+    local procedure CreatePurchaseHeader(var PurchaseHeader: Record "Purchase Header"; DocumentType: Enum "Purchase Document Type"; VendorNo: Code[20]; QRBill: Boolean; PmtRef: Code[50]; VendorInvoiceNo: Code[35]; PostingDescription: Text[100])
+    begin
+        LibraryPurchase.CreatePurchHeader(PurchaseHeader, DocumentType, VendorNo);
+        PurchaseHeader."Swiss QR-Bill" := QRBill;
+        PurchaseHeader."Vendor Invoice No." := VendorInvoiceNo;
+        PurchaseHeader."Payment Reference" := PmtRef;
+        PurchaseHeader."Posting Description" := PostingDescription;
+        PurchaseHeader.Modify();
+    end;
+
     local procedure CreateJournalLine(var GenJournalLine: Record "Gen. Journal Line"; VendorNo: Code[20]; QRBill: Boolean; PmtRef: Code[50])
     var
         SwissQRBillSetup: Record "Swiss QR-Bill Setup";


Reviews:
user: login: AleksanderGladkov
state: CHANGES_REQUESTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-10T15:29:02Z
user: login: AleksanderGladkov
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T20:00:07Z
user: login: JesperSchulz
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T09:00:47Z

Review comments:
diff_hunk: @@ -1749,8 +1853,11 @@ codeunit 148096 "Swiss QR-Bill Test Purchases"
         PurchaseHeader.TestField("Swiss QR-Bill IBAN", IBAN);
         PurchaseHeader.TestField("Swiss QR-Bill Unstr. Message", UnstrMsg);
         PurchaseHeader.TestField("Swiss QR-Bill Bill Info", BillInfo);
+        PurchaseHeader.TestField("Posting Date", WorkDate());
path: Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al
user: login: AleksanderGladkov
body: @PeterDurrer I think it is not necessary to test the Posting and Document dates here - you don't have changes related to them.
created_at: 2025-03-10T14:20:21Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1389,6 +1389,100 @@ codeunit 148096 "Swiss QR-Bill Test Purchases"
         LibraryVariableStorage.AssertEmpty();
     end;
 
+    [Test]
+    [HandlerFunctions('QRBillScanMPH,MessageHandler')]
+    procedure InvoiceScanQRBillOptionalInfos()
+    var
+        PurchaseHeader: Record "Purchase Header";
+        VendorNo: Code[20];
+        VendorBankAccountNo: Code[20];
+        QRCodeText: Text;
+        PaymentReference: Code[50];
+        IBAN: Code[50];
+        BillInfo: Text;
+        OldVendorInvoiceNo: Code[50];
+        OldPostingDescription: Text;
+    begin
+        // [FEATURE] [UI]
+        // [SCENARIO 467388] Scan QR-Bill from Purchase Invoice card when Document Date is specified in Billing Information.
path: Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al
user: login: AleksanderGladkov
body: @PeterDurrer Please update the description for the scenario.
Also the scenario ID should be 568198 - it is our internal bug id which you can find in the PR description (Fixes AB#**123456**).
created_at: 2025-03-10T15:02:49Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1389,6 +1389,100 @@ codeunit 148096 "Swiss QR-Bill Test Purchases"
         LibraryVariableStorage.AssertEmpty();
     end;
 
+    [Test]
+    [HandlerFunctions('QRBillScanMPH,MessageHandler')]
+    procedure InvoiceScanQRBillOptionalInfos()
+    var
+        PurchaseHeader: Record "Purchase Header";
+        VendorNo: Code[20];
+        VendorBankAccountNo: Code[20];
+        QRCodeText: Text;
+        PaymentReference: Code[50];
+        IBAN: Code[50];
+        BillInfo: Text;
+        OldVendorInvoiceNo: Code[50];
+        OldPostingDescription: Text;
+    begin
+        // [FEATURE] [UI]
+        // [SCENARIO 467388] Scan QR-Bill from Purchase Invoice card when Document Date is specified in Billing Information.
+        Initialize();
+
+        // [GIVEN] QR-Bill text with Billing Information with Document Date = 15.10.2023.
+        IBAN := SwissQRBillTestLibrary.GetRandomIBAN();
+        PaymentReference := SwissQRBillTestLibrary.GetRandomQRPaymentReference();
+        BillInfo := 'S1/10/DOCNO123/11/231015';
+        SwissQRBillTestLibrary.CreateVendorWithBankAccount(VendorNo, VendorBankAccountNo, IBAN);
+        QRCodeText := SwissQRBillTestLibrary.CreateQRCodeText(IBAN, 123.45, 'CHF', PaymentReference, 'Unstr Msg', BillInfo);
+        OldVendorInvoiceNo := 'DefaultInvoice0001';
path: Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al
user: login: AleksanderGladkov
body: @PeterDurrer Better to use LibraryUtility.GenerateGUID() function istead of hardcoded value.
That function will generate text like GU000001.
created_at: 2025-03-10T15:11:34Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1389,6 +1389,100 @@ codeunit 148096 "Swiss QR-Bill Test Purchases"
         LibraryVariableStorage.AssertEmpty();
     end;
 
+    [Test]
+    [HandlerFunctions('QRBillScanMPH,MessageHandler')]
+    procedure InvoiceScanQRBillOptionalInfos()
+    var
+        PurchaseHeader: Record "Purchase Header";
+        VendorNo: Code[20];
+        VendorBankAccountNo: Code[20];
+        QRCodeText: Text;
+        PaymentReference: Code[50];
+        IBAN: Code[50];
+        BillInfo: Text;
+        OldVendorInvoiceNo: Code[50];
+        OldPostingDescription: Text;
+    begin
+        // [FEATURE] [UI]
+        // [SCENARIO 467388] Scan QR-Bill from Purchase Invoice card when Document Date is specified in Billing Information.
+        Initialize();
+
+        // [GIVEN] QR-Bill text with Billing Information with Document Date = 15.10.2023.
path: Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al
user: login: AleksanderGladkov
body: @PeterDurrer Please update the GIVEN/WHEN/THEN sections according to what you test.
created_at: 2025-03-10T15:12:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1389,6 +1389,100 @@ codeunit 148096 "Swiss QR-Bill Test Purchases"
         LibraryVariableStorage.AssertEmpty();
     end;
 
+    [Test]
+    [HandlerFunctions('QRBillScanMPH,MessageHandler')]
+    procedure InvoiceScanQRBillOptionalInfos()
+    var
+        PurchaseHeader: Record "Purchase Header";
+        VendorNo: Code[20];
+        VendorBankAccountNo: Code[20];
+        QRCodeText: Text;
+        PaymentReference: Code[50];
+        IBAN: Code[50];
+        BillInfo: Text;
+        OldVendorInvoiceNo: Code[50];
+        OldPostingDescription: Text;
+    begin
+        // [FEATURE] [UI]
+        // [SCENARIO 467388] Scan QR-Bill from Purchase Invoice card when Document Date is specified in Billing Information.
+        Initialize();
+
+        // [GIVEN] QR-Bill text with Billing Information with Document Date = 15.10.2023.
+        IBAN := SwissQRBillTestLibrary.GetRandomIBAN();
+        PaymentReference := SwissQRBillTestLibrary.GetRandomQRPaymentReference();
+        BillInfo := 'S1/10/DOCNO123/11/231015';
+        SwissQRBillTestLibrary.CreateVendorWithBankAccount(VendorNo, VendorBankAccountNo, IBAN);
+        QRCodeText := SwissQRBillTestLibrary.CreateQRCodeText(IBAN, 123.45, 'CHF', PaymentReference, 'Unstr Msg', BillInfo);
+        OldVendorInvoiceNo := 'DefaultInvoice0001';
+        OldPostingDescription := 'Defaul Posting Description';
+
+        // [GIVEN] Purchase Invoice.
+        CreatePurchaseHeader(PurchaseHeader, DocumentType::Invoice, OldVendorInvoiceNo, false, PaymentReference,OldPostingDescription);
+
+        // [WHEN] Run scan QR-Bill from Purhchase Invoice card on the given QR-Bill text.
+        LibraryVariableStorage.Enqueue(QRCodeText);
+        ScanToInvoice(PurchaseHeader);
+
+        // [THEN] Posting Date was set to WorkDate, Document Date was set to 15.10.2023 in Purchase Invoice.
+        Assert.ExpectedMessage(ImportSuccessMsg, LibraryVariableStorage.DequeueText());
+        PurchaseHeader.Get(PurchaseHeader."Document Type", PurchaseHeader."No.");
+        VerifyPurchDoc(PurchaseHeader, true, PaymentReference, 'DOCNO123', 123.45, 'CHF', IBAN, 'Unstr Msg', BillInfo, 'Unstr Msg', Format(20231015D));
path: Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al
user: login: AleksanderGladkov
body: @PeterDurrer It is hard to understand how you test Vendor Invoice No. and Posting Description. And you don't test PaymentReference.
You need to have: 3 varilables with old values (vendor invoice no, posting description, payment reference) and 3 variables with new values.
Then you create QR code with new values and Purchase invoice with old values, and finally verify that new values were written to Purchase Invoice.
Also I would give other names to those variables, because it is not clear what old and new mean, for example PurchDocVendorInvNo, PurchDocPayRef, PurchDocPostingDescr and QRBillVendInvNo, QRBillPayRef, QRBillPostingDescr.

created_at: 2025-03-10T15:27:05Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1389,6 +1389,100 @@ codeunit 148096 "Swiss QR-Bill Test Purchases"
         LibraryVariableStorage.AssertEmpty();
     end;
 
+    [Test]
+    [HandlerFunctions('QRBillScanMPH,MessageHandler')]
+    procedure InvoiceScanQRBillOptionalInfos()
+    var
+        PurchaseHeader: Record "Purchase Header";
+        VendorNo: Code[20];
+        VendorBankAccountNo: Code[20];
+        QRCodeText: Text;
+        PaymentReference: Code[50];
+        IBAN: Code[50];
+        BillInfo: Text;
+        OldVendorInvoiceNo: Code[50];
+        OldPostingDescription: Text;
+    begin
+        // [FEATURE] [UI]
+        // [SCENARIO 467388] Scan QR-Bill from Purchase Invoice card when Document Date is specified in Billing Information.
+        Initialize();
+
+        // [GIVEN] QR-Bill text with Billing Information with Document Date = 15.10.2023.
+        IBAN := SwissQRBillTestLibrary.GetRandomIBAN();
+        PaymentReference := SwissQRBillTestLibrary.GetRandomQRPaymentReference();
+        BillInfo := 'S1/10/DOCNO123/11/231015';
+        SwissQRBillTestLibrary.CreateVendorWithBankAccount(VendorNo, VendorBankAccountNo, IBAN);
+        QRCodeText := SwissQRBillTestLibrary.CreateQRCodeText(IBAN, 123.45, 'CHF', PaymentReference, 'Unstr Msg', BillInfo);
+        OldVendorInvoiceNo := 'DefaultInvoice0001';
+        OldPostingDescription := 'Defaul Posting Description';
+
+        // [GIVEN] Purchase Invoice.
+        CreatePurchaseHeader(PurchaseHeader, DocumentType::Invoice, OldVendorInvoiceNo, false, PaymentReference,OldPostingDescription);
+
+        // [WHEN] Run scan QR-Bill from Purhchase Invoice card on the given QR-Bill text.
+        LibraryVariableStorage.Enqueue(QRCodeText);
+        ScanToInvoice(PurchaseHeader);
+
+        // [THEN] Posting Date was set to WorkDate, Document Date was set to 15.10.2023 in Purchase Invoice.
+        Assert.ExpectedMessage(ImportSuccessMsg, LibraryVariableStorage.DequeueText());
+        PurchaseHeader.Get(PurchaseHeader."Document Type", PurchaseHeader."No.");
+        VerifyPurchDoc(PurchaseHeader, true, PaymentReference, 'DOCNO123', 123.45, 'CHF', IBAN, 'Unstr Msg', BillInfo, 'Unstr Msg', Format(20231015D));
+
+        // tear down
+        VoidInvoice(PurchaseHeader);
+        PurchaseHeader.Delete();
+        SwissQRBillTestLibrary.ClearVendor(VendorNo);
+
+        LibraryVariableStorage.AssertEmpty();
+    end;
+
+    [Test]
+    [HandlerFunctions('QRBillScanMPH,MessageHandler')]
+    procedure InvoiceScanQRBillWithoutOptionalInfos()
path: Apps/CH/SwissQRBill/test/src/SwissQRBillTestPurchases.Codeunit.al
user: login: AleksanderGladkov
body: @PeterDurrer Please fix the issues that I mentioned for the previous test.
created_at: 2025-03-10T15:27:44Z
author_association: CONTRIBUTOR

PR comments:
user: login: AleksanderGladkov
created_at: 2025-03-03T12:17:06Z
body: @PeterDurrer You will need to create test(s) for this change.
See the Apps\CH\SwissQRBill\test\src folder with existing tests and add yours.
author_association: CONTRIBUTOR
user: login: PeterDurrer
created_at: 2025-03-03T12:23:13Z
body: > @PeterDurrer You will need to create test(s) for this change. See the Apps\CH\SwissQRBill\test\src folder with existing tests and add yours.

@AleksanderGladkov  i will made test if the Issue is approved, this PR is in draft that you can see in the Issue what i want to do.
author_association: CONTRIBUTOR
user: login: PeterDurrer
created_at: 2025-03-07T15:12:02Z
body: > @PeterDurrer You will need to create test(s) for this change. See the Apps\CH\SwissQRBill\test\src folder with existing tests and add yours.

@AleksanderGladkov  i have now add the Test.
author_association: CONTRIBUTOR
user: login: PeterDurrer
created_at: 2025-03-11T08:31:11Z
body: > > @PeterDurrer You will need to create test(s) for this change. See the Apps\CH\SwissQRBill\test\src folder with existing tests and add yours.
> 
> @AleksanderGladkov i have now add the Test.

@AleksanderGladkov  i have refactore my tests, New only add two new sceanrios without changed the other tests and only check the relevant fields for this change.
author_association: CONTRIBUTOR
user: login: AleksanderGladkov
created_at: 2025-03-12T19:59:50Z
body: @PeterDurrer I updated the tests according to internal best practices + fix compilation errors, and commited the changes.
If you are going to contribute in future, please read this [contribution guide](https://ssosic.com/bc-learn/bccontributionguide/) - it will give you understanding for how to setup local development environment to build and run your code.
author_association: CONTRIBUTOR
user: login: PeterDurrer
created_at: 2025-03-12T20:37:01Z
body: > @PeterDurrer I updated the tests according to internal best practices + fix compilation errors, and commited the changes.
> If you are going to contribute in future, please read this [contribution guide](https://ssosic.com/bc-learn/bccontributionguide/) - it will give you understanding for how to setup local development environment to build and run your code.

@AleksanderGladkov  Thank you it looks very good. It's New for me write Test Code in Microsoft Apps. Thanks for the link i will do my best to get better work on the other PullRequests. At the moment i have some Problems on my Machine to run the localDevEnv script for this repo i hope i can resolve them quickly.
author_association: CONTRIBUTOR
user: login: PeterDurrer
created_at: 2025-03-14T10:06:02Z
body: > > @PeterDurrer I updated the tests according to internal best practices + fix compilation errors, and commited the changes.
> > If you are going to contribute in future, please read this [contribution guide](https://ssosic.com/bc-learn/bccontributionguide/) - it will give you understanding for how to setup local development environment to build and run your code.
> 
> @AleksanderGladkov Thank you it looks very good. It's New for me write Test Code in Microsoft Apps. Thanks for the link i will do my best to get better work on the other PullRequests. At the moment i have some Problems on my Machine to run the localDevEnv script for this repo i hope i can resolve them quickly.

@JesperSchulz or @VolodySyn  Can you Review the PullRequest i can not approve the changes from @AleksanderGladkov but it looks good for me.
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-03-25T10:13:37Z
body: Processing this PR. The branch is now locked 🔒 Please don't push updates unless otherwise agreed.
author_association: CONTRIBUTOR