From 932ed8f498e5b77a6ce26d8c90d6033b313037bc Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 8 Apr 2021 16:40:27 +0200 Subject: [PATCH] IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed. (#634) * IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed. * IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed. Fix the problem also in model, to cover case when trying to add/modify lines for example via webservices * IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed. Fix the problem also in model, change approach to use isProcessed instead of isComplete --- .../oracle/202103161500_IDEMPIERE-4727.sql | 37 ++++++++ .../202103161500_IDEMPIERE-4727.sql | 34 ++++++++ .../org/compiere/model/MAllocationLine.java | 4 +- .../compiere/model/MBankStatementLine.java | 4 +- .../src/org/compiere/model/MCashLine.java | 4 +- .../src/org/compiere/model/MDepositBatch.java | 14 ++- .../org/compiere/model/MDepositBatchLine.java | 6 ++ .../src/org/compiere/model/MInOutConfirm.java | 16 +++- .../src/org/compiere/model/MInOutLine.java | 4 +- .../org/compiere/model/MInOutLineConfirm.java | 5 ++ .../src/org/compiere/model/MInOutLineMA.java | 6 ++ .../org/compiere/model/MInventoryLine.java | 4 +- .../org/compiere/model/MInventoryLineMA.java | 6 ++ .../src/org/compiere/model/MInvoiceLine.java | 4 +- .../src/org/compiere/model/MJournal.java | 7 ++ .../src/org/compiere/model/MJournalBatch.java | 15 +++- .../src/org/compiere/model/MJournalLine.java | 4 +- .../org/compiere/model/MMovementConfirm.java | 15 +++- .../src/org/compiere/model/MMovementLine.java | 4 +- .../compiere/model/MMovementLineConfirm.java | 6 ++ .../org/compiere/model/MMovementLineMA.java | 6 ++ .../src/org/compiere/model/MOrder.java | 6 +- .../src/org/compiere/model/MOrderLine.java | 4 +- .../src/org/compiere/model/MPOSPayment.java | 86 +++++++++++++++++++ .../org/compiere/model/MPaySelectionLine.java | 6 ++ .../src/org/compiere/model/MPayment.java | 2 +- .../src/org/compiere/model/MProduction.java | 15 +++- .../org/compiere/model/MProductionLine.java | 10 +++ .../org/compiere/model/MProductionLineMA.java | 22 ++++- .../org/compiere/model/MProductionPlan.java | 18 +++- .../src/org/compiere/model/MRMALine.java | 4 +- .../org/compiere/model/MRequisitionLine.java | 4 +- .../org/compiere/model/MTimeExpenseLine.java | 4 +- .../org/eevolution/model/MDDOrderLine.java | 4 +- 34 files changed, 348 insertions(+), 42 deletions(-) create mode 100644 migration/i8.2/oracle/202103161500_IDEMPIERE-4727.sql create mode 100644 migration/i8.2/postgresql/202103161500_IDEMPIERE-4727.sql create mode 100644 org.adempiere.base/src/org/compiere/model/MPOSPayment.java diff --git a/migration/i8.2/oracle/202103161500_IDEMPIERE-4727.sql b/migration/i8.2/oracle/202103161500_IDEMPIERE-4727.sql new file mode 100644 index 0000000000..b7c632be1c --- /dev/null +++ b/migration/i8.2/oracle/202103161500_IDEMPIERE-4727.sql @@ -0,0 +1,37 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed. +-- Mar 16, 2021, 2:59:48 PM CET +UPDATE AD_Tab SET ReadOnlyLogic='@Processed@=Y',Updated=TO_DATE('2021-03-16 14:59:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID IN ( +329 /* Bank/Cash Statement > Statement Line*/ , +200103 /* Cost Adjustment > Cost Adjustment Line*/ , +200138 /* Customer Return > Attributes*/ , +629 /* Customer RMA > RMA Line*/ , +200008 /* GL Journal > Line*/ , +160 /* GL Journal Batch > Journal*/ , +161 /* GL Journal Batch > Line*/ , +683 /* Internal Use Inventory > Internal Use Line*/ , +53134 /* Internal Use Inventory > Attributes*/ , +260 /* Inventory Move > Move Line*/ , +750 /* Inventory Move > Attributes*/ , +200137 /* Material Receipt > Attributes*/ , +667 /* Move Confirmation > Line*/ , +353 /* Payment Selection > Payment Selection Line*/ , +256 /* Physical Inventory > Inventory Count Line*/ , +749 /* Physical Inventory > Attributes*/ , +320 /* Production > Production Plan*/ , +321 /* Production > Production Line*/ , +53345 /* Production (Single Product) > Production Line*/ , +200224 /* Production (Single Product) > Attributes*/ , +200016 /* Sales Order > POS Payment*/ , +751 /* Shipment (Customer) > Attributes*/ , +659 /* Ship/Receipt Confirm > Line*/ , +53281 /* Vendor RMA > RMA Line*/ , +200068 /* Payments into Batch > Lines*/ +) +; + +SELECT register_migration_script('202103161500_IDEMPIERE-4727.sql') FROM dual +; + diff --git a/migration/i8.2/postgresql/202103161500_IDEMPIERE-4727.sql b/migration/i8.2/postgresql/202103161500_IDEMPIERE-4727.sql new file mode 100644 index 0000000000..d76b0c5e2b --- /dev/null +++ b/migration/i8.2/postgresql/202103161500_IDEMPIERE-4727.sql @@ -0,0 +1,34 @@ +-- IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed. +-- Mar 16, 2021, 2:59:48 PM CET +UPDATE AD_Tab SET ReadOnlyLogic='@Processed@=Y',Updated=TO_TIMESTAMP('2021-03-16 14:59:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID IN ( +329 /* Bank/Cash Statement > Statement Line*/ , +200103 /* Cost Adjustment > Cost Adjustment Line*/ , +200138 /* Customer Return > Attributes*/ , +629 /* Customer RMA > RMA Line*/ , +200008 /* GL Journal > Line*/ , +160 /* GL Journal Batch > Journal*/ , +161 /* GL Journal Batch > Line*/ , +683 /* Internal Use Inventory > Internal Use Line*/ , +53134 /* Internal Use Inventory > Attributes*/ , +260 /* Inventory Move > Move Line*/ , +750 /* Inventory Move > Attributes*/ , +200137 /* Material Receipt > Attributes*/ , +667 /* Move Confirmation > Line*/ , +353 /* Payment Selection > Payment Selection Line*/ , +256 /* Physical Inventory > Inventory Count Line*/ , +749 /* Physical Inventory > Attributes*/ , +320 /* Production > Production Plan*/ , +321 /* Production > Production Line*/ , +53345 /* Production (Single Product) > Production Line*/ , +200224 /* Production (Single Product) > Attributes*/ , +200016 /* Sales Order > POS Payment*/ , +751 /* Shipment (Customer) > Attributes*/ , +659 /* Ship/Receipt Confirm > Line*/ , +53281 /* Vendor RMA > RMA Line*/ , +200068 /* Payments into Batch > Lines*/ +) +; + +SELECT register_migration_script('202103161500_IDEMPIERE-4727.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/MAllocationLine.java b/org.adempiere.base/src/org/compiere/model/MAllocationLine.java index bf60f9a66a..ae2ede256c 100644 --- a/org.adempiere.base/src/org/compiere/model/MAllocationLine.java +++ b/org.adempiere.base/src/org/compiere/model/MAllocationLine.java @@ -184,8 +184,8 @@ public class MAllocationLine extends X_C_AllocationLine */ protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "C_AllocationLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "C_AllocationHdr_ID")); return false; } if (!newRecord diff --git a/org.adempiere.base/src/org/compiere/model/MBankStatementLine.java b/org.adempiere.base/src/org/compiere/model/MBankStatementLine.java index e66961856a..82a833088b 100644 --- a/org.adempiere.base/src/org/compiere/model/MBankStatementLine.java +++ b/org.adempiere.base/src/org/compiere/model/MBankStatementLine.java @@ -162,8 +162,8 @@ import org.compiere.util.Msg; */ protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "C_BankStatementLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "C_BankStatement_ID")); return false; } // Calculate Charge = Statement - trx - Interest diff --git a/org.adempiere.base/src/org/compiere/model/MCashLine.java b/org.adempiere.base/src/org/compiere/model/MCashLine.java index 7cc24d726e..541f9610f8 100644 --- a/org.adempiere.base/src/org/compiere/model/MCashLine.java +++ b/org.adempiere.base/src/org/compiere/model/MCashLine.java @@ -302,8 +302,8 @@ public class MCashLine extends X_C_CashLine */ protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "C_CashLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "C_Cash_ID")); return false; } // Cannot change generated Invoices diff --git a/org.adempiere.base/src/org/compiere/model/MDepositBatch.java b/org.adempiere.base/src/org/compiere/model/MDepositBatch.java index 3d34c13372..1b14e3c7e4 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepositBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MDepositBatch.java @@ -54,7 +54,7 @@ public class MDepositBatch extends X_C_DepositBatch /** * */ - private static final long serialVersionUID = -977397802747749777L; + private static final long serialVersionUID = 7691820074981291939L; /** * Create & Load existing Persistent Object @@ -310,4 +310,16 @@ public class MDepositBatch extends X_C_DepositBatch return retValue; } // getLines + /** + * Document Status is Complete or Closed + * @return true if CO, CL or RE + */ + public boolean isComplete() + { + String ds = getDocStatus(); + return DOCSTATUS_Completed.equals(ds) + || DOCSTATUS_Closed.equals(ds) + || DOCSTATUS_Reversed.equals(ds); + } // isComplete + } // MDepositBatch \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/model/MDepositBatchLine.java b/org.adempiere.base/src/org/compiere/model/MDepositBatchLine.java index 8f87402b69..5fc4b5be45 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepositBatchLine.java +++ b/org.adempiere.base/src/org/compiere/model/MDepositBatchLine.java @@ -36,6 +36,7 @@ import java.util.Properties; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; /** * Bank Statement Line Model @@ -122,6 +123,11 @@ import org.compiere.util.Env; */ protected boolean beforeSave (boolean newRecord) { + MDepositBatch parent = new MDepositBatch(getCtx(), getC_DepositBatch_ID(), get_TrxName()); + if (newRecord && parent.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "C_DepositBatch_ID")); + return false; + } // Set Line No if (getLine() == 0) { diff --git a/org.adempiere.base/src/org/compiere/model/MInOutConfirm.java b/org.adempiere.base/src/org/compiere/model/MInOutConfirm.java index 3e37eae9d3..f768f3691c 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutConfirm.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutConfirm.java @@ -51,7 +51,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction /** * */ - private static final long serialVersionUID = 5270365186462536874L; + private static final long serialVersionUID = -1998947558580855224L; /** * Create Confirmation or return existing one @@ -841,5 +841,17 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { return 0; } // getC_Currency_ID - + + /** + * Document Status is Complete or Closed + * @return true if CO, CL or RE + */ + public boolean isComplete() + { + String ds = getDocStatus(); + return DOCSTATUS_Completed.equals(ds) + || DOCSTATUS_Closed.equals(ds) + || DOCSTATUS_Reversed.equals(ds); + } // isComplete + } // MInOutConfirm diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLine.java b/org.adempiere.base/src/org/compiere/model/MInOutLine.java index 320e2f5ace..8cfb971a4d 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLine.java @@ -505,8 +505,8 @@ public class MInOutLine extends X_M_InOutLine protected boolean beforeSave (boolean newRecord) { log.fine(""); - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOutLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOut_ID")); return false; } if (getParent().pendingConfirmations()) { diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLineConfirm.java b/org.adempiere.base/src/org/compiere/model/MInOutLineConfirm.java index b8586f983f..178d20f5cc 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLineConfirm.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLineConfirm.java @@ -182,6 +182,11 @@ public class MInOutLineConfirm extends X_M_InOutLineConfirm */ protected boolean beforeSave (boolean newRecord) { + MInOutConfirm parent = new MInOutConfirm(getCtx(), getM_InOutConfirm_ID(), get_TrxName()); + if (newRecord && parent.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOutConfirm_ID")); + return false; + } // Calculate Difference = Target - Confirmed - Scrapped BigDecimal difference = getTargetQty(); difference = difference.subtract(getConfirmedQty()); diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java b/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java index 57a35a4eeb..3ed7ebca24 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java @@ -30,6 +30,7 @@ import org.adempiere.exceptions.AdempiereException; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; import org.compiere.util.Util; /** @@ -254,6 +255,11 @@ public class MInOutLineMA extends X_M_InOutLineMA */ protected boolean beforeSave (boolean newRecord) { + MInOutLine parentline = new MInOutLine(getCtx(), getM_InOutLine_ID(), get_TrxName()); + if (newRecord && parentline.getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOut_ID")); + return false; + } //Set DateMaterialPolicy if(!newRecord && is_ValueChanged(COLUMNNAME_M_AttributeSetInstance_ID)){ //TODO Require testing for all scenario diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java index 20b8cd0638..520e5d36a2 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java @@ -286,8 +286,8 @@ public class MInventoryLine extends X_M_InventoryLine */ protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InventoryLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Inventory_ID")); return false; } diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java b/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java index 7166228c46..ba39d9e58b 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java @@ -27,6 +27,7 @@ import java.util.logging.Level; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; import org.compiere.util.Util; @@ -236,6 +237,11 @@ public class MInventoryLineMA extends X_M_InventoryLineMA */ protected boolean beforeSave (boolean newRecord) { + MInventoryLine parentline = new MInventoryLine(getCtx(), getM_InventoryLine_ID(), get_TrxName()); + if (newRecord && parentline.getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Inventory_ID")); + return false; + } //Set DateMaterialPolicy if(!newRecord && is_ValueChanged(COLUMNNAME_M_AttributeSetInstance_ID)){ I_M_InventoryLine line = getM_InventoryLine(); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java index 0a96c612f2..f0f64e5622 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java @@ -840,10 +840,10 @@ public class MInvoiceLine extends X_C_InvoiceLine protected boolean beforeSave (boolean newRecord) { if (log.isLoggable(Level.FINE)) log.fine("New=" + newRecord); - boolean parentComplete = getParent().isComplete(); + boolean parentComplete = getParent().isProcessed(); boolean isReversal = getParent().isReversal(); if (newRecord && parentComplete) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "C_InvoiceLine")); + log.saveError("ParentComplete", Msg.translate(getCtx(), "C_Invoice_ID")); return false; } // Re-set invoice header (need to update m_IsSOTrx flag) - phib [ 1686773 ] diff --git a/org.adempiere.base/src/org/compiere/model/MJournal.java b/org.adempiere.base/src/org/compiere/model/MJournal.java index 568e54d16a..316fcef58d 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournal.java +++ b/org.adempiere.base/src/org/compiere/model/MJournal.java @@ -283,6 +283,13 @@ public class MJournal extends X_GL_Journal implements DocAction */ protected boolean beforeSave (boolean newRecord) { + if (getGL_JournalBatch_ID() > 0) { + MJournalBatch parent = new MJournalBatch(getCtx(), getGL_JournalBatch_ID(), get_TrxName()); + if (newRecord && parent.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "GL_JournalBatch_ID")); + return false; + } + } // Imported Journals may not have date if (getDateDoc() == null) { diff --git a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java index ed5c16f603..3dfe290bea 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java @@ -54,7 +54,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction /** * */ - private static final long serialVersionUID = 5920767495976301905L; + private static final long serialVersionUID = 4447134860127309777L; /** * Create new Journal Batch by copying @@ -947,4 +947,17 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction return true; } + + /** + * Document Status is Complete or Closed + * @return true if CO, CL or RE + */ + public boolean isComplete() + { + String ds = getDocStatus(); + return DOCSTATUS_Completed.equals(ds) + || DOCSTATUS_Closed.equals(ds) + || DOCSTATUS_Reversed.equals(ds); + } // isComplete + } // MJournalBatch diff --git a/org.adempiere.base/src/org/compiere/model/MJournalLine.java b/org.adempiere.base/src/org/compiere/model/MJournalLine.java index 82b2332b5f..1a24dd48fe 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalLine.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalLine.java @@ -285,8 +285,8 @@ public class MJournalLine extends X_GL_JournalLine */ protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "GL_JournalLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "GL_Journal_ID")); return false; } diff --git a/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java b/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java index 4bb131c938..251281fd47 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java @@ -51,7 +51,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction /** * */ - private static final long serialVersionUID = -399427235334348654L; + private static final long serialVersionUID = -3617284116557414217L; /** * Create Confirmation or return existing one @@ -770,5 +770,16 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction return 0; } // getC_Currency_ID - + /** + * Document Status is Complete or Closed + * @return true if CO, CL or RE + */ + public boolean isComplete() + { + String ds = getDocStatus(); + return DOCSTATUS_Completed.equals(ds) + || DOCSTATUS_Closed.equals(ds) + || DOCSTATUS_Reversed.equals(ds); + } // isComplete + } // MMovementConfirm diff --git a/org.adempiere.base/src/org/compiere/model/MMovementLine.java b/org.adempiere.base/src/org/compiere/model/MMovementLine.java index c193efd5e8..b6000af147 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementLine.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementLine.java @@ -167,8 +167,8 @@ public class MMovementLine extends X_M_MovementLine @Override protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "M_MovementLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Movement_ID")); return false; } if (getParent().pendingConfirmations()) { diff --git a/org.adempiere.base/src/org/compiere/model/MMovementLineConfirm.java b/org.adempiere.base/src/org/compiere/model/MMovementLineConfirm.java index 11068ec814..b0bc3dff9d 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementLineConfirm.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementLineConfirm.java @@ -21,6 +21,7 @@ import java.sql.ResultSet; import java.util.Properties; import org.compiere.util.Env; +import org.compiere.util.Msg; /** * Inventory Movement Confirmation Line @@ -148,6 +149,11 @@ public class MMovementLineConfirm extends X_M_MovementLineConfirm */ protected boolean beforeSave (boolean newRecord) { + MMovementConfirm parent = new MMovementConfirm(getCtx(), getM_MovementConfirm_ID(), get_TrxName()); + if (newRecord && parent.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_MovementConfirm_ID")); + return false; + } // Calculate Difference = Target - Confirmed BigDecimal difference = getTargetQty(); difference = difference.subtract(getConfirmedQty()); diff --git a/org.adempiere.base/src/org/compiere/model/MMovementLineMA.java b/org.adempiere.base/src/org/compiere/model/MMovementLineMA.java index f5e82d96ab..a956bd6725 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementLineMA.java @@ -27,6 +27,7 @@ import java.util.logging.Level; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; import org.compiere.util.Util; @@ -241,6 +242,11 @@ public class MMovementLineMA extends X_M_MovementLineMA */ protected boolean beforeSave (boolean newRecord) { + MMovementLine parentline = new MMovementLine(getCtx(), getM_MovementLine_ID(), get_TrxName()); + if (newRecord && parentline.getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Movement_ID")); + return false; + } //Set DateMaterialPolicy if(!newRecord && is_ValueChanged(COLUMNNAME_M_AttributeSetInstance_ID)){ I_M_MovementLine line = getM_MovementLine(); diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index d11a29360d..72a8656e2a 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -2026,12 +2026,12 @@ public class MOrder extends X_C_Order implements DocAction MInvoice lastInvoice = invoices[0]; BigDecimal grandTotal = lastInvoice.getGrandTotal(); - List pps = new Query(this.getCtx(), X_C_POSPayment.Table_Name, "C_Order_ID=?", this.get_TrxName()) + List pps = new Query(this.getCtx(), MPOSPayment.Table_Name, "C_Order_ID=?", this.get_TrxName()) .setParameters(this.getC_Order_ID()) .setOnlyActiveRecords(true) .list(); BigDecimal totalPOSPayments = Env.ZERO; - for (X_C_POSPayment pp : pps) { + for (MPOSPayment pp : pps) { totalPOSPayments = totalPOSPayments.add(pp.getPayAmt()); } if (totalPOSPayments.compareTo(grandTotal) != 0) @@ -2060,7 +2060,7 @@ public class MOrder extends X_C_Order implements DocAction // Create a payment for each non-guarantee record // associate the payment id and mark the record as processed - for (X_C_POSPayment pp : pps) { + for (MPOSPayment pp : pps) { X_C_POSTenderType tt = new X_C_POSTenderType (getCtx(),pp.getC_POSTenderType_ID(), get_TrxName()); if (tt.isGuarantee()) continue; diff --git a/org.adempiere.base/src/org/compiere/model/MOrderLine.java b/org.adempiere.base/src/org/compiere/model/MOrderLine.java index ae7103bfb4..fed54811e3 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrderLine.java +++ b/org.adempiere.base/src/org/compiere/model/MOrderLine.java @@ -775,8 +775,8 @@ public class MOrderLine extends X_C_OrderLine */ protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "C_OrderLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "C_Order_ID")); return false; } // Get Defaults from Parent diff --git a/org.adempiere.base/src/org/compiere/model/MPOSPayment.java b/org.adempiere.base/src/org/compiere/model/MPOSPayment.java new file mode 100644 index 0000000000..74e47aebf7 --- /dev/null +++ b/org.adempiere.base/src/org/compiere/model/MPOSPayment.java @@ -0,0 +1,86 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Carlos Ruiz - globalqss - bxservice * + **********************************************************************/ + +package org.compiere.model; + +import java.sql.ResultSet; +import java.util.Properties; + +import org.compiere.util.CLogger; +import org.compiere.util.Msg; + +/** +* +* @author Carlos Ruiz - globalqss - bxservice +* +*/ +public class MPOSPayment extends X_C_POSPayment +{ + /** + * + */ + private static final long serialVersionUID = -4889347016616915128L; + + /** Logger */ + protected static CLogger s_log = CLogger.getCLogger (MPOSPayment.class); + + /************************************************************************** + * Default Constructor + * @param ctx context + * @param C_POSPayment_ID order line to load + * @param trxName trx name + */ + public MPOSPayment (Properties ctx, int C_POSPayment_ID, String trxName) + { + super (ctx, C_POSPayment_ID, trxName); + } // MPOSPayment + + /** + * Load Constructor + * @param ctx context + * @param rs result set record + * @param trxName transaction + */ + public MPOSPayment (Properties ctx, ResultSet rs, String trxName) + { + super(ctx, rs, trxName); + } // MPOSPayment + + /************************************************************************** + * Before Save + * @param newRecord + * @return true if it can be saved + */ + protected boolean beforeSave (boolean newRecord) + { + MOrder parent = new MOrder(getCtx(), getC_Order_ID(), get_TrxName()); + if (newRecord && parent.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "C_Order_ID")); + return false; + } + return true; + } // beforeSave + +} // MPOSPayment diff --git a/org.adempiere.base/src/org/compiere/model/MPaySelectionLine.java b/org.adempiere.base/src/org/compiere/model/MPaySelectionLine.java index 9ff1970b7b..990b9f4093 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaySelectionLine.java +++ b/org.adempiere.base/src/org/compiere/model/MPaySelectionLine.java @@ -22,6 +22,7 @@ import java.util.Properties; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; /** * Payment Selection Line Model @@ -143,6 +144,11 @@ public class MPaySelectionLine extends X_C_PaySelectionLine */ protected boolean beforeSave (boolean newRecord) { + MPaySelection parent = new MPaySelection(getCtx(), getC_PaySelection_ID(), get_TrxName()); + if (newRecord && parent.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "C_PaySelection_ID")); + return false; + } setDifferenceAmt(getOpenAmt().subtract(getPayAmt()).subtract(getDiscountAmt()).subtract(getWriteOffAmt())); return true; } // beforeSave diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 003e100b7b..08e154f186 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -663,7 +663,7 @@ public class MPayment extends X_C_Payment */ protected boolean beforeSave (boolean newRecord) { - if (isComplete() && + if (isProcessed() && ! is_ValueChanged(COLUMNNAME_Processed) && ( is_ValueChanged(COLUMNNAME_C_BankAccount_ID) || is_ValueChanged(COLUMNNAME_C_BPartner_ID) diff --git a/org.adempiere.base/src/org/compiere/model/MProduction.java b/org.adempiere.base/src/org/compiere/model/MProduction.java index 19835d2b36..5010ae0c2d 100644 --- a/org.adempiere.base/src/org/compiere/model/MProduction.java +++ b/org.adempiere.base/src/org/compiere/model/MProduction.java @@ -26,7 +26,7 @@ public class MProduction extends X_M_Production implements DocAction { /** * */ - private static final long serialVersionUID = -4650232602150964606L; + private static final long serialVersionUID = 6714776372370644208L; /** * @@ -907,4 +907,17 @@ public class MProduction extends X_M_Production implements DocAction { } return true; } + + /** + * Document Status is Complete or Closed + * @return true if CO, CL or RE + */ + public boolean isStatusComplete() + { + String ds = getDocStatus(); + return DOCSTATUS_Completed.equals(ds) + || DOCSTATUS_Closed.equals(ds) + || DOCSTATUS_Reversed.equals(ds); + } // isStatusComplete + } diff --git a/org.adempiere.base/src/org/compiere/model/MProductionLine.java b/org.adempiere.base/src/org/compiere/model/MProductionLine.java index 3cf60305af..9a49377a06 100644 --- a/org.adempiere.base/src/org/compiere/model/MProductionLine.java +++ b/org.adempiere.base/src/org/compiere/model/MProductionLine.java @@ -13,6 +13,7 @@ import java.util.logging.Level; import org.adempiere.exceptions.AdempiereException; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; import org.compiere.util.Util; @@ -354,6 +355,10 @@ public class MProductionLine extends X_M_ProductionLine { if (getM_Production_ID() > 0) { + if (newRecord && productionParent.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Production_ID")); + return false; + } if ( productionParent.getM_Product_ID() == getM_Product_ID() && productionParent.getProductionQty().signum() == getMovementQty().signum()) setIsEndProduct(true); else @@ -362,6 +367,11 @@ public class MProductionLine extends X_M_ProductionLine { else { I_M_ProductionPlan plan = getM_ProductionPlan(); + MProduction prod = new MProduction(getCtx(), plan.getM_Production_ID(), get_TrxName()); + if (newRecord && prod.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Production_ID")); + return false; + } if (plan.getM_Product_ID() == getM_Product_ID() && plan.getProductionQty().signum() == getMovementQty().signum()) setIsEndProduct(true); else diff --git a/org.adempiere.base/src/org/compiere/model/MProductionLineMA.java b/org.adempiere.base/src/org/compiere/model/MProductionLineMA.java index 918591c343..b22203a04d 100644 --- a/org.adempiere.base/src/org/compiere/model/MProductionLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MProductionLineMA.java @@ -8,13 +8,14 @@ import java.util.List; import java.util.Properties; import org.compiere.util.Env; +import org.compiere.util.Msg; import org.compiere.util.Util; public class MProductionLineMA extends X_M_ProductionLineMA { /** * */ - private static final long serialVersionUID = -3935841562652510880L; + private static final long serialVersionUID = -2633782218494352620L; public MProductionLineMA(Properties ctx, int M_ProductionLineMA_ID, String trxName) { @@ -95,5 +96,22 @@ public class MProductionLineMA extends X_M_ProductionLineMA { return retValue; } // get - + @Override + protected boolean beforeSave(boolean newRecord) + { + MProductionLine parentLine = new MProductionLine(getCtx(), getM_ProductionLine_ID(), get_TrxName()); + MProduction prodParent; + if (parentLine.getM_Production_ID() > 0) { + prodParent = new MProduction(getCtx(), parentLine.getM_Production_ID(), get_TrxName()); + } else { + MProductionPlan plan = new MProductionPlan(getCtx(), parentLine.getM_ProductionPlan_ID(), get_TrxName()); + prodParent = new MProduction(getCtx(), plan.getM_Production_ID(), get_TrxName()); + } + if (newRecord && prodParent.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Production_ID")); + return false; + } + return true; + } + } diff --git a/org.adempiere.base/src/org/compiere/model/MProductionPlan.java b/org.adempiere.base/src/org/compiere/model/MProductionPlan.java index 228a568791..ca04467e1a 100644 --- a/org.adempiere.base/src/org/compiere/model/MProductionPlan.java +++ b/org.adempiere.base/src/org/compiere/model/MProductionPlan.java @@ -14,17 +14,17 @@ import org.adempiere.exceptions.AdempiereException; import org.compiere.util.AdempiereUserError; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; /** * @author hengsin * */ public class MProductionPlan extends X_M_ProductionPlan { - /** - * generated serial id + * */ - private static final long serialVersionUID = -8189507724698695756L; + private static final long serialVersionUID = 1830027775110768396L; /** * @param ctx @@ -303,4 +303,16 @@ public class MProductionPlan extends X_M_ProductionPlan { deleteLines(get_TrxName()); return true; } + + @Override + protected boolean beforeSave(boolean newRecord) + { + MProduction parent = new MProduction(getCtx(), getM_Production_ID(), get_TrxName()); + if (newRecord && parent.isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Production_ID")); + return false; + } + return true; + } + } diff --git a/org.adempiere.base/src/org/compiere/model/MRMALine.java b/org.adempiere.base/src/org/compiere/model/MRMALine.java index 8cc25e3106..b631bccadf 100644 --- a/org.adempiere.base/src/org/compiere/model/MRMALine.java +++ b/org.adempiere.base/src/org/compiere/model/MRMALine.java @@ -267,9 +267,9 @@ public class MRMALine extends X_M_RMALine @Override protected boolean beforeSave(boolean newRecord) { - if (newRecord && getParent().isComplete()) + if (newRecord && getParent().isProcessed()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "M_RMA")); + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_RMA_ID")); return false; } if (getM_InOutLine_ID() == 0 && getC_Charge_ID() == 0 && getM_Product_ID() == 0) diff --git a/org.adempiere.base/src/org/compiere/model/MRequisitionLine.java b/org.adempiere.base/src/org/compiere/model/MRequisitionLine.java index 4240c8d421..b90387e5d8 100644 --- a/org.adempiere.base/src/org/compiere/model/MRequisitionLine.java +++ b/org.adempiere.base/src/org/compiere/model/MRequisitionLine.java @@ -259,8 +259,8 @@ public class MRequisitionLine extends X_M_RequisitionLine */ protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "M_RequisitionLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Requisition_ID")); return false; } if (getLine() == 0) diff --git a/org.adempiere.base/src/org/compiere/model/MTimeExpenseLine.java b/org.adempiere.base/src/org/compiere/model/MTimeExpenseLine.java index 57e6319f77..f370931f56 100644 --- a/org.adempiere.base/src/org/compiere/model/MTimeExpenseLine.java +++ b/org.adempiere.base/src/org/compiere/model/MTimeExpenseLine.java @@ -190,8 +190,8 @@ public class MTimeExpenseLine extends X_S_TimeExpenseLine */ protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "S_TimeExpenseLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "S_TimeExpense_ID")); return false; } // Calculate Converted Amount diff --git a/org.adempiere.base/src/org/eevolution/model/MDDOrderLine.java b/org.adempiere.base/src/org/eevolution/model/MDDOrderLine.java index 9635b8b42a..591272a06b 100644 --- a/org.adempiere.base/src/org/eevolution/model/MDDOrderLine.java +++ b/org.adempiere.base/src/org/eevolution/model/MDDOrderLine.java @@ -515,8 +515,8 @@ public class MDDOrderLine extends X_DD_OrderLine */ protected boolean beforeSave (boolean newRecord) { - if (newRecord && getParent().isComplete()) { - log.saveError("ParentComplete", Msg.translate(getCtx(), "DD_OrderLine")); + if (newRecord && getParent().isProcessed()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "DD_Order_ID")); return false; } // Get Defaults from Parent