Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0047552Openbravo ERP07. Sales managementpublic2021-08-14 02:092021-08-30 11:44
lbressan 
vmromanos 
normalmajorhave not tried
closedfixed 
5
 
PR21Q4 
Core
No
0047552: Error while issue sales order with positive tolerance
When we activate the tolerance in the products and in the Advance Warehouse, when the tolerance is higher than the ordered quantity of the Sales Order, the difference is NOT being invoiced:
Example: Sales Order, with a line of a product of quantity 10, issues the sales order for 11, generates a sales invoice of 10, when it should generate a sales invoice with a line with 11
1) Access Sales Order and Create a header for any Business Partner and a warehouse that has positive tolerance enabled.
2) Create a line with any product that has Stock, and put operational quantity in 10. Then Book the Sales Order
3) Positioned in the header of the Sales Order, Press the Pick button, and in the task in question, change the Confirmed Quantity to 12, then confirm the Picking
4) Press the Issue button, without changing anything.
5) Access Sales Invoice and you will see that the amount invoiced will be 10, when it should be 12.
No tags attached.
Issue History
2021-08-14 02:09lbressanNew Issue
2021-08-14 02:09lbressanAssigned To => Triage Finance
2021-08-14 02:09lbressanResolution time => 1630620000
2021-08-23 11:08dmiguelezAssigned ToTriage Finance => vmromanos
2021-08-25 14:37vmromanosProjectModules => Openbravo ERP
2021-08-25 14:38vmromanosModules => Core
2021-08-25 14:38vmromanosTriggers an Emergency Pack => No
2021-08-25 14:38vmromanosNote Added: 0131361
2021-08-25 14:38vmromanosCategoryAdvance Warehouse Operations => 07. Sales management
2021-08-25 14:44vmromanosStatusnew => scheduled
2021-08-25 14:44vmromanosNote Added: 0131362
2021-08-25 14:49vmromanosNote Added: 0131364
2021-08-25 14:49vmromanosNote Edited: 0131364bug_revision_view_page.php?bugnote_id=0131364#r23039
2021-08-26 14:20hgbotNote Added: 0131376
2021-08-30 11:44hgbotNote Added: 0131431
2021-08-30 11:44hgbotNote Added: 0131432
2021-08-30 11:44hgbotResolutionopen => fixed
2021-08-30 11:44hgbotStatusscheduled => closed
2021-08-30 11:44hgbotNote Added: 0131433
2021-08-30 11:44hgbotFixed in Version => PR21Q4
2021-08-30 11:44hgbotNote Added: 0131434
2021-08-30 11:44hgbotNote Added: 0131435

Notes
(0131361)
vmromanos   
2021-08-25 14:38   
Originally reported for the WMS, but actually it's a bug in Core
(0131362)
vmromanos   
2021-08-25 14:44   
Steps to reproduce in Core:

Login as F&B admin
Go to Product window and search for Vino Tinto 0,75L product.
Set Is Quantity Variable flag to Yes
Create a Sales Order:
 - F&B España - Región Norte
 - Hoteles Buenas Noches, S.A.
 - After Delivery
Enter 10 units of Vino Tinto 0,75L
Book it.
Go to Goods Shipment and create a new record:
 - F&B España - Región Norte
 - Hoteles Buenas Noches, S.A.
Press Create Lines From:
 - Rn-0-0-0
 - Order: the one just created
 - Select the line for 10 units
Go to Lines tab and change the qty to 11 units
Complete the goods shipment:
 - Set "Invoice if possible"
Browse to the new invoice created (doc. no shown in the success message)
Go the invoice lines.
The invoice quantity is 10 but it should be 11 units
(0131364)
vmromanos   
2021-08-25 14:49   
Test plan I (Immediate/After Delivery):

Login as F&B admin
Go to Product window and search for Vino Tinto 0,75L product.
Set Is Quantity Variable flag to Yes
Create a Sales Order:
 - F&B España - Región Norte
 - Hoteles Buenas Noches, S.A.
 - Immediate
Enter 10 units of Vino Tinto 0,75L
Book it.
Go to Goods Shipment and create a new record:
 - F&B España - Región Norte
 - Hoteles Buenas Noches, S.A.
Press Create Lines From:
 - Rn-0-0-0
 - Order: the one just created
 - Select the line for 10 units
