IDEMPIERE-3047 Cost Adjustment propagate wrong cost amount to Organization accounting schema denoted in different currency
This commit is contained in:
parent
28f19b68de
commit
f5ab7ac27e
|
@ -75,10 +75,22 @@ public class CostAdjustmentCalloutFactory implements IColumnCalloutFactory {
|
|||
} else {
|
||||
MProduct product = MProduct.get(ctx, (Integer) value);
|
||||
MClient client = MClient.get(ctx);
|
||||
MAcctSchema as = client.getAcctSchema();
|
||||
Object asiValue = mTab.getValue(I_M_InventoryLine.COLUMNNAME_M_AttributeSetInstance_ID);
|
||||
int M_ASI_ID = asiValue != null ? (Integer)asiValue : 0;
|
||||
int AD_Org_ID = inventory.getAD_Org_ID();
|
||||
int C_Currency_ID = inventory.getC_Currency_ID();
|
||||
|
||||
MAcctSchema as = client.getAcctSchema();
|
||||
if (as.getC_Currency_ID() != C_Currency_ID)
|
||||
{
|
||||
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, 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 ;
|
||||
}
|
||||
}
|
||||
MCost cost = product.getCostingRecord(as, AD_Org_ID, M_ASI_ID, costingMethod);
|
||||
if (cost == null) {
|
||||
if (!MCostElement.COSTINGMETHOD_StandardCosting.equals(costingMethod)) {
|
||||
|
@ -111,8 +123,21 @@ public class CostAdjustmentCalloutFactory implements IColumnCalloutFactory {
|
|||
MProduct product = MProduct.get(ctx, (Integer)productValue);
|
||||
int M_ASI_ID = value != null ? (Integer)value : 0;
|
||||
int AD_Org_ID = inventory.getAD_Org_ID();
|
||||
int C_Currency_ID = inventory.getC_Currency_ID();
|
||||
|
||||
MClient client = MClient.get(ctx);
|
||||
MAcctSchema as = client.getAcctSchema();
|
||||
|
||||
if (as.getC_Currency_ID() != C_Currency_ID)
|
||||
{
|
||||
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, 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 ;
|
||||
}
|
||||
}
|
||||
MCost cost = product.getCostingRecord(as, AD_Org_ID, M_ASI_ID, costingMethod);
|
||||
if (cost != null) {
|
||||
BigDecimal currentCost = (BigDecimal) mTab.getValue(I_M_InventoryLine.COLUMNNAME_CurrentCostPrice);
|
||||
|
|
|
@ -81,16 +81,13 @@ public class Doc_Inventory extends Doc
|
|||
m_DocStatus = inventory.getDocStatus();
|
||||
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
|
||||
parentDocSubTypeInv = dt.getDocSubTypeInv();
|
||||
if (MDocType.DOCSUBTYPEINV_CostAdjustment.equals(parentDocSubTypeInv))
|
||||
{
|
||||
MClient client = MClient.get(getCtx(), inventory.getAD_Client_ID());
|
||||
int C_Currency_ID = client.getAcctSchema().getC_Currency_ID();
|
||||
setC_Currency_ID(C_Currency_ID);
|
||||
}
|
||||
else
|
||||
|
||||
// IDEMPIERE-3046 Add Currency Field to Cost Adjustment Window
|
||||
if (!MDocType.DOCSUBTYPEINV_CostAdjustment.equals(parentDocSubTypeInv))
|
||||
{
|
||||
setC_Currency_ID (NO_CURRENCY);
|
||||
}
|
||||
|
||||
// Contained Objects
|
||||
p_lines = loadLines(inventory);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Lines=" + p_lines.length);
|
||||
|
@ -175,7 +172,9 @@ public class Doc_Inventory extends Doc
|
|||
{
|
||||
// create Fact Header
|
||||
Fact fact = new Fact(this, as, Fact.POST_Actual);
|
||||
setC_Currency_ID(as.getC_Currency_ID());
|
||||
|
||||
if (!MDocType.DOCSUBTYPEINV_CostAdjustment.equals(parentDocSubTypeInv))
|
||||
setC_Currency_ID(as.getC_Currency_ID());
|
||||
|
||||
// Line pointers
|
||||
FactLine dr = null;
|
||||
|
|
Loading…
Reference in New Issue