Extract AU Withholding Tax code#9258
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
| Caption = 'Purch. - Tax Invoice'; | ||
| Image = "Report"; | ||
| RunObject = Report "Purch. - Tax Invoice"; | ||
| ToolTip = 'Create a new purchase tax credit invoice.'; |
There was a problem hiding this comment.
The tooltip on 'Purch.
- Tax Invoice' contradicts the action caption and RunObject by saying it creates a "purchase tax credit invoice." This mislabels the action in the Role Center. Update the tooltip to describe a purchase tax invoice instead.
| ToolTip = 'Create a new purchase tax credit invoice.'; | |
| ToolTip = 'Create a new purchase tax invoice.'; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| TotalWHTAmountToBeDeductedLCY: Decimal; | ||
| TotalWHTAmtTobeDeducted: Decimal; | ||
| TotalWHTAmountToBeDeductedACY: Decimal; | ||
| begin |
There was a problem hiding this comment.
The OnPrepareLineOnBeforeSetInvoiceDiscountPosting subscriber queries Purch.
Inv. Header and then WHT Entry before checking PurchLine."Prepayment Line". This subscriber runs while preparing purchase lines, so non-prepayment lines still pay those database round-trips. Add the cheap Prepayment Line guard first and only run the queries when it passes.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
begin
if not PurchLine."Prepayment Line" then
exit;
PrepmtPurchInvHeader.Reset();
PrepmtPurchInvHeader.SetRange("Prepayment Order No.", PurchLine."Document No.");
PrepmtPurchInvHeader.SetRange("Prepayment Invoice", true);
if PrepmtPurchInvHeader.FindSet() then
repeat
PrepmtWHTEntry.SetRange("Document Type", PrepmtWHTEntry."Document Type"::Invoice);
PrepmtWHTEntry.SetRange("Document No.", PrepmtPurchInvHeader."No.");
PrepmtWHTEntry.SetRange("Gen. Bus. Posting Group", GenPostingSetup."Gen. Bus. Posting Group");
PrepmtWHTEntry.SetRange("Gen. Prod. Posting Group", GenPostingSetup."Gen. Prod. Posting Group");
if PrepmtWHTEntry.FindSet() then
repeat
TotalWHTAmountToBeDeductedLCY := TotalWHTAmountToBeDeductedLCY + PrepmtWHTEntry."Unrealized Amount (LCY)";
TotalWHTAmtTobeDeducted := TotalWHTAmtTobeDeducted + PrepmtWHTEntry."Unrealized Amount";
until PrepmtWHTEntry.Next() = 0;
until PrepmtPurchInvHeader.Next() = 0;
GLSetup.Get();
if GLSetup."Additional Reporting Currency" <> '' then
TotalWHTAmountToBeDeductedACY :=
CurrExchRate.ExchangeAmtLCYToFCY(
PurchHeader."Posting Date", GLSetup."Additional Reporting Currency",
TotalWHTAmtTobeDeducted, 0);
TotalAmount := TotalAmount + TotalWHTAmountToBeDeductedLCY;
TotalAmountACY := TotalAmountACY + TotalWHTAmountToBeDeductedACY;
end;Knowledge:
- microsoft/knowledge/performance/guard-event-subscribers-before-db-call.md
- microsoft/knowledge/performance/apply-guards-before-get.md
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| action("Posted Purch. Tax Credit Memo") | ||
| { | ||
| ApplicationArea = Basic, Suite; | ||
| Caption = 'Posted Purch. Tax Credit Memo'; |
There was a problem hiding this comment.
The action caption `Posted Purch.
Tax Credit Memocontains a double space, which shows up as a visible typo in the Role Center. Change the caption text toPosted Purch. Tax Credit Memo`.
| Caption = 'Posted Purch. Tax Credit Memo'; | |
| Caption = 'Posted Purch. Tax Credit Memo'; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| action("AU/NZ Statement") | ||
| { | ||
| ApplicationArea = Basic, Suite; | ||
| Caption = 'AU/NZ Statement'; | ||
| RunObject = Report "AU/NZ Statement"; | ||
| } |
There was a problem hiding this comment.
The newly added AU/NZ Statement action has no ToolTip, so this Role Center entry loses the hover/help text that the same report action already provides elsewhere.
Add the standard report tooltip here as well.
| action("AU/NZ Statement") | |
| { | |
| ApplicationArea = Basic, Suite; | |
| Caption = 'AU/NZ Statement'; | |
| RunObject = Report "AU/NZ Statement"; | |
| } | |
| action("AU/NZ Statement") | |
| { | |
| ApplicationArea = Basic, Suite; | |
| Caption = 'AU/NZ Statement'; | |
| RunObject = Report "AU/NZ Statement"; | |
| ToolTip = 'Print the report of accounts receivable and accounts payable based on the selections you make in the report request window.'; | |
| } |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| PrepmtPurchInvHeader.Reset(); | ||
| PrepmtPurchInvHeader.SetRange("Prepayment Order No.", PurchLine."Document No."); | ||
| PrepmtPurchInvHeader.SetRange("Prepayment Invoice", true); | ||
| if PrepmtPurchInvHeader.FindSet() then | ||
| repeat | ||
| PrepmtWHTEntry.SetRange("Document Type", PrepmtWHTEntry."Document Type"::Invoice); | ||
| PrepmtWHTEntry.SetRange("Document No.", PrepmtPurchInvHeader."No."); | ||
| PrepmtWHTEntry.SetRange("Gen. Bus. Posting Group", GenPostingSetup."Gen. Bus. Posting Group"); | ||
| PrepmtWHTEntry.SetRange("Gen. Prod. Posting Group", GenPostingSetup."Gen. Prod. Posting Group"); | ||
| if PrepmtWHTEntry.FindSet() then |
There was a problem hiding this comment.
Both added FindSet() loops read only a small subset of fields from wide records (`Purch.
Inv. HeaderandWHT Entry), but no SetLoadFields(...)` is declared before the reads. That causes full-row materialization on every iteration instead of loading just the fields used by the accumulation logic.
| PrepmtPurchInvHeader.Reset(); | |
| PrepmtPurchInvHeader.SetRange("Prepayment Order No.", PurchLine."Document No."); | |
| PrepmtPurchInvHeader.SetRange("Prepayment Invoice", true); | |
| if PrepmtPurchInvHeader.FindSet() then | |
| repeat | |
| PrepmtWHTEntry.SetRange("Document Type", PrepmtWHTEntry."Document Type"::Invoice); | |
| PrepmtWHTEntry.SetRange("Document No.", PrepmtPurchInvHeader."No."); | |
| PrepmtWHTEntry.SetRange("Gen. Bus. Posting Group", GenPostingSetup."Gen. Bus. Posting Group"); | |
| PrepmtWHTEntry.SetRange("Gen. Prod. Posting Group", GenPostingSetup."Gen. Prod. Posting Group"); | |
| if PrepmtWHTEntry.FindSet() then | |
| PrepmtPurchInvHeader.Reset(); | |
| PrepmtPurchInvHeader.SetLoadFields("No."); | |
| PrepmtPurchInvHeader.SetRange("Prepayment Order No.", PurchLine."Document No."); | |
| PrepmtPurchInvHeader.SetRange("Prepayment Invoice", true); | |
| if PrepmtPurchInvHeader.FindSet() then | |
| repeat | |
| PrepmtWHTEntry.SetLoadFields("Unrealized Amount (LCY)", "Unrealized Amount"); | |
| PrepmtWHTEntry.SetRange("Document Type", PrepmtWHTEntry."Document Type"::Invoice); | |
| PrepmtWHTEntry.SetRange("Document No.", PrepmtPurchInvHeader."No."); | |
| PrepmtWHTEntry.SetRange("Gen. Bus. Posting Group", GenPostingSetup."Gen. Bus. Posting Group"); | |
| PrepmtWHTEntry.SetRange("Gen. Prod. Posting Group", GenPostingSetup."Gen. Prod. Posting Group"); | |
| if PrepmtWHTEntry.FindSet() then |
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| OnAfterInitGenJnlLineAmountFieldsFromTotalLines(GenJnlLine, SalesHeader, TotalSalesLine, TotalSalesLineLCY); | ||
| end; | ||
|
|
||
| [IntegrationEvent(false, false)] |
There was a problem hiding this comment.
The new OnAfterInitGenJnlLineAmountFieldsFromTotalLines publisher is raised inside sales invoice posting without [CommitBehavior(CommitBehavior::Ignore)].
A subscriber can call Commit() during posting and persist partial state before later posting code fails; add CommitBehavior::Ignore on the publisher to preserve rollback semantics.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
[CommitBehavior(CommitBehavior::Ignore)]
[IntegrationEvent(false, false)]
local procedure OnAfterInitGenJnlLineAmountFieldsFromTotalLines(var GenJnlLine: Record "Gen. Journal Line"; var SalesHeader: Record "Sales Header"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line")Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| WHTManagement: Codeunit WHTManagement; | ||
|
|
||
| [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnPostInvoiceOnAfterPostLines', '', true, false)] | ||
| local procedure OnPostInvoiceOnAfterPostLines(var SalesHeader: Record "Sales Header"; SrcCode: Code[10]; GenJnlLineDocType: Enum "Gen. Journal Document Type"; GenJnlLineDocNo: Code[20]; GenJnlLineExtDocNo: Code[35]; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; TotalAmount: Decimal; var TempSalesLineGlobal: Record "Sales Line" temporary; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var TotalSalesLineLCY: Record "Sales Line" temporary) |
There was a problem hiding this comment.
TotalSalesLineLCY is declared as Record "Sales Line" temporary in this new codeunit, but the parameter name does not start with Temp.
The same non-conforming temporary-record name is repeated in the subscriber signature, PostWHT, and InsertGenJournalWHT, which hides the fact that the record is in-memory only.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| begin | ||
| GLSetup.Get(); | ||
| if GLSetup."Enable WHT" and (not GLSetup."Enable GST (Australia)") then | ||
| PostWHT( |
There was a problem hiding this comment.
This new codeunit calls its own procedures as bare identifiers (PostWHT, InsertGenJournalWHT, CheckWHTApplication, UpdateTaxForPostedDoc) instead of qualifying them with this..
In a codeunit, this. is the required self-reference convention and makes the local call target unambiguous.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
What & why
Linked work
Fixes AB#636621
How I validated this
What I tested and the outcome (required — be specific: scenarios, commands, screenshots for UI changes)
Risk & compatibility