From edc96cca12f16d7cbbd8d76eb606475acbdf2060 Mon Sep 17 00:00:00 2001 From: hengsin Date: Tue, 26 Jul 2022 21:26:58 +0800 Subject: [PATCH] IDEMPIERE-5153 Cost Adjument Line Before Save: Update current cost price (#1411) - Fix always getting current cost from primary accounting schema. --- .../src/org/compiere/model/MInventoryLine.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java index 222d997c6c..5622fca4bc 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java @@ -369,6 +369,20 @@ public class MInventoryLine extends X_M_InventoryLine } } + //check currency and as + int C_Currency_ID = getParent().getC_Currency_ID(); + + if (as.getC_Currency_ID() != C_Currency_ID) + { + MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(getCtx(), client.get_ID()); + for (int i = 0; i < ass.length ; i ++) + { + MAcctSchema a = ass[i]; + if (a.getC_Currency_ID() == C_Currency_ID) + as = a ; + } + } + String costingMethod = getParent().getCostingMethod(); int AD_Org_ID = getAD_Org_ID(); MCost cost = product.getCostingRecord(as, AD_Org_ID, M_ASI_ID, costingMethod);