Division by zero File: /custom/Espo/Modules/Sales/Tools/Quote/BeforeSaveProcessor

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Russ
    Senior Member
    • Feb 2022
    • 502

    #1

    Division by zero File: /custom/Espo/Modules/Sales/Tools/Quote/BeforeSaveProcessor


    Hey guys,

    We’ve encountered a repeatable fatal error when saving a Quote/Delivery Order in EspoCRM Sales Pack.

    Error details:
    Type: DivisionByZeroError Message: Division by zero File: /custom/Espo/Modules/Sales/Tools/Quote/BeforeSaveProcessor.php Line: 267 Trace: Espo\Modules\Sales\Tools\Quote\BeforeSaveProcessor->calculateItem()
    Full stack trace is attached below.

    Context:
    • Occurs during beforeSave for Quote (and Delivery Order linked to an Opportunity).
    • We cannot modify PHP source code on our hosting.
    • Looks like calculateItem() is dividing by a field that sometimes ends up as zero (quantity, packQty, duration, or currency rate).

    Expected behavior:
    • BeforeSaveProcessor should gracefully handle zero or null divisor fields — either skip calculation or default to 1 — instead of throwing an uncaught DivisionByZeroError.

    Request:
    • Please update calculateItem() (and related calls) to validate divisor fields and avoid division by zero.
    • Ideally, it should log a warning and continue processing or block save with a clear validation error in the UI.

    Why this matters:
    • This error completely prevents saving affected records and disrupts workflows.
    • Since it’s in core logic, we cannot patch it without modifying EspoCRM code.



    This is happening across the board on different records
  • Russ
    Senior Member
    • Feb 2022
    • 502

    #2
    Version 9.1.5
    Sales Pack 3.0.4
    Advanced Pack 3.9.0

    Comment

    • yuri
      EspoCRM product developer
      • Mar 2014
      • 9249

      #3
      Would be good to reproduce the error somehow. It could indicate that something wrong is happening before. Maybe you have some formula that changes item values? The division by zero does not seem to have to occur there.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      Working...