Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0037580Openbravo ERP07. Sales managementpublic2018-01-03 21:462018-02-22 18:18
matias-bernal 
collazoandy4 
highmajoralways
closedfixed 
5
3.0PR16Q3.4 
3.0PR18Q2 
dmiguelez
Core
No
0037580: "division by zero" error when book sales order with BOM products
We created a sales order and a sales order line with a BOM product and quantity ordered > 0, book this order and try close it then OB show this error "division by zero"(see attachment).

When C_ORDER_POST runs the trigger C_ORDERLINE_TRG tries to calculate the variable v_PriceActual using :new.qtyordered equals to 0. So that, it returns division by zero error.

This error is also present in livebuilds for BOM products
1 - Create a New sales order
2 - Create a New sales order line whit quantity ordered > 0 and a product BOM.
3 - Book this order.
4 - Close this order.
Modify the C_ORDERLINE_TRG.xml
Replace in

https://code.openbravo.com/erp/devel/pi/file/a8b6912d30a3/src-db/database/model/triggers/C_ORDERLINE_TRG.xml#l227 [^]

this line:

 v_PriceActual := ROUND(v_NetActual / :new.qtyordered, v_price_prec);

using this:

      IF (:new.qtyordered <> 0) THEN
        v_PriceActual := ROUND(v_NetActual / :new.qtyordered, v_price_prec);
      ELSE
        v_PriceActual := 0;
      END IF;
No tags attached.
png Selección_379.png (141,967) 2018-01-03 21:46
https://issues.openbravo.com/file_download.php?file_id=11415&type=bug
png
Issue History
2018-01-03 21:46matias-bernalNew Issue
2018-01-03 21:46matias-bernalAssigned To => Triage Finance
2018-01-03 21:46matias-bernalFile Added: Selección_379.png
2018-01-03 21:46matias-bernalModules => Core
2018-01-03 21:46matias-bernalTriggers an Emergency Pack => No
2018-01-03 22:21rbianchiniIssue Monitored: rbianchini
2018-01-04 15:24rbianchiniResolution time => 1516762800
2018-01-04 17:41dmiguelezAssigned ToTriage Finance => collazoandy4
2018-01-06 02:05collazoandy4Statusnew => scheduled
2018-01-06 02:06collazoandy4Note Added: 0101604
2018-01-09 10:26hgbotCheckin
2018-01-09 10:26hgbotNote Added: 0101635
2018-01-09 10:26hgbotStatusscheduled => resolved
2018-01-09 10:26hgbotResolutionopen => fixed
2018-01-09 10:26hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/b37dfca128c9d4d7c315704e81f82c31a1aae42e [^]
2018-01-09 10:28dmiguelezReview Assigned To => dmiguelez
2018-01-09 10:28dmiguelezNote Added: 0101636
2018-01-09 10:28dmiguelezStatusresolved => closed
2018-01-09 10:28dmiguelezFixed in Version => 3.0PR18Q2
2018-02-22 18:18hudsonbotCheckin
2018-02-22 18:18hudsonbotNote Added: 0102651

Notes
(0101604)
collazoandy4   
2018-01-06 02:06   
As F&B International Group Admin Role
  Go to Tax Category and edit IVA Normal record:
    As per BOM: Y
  Go to Price List window and edit Tarifa de ventas record:
    Price Include Tax: Y
  Go to Product window and create a new record:
    Search Key/Name: IssueProduct
    Bill of Material: Y
    Create a new record in Price Tab:
      Price List Version: Tarifa de ventas
      Unit/List Price: 7
    Create a new record in Bill of Material tab:
      BOM Product: Agua sin Gas 1L
      BOM Quantity: 5
    Clic on Verify BOM
  Go to Sales Order and create a new record:
    Business Partner: Hoteles Buenas Noches, S.A.
    Create a new record in Lines tab:
      Product: Issue Product
      Tax: Entregas IVA 21%
    Book the order and check process ends successfull
    Close the order and check ends successfull
(0101635)
hgbot   
2018-01-09 10:26   
Repository: erp/devel/pi
Changeset: b37dfca128c9d4d7c315704e81f82c31a1aae42e
Author: Armaignac <collazoandy4 <at> gmail.com>
Date: Fri Jan 05 18:57:17 2018 -0500
URL: http://code.openbravo.com/erp/devel/pi/rev/b37dfca128c9d4d7c315704e81f82c31a1aae42e [^]

Fixes issue 37580: "division by zero" error when book sales order with BOM
products

When closing a sales order with a BOM product a division by zeror error was raise
while the process tries to calculate the v_PriceActual variable.

A validation was added to only calculate the value when the qtyordered is
different from cero, if not the v_PriceActual value is cero.

---
M src-db/database/model/triggers/C_ORDERLINE_TRG.xml
---
(0101636)
dmiguelez   
2018-01-09 10:28   
Code Review + Testing Ok
(0102651)
hudsonbot   
2018-02-22 18:18   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/980a6ad5bbf5 [^]
Maturity status: Test