Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The general ledger entries are incorrect after you post an invoice or an order that has a 100 percentage line discount in the Belgian version of Microsoft Dynamics NAV


View products that this article applies to.

This article applies to Microsoft Dynamics NAV for the Belgian (be) language locale.

↑ Back to the top


Symptoms

When you post a sales invoice, a sales order, a purchase invoice, a purchase order or a service order that has a 100 percentage line discount in the Belgian version of Microsoft Dynamics NAV, the general ledger (GL) entries are incorrect.
This problem occurs when the line amount, the line discount amount, the value-added tax (VAT) base amount and the "Amount Including VAT" amount are set to zero.

This problem occurs in the following products:
  • The Belgian version of Microsoft Dynamics NAV 2009 Service Pack 1 (SP1)
  • The Belgian version of Microsoft Dynamics NAV 2009 R2

↑ Back to the top


Resolution

Hotfix information

A supported hotfix is now available from Microsoft. However, it is only intended to correct the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Dynamics NAV 2009 service pack or the next Microsoft Dynamics NAV version that contains this hotfix.

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Technical Support Professional for Microsoft Dynamics and related products determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.


↑ Back to the top




Installation information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Note Before you install this hotfix, verify that all Microsoft Navision client users are logged off the system. This includes Microsoft Navision Application Services (NAS) client users. You should be the only client user who is logged on when you implement this hotfix.

To implement this hotfix, you must have a developer license.

We recommend that the user account in the Windows Logins window or in the Database Logins window be assigned the "SUPER" role ID. If the user account cannot be assigned the "SUPER" role ID, you must verify that the user account has the following permissions:
  • The Modify permission for the object that you will be changing.
  • The Execute permission for the System Object ID 5210 object and for the System Object ID 9015 object.


Note You do not have to have rights to the data stores unless you have to perform data repair.

Code changes

