Announcement

Collapse
No announcement yet.

VAT calculation; precision of 2 numbers after the decimal in calculations?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VAT calculation; precision of 2 numbers after the decimal in calculations?

    Could you please help me understanding, how Espo CRM calculates VAT (Invoice Items screenshot attached)? And is it possible to change precision to 2 instead of 4 numbers after the decimal in calculations?

    If I understand correctly, in the attached case (you see Invoice Items), VAT is calculated like this:

    $firstLineVAT = 151.2 * 0.21 = 31.752

    $secondLineVAT = 88.02 * 0.21 = 18.4842

    $taxAmount = 31.752 + 18.4842 = 50.2362

    Tax Amount has an "in-built" precision of 2 and shows a rounded number "Tax Amount = 50.24". Is this correct?

    If so, is it possible to have the precision of 2 in $firstLineVAT and $secondLineVAT? Then the values would be 31.75 and 18.48 accordingly. And finally, the result would be "Tax Amount = 50.23" (31.75 + 18.48).

    The thing is, that I need to have that "Tax Amount = 50.23" and I don't know how to get it... Any ideas?

    Thanks,
    Laimonas
    Attached Files

  • #2
    Hi,
    You can fetch it with the "taxAmount" attribute.
    Attached Files

    Comment


    • #3
      Maximus Ok, I can see that you have 2 numbers after the decimal, but I have 4 (see attachment). How do I make it like yours? Also, I need to have 2 numbers after the decimal in each line ($firstLineVAT and $secondLineVAT), not only in the final "taxAmount" field.
      Attached Files

      Comment


      • #4
        Hi Laimonas, here how I did mine to 2 decimal. Please update it to your.

        Tax = number\round(gross*(taxRate/100), 2)

        Where tax is the field I want to calculate,
        and taxRate is another field I have the rate in. I /100 to convert it to a decimal (a percentage). I use "round" which by default is round down I think. You probably can do roundup if you like. The ,2 mean I want 2 decimal place; for example $10.15. If I want 4 I would use ,4 it become something like $10.1532 for example.

        Comment


        • #5
          esforim that formula works on my own created fields, but how can I reach the espocrm built-in fields where taxes are calculated in each line?

          There is only taxRate, but there is no tax value in every line (something like taxAmount, but in every line). The only tax value I can find is the Tax Amount in "Bottom Total", already after summation of all lines.

          I need to change decimal place of built-in tax value field in every line.

          Now if I create my own taxValue field in every line and implement formula there I encounter a problem of how to sum the whole column, because each invoice can have a different number of lines. Thus it's quite complicated for me to create a custom "Bottom Total" section. That is why I want to reach built-in fields and use the existing "Bottom Total".

          I am not sure if I expressed myself clear enough here

          Comment


          • #6
            yuri espocrm I have created my own fields "Tax Amount Line" and "Total Amount Line" (two screenshots attached). The sum of two "Tax Amount Line" lines is 50.23, but Tax Amount in "Bottom Total" shows 50.24 because it has 4 numbers after the decimal of the built-in tax value field in every line.
            Attached Files

            Comment


            • #7
              Hi Laimonas, I think you pinged wrong person, that account is the official account... I'm just another user like yourself.

              With regard to your question unfortunately I don't have the extension to do testing with but I would suggest to try bunch of available field in it raw form to see which show what, find if there you want to see.

              Then I would go down the path of try to get it to 2 decimal place and see if it behave correctly. And finally once it does then I would try the last step, test it with calculation/formula.

              Looking at your picture it seem like you doing extra work? Why didn't you just do this...? It doesnt work?
              taxAmountLine = number\round((amount*taxRate)/100, 2)

              Perhaps making it 2 decimal earlier in the field might be the way to go also?

              Comment


              • #8
                Originally posted by Laimonas View Post
                Could you please help me understanding, how Espo CRM calculates VAT (Invoice Items screenshot attached)? And is it possible to change precision to 2 instead of 4 numbers after the decimal in calculations?

                If I understand correctly, in the attached case (you see Invoice Items), VAT is calculated like this:

                $firstLineVAT = 151.2 * 0.21 = 31.752

                $secondLineVAT = 88.02 * 0.21 = 18.4842

                $taxAmount = 31.752 + 18.4842 = 50.2362

                Tax Amount has an "in-built" precision of 2 and shows a rounded number "Tax Amount = 50.24". Is this correct?
                https://southafricanvatcalculator.co.za/​​
                If so, is it possible to have the precision of 2 in $firstLineVAT and $secondLineVAT? Then the values would be 31.75 and 18.48 accordingly. And finally, the result would be "Tax Amount = 50.23" (31.75 + 18.48).

                The thing is, that I need to have that "Tax Amount = 50.23" and I don't know how to get it... Any ideas?

                Thanks,
                Laimonas
                Hello. If an amount of R3 888 already includes VAT, if I want to show the amount minus the VAT portion in an invoice, it is R3,380.87, correct?

                The client calculates it as R3304.80.​
                Last edited by bojef; 12-27-2023, 12:56 AM.

                Comment


                • #9
                  what is your tax rate VAT?

                  Comment

                  Working...
                  X