Repository navigation
[API tests] Complete missing VAT posting fixtures #11224
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
Changes from all commits
c13bb37
0f0f3c6
bb81186
b5948c0
ef78428
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 |
|---|---|---|
|
|
@@ -578,17 +578,16 @@ codeunit 130619 "Library - Graph Document Tools" | |
| VATBusinessPostingGroup: Record "VAT Business Posting Group"; | ||
| FixedAsset: Record "Fixed Asset"; | ||
| GLAccount: Record "G/L Account"; | ||
| VATPostingSetup: Record "VAT Posting Setup"; | ||
| begin | ||
| LibraryInventory.CreateItemCharge(ItemCharge); | ||
| EnsureVATPostingSetupExists( | ||
| SalesHeader."VAT Bus. Posting Group", ItemCharge."VAT Prod. Posting Group"); | ||
| LibrarySales.CreateSalesLine(SalesLineCharge, SalesHeader, SalesLineCharge.Type::"Charge (Item)", ItemCharge."No.", 1); | ||
|
|
||
| LibraryERM.FindVATBusinessPostingGroup(VATBusinessPostingGroup); | ||
| LibraryResource.CreateResource(Resource, VATBusinessPostingGroup.Code); | ||
| VATPostingSetup.SetRange("VAT Bus. Posting Group", SalesHeader."VAT Bus. Posting Group"); | ||
| VATPostingSetup.SetRange("VAT Prod. Posting Group", Resource."VAT Prod. Posting Group"); | ||
| if not VATPostingSetup.FINDFIRST() then | ||
| LibraryERM.CreateVATPostingSetup(VATPostingSetup, SalesHeader."VAT Bus. Posting Group", Resource."VAT Prod. Posting Group"); | ||
| EnsureVATPostingSetupExists( | ||
| SalesHeader."VAT Bus. Posting Group", Resource."VAT Prod. Posting Group"); | ||
| LibrarySales.CreateSalesLine(SalesLineResource, SalesHeader, SalesLineResource.Type::Resource, Resource."No.", 1); | ||
|
|
||
| LibraryFixedAsset.CreateFixedAsset(FixedAsset); | ||
|
|
@@ -615,6 +614,8 @@ codeunit 130619 "Library - Graph Document Tools" | |
| GLAccount: Record "G/L Account"; | ||
| begin | ||
| LibraryInventory.CreateItemCharge(ItemCharge); | ||
| EnsureVATPostingSetupExists( | ||
| PurchaseHeader."VAT Bus. Posting Group", ItemCharge."VAT Prod. Posting Group"); | ||
| LibraryPurchase.CreatePurchaseLine( | ||
| PurchaseLineCharge, PurchaseHeader, PurchaseLineCharge.Type::"Charge (Item)", ItemCharge."No.", 1); | ||
|
|
||
|
|
@@ -632,10 +633,27 @@ codeunit 130619 "Library - Graph Document Tools" | |
| GLAccount.SetRange("Direct Posting", true); | ||
| #pragma warning restore AA0210 | ||
| GLAccount.FindFirst(); | ||
| EnsureVATPostingSetupExists( | ||
| PurchaseHeader."VAT Bus. Posting Group", GLAccount."VAT Prod. Posting Group"); | ||
| LibraryPurchase.CreatePurchaseLine( | ||
| PurchaseLineGLAccount, PurchaseHeader, PurchaseLineGLAccount.Type::"G/L Account", GLAccount."No.", 1); | ||
| end; | ||
|
|
||
| /// <summary>Creates VAT posting setup when the specified posting-group combination does not exist.</summary> | ||
| /// <param name="VATBusPostingGroup">VAT business posting group.</param> | ||
| /// <param name="VATProdPostingGroup">VAT product posting group.</param> | ||
| procedure EnsureVATPostingSetupExists(VATBusPostingGroup: Code[20]; VATProdPostingGroup: Code[20]) | ||
| var | ||
| VATPostingSetup: Record "VAT Posting Setup"; | ||
| begin | ||
| if (VATBusPostingGroup = '') and (VATProdPostingGroup = '') then | ||
| exit; | ||
| if VATPostingSetup.Get(VATBusPostingGroup, VATProdPostingGroup) then | ||
|
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. This helper must continue to create the VAT posting setup when the combination is missing, but the bare Record.Get raises a runtime error instead of returning false. Consume the Boolean result with an existence check so the CreateVATPostingSetup call can run when no setup exists. Suggested fix (apply manually — could not be anchored as a one-click suggestion): if not VATPostingSetup.Get(VATBusPostingGroup, VATProdPostingGroup) then
LibraryERM.CreateVATPostingSetup(VATPostingSetup, VATBusPostingGroup, VATProdPostingGroup);Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.48.6 |
||
| exit; | ||
|
|
||
| LibraryERM.CreateVATPostingSetup(VATPostingSetup, VATBusPostingGroup, VATProdPostingGroup); | ||
| end; | ||
|
|
||
| [Scope('OnPrem')] | ||
| procedure VerifySalesObjectTxtDescription(SalesLine: Record "Sales Line"; JObjectTxt: Text) | ||
| var | ||
|
|
||
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.
The new EnsureVATPostingSetupExists helper has no access modifier or Scope attribute, so it becomes a public API available beyond the test-library boundary even though it is an implementation helper. Restrict it to the existing OnPrem-scoped test-library surface, or otherwise use the narrowest access that supports its callers.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.46.6