From 86eb3d32fafe8a8b90672c9d46581dec9d5d3b52 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 20 Nov 2012 00:21:35 +0800 Subject: [PATCH] IDEMPIERE-378 Implement Reverse Accrual. Fixed reverse matching doesn't update current document's description correctly. Added validation to prevent repeated execution of reversal process. --- .../src/org/compiere/model/MMatchInv.java | 10 ++++++---- .../src/org/compiere/model/MMatchPO.java | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MMatchInv.java b/org.adempiere.base/src/org/compiere/model/MMatchInv.java index 347bd69cf8..dc1b9319f3 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchInv.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchInv.java @@ -427,7 +427,7 @@ public class MMatchInv extends X_M_MatchInv */ public boolean reverse(Timestamp reversalDate) { - if (this.isPosted()) + if (this.isPosted() && this.getReversal_ID() == 0) { MMatchInv reversal = new MMatchInv (getCtx(), 0, get_TrxName()); PO.copyValues(this, reversal); @@ -439,9 +439,11 @@ public class MMatchInv extends X_M_MatchInv reversal.set_ValueNoCheck ("DocumentNo", null); reversal.setPosted (false); reversal.setReversal_ID(getM_MatchInv_ID()); - this.setDescription("(" + this.getDocumentNo() + "<-)"); - if (reversal.save() && this.save()) - return true; + reversal.saveEx(); + this.setDescription("(" + reversal.getDocumentNo() + "<-)"); + this.setReversal_ID(reversal.getM_MatchInv_ID()); + this.saveEx(); + return true; } return false; } diff --git a/org.adempiere.base/src/org/compiere/model/MMatchPO.java b/org.adempiere.base/src/org/compiere/model/MMatchPO.java index 8a3405a591..98e3229b1b 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchPO.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchPO.java @@ -1175,7 +1175,7 @@ public class MMatchPO extends X_M_MatchPO public boolean reverse(Timestamp reversalDate) { - if (this.isPosted()) + if (this.isPosted() && this.getReversal_ID() == 0) { MMatchPO reversal = new MMatchPO (getCtx(), 0, get_TrxName()); reversal.setC_InvoiceLine_ID(getC_InvoiceLine_ID()); @@ -1189,9 +1189,11 @@ public class MMatchPO extends X_M_MatchPO reversal.set_ValueNoCheck ("DocumentNo", null); reversal.setPosted (false); reversal.setReversal_ID(getM_MatchPO_ID()); - this.setDescription("(" + this.getDocumentNo() + "<-)"); - if (reversal.save() && this.save()) - return true; + reversal.saveEx(); + this.setDescription("(" + reversal.getDocumentNo() + "<-)"); + this.setReversal_ID(reversal.getM_MatchPO_ID()); + this.saveEx(); + return true; } return false; }