Mục sổ cái chung không chính xác sau khi bạn gửi hóa đơn hoặc đơn hàng có giảm giá dòng 100 phần trăm trong phiên bản Microsoft Dynamics NAV của Bỉ

Áp dụng cho
Dynamics NAV 2009

Bài viết này áp dụng cho Microsoft Dynamics NAV dành cho ngôn ngữ (be) của Bỉ.

Triệu chứng

Khi bạn gửi một đơn bán hàng, một đơn bán hàng, một hóa đơn mua hàng, một đơn đặt hàng dịch vụ có một 100 phần trăm dòng giảm giá trong phiên bản Bỉ của Microsoft Dynamics NAV, sổ cái chung (GL) mục không chính xác.
Sự cố này xảy ra khi dòng số tiền, dòng chiết khấu số tiền, giá trị gia tăng thuế (VAT) cơ sở số tiền và "số tiền bao gồm VAT" số tiền được đặt không.

Sự cố này xảy ra trong các sản phẩm sau:

  • Phiên bản Microsoft Dynamics NAV 2009 Phiên bản Bỉ 1 (SP1)
  • Phiên bản Microsoft Dynamics NAV 2009 R2 dành cho Bỉ

Giải pháp

Thông tin cập nhật nóng

Hotfix được hỗ trợ hiện có sẵn từ Microsoft. Tuy nhiên, nó chỉ là nhằm sửa chữa vấn đề được mô tả trong bài viết này. Áp dụng nó chỉ cho hệ thống đang gặp này cụ thể vấn đề. Hotfix này có thể nhận được thử nghiệm bổ sung. Do đó, nếu bạn không bị ảnh hưởng nghiêm trọng bởi sự cố này, chúng tôi khuyên bạn nên đợi gói dịch vụ Microsoft Dynamics NAV 2009 tiếp theo hoặc phiên bản Microsoft Dynamics NAV tiếp theo có chứa hotfix này.

Lưu ý Trong trường hợp đặc biệt, các khoản phí thường phát sinh đối với các cuộc gọi hỗ trợ có thể bị hủy nếu Chuyên gia Hỗ trợ Kỹ thuật dành cho Microsoft Dynamics và các sản phẩm liên quan xác định rằng một bản cập nhật cụ thể sẽ giải quyết sự cố của bạn. Chi phí hỗ trợ thông thường sẽ áp dụng cho các câu hỏi và sự cố hỗ trợ bổ sung không đủ điều kiện cho bản cập nhật cụ thể được đề cập.

            
          

Thông tin cài đặt

Microsoft chỉ cung cấp các ví dụ lập trình để minh họa mà không cần bảo hành dù là rõ ràng hay ngụ ý. Điều này bao gồm, nhưng không giới hạn ở, bảo hành ngụ ý về khả năng bán được hoặc sự thích hợp cho một mục đích cụ thể. Bài viết này giả định rằng bạn đã quen thuộc với ngôn ngữ lập trình đang được chứng minh và với các công cụ được sử dụng để tạo và gỡ lỗi thủ tục. Các kỹ sư hỗ trợ của Microsoft có thể giúp giải thích chức năng của một quy trình cụ thể, nhưng họ sẽ không sửa đổi các ví dụ này để cung cấp chức năng bổ sung hoặc quy trình xây dựng để đáp ứng các yêu cầu cụ thể của bạn.

Lưu ý Trước khi bạn cài đặt hotfix này, hãy xác minh rằng tất cả người dùng máy khách Microsoft Navision đã được đăng xuất khỏi hệ thống. Điều này bao gồm người dùng máy khách Dịch vụ Ứng dụng Microsoft Navision (NAS). Bạn nên là người dùng khách duy nhất đăng nhập khi bạn thực hiện hotfix này.

Để thực hiện hotfix này, bạn phải có giấy phép nhà phát triển.

Chúng tôi khuyên bạn nên gán tài khoản người dùng trong cửa sổ Đăng nhập Windows hoặc trong cửa sổ Đăng nhập Cơ sở dữ liệu. Nếu tài khoản người dùng không thể được gán ID vai trò "SIÊU", bạn phải xác minh rằng tài khoản người dùng có các quyền sau đây:

  • Quyền Sửa đổi đối với đối tượng mà bạn sẽ thay đổi.
  • Quyền Thực thi đối với đối tượng ID Đối tượng Hệ thống 5210 và đối với đối tượng ID Đối tượng Hệ thống 9015.

                
