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; }