From 8e216841b6c27a01e508f4fd6579bada5dc21df4 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 20 Mar 2012 00:11:47 +0800 Subject: [PATCH] IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false --- .../oracle/825_IDEMPIERE-189.sql | 55 ++++++++++++++++++ .../postgresql/825_IDEMPIERE-189.sql | 56 +++++++++++++++++++ .../src/org/compiere/model/MCostDetail.java | 24 ++------ .../src/org/compiere/model/MMatchInv.java | 4 +- .../src/org/compiere/model/MMatchPO.java | 11 ++-- 5 files changed, 124 insertions(+), 26 deletions(-) create mode 100644 migration/360lts-release/oracle/825_IDEMPIERE-189.sql create mode 100644 migration/360lts-release/postgresql/825_IDEMPIERE-189.sql diff --git a/migration/360lts-release/oracle/825_IDEMPIERE-189.sql b/migration/360lts-release/oracle/825_IDEMPIERE-189.sql new file mode 100644 index 0000000000..21629b6647 --- /dev/null +++ b/migration/360lts-release/oracle/825_IDEMPIERE-189.sql @@ -0,0 +1,55 @@ +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=12326 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=50158 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=50159 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y' WHERE AD_Field_ID=50160 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=220,IsDisplayed='Y' WHERE AD_Field_ID=50184 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=230,IsDisplayed='Y' WHERE AD_Field_ID=50185 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y' WHERE AD_Field_ID=50186 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y' WHERE AD_Field_ID=54238 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y' WHERE AD_Field_ID=54680 +; + +-- Mar 19, 2012 8:36:52 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Column SET IsActive='N',Updated=TO_DATE('2012-03-19 20:36:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=14403 +; + +UPDATE AD_System + SET LastMigrationScriptApplied='825_IDEMPIERE-189.sql' +WHERE LastMigrationScriptApplied<'825_IDEMPIERE-189.sql' + OR LastMigrationScriptApplied IS NULL +; diff --git a/migration/360lts-release/postgresql/825_IDEMPIERE-189.sql b/migration/360lts-release/postgresql/825_IDEMPIERE-189.sql new file mode 100644 index 0000000000..a36579f315 --- /dev/null +++ b/migration/360lts-release/postgresql/825_IDEMPIERE-189.sql @@ -0,0 +1,56 @@ +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=12326 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=190,IsDisplayed='Y' WHERE AD_Field_ID=50158 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=200,IsDisplayed='Y' WHERE AD_Field_ID=50159 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=210,IsDisplayed='Y' WHERE AD_Field_ID=50160 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=220,IsDisplayed='Y' WHERE AD_Field_ID=50184 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=230,IsDisplayed='Y' WHERE AD_Field_ID=50185 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y' WHERE AD_Field_ID=50186 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y' WHERE AD_Field_ID=54238 +; + +-- Mar 19, 2012 8:36:26 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y' WHERE AD_Field_ID=54680 +; + +-- Mar 19, 2012 8:36:52 PM MYT +-- IDEMPIERE-189 Average Costing: moving average costing doesn't work if AD_Client.IsCostImmediate is false +UPDATE AD_Column SET IsActive='N',Updated=TO_TIMESTAMP('2012-03-19 20:36:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=14403 +; + +UPDATE AD_System + SET LastMigrationScriptApplied='825_IDEMPIERE-189.sql' +WHERE LastMigrationScriptApplied<'825_IDEMPIERE-189.sql' + OR LastMigrationScriptApplied IS NULL +; + diff --git a/org.adempiere.base/src/org/compiere/model/MCostDetail.java b/org.adempiere.base/src/org/compiere/model/MCostDetail.java index a36e100e81..fa6cde40aa 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostDetail.java +++ b/org.adempiere.base/src/org/compiere/model/MCostDetail.java @@ -111,9 +111,7 @@ public class MCostDetail extends X_M_CostDetail boolean ok = cd.save(); if (ok && !cd.isProcessed()) { - MClient client = MClient.get(as.getCtx(), as.getAD_Client_ID()); - if (client.isCostImmediate()) - cd.process(); + ok = cd.process(); } s_log.config("(" + ok + ") " + cd); return ok; @@ -180,9 +178,7 @@ public class MCostDetail extends X_M_CostDetail boolean ok = cd.save(); if (ok && !cd.isProcessed()) { - MClient client = MClient.get(as.getCtx(), as.getAD_Client_ID()); - if (client.isCostImmediate()) - cd.process(); + ok = cd.process(); } s_log.config("(" + ok + ") " + cd); return ok; @@ -250,9 +246,7 @@ public class MCostDetail extends X_M_CostDetail boolean ok = cd.save(); if (ok && !cd.isProcessed()) { - MClient client = MClient.get(as.getCtx(), as.getAD_Client_ID()); - if (client.isCostImmediate()) - cd.process(); + ok = cd.process(); } s_log.config("(" + ok + ") " + cd); return ok; @@ -318,9 +312,7 @@ public class MCostDetail extends X_M_CostDetail boolean ok = cd.save(); if (ok && !cd.isProcessed()) { - MClient client = MClient.get(as.getCtx(), as.getAD_Client_ID()); - if (client.isCostImmediate()) - cd.process(); + ok = cd.process(); } s_log.config("(" + ok + ") " + cd); return ok; @@ -390,9 +382,7 @@ public class MCostDetail extends X_M_CostDetail boolean ok = cd.save(); if (ok && !cd.isProcessed()) { - MClient client = MClient.get(as.getCtx(), as.getAD_Client_ID()); - if (client.isCostImmediate()) - cd.process(); + ok = cd.process(); } s_log.config("(" + ok + ") " + cd); return ok; @@ -458,9 +448,7 @@ public class MCostDetail extends X_M_CostDetail boolean ok = cd.save(); if (ok && !cd.isProcessed()) { - MClient client = MClient.get(as.getCtx(), as.getAD_Client_ID()); - if (client.isCostImmediate()) - cd.process(); + ok = cd.process(); } s_log.config("(" + ok + ") " + cd); return ok; diff --git a/org.adempiere.base/src/org/compiere/model/MMatchInv.java b/org.adempiere.base/src/org/compiere/model/MMatchInv.java index b4c31a805a..25792ba48d 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchInv.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchInv.java @@ -442,9 +442,7 @@ public class MMatchInv extends X_M_MatchInv cd.setQty(cd.getQty().subtract(qty)); if (!cd.isProcessed()) { - MClient client = MClient.get(getCtx(), getAD_Client_ID()); - if (client.isCostImmediate()) - cd.process(); + cd.process(); } if (cd.getQty().compareTo(Env.ZERO) == 0) { diff --git a/org.adempiere.base/src/org/compiere/model/MMatchPO.java b/org.adempiere.base/src/org/compiere/model/MMatchPO.java index 0faedbd0fe..2f73b62204 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchPO.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchPO.java @@ -946,11 +946,14 @@ public class MMatchPO extends X_M_MatchPO } // Set Total Amount and Total Quantity from Matched PO - MCostDetail.createOrder(as, oLine.getAD_Org_ID(), + if (!MCostDetail.createOrder(as, oLine.getAD_Org_ID(), getM_Product_ID(), getM_AttributeSetInstance_ID(), oLine.getC_OrderLine_ID(), 0, // no cost element tAmt, tQty, // Delivered - oLine.getDescription(), get_TrxName()); + oLine.getDescription(), get_TrxName())) + { + return "SaveError"; + } // end MZ } } @@ -987,9 +990,7 @@ public class MMatchPO extends X_M_MatchPO cd.setQty(cd.getQty().subtract(getQty())); if (!cd.isProcessed()) { - MClient client = MClient.get(getCtx(), getAD_Client_ID()); - if (client.isCostImmediate()) - cd.process(); + cd.process(); } } //after process clean-up