IDEMPIERE-814 POS Sales Order generating Cash transactions

This commit is contained in:
Carlos Ruiz 2013-05-29 13:33:36 -05:00
parent c8b2b44672
commit f1662191a5
3 changed files with 21 additions and 17 deletions

View File

@ -66,7 +66,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
/** /**
* *
*/ */
private static final long serialVersionUID = 6821562060687417857L; private static final long serialVersionUID = -1223767990636657474L;
/** /**
* Get Payments Of BPartner * Get Payments Of BPartner
@ -1132,11 +1132,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
* Test Allocation (and set paid flag) * Test Allocation (and set paid flag)
* @return true if updated * @return true if updated
*/ */
public boolean testAllocation() public boolean testAllocation(boolean beingCompleted)
{ {
boolean change = false; boolean change = false;
if ( isProcessed() ) { if ( isProcessed() || beingCompleted) {
BigDecimal alloc = getAllocatedAmt(); // absolute BigDecimal alloc = getAllocatedAmt(); // absolute
if (alloc == null) if (alloc == null)
alloc = Env.ZERO; alloc = Env.ZERO;
@ -1156,6 +1156,10 @@ public class MInvoice extends X_C_Invoice implements DocAction
return change; return change;
} // testAllocation } // testAllocation
public boolean testAllocation() {
return testAllocation(false);
}
/** /**
* Set Paid Flag for invoices * Set Paid Flag for invoices
* @param ctx context * @param ctx context
@ -1386,13 +1390,13 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = "@NoLines@"; m_processMsg = "@NoLines@";
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
// No Cash Book // No Cash Book // deprecated with IDEMPIERE-170 Complete Cash as Payment functionality
if (PAYMENTRULE_Cash.equals(getPaymentRule()) // if (PAYMENTRULE_Cash.equals(getPaymentRule())
&& MCashBook.get(getCtx(), getAD_Org_ID(), getC_Currency_ID()) == null) // && MCashBook.get(getCtx(), getAD_Org_ID(), getC_Currency_ID()) == null)
{ // {
m_processMsg = "@NoCashBook@"; // m_processMsg = "@NoCashBook@";
return DocAction.STATUS_Invalid; // return DocAction.STATUS_Invalid;
} // }
// Convert/Check DocType // Convert/Check DocType
if (getC_DocType_ID() != getC_DocTypeTarget_ID() ) if (getC_DocType_ID() != getC_DocTypeTarget_ID() )
@ -1773,7 +1777,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
payment.setDocAction(MPayment.DOCACTION_Complete); payment.setDocAction(MPayment.DOCACTION_Complete);
if (!payment.processIt(MPayment.DOCACTION_Complete)) { if (!payment.processIt(MPayment.DOCACTION_Complete)) {
m_processMsg = "Cannot Complete the Payment :" + payment; m_processMsg = "Cannot Complete the Payment : [" + payment.getProcessMsg() + "] " + payment;
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
@ -2080,6 +2084,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
} }
} }
if (PAYMENTRULE_Cash.equals(getPaymentRule())) {
if (testAllocation(true)) {
saveEx();
}
}
// 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)

View File

@ -2290,11 +2290,6 @@ public class MOrder extends X_C_Order implements DocAction
// end added // end added
invoice.saveEx(get_TrxName()); invoice.saveEx(get_TrxName());
setC_CashLine_ID(invoice.getC_CashLine_ID()); setC_CashLine_ID(invoice.getC_CashLine_ID());
if (PAYMENTRULE_Cash.equals(invoice.getPaymentRule()) && getC_POS_ID() == 0) {
if (invoice.testAllocation()) {
invoice.saveEx();
}
}
if (!DOCSTATUS_Completed.equals(invoice.getDocStatus())) if (!DOCSTATUS_Completed.equals(invoice.getDocStatus()))
{ {
m_processMsg = "@C_Invoice_ID@: " + invoice.getProcessMsg(); m_processMsg = "@C_Invoice_ID@: " + invoice.getProcessMsg();

View File

@ -1459,7 +1459,7 @@ public final class MPayment extends X_C_Payment
{ {
String sql = "SELECT idt.IsSOTrx " String sql = "SELECT idt.IsSOTrx "
+ "FROM C_Invoice i" + "FROM C_Invoice i"
+ " INNER JOIN C_DocType idt ON (i.C_DocType_ID=idt.C_DocType_ID) " + " INNER JOIN C_DocType idt ON (CASE WHEN i.C_DocType_ID=0 THEN i.C_DocTypeTarget_ID ELSE i.C_DocType_ID END=idt.C_DocType_ID) "
+ "WHERE i.C_Invoice_ID=?"; + "WHERE i.C_Invoice_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;