microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
728 stars 241 forks source link

Vendor Bill Line's Withholding Amount calculation during Suggest Payment is wrong in the Italian Version #7603

Closed Chuucommie closed 9 months ago

Chuucommie commented 9 months ago

Please include the following with each issue:

1. Describe the bug in the Italian version, When generating Vendor Bill Lines from Suggest Payments the field "Withholding Amount" is recalculated and the Withholding Code Lines are retrieved with a Findfirst() without checking for their dates or their validity, a Withholding Tax Code could have more than one Withholding Code Line with different dates and percentages.

image

this, in case you have more than one Withholding Code Line, uses the "Taxable Base %" from the Withholding Code Line and the "Withholding Tax %" from the Vendor Bill Lines's Withholding Tax table, this can and will cause an error during the recalculation and the Withholding Amount field will be wrongly populated.

2. To Reproduce To reproduce this behaviour: 1- Choose a Withholding Tax Code from the list page 2- Related --> Withhold Rates --> Withholding Code Lines 3- Create two Withholding Code Lines the first with a Start Date lower than the second line, in the first set the "Withholding Tax %" to 0 and the "Taxable Base %" to 100 in the second one the "Withholding Tax %" to 20 and the "Taxable Base %" to 0 4- Create a Purchase Invoice with a Vendor that has the Withholding Code you choose at the start, check that the Withholding Tax exists for the Purchase Invoice: Actions- Request Approval- Withhold Taxes Soc. Sec., check the Withholding Tax Amount 5- Post the Invoice 6- Create a Vendor Bill Line and Suggest Payments to get the line from the invoice you just posted 7- The withholding tax amount field will be different from the one you saw in the invoice's Withholding Tax 8- if you open the Withholding Tax for that Vendor Bill Line you can see the Withholding Tax Amount is the correct one, when you close the page it will update the vendor bill line correctly, the users can't do this for every single line every single time though.

![image](https://github.com/microsoft/AL/assets/88215251/4cbb268e-c353-42b1-92e6-6480f632fe1c)

if ("Vendor Entry No." <> 0) and (VendBillWithhTax."Withholding Tax Amount" = 0) then begin
            VendorLedgerEntry.Get("Vendor Entry No.");
            WithholdCodeLine.SetRange("Withhold Code", VendBillWithhTax."Withholding Tax Code");
            if WithholdCodeLine.FindFirst() then
                if VendorLedgerEntry."Purchase (LCY)" <> 0 then
                    "Withholding Tax Amount" := -Round(
                        (VendorLedgerEntry."Purchase (LCY)" *
                        WithholdCodeLine."Taxable Base %" *
                        VendBillWithhTax."Withholding Tax %") / 10000,
                        GetCurrencyAmtRoundingPrecision(VendBillWithhTax."Currency Code"));
        end;

Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.

3. Expected behavior The recalculation should check the Invoice Posting Date and then choose the right Withholding Code Line

4. Actual behavior The recalculation just takes the first Withholding Code Line for that Withholding Code.

5. Versions:

Final Checklist

Please remember to do the following:

BazookaMusic commented 9 months ago

Let's get the issue to a team who will fix and backport it, as this repository is only for issues related to the AL compiler in latest developer preview environment for Dynamics 365 Business Central. We suggest that you open a support case or file a bug in Collaborate, to ensure that all Business Central users benefit from your catch as soon as possible.

To open a support case, you can:

If you file the bug in Collaborate, remember to include steps to reproduce the issue, and the Business Central build number and country version you're using.