Giter VIP home page Giter VIP logo

Comments (5)

cornelpopa avatar cornelpopa commented on June 2, 2024

DivisionByZeroError: Division by zero in.../vendor/josemmo/einvoicing/src/InvoiceLine.php:305
Stack trace:
#0 .../vendor/josemmo/einvoicing/src/InvoiceLine.php(343): Einvoicing\InvoiceLine->getNetAmountBeforeAllowancesCharges()
#1 .../vendor/josemmo/einvoicing/src/Models/InvoiceTotals.php(102): Einvoicing\InvoiceLine->getNetAmount()
#2 .../vendor/josemmo/einvoicing/src/Invoice.php(892): Einvoicing\Models\InvoiceTotals::fromInvoice()
#3 .../app/Jobs/MessageDetailsJob.php(54): Einvoicing\Invoice->getTotals()

from einvoicing.

josemmo avatar josemmo commented on June 2, 2024

Hello @cornelpopa,

Thanks for reporting this issue.

I can add a check to avoid the DivisionByZeroError, but shouldn't this be the expected behavior? I mean, an InvoiceLine with a base quantity of 0 (zero) doesn't make sense, so the error is appropiate.

Otherwise, what should be the expected return value of InvoiceLine::getNetAmountBeforeAllowancesCharges() when the base quantity is zero?

from einvoicing.

cornelpopa avatar cornelpopa commented on June 2, 2024

@josemmo Yeah, you're right - that line doesn't make sense, and I agree that division by 0 should be checked for and return maybe an Exception? The invoice where I hit the problem was one "received" by me, not generated by me. You can never be assume that data sent by others is proper. :-(

from einvoicing.

josemmo avatar josemmo commented on June 2, 2024

Ok, for now I think is best to keep the current behavior and throw an exception.

from einvoicing.

cornelpopa avatar cornelpopa commented on June 2, 2024

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.