Lưu ý Bạn không phải có quyền đối với các kho dữ liệu trừ khi bạn phải thực hiện sửa chữa dữ liệu.

Thay đổi mã

Lưu ý Luôn kiểm tra các bản sửa lỗi mã trong môi trường được kiểm soát trước khi bạn áp dụng các bản sửa lỗi cho máy tính sản xuất của bạn.
Để giải quyết vấn đề này, hãy làm theo các bước sau:

  1. Thay đổi mã trong hàm ZeroAmountLine trong bảng Dòng Bán hàng (37) như sau:

    Mã hiện có

    ...
       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);  
    ...
    

    Mã thay thế

    ...
        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. Thay đổi mã trong hàm UpdateVATOnLines trong bảng Dòng Mua (39) như sau:

    Mã hiện có 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)" +
    ...
    

    Mã thay thế 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)" +
    ...
    

    Mã hiện có 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"); 
    ...
    

    Mã thay thế 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. Thay đổi mã trong hàm CalcVATAmountLines trong bảng Dòng Mua (39) như sau:

    Mã hiện có

    ...
          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); 
    ...
    

    Mã thay thế

    ...
          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. Tạo hàm ZeroAmountLine trong bảng Dòng Mua (39) như sau:

    ...
      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. Thay đổi mã trong hàm UpdInvPostingBuffer trong codeunit Sales-Post (80) như sau:

    Mã hiện có

    ...
         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";
    ...
    

    Mã thay thế

    ...
        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. Thay đổi mã trong hàm DivideAmount trong codeunit Sales-Post (80) như sau:

    Mã hiện có

    ...
         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;
    ...
    

    Mã thay thế

    ...
        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. Thay đổi mã trong hàm UpdInvPostingBuffer trong codeunit Purch.-Post (90) như sau:

    Mã hiện có

    ...
        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" := 
    ...
    

    Mã thay thế

    ...
       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. Thay đổi mã trong hàm DivideAmount trong đơn vị mã Purch.-Post (90) như sau:

    Mã hiện có

    ...
         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;
    ...
    

    Mã thay thế

    ...
       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. Thay đổi mã trong hàm FillInvPostingBuffer trong Serv-Amounts mgt. codeunit (5986) như sau:

    Mã hiện có 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
    ...
    

    Mã thay thế 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
    ...
    

    Mã hiện có 2

    ...
             TotalVATACY,
          TotalAmount,
          TotalAmountACY,
          TotalVATBase,
          TotalVATBaseACY);
        UpdInvPostingBuffer(InvPostingBuffer,TempDocDim);
      END;
    
      InvPostingBuffer[1].SetAmounts(
        TotalVAT,
    ...
    

    Mã thay thế 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,
    ...
    

    Mã hiện có 3

    ...
                TotalVATBase,
              TotalVATBaseACY);
          END;
        END;
      END;
    
      UpdInvPostingBuffer(InvPostingBuffer,TempDocDim); 
    ...
    

    Mã thay thế 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. Thay đổi mã trong hàm ClearSerLineDiscBuffer trong Serv-Amounts Mgt. codeunit (5986) như sau:

    ...
      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; 
    ...
    

Điều kiện tiên quyết

Bạn phải cài đặt một trong các sản phẩm sau để áp dụng bản cập nhật nóng này:

  • Phiên bản Microsoft Dynamics NAV 2009 Phiên bản Bỉ 1 (SP1)
  • Phiên bản Microsoft Dynamics NAV 2009 R2 dành cho Bỉ

                
              

Loại bỏ thông tin

Bạn không thể loại bỏ hotfix này.

Trạng thái

Microsoft đã xác nhận rằng đây là sự cố trong các sản phẩm của Microsoft được liệt kê trong mục "áp dụng cho".

Tham khảo

VSTF DynamicsNAV SE: 284212

Lưu ý Đây là bài viết "PHÁT HÀNH NHANH" được tạo trực tiếp từ trong tổ chức hỗ trợ của Microsoft. Thông tin có trong tài liệu này được cung cấp tương tự để đáp ứng các vấn đề mới xuất hiện. Do tốc độ làm cho nó có sẵn, các tài liệu có thể bao gồm lỗi đánh máy và có thể được sửa đổi bất cứ lúc nào mà không cần thông báo. Hãy xem Điều khoản Sử dụng để biết những điều cần cân nhắc khác.