Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0034993Openbravo ERP07. Sales managementpublic2017-01-18 12:282017-03-15 20:20
nataliag 
Sanjota 
normalmajoralways
closedfixed 
5
 
3.0PR17Q2 
markmm82
Core
No
0034993: Prepayment amount value is not correctly updated after changing the Sales Invoice lines.
If you import the lines of a sales invoice from a sales order which has been prepaid and then you delete them for example, the prepayment amount is not updated and it continues to show the previous value.
1- Go to Sales Order window in backend and create a new register with a line and prepay it adding a payment.
2- Go to Sales Invoice window and create a new one, using the “Create Lines From” button to import the lines from the sales order created in step 1. Now you can see on the header the Prepayment Amount field showing the payment amount made in step 1. That is correct.
3- Now delete the lines from the Sales invoice. The Prepayment Amount is still showing the quantity of step 2 and it should be now 0.
4- If you add again the lines from the sales order, then the prepayment amount is duplicated.
5- Complete the sales invoice and the prepayment amount continue wrong.
No tags attached.
related to design defect 0035339 scheduled collazoandy4 Prepayment Amount shown / updated in the invoices is not correct for some scenarios. 
related to defect 0036297 closed collazoandy4 Wrong schedule details information when Voiding an invoice which is prepaid via sales order 
Issue History
2017-01-18 12:28nataliagNew Issue
2017-01-18 12:28nataliagAssigned To => Triage Finance
2017-01-18 12:28nataliagModules => Core
2017-01-18 12:28nataliagTriggers an Emergency Pack => No
2017-01-18 21:12markmm82Assigned ToTriage Finance => collazoandy4
2017-02-02 12:52SanjotaAssigned Tocollazoandy4 => Sanjota
2017-02-02 12:52SanjotaStatusnew => scheduled
2017-02-06 12:35SanjotaNote Added: 0094074
2017-02-06 17:16psanjuanNote Added: 0094097
2017-02-06 17:36psanjuanNote Added: 0094098
2017-02-06 17:40psanjuanNote Edited: 0094098bug_revision_view_page.php?bugnote_id=0094098#r14495
2017-02-06 17:41psanjuanNote Edited: 0094098bug_revision_view_page.php?bugnote_id=0094098#r14496
2017-02-07 11:37psanjuanNote Edited: 0094098bug_revision_view_page.php?bugnote_id=0094098#r14509
2017-02-14 12:12psanjuanNote Added: 0094301
2017-02-14 12:13psanjuanNote Edited: 0094301bug_revision_view_page.php?bugnote_id=0094301#r14576
2017-02-14 12:15psanjuanNote Added: 0094302
2017-02-14 12:15psanjuanNote Added: 0094303
2017-02-14 12:15psanjuanNote Edited: 0094301bug_revision_view_page.php?bugnote_id=0094301#r14577
2017-02-14 12:27psanjuanNote Edited: 0094303bug_revision_view_page.php?bugnote_id=0094303#r14579
2017-02-14 12:33psanjuanNote Edited: 0094303bug_revision_view_page.php?bugnote_id=0094303#r14580
2017-02-14 12:37psanjuanNote Added: 0094304
2017-02-14 12:39psanjuanNote Added: 0094305
2017-02-15 15:49hgbotCheckin
2017-02-15 15:49hgbotNote Added: 0094365
2017-02-15 15:49hgbotStatusscheduled => resolved
2017-02-15 15:49hgbotResolutionopen => fixed
2017-02-15 15:49hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/dcd88a9918fe3725a37d8460c41d1038956564e2 [^]
2017-02-15 15:49hgbotCheckin
2017-02-15 15:49hgbotNote Added: 0094366
2017-02-15 15:54markmm82Review Assigned To => markmm82
2017-02-15 15:54markmm82Note Added: 0094367
2017-02-15 15:54markmm82Statusresolved => closed
2017-02-15 15:54markmm82Fixed in Version => 3.0PR17Q2
2017-02-15 22:08markmm82Statusclosed => new
2017-02-15 22:08markmm82Resolutionfixed => open
2017-02-15 22:08markmm82Fixed in Version3.0PR17Q2 =>
2017-02-15 22:08markmm82Statusnew => scheduled
2017-02-15 22:08markmm82Note Deleted: 0094367
2017-02-15 22:10markmm82Note Added: 0094375
2017-02-15 22:12hgbotCheckin
2017-02-15 22:12hgbotNote Added: 0094376
2017-02-15 23:15markmm82Statusscheduled => resolved
2017-02-15 23:15markmm82Fixed in Version => 3.0PR17Q2
2017-02-15 23:15markmm82Fixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/dcd88a9918fe3725a37d8460c41d1038956564e2 [^] => http://code.openbravo.com/erp/devel/pi/rev/42227f2c47c35fcef34529b14bd2a2d5ec293f0e [^]
2017-02-15 23:15markmm82Resolutionopen => fixed
2017-02-15 23:16markmm82Note Added: 0094377
2017-02-15 23:16markmm82Statusresolved => closed
2017-02-16 09:03hgbotCheckin
2017-02-16 09:03hgbotNote Added: 0094378
2017-02-16 11:00vmromanosNote Added: 0094383
2017-02-16 11:00vmromanosStatusclosed => new
2017-02-16 11:00vmromanosResolutionfixed => open
2017-02-16 11:00vmromanosFixed in Version3.0PR17Q2 =>
2017-02-20 15:27psanjuanNote Edited: 0094375bug_revision_view_page.php?bugnote_id=0094375#r14645
2017-02-20 15:28psanjuanNote Edited: 0094375bug_revision_view_page.php?bugnote_id=0094375#r14646
2017-02-20 15:29psanjuanNote Added: 0094475
2017-02-22 12:59psanjuanRelationship addedrelated to 0035339
2017-02-22 13:02psanjuanNote Added: 0094532
2017-02-22 13:02psanjuanNote Added: 0094533
2017-02-22 14:40hgbotCheckin
2017-02-22 14:40hgbotNote Added: 0094536
2017-02-22 14:40hgbotStatusnew => resolved
2017-02-22 14:40hgbotResolutionopen => fixed
2017-02-22 14:40hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/42227f2c47c35fcef34529b14bd2a2d5ec293f0e [^] => http://code.openbravo.com/erp/devel/pi/rev/e6fef7749bc40f73ddd5232cb0883b55d133dd86 [^]
2017-02-22 14:42markmm82Note Added: 0094538
2017-02-22 14:42markmm82Statusresolved => closed
2017-02-22 14:42markmm82Fixed in Version => 3.0PR17Q2
2017-03-01 15:55hgbotCheckin
2017-03-01 15:55hgbotNote Added: 0094668
2017-03-15 20:19hudsonbotCheckin
2017-03-15 20:19hudsonbotNote Added: 0095185
2017-03-15 20:19hudsonbotCheckin
2017-03-15 20:19hudsonbotNote Added: 0095186
2017-03-15 20:19hudsonbotCheckin
2017-03-15 20:19hudsonbotNote Added: 0095187
2017-03-15 20:19hudsonbotCheckin
2017-03-15 20:19hudsonbotNote Added: 0095188
2017-03-15 20:19hudsonbotCheckin
2017-03-15 20:19hudsonbotNote Added: 0095204
2017-03-15 20:20hudsonbotCheckin
2017-03-15 20:20hudsonbotNote Added: 0095242
2017-07-04 09:24aferrazRelationship addedrelated to 0036297