Go to Lines tab and change the qty to 11 units
Complete the goods shipment:
 - Set "Invoice if possible"
Browse to the new invoice created (doc. no shown in the success message)
Go the invoice lines.
The invoice quantity is 11 [before the fix was 10 units]


Test plan II (After Delivery):

Repeat test plan I, but setting sales order invoice terms to "After Delivery".
The results should be the same.


Test plan III (After Order Delivered):

Repeat test plan I, but setting sales order invoice terms to "After Order Delivery".
The results should be the same [before the fix the invoice was not generated]

(0131376)
hgbot   
2021-08-26 14:20   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/425 [^]
(0131431)
hgbot   
2021-08-30 11:44   
Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 895d7dd23cc76d5715174632da9dcab84b7bbc59
Author: Víctor Martínez Romanos <victor.martinez@openbravo.com>
Date: 2021-08-26T14:24:38+02:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/895d7dd23cc76d5715174632da9dcab84b7bbc59 [^]

Related to ISSUE-47552: Centralize refresh in tests

Instead of manually refreshing the sales order everytime the goods shipment
is processed, we do it inside the test's method that process the shipment.

---
M src-test/src/org/openbravo/test/materialMgmt/invoiceFromShipment/InvoiceFromShipmentTest.java
M src-test/src/org/openbravo/test/materialMgmt/invoiceFromShipment/TestUtils.java
---
(0131432)
hgbot   
2021-08-30 11:44   
Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 2673733ff74c5a47b4d34f25c8fc95de4efdfd3e
Author: Víctor Martínez Romanos <victor.martinez@openbravo.com>
Date: 2021-08-26T14:35:17+02:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/2673733ff74c5a47b4d34f25c8fc95de4efdfd3e [^]

Related to ISSUE-47552: Added new tests to cover the reported issue

* Sales order fully/partially invoiced before the shipment
* Shipping more quantity than the originally ordered with different invoice terms

Also includes fixes in the javadoc of one method that wasn't accurate

---
M src-test/src/org/openbravo/test/materialMgmt/invoiceFromShipment/InvoiceFromShipmentTest.java
---
(0131433)
hgbot   
2021-08-30 11:44   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/425 [^]
(0131434)
hgbot   
2021-08-30 11:44   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 89871c14fe9491f1d87e27ec2d1bbb28711736f0
Author: Víctor Martínez Romanos <victor.martinez@openbravo.com>
Date: 2021-08-26T14:35:17+02:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/89871c14fe9491f1d87e27ec2d1bbb28711736f0 [^]

Fixed ISSUE-47552: Invoice generator from goods shipment with positive tolerance

The fix makes sure we invoice any quantity shipped that wasn't been invoiced yet.

The code has been fixed in two concrete places, both associated with the scenario of
a goods shipment linked to a sales order:

1. When the invoice terms is After Order delivery: in this case que make sure we invoice
even in the case the order's delivery status is greater than 100 (that might happen with
quantity variable products or tolerances in WMS).

2. When the invoice terms allows to invoice before the shipment: in this case the formula
to calculate the qty to invoice has changed. Before it was:
  min(qtyOrdered - qtyInvoiced, qtyInThisShipment).
which was trying to support the corner case where the sales order was previously invoiced
before the shipment.

After the fix the formula is:
  qtyTotallyShipped - qtyPreviouslyInvoiced
and supports the corner case where the sales order has been previously invoiced but in a
different way. Instead of looking at the qty being shipped right now, it considers all the
shipped qty (including this shipment). This allows to easily know the qty actually pending
to invoice.

---
M src/org/openbravo/materialmgmt/InvoiceGeneratorFromGoodsShipment.java
---
(0131435)
hgbot   
2021-08-30 11:44   
Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 79b67ae2252a9465840c18209f18c9a9b5df440c
Author: Víctor Martínez Romanos <victor.martinez@openbravo.com>
Date: 2021-08-30T11:30:18+02:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/79b67ae2252a9465840c18209f18c9a9b5df440c [^]

Related to ISSUE-47552: Force to refresh sales order line before calculations

When the shipment has been generated programatically just before calling the
InvoiceGeneratorFromGoodsShipment, it might happen that the order line object
is not updated, and therefore the delivery quantity is not updated.
We force an hibernate object refresh to make sure we always work with the updated qtys.

---
M src/org/openbravo/materialmgmt/InvoiceGeneratorFromGoodsShipment.java
---