Coder Social home page Coder Social logo

Comments (6)

horstoeko avatar horstoeko commented on August 27, 2024

Hi @danielmarschall ,

Please Look for ZugferdSettings...

It is described in the README.md and in the Wiki...

Have a nice evening...

from zugferd.

danielmarschall avatar danielmarschall commented on August 27, 2024

Thank you for the quick reply!

Unfortunately, the method ZugferdSettings::setAmountDecimals is very useless, because different prices attributes allow different amount of decimals.

When I do setAmountDecimals(11), then I get the error:

BR-DEC-19
The allowed maximum number of decimals for the VAT category taxable amount (BT-116) is 2.

So, I think what I actually need is to have single unit prices to be with high precision and summarization prices as 2 decimals (since the standard defines it this way).

For now, my only workaround is this (but it is very dirty):

    public function serializeAmountType(XmlSerializationVisitor $visitor, $data, array $type, Context $context)
    {
        $node = $visitor->getDocument()->createTextNode(
            number_format(
                $data->value(),
                // Dirty workaround
                $visitor->getCurrentNode()->localName=='ChargeAmount'?5:2,//ZugferdSettings::getAmountDecimals(),
                ZugferdSettings::getDecimalSeparator(),
                ZugferdSettings::getThousandsSeparator()
            )
        );

Do you have an idea how to make this solution cleaner? Maybe I can try to contribute.

from zugferd.

horstoeko avatar horstoeko commented on August 27, 2024

Hi,

You are welcome to suggest another solution, even as a PR. However, there was no such requirement in the recent and even in the older past.

from zugferd.

danielmarschall avatar danielmarschall commented on August 27, 2024

Ok, I will think about a solution which is a bit cleaner.

Just to explain why more than 2 decimal places are needed in my case.

Customer pays gross prices ("Brutto-Kunde"). They buy 500 pieces of 0.15 EUR gross price. Price to pay = 500x0.15EUR=75.00EUR (taxes 19% included)

In the ZUGFeRD invoice, since the tax is applied on top of the the sum of the item prices, this means that item prices needs to be net, not gross. So I have to convert the single item prices from gross to net: 0.15 EUR / 1.19 = 0.126050420168067EUR
If I round to 0.13, then the customer will pay 500 x 0.13EUR * 1.19 = 77.35EUR (taxes 19% included). So we have a rounding error of -2.35EUR, that's a lot!

from zugferd.

danielmarschall avatar danielmarschall commented on August 27, 2024

Fixed in #62

Example usage:

ZugferdSettings::setAmountDecimals(2);
ZugferdSettings::setAmountDecimals(5, "ram:ChargeAmount");

from zugferd.

horstoeko avatar horstoeko commented on August 27, 2024

Hi @danielmarschall,

please review #64 ...

Thanks and best regards

from zugferd.

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.