Notes
(0094074)
Sanjota   
2017-02-06 12:35   
Test Plan:
For Purchase Invoice
1) Create Purchase order with lines. Book the same. Click on add prepayment. Do the Payment
2) Go to Goods Receipt, create goods receipt agianst the above purchase order and complete it.
3) Go to purchase invoice window and create header. Click on “Create Lines From” and add above created purchase order lines.
4) Check that prepayment in invoice header is updated to payment amount of the order.
5) Delete lines or make invoice qty to zero for the invoicelines that belong to above order.
6) Observe that the prepayment amount in header changed to zero and if we add same lines again,
   pre payment amount in the header will be sum(prepayment amount of orders assoiciated with invoiceline)

Similarly check for Sales Invoice
1) Create Sales order with lines. Book the same. Click on add prepayment. Do the Payment
2) Go to Goods Shipment, create goods shipment agianst the above sales order and complete it.
3) Go to sales invoice window and create header. Click on “Create Lines From” and add above created sales order lines.
4) Check that prepayment in invoice header is updated to payment amount of the order.
5) Delete lines or make invoice qty to zero for the invoicelines that belong to above order.
6) Observe that the prepayment amount in header changed to zero and if we add same lines again,
   pre payment amount in the header will be sum(prepayment amount of orders assoiciated with invoiceline)
