-
Notifications
You must be signed in to change notification settings - Fork 420
[Main] [all-e]CompAuxNum and CompAuxLib columns should be informed for Payment Discount lines in the French Audit File.Initial Commit #9710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2345,6 +2345,62 @@ codeunit 148017 "FEC Audit File Export Tests" | |
| VerifyExportGLEntriesReport(GLRegister, AuditFile, '', BankAccount."No.", BankAccount.Name); | ||
| end; | ||
|
|
||
| [Test] | ||
| [HandlerFunctions('ConfirmHandlerYes')] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new test PaymentDiscountLineHasCustomerInfo lists [HandlerFunctions('ConfirmHandlerYes')] but never enqueues/verifies the expected confirm text via LibraryVariableStorage, and does not call AssertEmpty(). ConfirmHandlerYes hardcodes its answer, so nothing proves the correct dialog fired the expected number of times; the scenario can pass even if the wrong confirm appears or an extra confirm is introduced. Follow the enqueue/dequeue pattern (Enqueue expected text before acting, Dequeue and Assert.ExpectedConfirm in the handler, AssertEmpty() at the end) instead of a hardcoded-answer handler. Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.18.4 |
||
| procedure PaymentDiscountLineHasCustomerInfo() | ||
| var | ||
| Customer: Record Customer; | ||
| CustomerPostingGroup: Record "Customer Posting Group"; | ||
| CustLedgerEntry: Record "Cust. Ledger Entry"; | ||
| GenJournalBatch: Record "Gen. Journal Batch"; | ||
| AuditFile: Record "Audit File"; | ||
| iStream: InStream; | ||
| StartingDate: Date; | ||
| InvoiceDocNo: Code[20]; | ||
| PaymentDocNo: Code[20]; | ||
| InvoiceAmount: Decimal; | ||
| DiscountAmount: Decimal; | ||
| PmtDiscAccountNo: Code[20]; | ||
| LineToRead: Text; | ||
| begin | ||
| // [SCENARIO 639574] CompAuxNum and CompAuxLib are informed for Payment Discount lines in the French Audit File | ||
| Initialize(); | ||
| StartingDate := GetStartingDate(); | ||
|
|
||
| // [GIVEN] Customer with a payment-discount payment term whose posting group has a Payment Disc. Debit Acc. | ||
| CreateCustomer(Customer); | ||
| CustomerPostingGroup.Get(Customer."Customer Posting Group"); | ||
| if CustomerPostingGroup."Payment Disc. Debit Acc." = '' then begin | ||
| CustomerPostingGroup.Validate("Payment Disc. Debit Acc.", LibraryERM.CreateGLAccountNo()); | ||
| CustomerPostingGroup.Modify(true); | ||
| end; | ||
| PmtDiscAccountNo := CustomerPostingGroup."Payment Disc. Debit Acc."; | ||
|
|
||
| // [GIVEN] A posted sales invoice with a possible payment discount | ||
| CreateGenJournalBatch(GenJournalBatch); | ||
| InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); | ||
| InvoiceDocNo := | ||
| CreateGenJournalLine(GenJournalBatch, "Gen. Journal Document Type"::Invoice, "Gen. Journal Account Type"::Customer, | ||
| Customer."No.", StartingDate, InvoiceAmount); | ||
| LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry, "Gen. Journal Document Type"::Invoice, InvoiceDocNo); | ||
| DiscountAmount := CustLedgerEntry."Original Pmt. Disc. Possible"; | ||
| Assert.IsTrue(DiscountAmount > 0, 'The posted invoice should have a possible payment discount.'); | ||
|
|
||
| // [GIVEN] A payment for (invoice amount - discount) applied to the invoice within the discount date, so the discount is granted | ||
| PaymentDocNo := | ||
| CreateGenJournalLine(GenJournalBatch, "Gen. Journal Document Type"::Payment, "Gen. Journal Account Type"::Customer, | ||
| Customer."No.", StartingDate, -(InvoiceAmount - DiscountAmount)); | ||
| ApplyAndPostGenJournalLine(PaymentDocNo, "Gen. Journal Document Type"::Invoice, InvoiceDocNo); | ||
|
|
||
| // [WHEN] Export Audit File in FEC format for the Payment Disc. Debit Acc. only | ||
| RunFECExport(AuditFile, PmtDiscAccountNo, StartingDate, StartingDate, false); | ||
|
|
||
| // [THEN] The exported Payment Discount line has CompAuxNum = Customer No. and CompAuxLib = Customer Name | ||
| CreateReadStream(iStream, AuditFile); | ||
| iStream.ReadText(LineToRead); // header | ||
| VerifyFilePartyNoAndName(iStream, Customer."No.", Customer.Name); | ||
| end; | ||
|
|
||
| local procedure Initialize() | ||
| begin | ||
| LibrarySetupStorage.Restore(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetPartyForPaymentDiscount() is invoked from inside the G/L Entry export loop for every entry that resolves to a payment-discount account, and performs a fresh Customer.Get()/Vendor.Get() per matching entry. On a ledger with many payment-discount postings for the same customer/vendor this is an N+1 lookup pattern; cache resolved party No./Name per source type + source No. (e.g. in a Dictionary) instead of re-reading the persistent table for every matching row.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.18.4