SERIOUS ERROR- Attain US 3.10B - Improvements 007

There’s a SERIOUS error created by the official Navision Attain 3.10B Improvement 007 that’s not fixed either on the Improvement 008. I’m just now sending a message to Navision US explaining the error and how to solve. If you’re having a customer with that version and you’re thinking on installing the improvement 007, please, don’t do it yet. It’s getting a wrong invoice discount calculation and posting the full amount of the discount in partial shipments. Regards,

quote:


Originally posted by apertierra
There’s a SERIOUS error created by the official Navision Attain 3.10B Improvement 007 that’s not fixed either on the Improvement 008. I’m just now sending a message to Navision US explaining the error and how to solve. If you’re having a customer with that version and you’re thinking on installing the improvement 007, please, don’t do it yet. It’s getting a wrong invoice discount calculation and posting the full amount of the discount in partial shipments. Regards,


It seems that they didn’t yet published the patch… well… for anyone interested on the error, it consists that whenever you were invoicing partially a sales order using invoice discount (let’s say you’ve an order with one line where qty. = 100 and invoice discount amount = $100, if you invoice just half the qty. (let’s say in this example 50), the applied invoice discount amount was the total invoice discount amount (instead of applying a $50 invoice discount it’s applying $100). If the partial amount was higher or equal to the total invoice discount it was posting, if not showing an error as the invoiced amount could not be a negative number… Here’s is the explanation i sent navision the other day… it’s including the fixed code.

quote:


After a lot of debugging and code analyzing, I’ve discovered that your Improvement 007 for Navision Attain 3.10B is having a SERIOUS error on it’s calculation of the invoice discount when the quantity invoiced is less than the line quantity. On your code for the improvement 007, your modification for codeunit 80 changes the code as follows: [Function AddSalesTaxLineToSalesTaxCalc] — NAVW13.10.01,NAVUS3.10.02.07 ----------------------------------------------- WITH TempSalesLineForSalesTax DO BEGIN IF “Qty. per Unit of Measure” = 0 THEN “Qty. per Unit of Measure” := 1; IF “Document Type” IN [“Document Type”::“Return Order”,“Document Type”::“Credit Memo”] THEN BEGIN MaxInvQty := (“Return Qty. Received” - “Quantity Invoiced”); MaxInvQtyBase := (“Return Qty. Received (Base)” - “Qty. Invoiced (Base)”); IF SalesHeader.Receive THEN BEGIN MaxInvQty := MaxInvQty + “Return Qty. to Receive”; MaxInvQtyBase := MaxInvQtyBase + “Return Qty. to Receive (Base)”; END; END ELSE BEGIN MaxInvQty := (“Quantity Shipped” - “Quantity Invoiced”); MaxInvQtyBase := (“Qty. Shipped (Base)” - “Qty. Invoiced (Base)”); IF SalesHeader.Ship THEN BEGIN MaxInvQty := MaxInvQty + “Qty. to Ship”; MaxInvQtyBase := MaxInvQtyBase + “Qty. to Ship (Base)”; END; END; IF ABS(“Qty. to Invoice”) > ABS(MaxInvQty) THEN BEGIN “Qty. to Invoice” := MaxInvQty; “Qty. to Invoice (Base)” := MaxInvQtyBase; END; Quantity := “Qty. to Invoice”; “Quantity (Base)” := “Qty. to Invoice (Base)”; IF Quantity = 0 THEN VALIDATE(“Inv. Disc. Amount to Invoice”,0) ELSE VALIDATE( “Inv. Disc. Amount to Invoice”, ROUND( “Inv. Discount Amount” * “Qty. to Invoice” / Quantity, Currency.“Amount Rounding Precision”)); “Line Amount” := ROUND(“Qty. to Invoice” * “Unit Price”,Currency.“Amount Rounding Precision”); “Line Discount Amount” := ROUND(“Line Amount” * “Line Discount %” / 100,Currency.“Amount Rounding Precision”); “Line Amount” := “Line Amount” - “Line Discount Amount”; “Inv. Discount Amount” := “Inv. Disc. Amount to Invoice”; Amount := “Line Amount” - “Inv. Discount Amount”; “Tax Base Amount” := Amount; INSERT; END; -------------------------------------------------------------------------------- That code is totally erroneous, as the calculation for the invoice discount amount to invoice field on the sales line tables is recalculating again the invoice discount… and not only that, when calculating the invoice discount amount, you’re multiplying by “qty. to invoice” and dividing by “quantity” BUT WITHOUT NOTICING THAT JUST A FEW LINES OF CODE ABOVE YOU’RE HAVING THESE TWO OTHER LINES OF CODE: Quantity := “Qty. to Invoice”; “Quantity (Base)” := “Qty. to Invoice (Base)”; So your calculation is doing “Inv. Discount Amount” * “Qty. to invoice” / Quantity , and as Quantity = “Qty. to invoice”, your calculation is “Inv. Discount Amount” * “Qty. to invoice” / “Qty. to invoice”… As “Qty. to invoice” / “Qty. to invoice” … it means that your Calculation of the partial invoice discount amount is at the end “Inv. Discount Amount” := ROUND (“Inv. Discount Amount” * 1)… So you’re trying to invoice the total invoice discount amount for a partial invoice… Example: if i’m having 100 units of a part and i’m having a total amount of $1000 and a total invoice discount of $200 with your changes on that function, when trying to ship and post just 40 units (each with a unit price of 10), i’ll have that the posted value to the customer entry will be 200 dollars ((40 * 10) - 200) instead of being 320 ((40*10) - (200 * 40 / 100)) Also if trying to post just 1 unit, i’ll have an error stating that the entry amount cannot be a negative amount. The error is specially serious in companies using a lot partial shipments… and that’s a lot of companies. I should suggest you using the following code instead: WITH TempSalesLineForSalesTax DO BEGIN IF “Qty. per Unit of Measure” = 0 THEN “Qty. per Unit of Measure” := 1; IF “Document Type” IN [“Document Type”::“Return Order”,“Document Type”::“Credit Memo”] THEN BEGIN MaxInvQty := (“Return Qty. Received” - “Quantity Invoiced”); MaxInvQtyBase := (“Return Qty. Received (Base)” - “Qty. Invoiced (Base)”); IF SalesHeader.Receive THEN BEGIN MaxInvQty := MaxInvQty + “Return Qty. to Receive”; MaxInvQtyBase := MaxInvQtyBase + “Return Qty. to Receive (Base)”; END; END ELSE BEGIN MaxInvQty := (“Quantity Shipped” - “Quantity Invoiced”); MaxInvQtyBase := (“Qty. Shipped (Base)” - “Qty. Invoiced (Base)”); IF SalesHeader.Ship THEN BEGIN MaxInvQty := MaxInvQty + “Qty. to Ship”; MaxInvQtyBase := MaxInvQtyBase + “Qty. to Ship (Base)”; END; END; IF ABS(“Qty. to Invoice”) > ABS(MaxInvQty) THEN BEGIN “Qty. to Invoice” := MaxInvQty; “Qty. to Invoice (Base)” := MaxInvQtyBase; END; //>>WC // Fixed improvement 007 // Alfonso Pertierra - Western Computer IF (“Qty. to Invoice” = 0) THEN “Inv. Disc. Amount to Invoice” := 0 ELSE “Inv. Disc. Amount to Invoice” := ROUND( “Inv. Discount Amount” * “Qty. to Invoice” / Quantity, Currency.“Amount Rounding Precision”); “Line Amount” := ROUND(“Qty. to Invoice” * “Unit Price”,Currency.“Amount Rounding Precision”); “Line Discount Amount” := ROUND(“Line Amount” * “Line Discount %” / 100,Currency.“Amount Rounding Precision”); “Line Amount” := “Line Amount” - “Line Discount Amount”; “Inv. Discount Amount” := “Inv. Disc. Amount to Invoice”; Amount := “Line Amount” - “Inv. Discount Amount”; “Tax Base Amount” := Amount; Quantity := “Qty. to Invoice”; “Quantity (Base)” := “Qty. to Invoice (Base)”; //<< INSERT; END;


Regards,

Thanks for the fix -