(0094097)
psanjuan   
2017-02-06 17:16   
Issue verified.
(0094098)
psanjuan   
2017-02-06 17:36   
(edited on: 2017-02-07 11:37)
Test Plan.

Verify this issue in the following scenarios, for both purchase order/invoice, sales order/invoice.

1 - Sales order do not pay, therefore sales invoice prepayment info = 0

2 - Sales order partialy paid, prepayment info is deleted if the prepaid order line once selected is removed from the invoice. Include it again. Include more than one sales order line that belongs to a prepaid order. After that complete the invoice and post the invoice. Prepayment info is correctly calculated and post. Verify accounting entry is correct and the quantity shown in Prepayment Amount field is the same as the one shown in the ledger (prepayment).

3 - Sales order totaly paid, included in a sales invoice. Delete the lines and include them once again. Complete and Post. Verify accounting entry is correct and the quantity shown in Prepayment Amount field is the same as the one shown in the ledger (prepayment).


Verify that after the invoice is complete and post, and then reactivated, if prepaid order lines are removed from the invoice, prepayment amount = 0.00

Include more than one prepaid order, together with others do not paid through Create lines from function and by just adding new lines in the invoice.

(0094301)
psanjuan   
2017-02-14 12:12   
(edited on: 2017-02-14 12:15)
Test Case 1 - Fully paid order, included in an invoice together with other lines fully paid and not paid.

Create a Sales Order for F&B España, Alimentos y Supermercados business parter.
Add a line for Cerveza Ale 0.5L product. Enter a qty = 5. Book the order.
Fully pay the order, that is 12.34.

Go to Sales Invoice window and create a new one for F&B España, Alimentos y Supermercados business partner. User Create Lines From. Select the order.

Verify that a prepayment amount = 12.34 is shown in the header.

Delete the line. Verify prepayment amount shown is = 0.00

Use Create lines from and select once again the order.

Verify that a prepayment amount = 12.34 is shown in the header.

Add another order line by using create lines from by making sure that the new order line is not prepaid.

Verify that a prepayment amount = 12.34 is shown in the header.

Delete first line.

Verify prepayment amount = 0.00

Add once more the same last order created.

Verify that a prepayment amount = 12.34 is shown in the header.

Add another order line by using create lines from by making sure that this time the order line is prepaid (ie. 10.04)

Verify that a prepayment amount = 12.34 + 10.04= 22.38 is shown in the header.

Remove last line added.

Verify that a prepayment amount = 12.34 is shown.

Delete all lines. Verify prepayment amount = 0.00

By using create lines from select once again the same sales order lines, the one just created, another one do not prepaid, and the last one prepaid.

Verify that total gross amount of the invoice = 47.07, for instance with a prepaid amount = 22.38.

Complete and post the invoice.

Verify below posting is shown:

24.69 (43000) Clientes DEBIT
22.38 (43800) Anticipo a clientes DEBIT
38.90 (70000) Ventas CREDIT
8.17 (47700) HP IVA CREDIT
 
Test Case 2

Repeat same test as above for Purchase order/Invoice.

(0094302)
psanjuan   
2017-02-14 12:15   
Test Case 3 Not paid sales order.

Verify that once the order do not paid is included in an invoice, prepayment amount = 0.00

Test Case 4 Repeat same test as above for purchase order / purchase invoice.
(0094303)
psanjuan   
2017-02-14 12:15   
(edited on: 2017-02-14 12:33)
Test Case 5 - Partially paid order, included in an invoice together with other lines partially paid, fully paid and not paid.

Create a Sales Order for F&B España, Alimentos y Supermercados business parter.
Add a line for Cerveza Ale 0.5L product. Enter a qty = 25. Book the order.
Fully pay the order (ie.100252), total gross amount = 61.71

Create a Sales Order for F&B España, Alimentos y Supermercados business parter.
Add a line for Bebida Energetica 0.5L product. Enter a qty = 5. Book the order (ie. 1000253). Total Gross Amount 9.01
Do not pay the order.

Create a Sales Order for F&B España, Alimentos y Supermercados business parter.
Add a line for Cerveza Ale 0.5L product. Enter a qty = 55. Book the order.
Partially pay the order for instance 100.00 (ie.100254 , total gross amount = 135.76)

Go to Sales Invoice window and create a new one for F&B España, Alimentos y Supermercados business partner. User Create Lines From. Select order 254

Verify that a prepayment amount = 100.00 is shown in the header.

Delete the line. Verify prepayment amount shown is = 0.00

Use Create lines from and select the order 253

Verify that a prepayment amount = 61.71

Add another order line by using create lines from and selecting order 253 (not paid).

Verify that prepayment amount remains as = 61.71

Add another order line by using create lines from and selecting order 254 (partially paid).

Verify that prepayment amount is now = 61.71 + 100.00 = 161.71

Delete all lines, prepayment amount is = 0.00

By using create lines from select once again all the 3 orders 252.253 and 254

Verify prepayment amount = 161.71

Go to lines and add a new line, for instace product = Cola de Cereza, 80 units.

Complete and post the invoice.

Verify that total gross amount of the invoice = 286.83, with a prepaid amount = 161.71.

Complete and post the invoice.

Verify below posting is shown:

125.12 (43000) Clientes DEBIT
161.71 (43800) Anticipo a clientes DEBIT
237.05 (70000) Ventas CREDIT
49.78 (47700) HP IVA CREDIT
 
Test Case 6

Repeat same test as above for Purchase order/Invoice.

(0094304)
psanjuan   
2017-02-14 12:37   
Test Case 7

Repeat test case 6, by adding a negative sales order, partially paid = -10.00
Verify that one selected in the invoice, prepayment amount is reduce in -10.00

Add another invoice line for another product, positive.
Add another invoice line for another product, negative.

Complete and post the invoice.

Verify that 10.00 is post as prepayment in the Credit.

Test Case 8

Repeat same test as above for purchase order / Invoice.
(0094305)
psanjuan   
2017-02-14 12:39   
Test Plan above verified.
Issue can be code reviewed and closed.
(0094365)
hgbot   
2017-02-15 15:49   
Repository: erp/devel/pi
Changeset: dcd88a9918fe3725a37d8460c41d1038956564e2
Author: Sanjota <sanjota.nelagi <at> promantia.com>
Date: Tue Feb 07 18:24:43 2017 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/dcd88a9918fe3725a37d8460c41d1038956564e2 [^]

Fixes issue 34993: Update Prepaymentamt properly on changing the Invoicelines.

Update the prepayment amount value in invoice as per updation of invoice lines referriing to orderlines.
Ex : If Order linked to invoice line is prepaid, the invoice prepayment is updated,
if the same invoiceline referring to orderline is deleted then the prepayment amount is updated properly.

---
M src-db/database/model/triggers/C_INVOICELINE_TRG2.xml
---
(0094366)
hgbot   
2017-02-15 15:49   
Repository: erp/devel/pi
Changeset: e1c6deda8742ac8ecf9ada00eb5cddf897ba4570
Author: Mark <markmm82 <at> gmail.com>
Date: Tue Feb 14 15:52:41 2017 -0500
URL: http://code.openbravo.com/erp/devel/pi/rev/e1c6deda8742ac8ecf9ada00eb5cddf897ba4570 [^]

Related to issue 34993: Code review improvements

Removed unnecessary variables and query.
If the invoice line will be deleted always the invoice must update it prepayment
amount. If the invoice line is related to a paid order line, then invoice
prepayment will be updated discounting the prepaid value of the order line, in
other hands the prepayment amount of the invoice will still with its value because
there are not any pay related to the order line.

---
M src-db/database/model/triggers/C_INVOICELINE_TRG2.xml
---
(0094375)
markmm82   
2017-02-15 22:10   
(edited on: 2017-02-20 15:28)
New scenarios taken into account when lines are updated.


Test Plan 8: Update the amount to 0 of the created invoice line.

Create a Sales Order for F&B España, Alimentos y Supermercados business parter.
Add a line for Cerveza Ale 0.5L product. Enter a qty = 5. Book the order.
Fully pay the order, that is 12.34.

Go to Sales Invoice window and create a new one for F&B España, Alimentos y Supermercados business partner. User Create Lines From. Select the order.

Verify that a prepayment amount = 12.34 is shown in the header.

Go to the line, and changes the qty to 0. Verify prepayment amount shown is = 0.00

Go to the line, and changes the qty to 5. Verify prepayment amount shown is = 12.34 again.

Complete and post the invoice, check prepayment amount still as 12.34 and posting was OK.

Repeat the same for Purchase flow.


Test Plan 9: Add the same order line twice

Create a Sales Order for F&B España, Alimentos y Supermercados business parter.
Add a line for Cerveza Ale 0.5L product. Enter a qty = 5. Book the order.
Fully pay the order, that is 12.34.

Go to Sales Invoice window and create a new one for F&B España, Alimentos y Supermercados business partner. User Create Lines From. Select the order.

Verify that a prepayment amount = 12.34 is shown in the header.

Go to Create Lines From agin and select the same order.

Verify that a prepayment amount = 24.68 is shown in the header. If you try to complete this invoice an error is shown because more quantity than ordered quantity can not be invoiced.

Delete first line. Verify that a prepayment amount = 12.34 is shown in the header.

Complete and post the invoice, check prepayment amount still as 12.34 and posting was OK.

Repeat the same for Purchase flow, and verify it is not possible to select the order within same invoice more than once.

(0094376)
hgbot   
2017-02-15 22:12   
Repository: erp/devel/pi
Changeset: 42227f2c47c35fcef34529b14bd2a2d5ec293f0e
Author: Mark <markmm82 <at> gmail.com>
Date: Wed Feb 15 15:56:52 2017 -0500
URL: http://code.openbravo.com/erp/devel/pi/rev/42227f2c47c35fcef34529b14bd2a2d5ec293f0e [^]

Related to issue 34993: Update the invoice prepaiment amount with correct value
if after create from a paid order line, it updates the line net amount to 0
or it changes from 0 to a another value.

If you create the invoice line from a paid order line, and then the line net amount
changes it value to 0 (by updating qty = 0 or price = 0, for instance), then
previously prepayment was remaining instead of be discarded. So, you may have an
invoice with Total Gross Amount of 0 and a prepayment different than 0.

When you are updating a line with a NEW line net amount = 0 or deleting the line,
it is needed to remove the prepayment of this line from the invoice.

If the OLD line net amount was zero (the prepayment was removed or not taken into
account when creating or updating the line) and it changes
to a non-zero new line net amount value, is necessary take into account the prepaid
order line amount to increase the invoice prepayment amount with its value.

In any other case it is not necessary update the prepayment amount of the invoice.

---
M src-db/database/model/triggers/C_INVOICELINE_TRG2.xml
---
(0094377)
markmm82   
2017-02-15 23:16   
Code review + Testing OK
(0094378)
hgbot   
2017-02-16 09:03   
Repository: erp/devel/pi
Changeset: 0c31b06dd16894df1e72d743b7cd35b538a40fdd
Author: Sanjota <sanjota.nelagi <at> promantia.com>
Date: Thu Feb 16 13:32:25 2017 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/0c31b06dd16894df1e72d743b7cd35b538a40fdd [^]

Related to issue 34993: reverting changes of the issue.

Reverting the changes of the issue due to failure in oracle.

---
M src-db/database/model/triggers/C_INVOICELINE_TRG2.xml
---
(0094383)
vmromanos   
2017-02-16 11:00   
Reopened because the changesets won't work in Oracle
(0094475)
psanjuan   
2017-02-20 15:29   
Test plan above verified for new fix adjusted to Oracle.
(0094532)
psanjuan   
2017-02-22 13:02   
There are some more scenarios in which prepayment amount is not being updated properly, therefore regardless that the scenario reported in this issue has been fixed, as well as some others; a design defect has been created, and related to this issue, to define other scenarios and make them work after being analized and researched. See design defect related 35339
(0094533)
psanjuan   
2017-02-22 13:02   
This issue can be closed.
(0094536)
hgbot   
2017-02-22 14:40   
Repository: erp/devel/pi
Changeset: e6fef7749bc40f73ddd5232cb0883b55d133dd86
Author: Mark <markmm82 <at> gmail.com>
Date: Tue Feb 21 16:04:04 2017 -0500
URL: http://code.openbravo.com/erp/devel/pi/rev/e6fef7749bc40f73ddd5232cb0883b55d133dd86 [^]

Fixes issue 34993: Update the invoice prepayment amount with correct value
if after create from a paid order line, it updates the line net amount to 0
or it changes from 0 to a another value.

If you create the invoice line from a paid order line, and then the line net amount
changes it value to 0 (by updating qty = 0 or price = 0, for instance), then
previously prepayment was remaining instead of be discarded. So, you may have an
invoice with Total Gross Amount of 0 and a prepayment different than 0.

When you are updating a line with a NEW line net amount = 0 or deleting the line,
it is needed to remove the prepayment of this line from the invoice.

If the OLD line net amount was zero (the prepayment was removed or not taken into
account when creating or updating the line) and it changes
to a non-zero new line net amount value, is necessary take into account the prepaid
order line amount to increase the invoice prepayment amount with its value.

In any other case it is not necessary update the prepayment amount of the invoice.

---
M src-db/database/model/triggers/C_INVOICELINE_TRG2.xml
---
(0094538)
markmm82   
2017-02-22 14:42   
Code review + Testing OK
(0094668)
hgbot   
2017-03-01 15:55   
Repository: erp/devel/pi
Changeset: 68702618a590c2a9012534e4d5e9530bc9a84f3b
Author: Mark <markmm82 <at> gmail.com>
Date: Tue Feb 28 14:56:32 2017 -0500
URL: http://code.openbravo.com/erp/devel/pi/rev/68702618a590c2a9012534e4d5e9530bc9a84f3b [^]

Related to issue 34993: Logic moved to the complete action

To avoid inconsistents scenarios in this issue, the processing logic included inside
the c_invoiceline_trg2 trigger was removed and included inside the c_invoice_post function.

This way the prepayment amount is always updated when the invoice is completed and
not when it lines are created, updated or deleted.

All other possible scenarios will be covered when the related design defect
https://issues.openbravo.com/view.php?id=35339 [^] be fixed.

---
M src-db/database/model/functions/C_INVOICE_POST.xml
M src-db/database/model/triggers/C_INVOICELINE_TRG2.xml
---
(0095185)
hudsonbot   
2017-03-15 20:19   
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/54e102bef53e [^]
Maturity status: Test
(0095186)
hudsonbot   
2017-03-15 20:19   
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/54e102bef53e [^]
Maturity status: Test
(0095187)
hudsonbot   
2017-03-15 20:19   
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/54e102bef53e [^]
Maturity status: Test
(0095188)
hudsonbot   
2017-03-15 20:19   
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/54e102bef53e [^]
Maturity status: Test
(0095204)
hudsonbot   
2017-03-15 20:19   
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/54e102bef53e [^]
Maturity status: Test
(0095242)
hudsonbot   
2017-03-15 20:20   
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/54e102bef53e [^]
Maturity status: Test