From 0eb7daffcb41458625acad1a8ba6cd29708f8d08 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 18 Dec 2014 12:28:43 -0500 Subject: [PATCH] IDEMPIERE-2287 Overwrite Date on Complete - doesn't update dateacct / move call to setDefiniteDocumentNo to the beginning of completeIt (just after prepareIt) --- .../src/org/compiere/model/MAssetReval.java | 9 ++++----- .../src/org/compiere/model/MAssetTransfer.java | 9 ++++----- org.adempiere.base/src/org/compiere/model/MInOut.java | 6 +++--- .../src/org/compiere/model/MInventory.java | 6 +++--- .../src/org/compiere/model/MInvoice.java | 8 ++++---- .../src/org/compiere/model/MJournal.java | 8 ++++---- .../src/org/compiere/model/MJournalBatch.java | 8 ++++---- .../src/org/compiere/model/MMovement.java | 8 ++++---- org.adempiere.base/src/org/compiere/model/MOrder.java | 11 +++++------ .../src/org/compiere/model/MPayment.java | 8 ++++---- org.adempiere.base/src/org/compiere/model/MRMA.java | 6 +++--- .../src/org/compiere/model/MRequisition.java | 6 +++--- .../src/org/compiere/process/DocActionTemplate.java | 8 ++++++-- 13 files changed, 51 insertions(+), 50 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MAssetReval.java b/org.adempiere.base/src/org/compiere/model/MAssetReval.java index 822d7094db..0cebc627fd 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetReval.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetReval.java @@ -131,8 +131,10 @@ implements DocAction if (!DocAction.STATUS_InProgress.equals(status)) return status; } - - + + // Set the definite document number after completed (if needed) + //setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -156,9 +158,6 @@ implements DocAction m_processMsg = valid; return DocAction.STATUS_Invalid; } - - // Set the definite document number after completed (if needed) - //setDefiniteDocumentNo(); setProcessed(true); setDocAction(DOCACTION_Close); diff --git a/org.adempiere.base/src/org/compiere/model/MAssetTransfer.java b/org.adempiere.base/src/org/compiere/model/MAssetTransfer.java index b571bcc66b..93adfcd8ab 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetTransfer.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetTransfer.java @@ -194,8 +194,10 @@ implements DocAction if (!DocAction.STATUS_InProgress.equals(status)) return status; } - - + + // Set the definite document number after completed (if needed) + //setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -223,9 +225,6 @@ implements DocAction m_processMsg = valid; return DocAction.STATUS_Invalid; } - - // Set the definite document number after completed (if needed) - //setDefiniteDocumentNo(); setProcessed(true); setDocAction(DOCACTION_Close); diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index 7798c5d2c9..705e327516 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -1256,6 +1256,9 @@ public class MInOut extends X_M_InOut implements DocAction return status; } + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -1652,9 +1655,6 @@ public class MInOut extends X_M_InOut implements DocAction return DocAction.STATUS_Invalid; } - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); - m_processMsg = info.toString(); setProcessed(true); setDocAction(DOCACTION_Close); diff --git a/org.adempiere.base/src/org/compiere/model/MInventory.java b/org.adempiere.base/src/org/compiere/model/MInventory.java index e8ab43fe8c..765f682429 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventory.java +++ b/org.adempiere.base/src/org/compiere/model/MInventory.java @@ -390,6 +390,9 @@ public class MInventory extends X_M_Inventory implements DocAction return status; } + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -579,9 +582,6 @@ public class MInventory extends X_M_Inventory implements DocAction return DocAction.STATUS_Invalid; } - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); - // setProcessed(true); setDocAction(DOCACTION_Close); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 542def1ddd..d2f051fe66 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -1692,6 +1692,9 @@ public class MInvoice extends X_C_Invoice implements DocAction return status; } + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -2086,9 +2089,6 @@ public class MInvoice extends X_C_Invoice implements DocAction return DocAction.STATUS_Invalid; } - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); - // Counter Documents MInvoice counter = createCounterDoc(); if (counter != null) @@ -2120,7 +2120,7 @@ public class MInvoice extends X_C_Invoice implements DocAction setDateInvoiced(new Timestamp (System.currentTimeMillis())); if (getDateAcct().before(getDateInvoiced())) { setDateAcct(getDateInvoiced()); - MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID()); + MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); } } if (dt.isOverwriteSeqOnComplete()) { diff --git a/org.adempiere.base/src/org/compiere/model/MJournal.java b/org.adempiere.base/src/org/compiere/model/MJournal.java index 8953a199de..afc905b8ad 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournal.java +++ b/org.adempiere.base/src/org/compiere/model/MJournal.java @@ -593,7 +593,10 @@ public class MJournal extends X_GL_Journal implements DocAction if (!DocAction.STATUS_InProgress.equals(status)) return status; } - + + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -610,9 +613,6 @@ public class MJournal extends X_GL_Journal implements DocAction return DocAction.STATUS_Invalid; } - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); - // setProcessed(true); setDocAction(DOCACTION_Close); diff --git a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java index 7b5a10583e..8903646cd3 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java @@ -438,7 +438,10 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction if (!DocAction.STATUS_InProgress.equals(status)) return status; } - + + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -494,9 +497,6 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction return DocAction.STATUS_Invalid; } - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); - // setProcessed(true); setDocAction(DOCACTION_Close); diff --git a/org.adempiere.base/src/org/compiere/model/MMovement.java b/org.adempiere.base/src/org/compiere/model/MMovement.java index 5d920457f9..2614d6a421 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovement.java +++ b/org.adempiere.base/src/org/compiere/model/MMovement.java @@ -353,7 +353,10 @@ public class MMovement extends X_M_Movement implements DocAction if (!DocAction.STATUS_InProgress.equals(status)) return status; } - + + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -531,9 +534,6 @@ public class MMovement extends X_M_Movement implements DocAction m_processMsg = valid; return DocAction.STATUS_Invalid; } - - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); // setProcessed(true); diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index c3a61334bb..4462c3e6d6 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -1869,6 +1869,10 @@ public class MOrder extends X_C_Order implements DocAction setProcessed(false); return DocAction.STATUS_InProgress; } + + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + // Offers if (MDocType.DOCSUBTYPESO_Proposal.equals(DocSubTypeSO) || MDocType.DOCSUBTYPESO_Quotation.equals(DocSubTypeSO)) @@ -1882,8 +1886,6 @@ public class MOrder extends X_C_Order implements DocAction m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); setProcessed(true); return DocAction.STATUS_Completed; } @@ -1986,9 +1988,6 @@ public class MOrder extends X_C_Order implements DocAction return DocAction.STATUS_Invalid; } } - - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); setProcessed(true); m_processMsg = info.toString(); @@ -2130,7 +2129,7 @@ public class MOrder extends X_C_Order implements DocAction setDateOrdered(new Timestamp (System.currentTimeMillis())); if (getDateAcct().before(getDateOrdered())) { setDateAcct(getDateOrdered()); - MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID()); + MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); } } } diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index cbc31d6be2..11225b5447 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -1943,7 +1943,10 @@ public class MPayment extends X_C_Payment if (!DocAction.STATUS_InProgress.equals(status)) return status; } - + + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -2077,9 +2080,6 @@ public class MPayment extends X_C_Payment m_processMsg = valid; return DocAction.STATUS_Invalid; } - - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); // setProcessed(true); diff --git a/org.adempiere.base/src/org/compiere/model/MRMA.java b/org.adempiere.base/src/org/compiere/model/MRMA.java index c1587b49f8..f537eaa4d9 100644 --- a/org.adempiere.base/src/org/compiere/model/MRMA.java +++ b/org.adempiere.base/src/org/compiere/model/MRMA.java @@ -430,6 +430,9 @@ public class MRMA extends X_M_RMA implements DocAction return status; } + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -461,9 +464,6 @@ public class MRMA extends X_M_RMA implements DocAction return DocAction.STATUS_Invalid; } - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); - // setProcessed(true); setDocAction(DOCACTION_Close); diff --git a/org.adempiere.base/src/org/compiere/model/MRequisition.java b/org.adempiere.base/src/org/compiere/model/MRequisition.java index e9108c17df..cc743f2c7a 100644 --- a/org.adempiere.base/src/org/compiere/model/MRequisition.java +++ b/org.adempiere.base/src/org/compiere/model/MRequisition.java @@ -331,6 +331,9 @@ public class MRequisition extends X_M_Requisition implements DocAction return status; } + // Set the definite document number after completed (if needed) + setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -348,9 +351,6 @@ public class MRequisition extends X_M_Requisition implements DocAction return DocAction.STATUS_Invalid; } - // Set the definite document number after completed (if needed) - setDefiniteDocumentNo(); - // setProcessed(true); setDocAction(ACTION_Close); diff --git a/org.adempiere.base/src/org/compiere/process/DocActionTemplate.java b/org.adempiere.base/src/org/compiere/process/DocActionTemplate.java index df0c3d5a39..de527dd5a0 100644 --- a/org.adempiere.base/src/org/compiere/process/DocActionTemplate.java +++ b/org.adempiere.base/src/org/compiere/process/DocActionTemplate.java @@ -216,6 +216,8 @@ public class DocActionTemplate extends PO implements DocAction return status; } + // setDefiniteDocumentNo(); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -233,8 +235,6 @@ public class DocActionTemplate extends PO implements DocAction m_processMsg = valid; return DocAction.STATUS_Invalid; } - // setDefiniteDocumentNo(); - // setProcessed(true); // setDocAction(DOCACTION_Close); return DocAction.STATUS_Completed; @@ -248,6 +248,10 @@ public class DocActionTemplate extends PO 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_DocType_ID(), getAD_Org_ID()); + } } if (dt.isOverwriteSeqOnComplete()) { String value = null;