IDEMPIERE-5757 immediate post: Payment REVERSE/CORRECT allocation document NOT posted (#1922)
* IDEMPIERE-5757 immediate post: Payment REVERSE/CORRECT allocation document NOT posted
This commit is contained in:
parent
8aacbb4c29
commit
eed078308c
|
@ -379,10 +379,38 @@ public class DocumentEngine implements DocAction
|
|||
}
|
||||
if (ACTION_ReActivate.equals(m_action))
|
||||
return reActivateIt();
|
||||
if (ACTION_Reverse_Accrual.equals(m_action))
|
||||
return reverseAccrualIt();
|
||||
if (ACTION_Reverse_Correct.equals(m_action))
|
||||
return reverseCorrectIt();
|
||||
if (ACTION_Reverse_Accrual.equals(m_action) || ACTION_Reverse_Correct.equals(m_action))
|
||||
{
|
||||
boolean ok = false;
|
||||
if (ACTION_Reverse_Accrual.equals(m_action))
|
||||
ok = reverseAccrualIt();
|
||||
else if (ACTION_Reverse_Correct.equals(m_action))
|
||||
ok = reverseCorrectIt();
|
||||
|
||||
if (m_document != null && ok)
|
||||
{
|
||||
if (MClient.isClientAccountingImmediate() && m_document instanceof IDocsPostProcess && m_document instanceof PO)
|
||||
{
|
||||
List<PO> docsPostProcess = ((IDocsPostProcess) m_document).getDocsPostProcess();
|
||||
if (docsPostProcess.size() > 0) {
|
||||
if (((PO) m_document).get_ValueAsBoolean("Posted")) {
|
||||
for (PO docafter : docsPostProcess) {
|
||||
if (docafter.get_ValueAsBoolean("Posted"))
|
||||
continue;
|
||||
String ignoreError = DocumentEngine.postImmediate(docafter.getCtx(), docafter.getAD_Client_ID(), docafter.get_Table_ID(), docafter.get_ID(), true, docafter.get_TrxName());
|
||||
if (!Util.isEmpty(ignoreError, true)) {
|
||||
log.warning("Error posting " + docafter + ". Error="+ignoreError);
|
||||
} else {
|
||||
docafter.load(docafter.get_TrxName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
if (ACTION_Close.equals(m_action))
|
||||
return closeIt();
|
||||
if (ACTION_Void.equals(m_action))
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.compiere.model.MAllocationHdr;
|
|||
import org.compiere.model.MAllocationLine;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MBankAccount;
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MConversionRate;
|
||||
import org.compiere.model.MCurrency;
|
||||
import org.compiere.model.MDocType;
|
||||
|
@ -485,6 +486,60 @@ public class AllocationTest extends AbstractTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ResourceLock(value = MConversionRate.Table_Name)
|
||||
/**
|
||||
* https://idempiere.atlassian.net/browse/IDEMPIERE-5757
|
||||
*/
|
||||
public void testPaymentReverseImmediatePosting() {
|
||||
try {
|
||||
boolean isImmediate = MClient.isClientAccountingImmediate();
|
||||
if (!isImmediate)
|
||||
return;
|
||||
|
||||
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id);
|
||||
|
||||
Timestamp date = TimeUtil.getDay(null);
|
||||
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
|
||||
|
||||
int payterm = DictionaryIDs.C_PaymentTerm.IMMEDIATE.id; // Immediate
|
||||
int taxid = DictionaryIDs.C_Tax.EXEMPT.id; // Exempt
|
||||
|
||||
MInvoice invoice = createInvoice(false, false, date, date, bpartner.getC_BPartner_ID(), payterm, taxid, Env.ONEHUNDRED);
|
||||
completeDocument(invoice);
|
||||
assertTrue(invoice.isPosted(), "Invoice not posted");
|
||||
|
||||
String whereClause = "AD_Org_ID=? AND C_Currency_ID=?";
|
||||
MBankAccount ba = new Query(Env.getCtx(),MBankAccount.Table_Name, whereClause, getTrxName())
|
||||
.setParameters(Env.getAD_Org_ID(Env.getCtx()), usd.getC_Currency_ID())
|
||||
.setOrderBy("IsDefault DESC")
|
||||
.first();
|
||||
assertTrue(ba != null, "@NoAccountOrgCurrency@");
|
||||
|
||||
MPayment payment = createPayment(bpartner.getC_BPartner_ID(), ba.getC_BankAccount_ID(), date, usd.getC_Currency_ID(), 0, Env.ONEHUNDRED);
|
||||
payment.setC_Invoice_ID(invoice.getC_Invoice_ID());
|
||||
payment.saveEx();
|
||||
completeDocument(payment);
|
||||
assertTrue(payment.isPosted(), "Payment not posted");
|
||||
|
||||
MAllocationHdr[] allocations = MAllocationHdr.getOfPayment(Env.getCtx(), payment.getC_Payment_ID(), getTrxName());
|
||||
for (MAllocationHdr allocation : allocations) {
|
||||
assertTrue(allocation.isPosted(), "Allocation not posted");
|
||||
}
|
||||
|
||||
reverseCorrectDocument(payment);
|
||||
MPayment reversalPayment = new MPayment(Env.getCtx(), payment.getReversal_ID(), getTrxName());
|
||||
assertTrue(reversalPayment.isPosted(), "Reversal payment not posted");
|
||||
|
||||
allocations = MAllocationHdr.getOfPayment(Env.getCtx(), reversalPayment.getC_Payment_ID(), getTrxName());
|
||||
for (MAllocationHdr allocation : allocations) {
|
||||
assertTrue(allocation.isPosted(), "Allocation not posted");
|
||||
}
|
||||
} finally {
|
||||
rollback();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ResourceLock(value = MConversionRate.Table_Name)
|
||||
/**
|
||||
|
@ -739,6 +794,14 @@ public class AllocationTest extends AbstractTestCase {
|
|||
assertEquals(DocAction.STATUS_Reversed, docStatus, DocAction.STATUS_Reversed + " != " + docStatus);
|
||||
}
|
||||
|
||||
private void reverseCorrectDocument(PO po) {
|
||||
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(po, DocAction.ACTION_Reverse_Correct);
|
||||
po.load(getTrxName());
|
||||
assertFalse(info.isError(), info.getSummary());
|
||||
String docStatus = (String) po.get_Value("DocStatus");
|
||||
assertEquals(DocAction.STATUS_Reversed, docStatus, DocAction.STATUS_Reversed + " != " + docStatus);
|
||||
}
|
||||
|
||||
private void postDocument(PO po) {
|
||||
if (!po.get_ValueAsBoolean("Posted")) {
|
||||
String error = DocumentEngine.postImmediate(Env.getCtx(), po.getAD_Client_ID(), po.get_Table_ID(), po.get_ID(), false, getTrxName());
|
||||
|
|
Loading…
Reference in New Issue