From 5d5f073bd5606134121a6daa7154871b73b69d47 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 17 Dec 2014 19:04:33 -0500 Subject: [PATCH] IDEMPIERE-2287 Overwrite Date on Complete - doesn't update dateacct --- org.adempiere.base/src/org/compiere/model/MInOut.java | 4 ++++ org.adempiere.base/src/org/compiere/model/MInventory.java | 1 + org.adempiere.base/src/org/compiere/model/MInvoice.java | 4 ++++ org.adempiere.base/src/org/compiere/model/MJournal.java | 4 ++++ .../src/org/compiere/model/MJournalBatch.java | 4 ++++ org.adempiere.base/src/org/compiere/model/MMovement.java | 1 + org.adempiere.base/src/org/compiere/model/MOrder.java | 4 ++++ org.adempiere.base/src/org/compiere/model/MPayment.java | 7 ++++++- .../src/org/compiere/model/MRequisition.java | 1 + 9 files changed, 29 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index ab1be4ae26..7798c5d2c9 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -1752,6 +1752,10 @@ public class MInOut extends X_M_InOut implements DocAction MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (dt.isOverwriteDateOnComplete()) { setMovementDate(new Timestamp (System.currentTimeMillis())); + if (getDateAcct().before(getMovementDate())) { + setDateAcct(getMovementDate()); + MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); + } } if (dt.isOverwriteSeqOnComplete()) { String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this); diff --git a/org.adempiere.base/src/org/compiere/model/MInventory.java b/org.adempiere.base/src/org/compiere/model/MInventory.java index 62f44e20cc..e8ab43fe8c 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventory.java +++ b/org.adempiere.base/src/org/compiere/model/MInventory.java @@ -595,6 +595,7 @@ public class MInventory extends X_M_Inventory implements DocAction MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (dt.isOverwriteDateOnComplete()) { setMovementDate(new Timestamp (System.currentTimeMillis())); + MPeriod.testPeriodOpen(getCtx(), getMovementDate(), MDocType.DOCBASETYPE_MaterialPhysicalInventory, getAD_Org_ID()); } if (dt.isOverwriteSeqOnComplete()) { String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 13a12db064..542def1ddd 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -2118,6 +2118,10 @@ public class MInvoice extends X_C_Invoice implements DocAction MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (dt.isOverwriteDateOnComplete()) { setDateInvoiced(new Timestamp (System.currentTimeMillis())); + if (getDateAcct().before(getDateInvoiced())) { + setDateAcct(getDateInvoiced()); + MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID()); + } } if (dt.isOverwriteSeqOnComplete()) { String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this); diff --git a/org.adempiere.base/src/org/compiere/model/MJournal.java b/org.adempiere.base/src/org/compiere/model/MJournal.java index 170f93aa52..8953a199de 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournal.java +++ b/org.adempiere.base/src/org/compiere/model/MJournal.java @@ -627,6 +627,10 @@ public class MJournal extends X_GL_Journal implements DocAction if (dt.isOverwriteDateOnComplete()) { if (this.getProcessedOn().signum() == 0) { setDateDoc(new Timestamp (System.currentTimeMillis())); + if (getDateAcct().before(getDateDoc())) { + setDateAcct(getDateDoc()); + MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); + } } } if (dt.isOverwriteSeqOnComplete()) { diff --git a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java index 9270bdfe45..7b5a10583e 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java @@ -510,6 +510,10 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (dt.isOverwriteDateOnComplete()) { setDateDoc(new Timestamp (System.currentTimeMillis())); + if (getDateAcct().before(getDateDoc())) { + setDateAcct(getDateDoc()); + MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); + } } if (dt.isOverwriteSeqOnComplete()) { String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this); diff --git a/org.adempiere.base/src/org/compiere/model/MMovement.java b/org.adempiere.base/src/org/compiere/model/MMovement.java index 75f705f3df..5d920457f9 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovement.java +++ b/org.adempiere.base/src/org/compiere/model/MMovement.java @@ -548,6 +548,7 @@ public class MMovement extends X_M_Movement implements DocAction MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (dt.isOverwriteDateOnComplete()) { setMovementDate(new Timestamp (System.currentTimeMillis())); + MPeriod.testPeriodOpen(getCtx(), getMovementDate(), getC_DocType_ID(), getAD_Org_ID()); } if (dt.isOverwriteSeqOnComplete()) { String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this); diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index 6f70fcc5ef..c3a61334bb 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -2128,6 +2128,10 @@ public class MOrder extends X_C_Order implements DocAction /* a42niem - BF IDEMPIERE-63 - check if document has been completed before */ if (this.getProcessedOn().signum() == 0) { setDateOrdered(new Timestamp (System.currentTimeMillis())); + if (getDateAcct().before(getDateOrdered())) { + setDateAcct(getDateOrdered()); + MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID()); + } } } if (dt.isOverwriteSeqOnComplete()) { diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index eaa222be18..cbc31d6be2 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -654,7 +654,8 @@ public class MPayment extends X_C_Payment */ protected boolean beforeSave (boolean newRecord) { - if (isComplete() && + if (isComplete() && + ! is_ValueChanged(COLUMNNAME_Processed) && ( is_ValueChanged(COLUMNNAME_C_BankAccount_ID) || is_ValueChanged(COLUMNNAME_C_BPartner_ID) || is_ValueChanged(COLUMNNAME_C_Charge_ID) @@ -2094,6 +2095,10 @@ public class MPayment extends X_C_Payment MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (dt.isOverwriteDateOnComplete()) { setDateTrx(new Timestamp (System.currentTimeMillis())); + if (getDateAcct().before(getDateTrx())) { + setDateAcct(getDateTrx()); + MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); + } } if (dt.isOverwriteSeqOnComplete()) { String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this); diff --git a/org.adempiere.base/src/org/compiere/model/MRequisition.java b/org.adempiere.base/src/org/compiere/model/MRequisition.java index 54b89140b8..e9108c17df 100644 --- a/org.adempiere.base/src/org/compiere/model/MRequisition.java +++ b/org.adempiere.base/src/org/compiere/model/MRequisition.java @@ -364,6 +364,7 @@ public class MRequisition extends X_M_Requisition implements DocAction MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (dt.isOverwriteDateOnComplete()) { setDateDoc(new Timestamp (System.currentTimeMillis())); + MPeriod.testPeriodOpen(getCtx(), getDateDoc(), MDocType.DOCBASETYPE_PurchaseRequisition, getAD_Org_ID()); } if (dt.isOverwriteSeqOnComplete()) { String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this);