Giter VIP home page Giter VIP logo

Comments (4)

floriankraemer avatar floriankraemer commented on June 2, 2024

I think this ->setPrice(100 / 1.19) is the problem. Try using https://github.com/piggly-dev/php-decimal to fix the issue. I don't think that this is a problem of the library but PHPs precision for this operation 100 / 1.19. Why do you need to divide it and then add it back anyway, if I get that right?

from einvoicing.

robert-stanciu avatar robert-stanciu commented on June 2, 2024

The reason I need to do that is because a customer could set the invoice line's price as 100 RON including VAT (on my platform).

If it does that with quantity = 1, then we have no issue. However, if he wants 100k units of that invoice line, the invoice's total must be 10.000.000.

I believe that the precision is not the issue because of the way rounding is done in this library.
Here's a possible fix I prepared: https://github.com/robert-stanciu/einvoicing/pull/2/files

from einvoicing.

robert-stanciu avatar robert-stanciu commented on June 2, 2024

Today I found that this behavior happens in the UBL reader too.
Because of the roundings that might appear, the invoice line price won't have enough precision to calculate the invoice totals.

This is a solution: robert-stanciu#3

P.S.: I am aware that this edge case can appear only in certain countries.

from einvoicing.

josemmo avatar josemmo commented on June 2, 2024

Hello @robert-stanciu,

Sorry for the delay.

This is because EN 16931 mandates the price without VAT of an item has to be rounded to 2 decimals. AFAIK, this is just how the specification works.

Maybe CIUS-RO has different decimal precision for some of the invoice fields, but I cannot find the specification in English to verify it.

from einvoicing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.