IDEMPIERE-2216:when make a warehouse order (in counter document test)… (#226)

* IDEMPIERE-2216:when make a warehouse order (in counter document test). new document material receipt is link with warehouse order not link with purchase order. it's correct?

* IDEMPIERE-2240:when create "On Credit Order" in counter document mode. invoice vendor make wrong reference to sale order

* IDEMPIERE-2257:can't complete invoice (vendor) generate from "order credit" by counter.

Integrating patch from Hiep hieplq@hasuvimex.vn
Changed syntax to be more readable
Used Processed instead of checking list of DocStatus

Co-authored-by: hieplq@hasuvimex.vn <hieplq@hasuvimex.vn>
This commit is contained in:
Carlos Ruiz 2020-08-22 20:55:44 +02:00 committed by GitHub
parent a9d24a2d5b
commit 2ad8fdfb3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 18 deletions

View File

@ -1873,20 +1873,25 @@ public class MInvoice extends X_C_Invoice implements DocAction
&& !isReversal()) && !isReversal())
{ {
MInOutLine receiptLine = new MInOutLine (getCtx(),line.getM_InOutLine_ID(), get_TrxName()); MInOutLine receiptLine = new MInOutLine (getCtx(),line.getM_InOutLine_ID(), get_TrxName());
BigDecimal movementQty = receiptLine.getM_InOut().getMovementType().charAt(1) == '-' ? receiptLine.getMovementQty().negate() : receiptLine.getMovementQty(); MInOut receipt = receiptLine.getParent();
BigDecimal matchQty = isCreditMemo() ? line.getQtyInvoiced().negate() : line.getQtyInvoiced();
if (movementQty.compareTo(matchQty) < 0) if (receipt.isProcessed()){
matchQty = movementQty;
MMatchInv inv = new MMatchInv(line, getDateInvoiced(), matchQty); BigDecimal movementQty = receiptLine.getM_InOut().getMovementType().charAt(1) == '-' ? receiptLine.getMovementQty().negate() : receiptLine.getMovementQty();
if (!inv.save(get_TrxName())) BigDecimal matchQty = isCreditMemo() ? line.getQtyInvoiced().negate() : line.getQtyInvoiced();
{
m_processMsg = CLogger.retrieveErrorString("Could not create Invoice Matching"); if (movementQty.compareTo(matchQty) < 0)
return DocAction.STATUS_Invalid; matchQty = movementQty;
MMatchInv inv = new MMatchInv(line, getDateInvoiced(), matchQty);
if (!inv.save(get_TrxName()))
{
m_processMsg = CLogger.retrieveErrorString("Could not create Invoice Matching");
return DocAction.STATUS_Invalid;
}
matchInv++;
addDocsPostProcess(inv);
} }
matchInv++;
addDocsPostProcess(inv);
} }
// Update Order Line // Update Order Line

View File

@ -63,8 +63,10 @@ public class MInvoiceLine extends X_C_InvoiceLine
{ {
if (sLine == null) if (sLine == null)
return null; return null;
final String whereClause = I_M_InOutLine.COLUMNNAME_M_InOutLine_ID+"=?";
List<MInvoiceLine> list = new Query(sLine.getCtx(),I_C_InvoiceLine.Table_Name,whereClause,sLine.get_TrxName()) final String whereClause = "C_InvoiceLine.M_InOutLine_ID=? AND C_Invoice.Processed='Y'";
final String joinInvoice = "JOIN C_Invoice ON (C_Invoice.C_Invoice_ID = C_InvoiceLine.C_Invoice_ID)";
List<MInvoiceLine> list = new Query(sLine.getCtx(),I_C_InvoiceLine.Table_Name,whereClause,sLine.get_TrxName()).addJoinClause(joinInvoice)
.setParameters(sLine.getM_InOutLine_ID()) .setParameters(sLine.getM_InOutLine_ID())
.list(); .list();

View File

@ -136,8 +136,11 @@ public class MOrder extends X_C_Order implements DocAction
// //
if (!to.save(trxName)) if (!to.save(trxName))
throw new IllegalStateException("Could not create Order"); throw new IllegalStateException("Could not create Order");
if (counter) if (counter){
// save to other counter document can re-get refer document
from.setRef_Order_ID(to.getC_Order_ID()); from.setRef_Order_ID(to.getC_Order_ID());
from.saveEx();
}
if (to.copyLinesFrom(from, counter, copyASI) == 0) if (to.copyLinesFrom(from, counter, copyASI) == 0)
throw new IllegalStateException("Could not create Order Lines"); throw new IllegalStateException("Could not create Order Lines");
@ -1932,6 +1935,12 @@ public class MOrder extends X_C_Order implements DocAction
boolean realTimePOS = MSysConfig.getBooleanValue(MSysConfig.REAL_TIME_POS, false , getAD_Client_ID()); boolean realTimePOS = MSysConfig.getBooleanValue(MSysConfig.REAL_TIME_POS, false , getAD_Client_ID());
// Counter Documents
// move by IDEMPIERE-2216
MOrder counter = createCounterDoc();
if (counter != null)
info.append(" - @CounterDoc@: @Order@=").append(counter.getDocumentNo());
// Create SO Shipment - Force Shipment // Create SO Shipment - Force Shipment
MInOut shipment = null; MInOut shipment = null;
if (MDocType.DOCSUBTYPESO_OnCreditOrder.equals(DocSubTypeSO) // (W)illCall(I)nvoice if (MDocType.DOCSUBTYPESO_OnCreditOrder.equals(DocSubTypeSO) // (W)illCall(I)nvoice
@ -1976,10 +1985,6 @@ public class MOrder extends X_C_Order implements DocAction
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
// Counter Documents
MOrder counter = createCounterDoc();
if (counter != null)
info.append(" - @CounterDoc@: @Order@=").append(counter.getDocumentNo());
// User Validation // User Validation
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
if (valid != null) if (valid != null)