Note Always test code fixes in a controlled environment before you apply the fixes to your production computers.
To resolve this problem, follow these steps:
  1. Change the code in the ZeroAmountLine function in the Sales Line table (37) as follows:

    Existing code
    ...
    IF Type = Type::" " THEN
    EXIT(TRUE);
    IF Quantity = 0 THEN
    EXIT(TRUE);

    // Delete the following line.
    IF ("Unit Price" = 0) OR ("Line Discount %" = 100) THEN

    EXIT(TRUE);
    IF QtyType = QtyType::Invoicing THEN
    IF "Qty. to Invoice" = 0 THEN
    EXIT(TRUE);
    EXIT(FALSE);
    ...
    Replacement code
    ...
    IF Type = Type::" " THEN
    EXIT(TRUE);
    IF Quantity = 0 THEN
    EXIT(TRUE);
    // Add the following line.
    IF ("Unit Price" = 0) THEN

    EXIT(TRUE);
    IF QtyType = QtyType::Invoicing THEN
    IF "Qty. to Invoice" = 0 THEN
    EXIT(TRUE);
    EXIT(FALSE);
    ...
  2. Change the code in the UpdateVATOnLines function in the Purchase Line table (39) as follows:

    Existing code 1
    ...
    IF FINDSET THEN
    REPEAT
    // Delete the following lines.
    VATAmountLine.GET("VAT Identifier","VAT Calculation Type","Tax Group Code","Use Tax","Line Amount" >= 0);
    IF VATAmountLine.Modified THEN BEGIN
    xRecRef.GETTABLE(PurchLine);
    IF NOT TempVATAmountLineRemainder.GET(
    "VAT Identifier","VAT Calculation Type","Tax Group Code","Use Tax","Line Amount" >= 0)
    THEN BEGIN
    TempVATAmountLineRemainder := VATAmountLine;
    TempVATAmountLineRemainder.INIT;
    TempVATAmountLineRemainder.INSERT;
    END;

    IF QtyType = QtyType::General THEN
    LineAmountToInvoice := "Line Amount"
    ELSE
    LineAmountToInvoice :=
    ROUND("Line Amount" * "Qty. to Invoice" / Quantity,Currency."Amount Rounding Precision");

    IF "Allow Invoice Disc." THEN BEGIN
    IF VATAmountLine."Inv. Disc. Base Amount" = 0 THEN
    InvDiscAmount := 0
    ELSE BEGIN
    IF QtyType = QtyType::General THEN
    LineAmountToInvoice := "Line Amount"
    ELSE
    LineAmountToInvoice :=
    ROUND("Line Amount" * "Qty. to Invoice" / Quantity,Currency."Amount Rounding Precision");
    TempVATAmountLineRemainder."Invoice Discount Amount" :=
    TempVATAmountLineRemainder."Invoice Discount Amount" +
    VATAmountLine."Invoice Discount Amount" * LineAmountToInvoice /
    VATAmountLine."Inv. Disc. Base Amount";
    InvDiscAmount :=
    ROUND(
    TempVATAmountLineRemainder."Invoice Discount Amount",Currency."Amount Rounding Precision");
    TempVATAmountLineRemainder."Invoice Discount Amount" :=
    TempVATAmountLineRemainder."Invoice Discount Amount" - InvDiscAmount;
    END;
    IF QtyType = QtyType::General THEN BEGIN
    "Inv. Discount Amount" := InvDiscAmount;
    CalcInvDiscToInvoice;
    END ELSE
    "Inv. Disc. Amount to Invoice" := InvDiscAmount;
    END ELSE
    InvDiscAmount := 0;
    IF QtyType = QtyType::General THEN
    IF PurchHeader."Prices Including VAT" THEN BEGIN
    IF (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount" = 0) OR
    ("Line Amount" = 0)
    THEN BEGIN
    VATAmount := 0;
    NewAmountIncludingVAT := 0;
    END ELSE BEGIN
    VATAmount :=
    TempVATAmountLineRemainder."VAT Amount" +
    VATAmountLine."VAT Amount" *
    ("Line Amount" - "Inv. Discount Amount") /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount");
    NewAmountIncludingVAT :=
    TempVATAmountLineRemainder."Amount Including VAT" +
    VATAmountLine."Amount Including VAT" *
    ("Line Amount" - "Inv. Discount Amount") /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount");
    END;
    NewAmount :=
    ROUND(NewAmountIncludingVAT,Currency."Amount Rounding Precision") -
    ROUND(VATAmount,Currency."Amount Rounding Precision");
    IF ("VAT %" <> 0) AND
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount"<> 0)
    THEN
    NewVATBaseAmount :=
    TempVATAmountLineRemainder."VAT Base (Lowered)" +
    VATAmountLine."Line Amount" * (1 - PurchHeader."VAT Base Discount %" / 100) *
    ("Line Amount" - "Inv. Discount Amount") /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount")
    ELSE NewVATBaseAmount := NewAmount;
    END ELSE BEGIN
    IF "VAT Calculation Type" = "VAT Calculation Type"::"Full VAT" THEN BEGIN
    VATAmount := "Line Amount" - "Inv. Discount Amount";
    NewAmount := 0;
    NewVATBaseAmount := 0;
    END ELSE BEGIN
    NewAmount := "Line Amount" - "Inv. Discount Amount";
    // End of the deleted lines.
    IF ("VAT %" <> 0) AND
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount" <> 0)
    THEN
    NewVATBaseAmount :=
    TempVATAmountLineRemainder."VAT Base (Lowered)" +
    ...
    Replacement code 1
    ...
    IF FINDSET THEN
    REPEAT
    // Add the following lines.
    IF NOT ZeroAmountLine(QtyType) THEN BEGIN
    VATAmountLine.GET("VAT Identifier","VAT Calculation Type","Tax Group Code","Use Tax","Line Amount" >= 0);
    IF VATAmountLine.Modified THEN BEGIN
    xRecRef.GETTABLE(PurchLine);
    IF NOT TempVATAmountLineRemainder.GET(
    "VAT Identifier","VAT Calculation Type","Tax Group Code","Use Tax","Line Amount" >= 0)
    THEN BEGIN
    TempVATAmountLineRemainder := VATAmountLine;
    TempVATAmountLineRemainder.INIT;
    TempVATAmountLineRemainder.INSERT;
    END;

    IF QtyType = QtyType::General THEN
    LineAmountToInvoice := "Line Amount"
    ELSE
    LineAmountToInvoice :=
    ROUND("Line Amount" * "Qty. to Invoice" / Quantity,Currency."Amount Rounding Precision");

    IF "Allow Invoice Disc." THEN BEGIN
    IF VATAmountLine."Inv. Disc. Base Amount" = 0 THEN
    InvDiscAmount := 0
    ELSE BEGIN
    IF QtyType = QtyType::General THEN
    LineAmountToInvoice := "Line Amount"
    ELSE
    LineAmountToInvoice :=
    ROUND("Line Amount" * "Qty. to Invoice" / Quantity,Currency."Amount Rounding Precision");
    TempVATAmountLineRemainder."Invoice Discount Amount" :=
    TempVATAmountLineRemainder."Invoice Discount Amount" +
    VATAmountLine."Invoice Discount Amount" * LineAmountToInvoice /
    VATAmountLine."Inv. Disc. Base Amount";
    InvDiscAmount :=
    ROUND(
    TempVATAmountLineRemainder."Invoice Discount Amount",Currency."Amount Rounding Precision");
    TempVATAmountLineRemainder."Invoice Discount Amount" :=
    TempVATAmountLineRemainder."Invoice Discount Amount" - InvDiscAmount;
    END;
    IF QtyType = QtyType::General THEN BEGIN
    "Inv. Discount Amount" := InvDiscAmount;
    CalcInvDiscToInvoice;
    END ELSE
    "Inv. Disc. Amount to Invoice" := InvDiscAmount;
    END ELSE
    InvDiscAmount := 0;
    IF QtyType = QtyType::General THEN
    IF PurchHeader."Prices Including VAT" THEN BEGIN
    IF (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount" = 0) OR
    ("Line Amount" = 0)
    THEN BEGIN
    VATAmount := 0;
    NewAmountIncludingVAT := 0;
    END ELSE BEGIN
    VATAmount :=
    TempVATAmountLineRemainder."VAT Amount" +
    VATAmountLine."VAT Amount" *
    ("Line Amount" - "Inv. Discount Amount") /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount");
    NewAmountIncludingVAT :=
    TempVATAmountLineRemainder."Amount Including VAT" +
    VATAmountLine."Amount Including VAT" *
    ("Line Amount" - "Inv. Discount Amount") /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount");
    END;
    NewAmount :=
    ROUND(NewAmountIncludingVAT,Currency."Amount Rounding Precision") -
    ROUND(VATAmount,Currency."Amount Rounding Precision");
    // End of the added lines.
    IF ("VAT %"<> 0) AND
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount" <> 0)
    THEN
    NewVATBaseAmount :=
    TempVATAmountLineRemainder."VAT Base (Lowered)" +
    ...
    Existing code 2
    ...
    TempVATAmountLineRemainder."VAT Base (Lowered)" +
    VATAmountLine."Line Amount" * (1 - PurchHeader."VAT Base Discount %" / 100) *
    ("Line Amount" - "Inv. Discount Amount") /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount")
    ELSE NewVATBaseAmount := NewAmount;
    // Delete the following lines.
    IF VATAmountLine."VAT Base" = 0 THEN
    VATAmount := 0
    ELSE
    VATAmount :=
    TempVATAmountLineRemainder."VAT Amount" +
    VATAmountLine."VAT Amount" * NewAmount / VATAmountLine."VAT Base";
    END;
    NewAmountIncludingVAT := NewAmount + ROUND(VATAmount,Currency."Amount Rounding Precision");
    END
    ELSE BEGIN
    IF (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount") = 0 THEN
    VATDifference := 0
    ELSE
    VATDifference :=
    TempVATAmountLineRemainder."VAT Difference" +
    VATAmountLine."VAT Difference" * (LineAmountToInvoice - InvDiscAmount) /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount");
    IF LineAmountToInvoice = 0 THEN
    "VAT Difference" := 0
    ELSE
    "VAT Difference" := ROUND(VATDifference,Currency."Amount Rounding Precision");
    END;

    IF (QtyType = QtyType::General) AND (PurchHeader.Status = PurchHeader.Status::Released) THEN BEGIN
    Amount := NewAmount;
    "Amount Including VAT" := ROUND(NewAmountIncludingVAT,Currency."Amount Rounding Precision");
    IF "VAT %" <> 0 THEN
    "VAT Base Amount" := ROUND(NewVATBaseAmount,Currency."Amount Rounding Precision")
    ELSE "VAT Base Amount" := Amount;
    END;
    InitOutstanding;
    IF NOT ((Type = Type::"Charge (Item)") AND ("Quantity Invoiced" <> "Qty. Assigned")) THEN BEGIN
    SetUpdateFromVAT(TRUE);
    UpdateUnitCost;
    END;
    IF Type = Type::"Charge (Item)" THEN
    UpdateItemChargeAssgnt;
    MODIFY;
    RecRef.GETTABLE(PurchLine);
    ChangeLogMgt.LogModification(RecRef,xRecRef);

    TempVATAmountLineRemainder."Amount Including VAT" :=
    NewAmountIncludingVAT - ROUND(NewAmountIncludingVAT,Currency."Amount Rounding Precision");
    TempVATAmountLineRemainder."VAT Amount" := VATAmount - NewAmountIncludingVAT + NewAmount;
    TempVATAmountLineRemainder."VAT Difference" := VATDifference - "VAT Difference";
    TempVATAmountLineRemainder."VAT Base (Lowered)" := NewVATBaseAmount - "VAT Base Amount";
    TempVATAmountLineRemainder.MODIFY;
    // End of the deleted lines.
    END;
    UNTIL NEXT = 0;
    SETRANGE(Type);
    SETRANGE(Quantity);
    SETRANGE("Qty. to Invoice");
    ...
    Replacement code 2
    ...
    TempVATAmountLineRemainder."VAT Base (Lowered)" +
    VATAmountLine."Line Amount" * (1 - PurchHeader."VAT Base Discount %" / 100) *
    ("Line Amount" - "Inv. Discount Amount") /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount")
    ELSE NewVATBaseAmount := NewAmount;
    // Add the following lines.
    END ELSE BEGIN
    IF "VAT Calculation Type" = "VAT Calculation Type"::"Full VAT" THEN BEGIN
    VATAmount := "Line Amount" - "Inv. Discount Amount";
    NewAmount := 0;
    NewVATBaseAmount := 0;
    END ELSE BEGIN
    NewAmount := "Line Amount" - "Inv. Discount Amount";
    IF ("VAT %" <>0) AND
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount"<>0)
    THEN
    NewVATBaseAmount :=
    TempVATAmountLineRemainder."VAT Base (Lowered)" +
    VATAmountLine."Line Amount" * (1 - PurchHeader."VAT Base Discount %" / 100) *
    ("Line Amount" - "Inv. Discount Amount") /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount")
    ELSE NewVATBaseAmount := NewAmount;
    IF VATAmountLine."VAT Base" = 0 THEN
    VATAmount := 0
    ELSE
    VATAmount :=
    TempVATAmountLineRemainder."VAT Amount" +
    VATAmountLine."VAT Amount" * NewAmount / VATAmountLine."VAT Base";
    END;
    NewAmountIncludingVAT := NewAmount + ROUND(VATAmount,Currency."Amount Rounding Precision");
    END
    ELSE BEGIN
    IF (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount") = 0 THEN
    VATDifference := 0
    ELSE
    VATDifference :=
    TempVATAmountLineRemainder."VAT Difference" +
    VATAmountLine."VAT Difference" * (LineAmountToInvoice - InvDiscAmount) /
    (VATAmountLine."Line Amount" - VATAmountLine."Invoice Discount Amount");
    IF LineAmountToInvoice = 0 THEN
    "VAT Difference" := 0
    ELSE
    "VAT Difference" := ROUND(VATDifference,Currency."Amount Rounding Precision");
    END;

    IF (QtyType = QtyType::General) AND (PurchHeader.Status = PurchHeader.Status::Released) THEN BEGIN
    Amount := NewAmount;
    "Amount Including VAT" := ROUND(NewAmountIncludingVAT,Currency."Amount Rounding Precision");
    IF "VAT %" <> 0 THEN
    "VAT Base Amount" := ROUND(NewVATBaseAmount,Currency."Amount Rounding Precision")
    ELSE "VAT Base Amount" := Amount;
    END;
    InitOutstanding;
    IF NOT ((Type = Type::"Charge (Item)") AND ("Quantity Invoiced" <>"Qty. Assigned")) THEN BEGIN
    SetUpdateFromVAT(TRUE);
    UpdateUnitCost;
    END;
    IF Type = Type::"Charge (Item)" THEN
    UpdateItemChargeAssgnt;
    MODIFY;
    RecRef.GETTABLE(PurchLine);
    ChangeLogMgt.LogModification(RecRef,xRecRef);

    TempVATAmountLineRemainder."Amount Including VAT" :=
    NewAmountIncludingVAT - ROUND(NewAmountIncludingVAT,Currency."Amount Rounding Precision");
    TempVATAmountLineRemainder."VAT Amount" := VATAmount - NewAmountIncludingVAT + NewAmount;
    TempVATAmountLineRemainder."VAT Difference" := VATDifference - "VAT Difference";
    TempVATAmountLineRemainder."VAT Base (Lowered)" := NewVATBaseAmount - "VAT Base Amount";
    TempVATAmountLineRemainder.MODIFY;
    END;
    // End of the added lines.
    END;
    UNTIL NEXT = 0;
    SETRANGE(Type);
    SETRANGE(Quantity);
    SETRANGE("Qty. to Invoice");
    ...
  3. Change the code in the CalcVATAmountLines function in the Purchase Line table (39) as follows:

    Existing code
    ...
    Vendor.GET(PurchHeader."Pay-to Vendor No.");
    VendorPostingGroup.GET(Vendor."Vendor Posting Group");
    END;
    IF FINDSET THEN
    REPEAT
    // Delete the following lines.
    IF (Type = Type::"G/L Account") AND NOT "Prepayment Line" THEN
    RoundingLineInserted := ("No." = VendorPostingGroup."Invoice Rounding Account") OR RoundingLineInserted;
    IF "VAT Calculation Type" IN
    ["VAT Calculation Type"::"Reverse Charge VAT","VAT Calculation Type"::"Sales Tax"]
    THEN
    "VAT %" := 0;
    IF NOT VATAmountLine.GET(
    "VAT Identifier","VAT Calculation Type","Tax Group Code","Use Tax","Line Amount" >= 0)
    THEN BEGIN
    VATAmountLine.INIT;
    VATAmountLine."VAT Identifier" := "VAT Identifier";
    VATAmountLine."VAT Calculation Type" := "VAT Calculation Type";
    VATAmountLine."Tax Group Code" := "Tax Group Code";
    VATAmountLine."Use Tax" := "Use Tax";
    VATAmountLine."VAT %" := "VAT %";
    VATAmountLine.Modified := TRUE;
    VATAmountLine.Positive := "Line Amount" >= 0;
    VATAmountLine.INSERT;
    END;
    CASE QtyType OF
    QtyType::General:
    BEGIN
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Quantity (Base)";
    VATAmountLine."Line Amount" := VATAmountLine."Line Amount" + "Line Amount";
    IF "Allow Invoice Disc." THEN
    VATAmountLine."Inv. Disc. Base Amount" :=
    VATAmountLine."Inv. Disc. Base Amount" + "Line Amount";
    VATAmountLine."Invoice Discount Amount" :=
    VATAmountLine."Invoice Discount Amount" + "Inv. Discount Amount";
    VATAmountLine."VAT Difference" := VATAmountLine."VAT Difference" + "VAT Difference";
    IF "Prepayment Line" THEN
    VATAmountLine."Includes Prepayment" := TRUE;
    VATAmountLine."VAT Base (Lowered)" := VATAmountLine."VAT Base (Lowered)" + "VAT Base Amount";
    VATAmountLine.MODIFY;
    END;
    QtyType::Invoicing:
    BEGIN
    CASE TRUE OF
    ("Document Type" IN ["Document Type"::Order,"Document Type"::Invoice]) AND
    (NOT PurchHeader.Receive) AND PurchHeader.Invoice AND (NOT "Prepayment Line"):
    BEGIN
    IF "Receipt No." = '' THEN BEGIN
    QtyToHandle := GetAbsMin("Qty. to Invoice","Qty. Rcd. Not Invoiced");
    VATAmountLine.Quantity :=
    VATAmountLine.Quantity + GetAbsMin("Qty. to Invoice (Base)","Qty. Rcd. Not Invoiced (Base)");
    END ELSE BEGIN
    QtyToHandle := "Qty. to Invoice";
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Qty. to Invoice (Base)";
    END;
    END;
    ("Document Type" IN ["Document Type"::"Return Order","Document Type"::"Credit Memo"]) AND
    (NOT PurchHeader.Ship) AND PurchHeader.Invoice:
    BEGIN
    QtyToHandle := GetAbsMin("Qty. to Invoice","Return Qty. Shipped Not Invd.");
    VATAmountLine.Quantity :=
    VATAmountLine.Quantity + GetAbsMin("Qty. to Invoice (Base)","Ret. Qty. Shpd Not Invd.(Base)");
    END;
    ELSE
    BEGIN
    QtyToHandle := "Qty. to Invoice";
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Qty. to Invoice (Base)";
    END;
    END;
    VATAmountLine."Line Amount" :=
    VATAmountLine."Line Amount" +
    (ROUND(QtyToHandle * "Direct Unit Cost" - ("Line Discount Amount" * QtyToHandle / Quantity),
    Currency."Amount Rounding Precision"));
    IF "Allow Invoice Disc." THEN
    VATAmountLine."Inv. Disc. Base Amount" :=
    VATAmountLine."Inv. Disc. Base Amount" +
    (ROUND(QtyToHandle * "Direct Unit Cost" - ("Line Discount Amount" * QtyToHandle / Quantity),
    Currency."Amount Rounding Precision"));
    IF (PurchHeader."Invoice Discount Calculation" <> PurchHeader."Invoice Discount Calculation"::Amount) THEN
    VATAmountLine."Invoice Discount Amount" :=
    VATAmountLine."Invoice Discount Amount" +
    ROUND("Inv. Discount Amount" * QtyToHandle / Quantity,Currency."Amount Rounding Precision")
    ELSE
    VATAmountLine."Invoice Discount Amount" :=
    VATAmountLine."Invoice Discount Amount" + "Inv. Disc. Amount to Invoice";
    VATAmountLine."VAT Difference" := VATAmountLine."VAT Difference" + "VAT Difference";
    IF "Prepayment Line" THEN
    VATAmountLine."Includes Prepayment" := TRUE;
    VATAmountLine."VAT Base (Lowered)" := VATAmountLine."VAT Base (Lowered)" + "VAT Base Amount";
    VATAmountLine.MODIFY;
    END;
    QtyType::Shipping:
    BEGIN
    IF "Document Type" IN
    ["Document Type"::"Return Order","Document Type"::"Credit Memo"]
    THEN BEGIN
    QtyToHandle := "Return Qty. to Ship";
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Return Qty. to Ship (Base)";
    END ELSE BEGIN
    QtyToHandle := "Qty. to Receive";
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Qty. to Receive (Base)";
    END;
    VATAmountLine."Line Amount" :=
    VATAmountLine."Line Amount" +
    (ROUND(QtyToHandle * "Direct Unit Cost" - ("Line Discount Amount" * QtyToHandle / Quantity),
    Currency."Amount Rounding Precision"));
    IF "Allow Invoice Disc." THEN
    VATAmountLine."Inv. Disc. Base Amount" :=
    VATAmountLine."Inv. Disc. Base Amount" +
    (ROUND(QtyToHandle * "Direct Unit Cost" - ("Line Discount Amount" * QtyToHandle / Quantity),
    Currency."Amount Rounding Precision"));
    VATAmountLine."Invoice Discount Amount" :=
    VATAmountLine."Invoice Discount Amount" +
    ROUND("Inv. Discount Amount" * QtyToHandle / Quantity,Currency."Amount Rounding Precision");
    VATAmountLine."VAT Difference" := VATAmountLine."VAT Difference" + "VAT Difference";
    IF "Prepayment Line" THEN
    VATAmountLine."Includes Prepayment" := TRUE;
    VATAmountLine.MODIFY;
    END;
    END;
    TotalVATAmount := TotalVATAmount + "Amount Including VAT" - Amount;
    // End of the deleted lines.
    UNTIL NEXT = 0;
    SETRANGE(Type);
    SETRANGE(Quantity);
    ...
    Replacement code
    ...
    Vendor.GET(PurchHeader."Pay-to Vendor No.");
    VendorPostingGroup.GET(Vendor."Vendor Posting Group");
    END;
    IF FINDSET THEN
    REPEAT
    // Add the following lines.
    IF NOT ZeroAmountLine(QtyType) THEN BEGIN
    IF (Type = Type::"G/L Account") AND NOT "Prepayment Line" THEN
    RoundingLineInserted := ("No." = VendorPostingGroup."Invoice Rounding Account") OR RoundingLineInserted;
    IF "VAT Calculation Type" IN
    ["VAT Calculation Type"::"Reverse Charge VAT","VAT Calculation Type"::"Sales Tax"]
    THEN
    "VAT %" := 0;
    IF NOT VATAmountLine.GET(
    "VAT Identifier","VAT Calculation Type","Tax Group Code","Use Tax","Line Amount" >= 0)
    THEN BEGIN
    VATAmountLine.INIT;
    VATAmountLine."VAT Identifier" := "VAT Identifier";
    VATAmountLine."VAT Calculation Type" := "VAT Calculation Type";
    VATAmountLine."Tax Group Code" := "Tax Group Code";
    VATAmountLine."Use Tax" := "Use Tax";
    VATAmountLine."VAT %" := "VAT %";
    VATAmountLine.Modified := TRUE;
    VATAmountLine.Positive := "Line Amount" >= 0;
    VATAmountLine.INSERT;
    END;
    CASE QtyType OF
    QtyType::General:
    BEGIN
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Quantity (Base)";
    VATAmountLine."Line Amount" := VATAmountLine."Line Amount" + "Line Amount";
    IF "Allow Invoice Disc." THEN
    VATAmountLine."Inv. Disc. Base Amount" :=
    VATAmountLine."Inv. Disc. Base Amount" + "Line Amount";
    VATAmountLine."Invoice Discount Amount" :=
    VATAmountLine."Invoice Discount Amount" + "Inv. Discount Amount";
    VATAmountLine."VAT Difference" := VATAmountLine."VAT Difference" + "VAT Difference";
    IF "Prepayment Line" THEN
    VATAmountLine."Includes Prepayment" := TRUE;
    VATAmountLine."VAT Base (Lowered)" := VATAmountLine."VAT Base (Lowered)" + "VAT Base Amount";
    VATAmountLine.MODIFY;
    END;
    QtyType::Invoicing:
    BEGIN
    CASE TRUE OF
    ("Document Type" IN ["Document Type"::Order,"Document Type"::Invoice]) AND
    (NOT PurchHeader.Receive) AND PurchHeader.Invoice AND (NOT "Prepayment Line"):
    BEGIN
    IF "Receipt No." = '' THEN BEGIN
    QtyToHandle := GetAbsMin("Qty. to Invoice","Qty. Rcd. Not Invoiced");
    VATAmountLine.Quantity :=
    VATAmountLine.Quantity + GetAbsMin("Qty. to Invoice (Base)","Qty. Rcd. Not Invoiced (Base)");
    END ELSE BEGIN
    QtyToHandle := "Qty. to Invoice";
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Qty. to Invoice (Base)";
    END;
    END;
    ("Document Type" IN ["Document Type"::"Return Order","Document Type"::"Credit Memo"]) AND
    (NOT PurchHeader.Ship) AND PurchHeader.Invoice:
    BEGIN
    QtyToHandle := GetAbsMin("Qty. to Invoice","Return Qty. Shipped Not Invd.");
    VATAmountLine.Quantity :=
    VATAmountLine.Quantity + GetAbsMin("Qty. to Invoice (Base)","Ret. Qty. Shpd Not Invd.(Base)");
    END;
    ELSE
    BEGIN
    QtyToHandle := "Qty. to Invoice";
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Qty. to Invoice (Base)";
    END;
    END;
    VATAmountLine."Line Amount" :=
    VATAmountLine."Line Amount" +
    (ROUND(QtyToHandle * "Direct Unit Cost" - ("Line Discount Amount" * QtyToHandle / Quantity),
    Currency."Amount Rounding Precision"));
    IF "Allow Invoice Disc." THEN
    VATAmountLine."Inv. Disc. Base Amount" :=
    VATAmountLine."Inv. Disc. Base Amount" +
    (ROUND(QtyToHandle * "Direct Unit Cost" - ("Line Discount Amount" * QtyToHandle / Quantity),
    Currency."Amount Rounding Precision"));
    IF (PurchHeader."Invoice Discount Calculation" <> PurchHeader."Invoice Discount Calculation"::Amount) THEN
    VATAmountLine."Invoice Discount Amount" :=
    VATAmountLine."Invoice Discount Amount" +
    ROUND("Inv. Discount Amount" * QtyToHandle / Quantity,Currency."Amount Rounding Precision")
    ELSE
    VATAmountLine."Invoice Discount Amount" :=
    VATAmountLine."Invoice Discount Amount" + "Inv. Disc. Amount to Invoice";
    VATAmountLine."VAT Difference" := VATAmountLine."VAT Difference" + "VAT Difference";
    IF "Prepayment Line" THEN
    VATAmountLine."Includes Prepayment" := TRUE;
    VATAmountLine."VAT Base (Lowered)" := VATAmountLine."VAT Base (Lowered)" + "VAT Base Amount";
    VATAmountLine.MODIFY;
    END;
    QtyType::Shipping:
    BEGIN
    IF "Document Type" IN
    ["Document Type"::"Return Order","Document Type"::"Credit Memo"]
    THEN BEGIN
    QtyToHandle := "Return Qty. to Ship";
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Return Qty. to Ship (Base)";
    END ELSE BEGIN
    QtyToHandle := "Qty. to Receive";
    VATAmountLine.Quantity := VATAmountLine.Quantity + "Qty. to Receive (Base)";
    END;
    VATAmountLine."Line Amount" :=
    VATAmountLine."Line Amount" +
    (ROUND(QtyToHandle * "Direct Unit Cost" - ("Line Discount Amount" * QtyToHandle / Quantity),
    Currency."Amount Rounding Precision"));
    IF "Allow Invoice Disc." THEN
    VATAmountLine."Inv. Disc. Base Amount" :=
    VATAmountLine."Inv. Disc. Base Amount" +
    (ROUND(QtyToHandle * "Direct Unit Cost" - ("Line Discount Amount" * QtyToHandle / Quantity),
    Currency."Amount Rounding Precision"));
    VATAmountLine."Invoice Discount Amount" :=
    VATAmountLine."Invoice Discount Amount" +
    ROUND("Inv. Discount Amount" * QtyToHandle / Quantity,Currency."Amount Rounding Precision");
    VATAmountLine."VAT Difference" := VATAmountLine."VAT Difference" + "VAT Difference";
    IF "Prepayment Line" THEN
    VATAmountLine."Includes Prepayment" := TRUE;
    VATAmountLine.MODIFY;
    END;
    END;
    TotalVATAmount := TotalVATAmount + "Amount Including VAT" - Amount;
    END;
    // End of the added lines.
    UNTIL NEXT = 0;
    SETRANGE(Type);
    SETRANGE(Quantity);
    ...
  4. Create the ZeroAmountLine function in the Purchase Line table (39) as follows:
    ...
    PROCEDURE ZeroAmountLine@66(QtyType@1000 : 'General,Invoicing,Shipping') : Boolean;
    BEGIN
    IF Type = Type::" " THEN
    EXIT(TRUE);
    IF Quantity = 0 THEN
    EXIT(TRUE);
    IF ("Direct Unit Cost" = 0) THEN // W10001
    EXIT(TRUE);
    IF QtyType = QtyType::Invoicing THEN
    IF "Qty. to Invoice" = 0 THEN
    EXIT(TRUE);
    EXIT(FALSE);
    END;
    ...
  5. Change the code in the UpdInvPostingBuffer function in the Sales-Post codeunit (80) as follows:

    Existing code
    ...
    InvPostingBuffer[1]."Dimension Entry No." := EntryNo;
    IF InvPostingBuffer[1].Type = InvPostingBuffer[1].Type::"Fixed Asset" THEN BEGIN
    FALineNo := FALineNo + 1;
    InvPostingBuffer[1]."Fixed Asset Line No." := FALineNo;
    END;

    InvPostingBuffer[2] := InvPostingBuffer[1];
    IF InvPostingBuffer[2].FIND THEN BEGIN
    InvPostingBuffer[2].Amount := InvPostingBuffer[2].Amount + InvPostingBuffer[1].Amount;
    InvPostingBuffer[2]."VAT Amount" :=
    InvPostingBuffer[2]."VAT Amount" + InvPostingBuffer[1]."VAT Amount";
    ...
    Replacement code
    ...
    InvPostingBuffer[1]."Dimension Entry No." := EntryNo;
    IF InvPostingBuffer[1].Type = InvPostingBuffer[1].Type::"Fixed Asset" THEN BEGIN
    FALineNo := FALineNo + 1;
    InvPostingBuffer[1]."Fixed Asset Line No." := FALineNo;
    END;
    // Add the following lines.
    IF (SalesLine."Line Discount %" = 100) THEN BEGIN
    InvPostingBuffer[1]."VAT Base Amount" := 0;
    InvPostingBuffer[1]."VAT Base Amount (ACY)" := 0;
    InvPostingBuffer[1]."VAT Amount" := 0;
    InvPostingBuffer[1]."VAT Amount (ACY)" := 0;
    END;
    // End of the added lines.
    InvPostingBuffer[2] := InvPostingBuffer[1];
    IF InvPostingBuffer[2].FIND THEN BEGIN
    InvPostingBuffer[2].Amount := InvPostingBuffer[2].Amount + InvPostingBuffer[1].Amount;
    InvPostingBuffer[2]."VAT Amount" :=
    InvPostingBuffer[2]."VAT Amount" + InvPostingBuffer[1]."VAT Amount";
    ...
  6. Change the code in the DivideAmount function in the Sales-Post codeunit (80) as follows:

    Existing code
    ...
    IF RoundingLineInserted AND (RoundingLineNo = SalesLine."Line No.") THEN
    EXIT;
    WITH SalesLine DO
    // Delete the following line
    IF (SalesLineQty = 0) OR ("Unit Price" = 0) OR ("Line Discount %" = 100) THEN BEGIN
    "Line Amount" := 0;
    "Line Discount Amount" := 0;
    "Inv. Discount Amount" := 0;
    "VAT Base Amount" := 0;
    Amount := 0;
    ...
    Replacement code
    ...
    IF RoundingLineInserted AND (RoundingLineNo = SalesLine."Line No.") THEN
    EXIT;
    WITH SalesLine DO
    // Add the following line
    IF (SalesLineQty = 0) OR ("Unit Price" = 0) THEN BEGIN // W10001
    "Line Amount" := 0;
    "Line Discount Amount" := 0;
    "Inv. Discount Amount" := 0;
    "VAT Base Amount" := 0;
    Amount := 0;
    ...
  7. Change the code in the UpdInvPostingBuffer function in the Purch.-Post codeunit (90) as follows:

    Existing code
    ...
    IF InvPostingBuffer[1].Type = InvPostingBuffer[1].Type::"Fixed Asset" THEN BEGIN
    FALineNo := FALineNo + 1;
    InvPostingBuffer[1]."Fixed Asset Line No." := FALineNo;
    END;
    InvPostingBuffer[2] := InvPostingBuffer[1];
    IF InvPostingBuffer[2].FIND THEN BEGIN
    InvPostingBuffer[2].Amount :=
    InvPostingBuffer[2].Amount + InvPostingBuffer[1].Amount;
    InvPostingBuffer[2]."VAT Amount" :=
    ...
    Replacement code
    ...
    IF InvPostingBuffer[1].Type = InvPostingBuffer[1].Type::"Fixed Asset" THEN BEGIN
    FALineNo := FALineNo + 1;
    InvPostingBuffer[1]."Fixed Asset Line No." := FALineNo;
    END;
    // Add the following lines.
    IF (PurchLine."Line Discount %" = 100) THEN BEGIN
    InvPostingBuffer[1]."VAT Base Amount" := 0;
    InvPostingBuffer[1]."VAT Base Amount (ACY)" := 0;
    InvPostingBuffer[1]."VAT Amount" := 0;
    InvPostingBuffer[1]."VAT Amount (ACY)" := 0;
    END;
    // End of the added lines.
    InvPostingBuffer[2] := InvPostingBuffer[1];
    IF InvPostingBuffer[2].FIND THEN BEGIN
    InvPostingBuffer[2].Amount :=
    InvPostingBuffer[2].Amount + InvPostingBuffer[1].Amount;
    InvPostingBuffer[2]."VAT Amount" :=
    ...
  8. Change the code in the DivideAmount function in the Purch.-Post codeunit (90) as follows:

    Existing code
    ...
    IF RoundingLineInserted AND (RoundingLineNo = PurchLine."Line No.") THEN
    EXIT;
    WITH PurchLine DO
    // Delete the following line
    IF (PurchLineQty = 0) OR ("Direct Unit Cost" = 0) OR ("Line Discount %" = 100) THEN BEGIN
    "Line Amount" := 0;
    "Line Discount Amount" := 0;
    "Inv. Discount Amount" := 0;
    "VAT Base Amount" := 0;
    Amount := 0;
    ...
    Replacement code
    ...
    IF RoundingLineInserted AND (RoundingLineNo = PurchLine."Line No.") THEN
    EXIT;
    WITH PurchLine DO
    // Add the following line
    IF (PurchLineQty = 0) OR ("Direct Unit Cost" = 0) THEN BEGIN // W10001
    "Line Amount" := 0;
    "Line Discount Amount" := 0;
    "Inv. Discount Amount" := 0;
    "VAT Base Amount" := 0;
    Amount := 0;
    ...
  9. Change the code in the FillInvPostingBuffer function in the Serv-Amounts Mgt. codeunit (5986) as follows:

    Existing code 1
    ...
    TotalVATACY,
    TotalAmount,
    TotalAmountACY,
    TotalVATBase,
    TotalVATBaseACY);
    UpdInvPostingBuffer(InvPostingBuffer,TempDocDim);
    END;

    IF SalesSetup."Discount Posting" IN
    [SalesSetup."Discount Posting"::"Line Discounts",SalesSetup."Discount Posting"::"All Discounts"] THEN
    ...
    Replacement code 1
    ...
    TotalVATACY,
    TotalAmount,
    TotalAmountACY,
    TotalVATBase,
    TotalVATBaseACY);
    // Add the following lines.
    IF ServiceLine."Line Discount %" = 100 THEN
    ClearSerLineDiscBuffer(InvPostingBuffer[1]);
    // End of the added lines.
    UpdInvPostingBuffer(InvPostingBuffer,TempDocDim);
    END;

    IF SalesSetup."Discount Posting" IN
    [SalesSetup."Discount Posting"::"Line Discounts",SalesSetup."Discount Posting"::"All Discounts"] THEN
    ...
    Existing code 2
    ...
    TotalVATACY,
    TotalAmount,
    TotalAmountACY,
    TotalVATBase,
    TotalVATBaseACY);
    UpdInvPostingBuffer(InvPostingBuffer,TempDocDim);
    END;

    InvPostingBuffer[1].SetAmounts(
    TotalVAT,
    ...
    Replacement code 2
    ...
    TotalVATACY,
    TotalAmount,
    TotalAmountACY,
    TotalVATBase,
    TotalVATBaseACY);
    // Add the following lines.
    IF ServiceLine."Line Discount %" = 100 THEN
    ClearSerLineDiscBuffer(InvPostingBuffer[1]);
    // End of the added lines.
    UpdInvPostingBuffer(InvPostingBuffer,TempDocDim);
    END;

    InvPostingBuffer[1].SetAmounts(
    TotalVAT,
    ...
    Existing code 3
    ...
    TotalVATBase,
    TotalVATBaseACY);
    END;
    END;
    END;

    UpdInvPostingBuffer(InvPostingBuffer,TempDocDim);
    ...
    Replacement code 3
    ...
    TotalVATBase,
    TotalVATBaseACY);
    END;
    END;
    END;
    // Add the following lines.
    IF ServiceLine."Line Discount %" = 100 THEN
    ClearSerLineDiscBuffer(InvPostingBuffer[1]);
    // End of the added lines.

    UpdInvPostingBuffer(InvPostingBuffer,TempDocDim);
    ...
  10. Change the code in the ClearSerLineDiscBuffer function in the Serv-Amounts Mgt. codeunit (5986) as follows:
    ...
    LOCAL PROCEDURE ClearSerLineDiscBuffer@50(VAR InvPostingBuffer@1050 : Record 49);
    BEGIN
    InvPostingBuffer."VAT Base Amount" := 0;
    InvPostingBuffer."VAT Base Amount (ACY)" := 0;
    InvPostingBuffer."VAT Amount" := 0;
    InvPostingBuffer."VAT Amount (ACY)" := 0;
    END;
    ...

Prerequisites

You must have one of the following products installed to apply this hotfix:
  • The Belgian version of Microsoft Dynamics NAV 2009 Service Pack 1 (SP1)
  • The Belgian version of Microsoft Dynamics NAV 2009 R2


Removal information

You cannot remove this hotfix.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


References

VSTF DynamicsNAV SE: 284212

↑ Back to the top


Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

↑ Back to the top


Keywords: kbqfe, kbmbsquickpub, kbmbsmigrate, kbmbspartner, kbmbscodefix, kbsurveynew, kb

↑ Back to the top

Article Info
Article ID : 2629970
Revision : 1
Created on : 1/7/2017
Published on : 10/31/2011
Exists online : False
Views : 205