From 6d4e756e126b1572889dce9ca2ea6594b85cbefe Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 19 Aug 2015 13:40:48 -0500 Subject: [PATCH] IDEMPIERE-2766 Error on total open balance when void POS Order with Cash Payment Rule --- .../src/org/compiere/model/MInvoice.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index ad7c08e171..bab3f7d96c 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -2358,23 +2358,7 @@ public class MInvoice extends X_C_Invoice implements DocAction MPeriod.testPeriodOpen(getCtx(), reversalDate, getC_DocType_ID(), getAD_Org_ID()); // - MAllocationHdr[] allocations = MAllocationHdr.getOfInvoice(getCtx(), - getC_Invoice_ID(), get_TrxName()); - for (int i = 0; i < allocations.length; i++) - { - if (accrual) - { - allocations[i].setDocAction(DocAction.ACTION_Reverse_Accrual); - allocations[i].reverseAccrualIt(); - allocations[i].saveEx(get_TrxName()); - } - else - { - allocations[i].setDocAction(DocAction.ACTION_Reverse_Correct); - allocations[i].reverseCorrectIt(); - allocations[i].saveEx(get_TrxName()); - } - } + reverseAllocations(accrual, getC_Invoice_ID()); // Reverse/Delete Matching if (!isSOTrx()) { @@ -2462,6 +2446,9 @@ public class MInvoice extends X_C_Invoice implements DocAction m_processMsg = "Reversal ERROR: " + reversal.getProcessMsg(); return null; } + // + reverseAllocations(accrual, reversal.getC_Invoice_ID()); + reversal.setC_Payment_ID(0); reversal.setIsPaid(true); reversal.closeIt(); @@ -2529,6 +2516,19 @@ public class MInvoice extends X_C_Invoice implements DocAction return reversal; } + private void reverseAllocations(boolean accrual, int invoiceID) { + for (MAllocationHdr allocation : MAllocationHdr.getOfInvoice(getCtx(), invoiceID, get_TrxName())) { + if (accrual) { + allocation.setDocAction(DocAction.ACTION_Reverse_Accrual); + allocation.reverseAccrualIt(); + } else { + allocation.setDocAction(DocAction.ACTION_Reverse_Correct); + allocation.reverseCorrectIt(); + } + allocation.saveEx(get_TrxName()); + } + } + /** * Reverse Accrual - none * @return false