====== rm#25486 PO - Wrong error message when undergoing already invoiced quantites via modify ======
https://cust-projects.seeburger.de/redmine/issues/25486
===== Description =====
...
===== TODO =====
* **-** Analyze
* The error message is formed in ''POCollabPreprocessor.doPreProcessing():120''
* **-** Fix
* **-** Test
===== Analyze =====
The error message is formed in ''POCollabPreprocessor.doPreProcessing():120''
The invoice information seems to be written in the database with the help of BillableObject import ( see ''BillableObjectStatusInboundXMLHandler.processRootElement()'').
==== Reproduce ====
The invoice information seems to be imported in the system through BillableObject import, but it was too difficult for me to get such a file (no one seems to have such files now). It is possible to reproduce it on the simple way and
Simple
1. Import PO with 3 Positions ( an example: D:\development\testdata\purchaseorder\rm#25486_WrongErrMsgAboutInvoicedQties\po_003.xml )
2. Find out ''CREFHEADERID'' for this PO:
SELECT * FROM TAIRPOSCHEDULE where CLINEPONUM = 'rm25486_003';
3. Update invoice quantities for example with the following statement :
UPDATE TAIRPOLINEITEM
SET CFULLYINVOICED=1,CINVOICEREMAININGQTY=35,CINVOICETOTALQTY=90,CREQTOTALQTY=90,CPROMTOTALQTY=90
WHERE CREFHEADERID=
==== Misc ====
* Fetch PO schedule lines for given PO Number: ''SELECT * FROM TAIRPOSCHEDULE where CLINEPONUM = 'rm25486_003';''
* Fetch POLineItem for given RefId: ''select * from TAIRPOLINEITEM where CREFHEADERID = 545442''
* Original entry in tAirPOLineItem: ''INSERT INTO TAIRPOLINEITEM (CLINEITEMID,CREFHEADERID,CPOSNUM,CFULLYINVOICED,CINVOICEREMAININGQTY,CINVOICETOTALQTY,CREQTOTALQTY,CPROMTOTALQTY) VALUES (5755555,545442,'1',0,0,0,90,70);''
* I've changed it with: ''UPDATE TAIRPOLINEITEM SET CFULLYINVOICED=1,CINVOICEREMAININGQTY=35,CINVOICETOTALQTY=90,CREQTOTALQTY=90,CPROMTOTALQTY=90 WHERE CREFHEADERID=545442''
===== Result =====
''POCollabPreProcessor.doPreProcessing()'' was changed:
BigDecimal invoicedQty =
Toolbox.getBigDecimalOrZero(poLineItemData.getInvoiceTotalQty()).subtract(
Toolbox.getBigDecimalOrZero(poLineItemData.getInvoiceRemainingQty()));
resultModel.addMessage(new ClientResultMessageEntry(false, IPOConstants.ERROR_CODE_REQ_QTY_BELOW_INV_QTY, nlsKey,
"The quantity of the schedule lines %s1 of the PO item %s2 can't be changed because the resulting item quantity %s3 would be below the already invoiced quantity %s4",
slText, preProcData.getPosNumber(), poLineItemData.getReqTotalQty(), invoicedQty));