web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Round problem Sales Line

(0) ShareShare
ReportReport
Posted on by

So Hi everyone, I've created a page where I use a list of sales order. Here the source table of my page is "Sales Line" and when i enter the same item twice (or more times) the round of the price in the column "Amount Including VAT" is not right, shpuld be always the same value but for each line have differences.

Here's the image below.

round.png

I try to comment this code in Sales Line table

Amount Including VAT - OnValidate()
GetPurchHeader;
"Amount Including VAT" := ROUND("Amount Including VAT",Currency."Amount Rounding Precision");

But everything stay the same... any idea?

*This post is locked for comments

I have the same question (0)
  • Hannes Holst Profile Picture
    5,767 on at

    Hi,

    Maybe you didn't reset the variables for the new line?

  • Community Member Profile Picture
    on at

    which variables? Can you ellaborate pls?

  • Hannes Holst Profile Picture
    5,767 on at

    Did you create a new Subpage or do you use an existing one?

  • Community Member Profile Picture
    on at

    This page is new and use Sales Header table and another page linekd to sales Line

    posproblem.png

  • Hannes Holst Profile Picture
    5,767 on at

    Hi,

    sorry, I did misunderstand your question.

    The field "Amount Including VAT" is calculated in the Table "Sales Line" and not in the page.

    Are you sure you do not have any customization in the table "Sales Line"?

    I'm not sure for NAV2016, but in NAV2017 there is no function called "GetPurchHeader" in that table.

  • Community Member Profile Picture
    on at

    In table "Sales Line" I have this code for "Amout Including Vat" field

    Amount Including VAT - OnValidate()
    //"Amount Including VAT" := ROUND("Amount Including VAT",Currency."Amount Rounding Precision");
    CASE "VAT Calculation Type" OF
      "VAT Calculation Type"::"Normal VAT",
      "VAT Calculation Type"::"Reverse Charge VAT",
      "VAT Calculation Type"::"No Taxable VAT": //soft,n
        BEGIN
          Amount :=
            ROUND(
              "Amount Including VAT" /
    
              //soft,o (1 + (1 - SalesHeader."VAT Base Discount %" / 100) * "VAT %" / 100),
              (1 + (1 - SalesHeader."VAT Base Discount %" / 100) * ("VAT %" + "ND %") / 100), //soft,n
    
              Currency."Amount Rounding Precision");
          "VAT Base Amount" :=
            ROUND(Amount * (1 - SalesHeader."VAT Base Discount %" / 100),Currency."Amount Rounding Precision");
        END;
      "VAT Calculation Type"::"Full VAT":
        BEGIN
          Amount := 0;
          "VAT Base Amount" := 0;
        END;
      "VAT Calculation Type"::"Sales Tax":
        BEGIN
          SalesHeader.TESTFIELD("VAT Base Discount %",0);
          Amount :=
            SalesTaxCalculate.ReverseCalculateTax(
              "Tax Area Code","Tax Group Code","Tax Liable",SalesHeader."Posting Date",
              "Amount Including VAT","Quantity (Base)",SalesHeader."Currency Factor");
          IF Amount <> 0 THEN
            "VAT %" :=
              ROUND(100 * ("Amount Including VAT" - Amount) / Amount,0.00001)
          ELSE
            //soft,o "VAT %" := 0;
            //soft,sn
            BEGIN
              "VAT %" := 0;
              "ND %" := 0;
            END;
            //soft,en
          Amount := ROUND(Amount,Currency."Amount Rounding Precision");
          "VAT Base Amount" := Amount;
        END;
    END;
    
    "Pmt. Disc. Given Amount" := 0; //soft,n
    
    InitOutstandingAmount;


    In my page "Purchase Quote Subform" I have this function called several times, to recalculate the amounts RedistributeTotalsOnAfterValidate

    LOCAL RedistributeTotalsOnAfterValidate
    
    CurrPage.SAVERECORD;
    
    PurchHeader.GET("Document Type","Document No.");
    IF DocumentTotals.PurchaseCheckNumberOfLinesLimit(PurchHeader) THEN
    DocumentTotals.PurchaseRedistributeInvoiceDiscountAmounts(Rec,VATAmount,TotalPurchaseLine);
    CurrPage.UPDATE;


  • Hannes Holst Profile Picture
    5,767 on at

    HI,

    This is the standard code of the OnValidate-Trigger of field "Amount Including VAT" of NAV2017:

    "Amount Including VAT" := ROUND("Amount Including VAT",Currency."Amount Rounding Precision");
    CASE "VAT Calculation Type" OF
      "VAT Calculation Type"::"Normal VAT",
      "VAT Calculation Type"::"Reverse Charge VAT":
        BEGIN
          Amount :=
            ROUND(
              "Amount Including VAT" /
              (1 + (1 - SalesHeader."VAT Base Discount %" / 100) * "VAT %" / 100),
              Currency."Amount Rounding Precision");
          "VAT Base Amount" :=
            ROUND(Amount * (1 - SalesHeader."VAT Base Discount %" / 100),Currency."Amount Rounding Precision");
        END;
      "VAT Calculation Type"::"Full VAT":
        BEGIN
          Amount := 0;
          "VAT Base Amount" := 0;
        END;
      "VAT Calculation Type"::"Sales Tax":
        BEGIN
          SalesHeader.TESTFIELD("VAT Base Discount %",0);
          Amount :=
            SalesTaxCalculate.ReverseCalculateTax(
              "Tax Area Code","Tax Group Code","Tax Liable",SalesHeader."Posting Date",
              "Amount Including VAT","Quantity (Base)",SalesHeader."Currency Factor");
          IF Amount <> 0 THEN
            "VAT %" :=
              ROUND(100 * ("Amount Including VAT" - Amount) / Amount,0.00001)
          ELSE
            "VAT %" := 0;
          Amount := ROUND(Amount,Currency."Amount Rounding Precision");
          "VAT Base Amount" := Amount;
        END;
    END;
    
    InitOutstandingAmount;


    As you can see, you have some modifications in your code:

     (1 + (1 - SalesHeader."VAT Base Discount %" / 100) * ("VAT %" + "ND %") / 100), //soft,n

    This could be a reason for the problem.
    What is the relation to the "Purchase Quote Subform"?

    It's difficult to troubleshoot the problem because it possible was created due to customized code.
    When you create a clean database without customization, you will notice that this problem will not occur.

  • Community Member Profile Picture
    on at

    I will try your code, thanks. I don't know why this is modified

  • Community Member Profile Picture
    on at

    The code dind't work... it's the same

  • Hannes Holst Profile Picture
    5,767 on at

    I can't help you any further. Next step would be to debugg the problem.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans