Vendor Return Material: Qty deducted twice from MCost.CurrentQty (AvgInv and FIFO)
Description
Environment
Attachments
Activity
Andres Lopez Andrade August 22, 2020 at 6:27 PM
Triaged by arlopeza
Create a new stock item
PO Qty=100 Price=1
Material Receipt
Generate Invoice from Receipt
Complete invoice.
Verify that the current qty is 100 on the cost record.
Create Vendor RMA
Return 1 of the 100
Complete RMA
Generate Shipments (manual)
Document type - Vendor RMAComplete Return to Vendor
Current qty is 99 on the cost record.
Create and Complete an AP CreditMemo from Generate Invoice from Receipt on the Return to Vendor document.
Verify that the current qty is 99 on the cost record.
Everything normal, test with FIFO
When create the Vendor RMA, on Receipt Line still appear Qty=100, must be 99
the process change the cost to 0.9604 ans Qty = 101
Still reproducible on 7.1z
Carlos Ruiz December 14, 2017 at 1:46 PM
Hi ,
I reproduced the issue as you described using Average Invoice.
Using Average PO worked fine.
I think from previous analysis we have done the Average PO is the recommended method, in the end I think we must not support both - Average Invoice is really problematic, and when you try to solve the problems of Average Invoice you finish implementing Average PO.
_______________
On the other hand - with the same test case you described above the FIFO method failed:
After posting the AP Credit Memo:
Current Cost Price = 1.0204 - this seems wrong - cost has not changed, must be 1 as I tested with a price of $1
Current Qty = 98 - must be 99
Accumulated Amt = 101 - must be 100 (I tested with a price of $1)
Accumulated Qty = 99 - must be 100

Boonphan.S December 11, 2017 at 8:21 AM
I tested follow your step (for version 4.1)
Verify that the beginning qty is 185 on the cost record
Create PO for 100 of item
Create Material Receipt
Create Invoice (Vendor) and Complete the invoice.
Verify that the current qty is 285 on the cost record
Create Vendor RMA (Return 1 of the 100)
Complete the RMA
Create Return to Vendor and Complete the document.
Create an AP Credit Memo (Invoice (Vendor)) and Complete the document
Verify that the current qty is 284 on the cost record
The quantity is correct.

Neil G August 3, 2015 at 2:46 PMEdited
In case this helps:
If one puts a breakpoint into X_M_Cost.setCurrentQty, the trace going up is illustrated in the following screenshots:
https://idempiere.atlassian.net/secure/attachment/21604/Selection_788.png
https://idempiere.atlassian.net/secure/attachment/21605/Selection_789.png
(Second pass = matched inv, the other one is the Return to Vendor)
Return of material via Vendor RMA process deducts the quantity twice from the MCost.CurrentQty (Current Quantity) field.
The system deducts 1 when the material is posted, and 1 again when the match invoice is posted.
Steps to reproduce:
Purchase:
Create a new stock item
PO for 100 of item
Material Receipt
Invoice (Vendor) by "Generate Invoice from Receipt" (click on the toolbar gear icon in the material receipt).
Complete the invoice.
Verify that the current qty is 100 on the cost record.
Return:
Create Vendor RMA
Select the original material receipt (from Purchase, above)
Return 1 of the 100
Complete the RMA
Generate Shipments (manual) - select Document type - Vendor RMA - Select the RMA
A Return to Vendor , "MM Vendor Return" is created.
Complete the document
Verify that the current qty is 99 on the cost record.
Create an Invoice (Vendor) from Generate Invoice from Receipt (click on the toolbar gear icon in the material receipt, on the Return to Vendor document).
This creates an AP Credit Memo
Complete the document
Verify that the current qty is 98 on the cost record..
This is incorrect, since only 1 has been returned.