IDEMPIERE-3047 Cost Adjustment propagate wrong cost amount to Organization accounting schema denoted in different currency

This commit is contained in:
Soo Fang Lee 2016-05-05 22:09:37 -07:00
parent 28f19b68de
commit f5ab7ac27e
2 changed files with 35 additions and 11 deletions

View File

@ -75,10 +75,22 @@ public class CostAdjustmentCalloutFactory implements IColumnCalloutFactory {
} else { } else {
MProduct product = MProduct.get(ctx, (Integer) value); MProduct product = MProduct.get(ctx, (Integer) value);
MClient client = MClient.get(ctx); MClient client = MClient.get(ctx);
MAcctSchema as = client.getAcctSchema();
Object asiValue = mTab.getValue(I_M_InventoryLine.COLUMNNAME_M_AttributeSetInstance_ID); Object asiValue = mTab.getValue(I_M_InventoryLine.COLUMNNAME_M_AttributeSetInstance_ID);
int M_ASI_ID = asiValue != null ? (Integer)asiValue : 0; int M_ASI_ID = asiValue != null ? (Integer)asiValue : 0;
int AD_Org_ID = inventory.getAD_Org_ID(); 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); MCost cost = product.getCostingRecord(as, AD_Org_ID, M_ASI_ID, costingMethod);
if (cost == null) { if (cost == null) {
if (!MCostElement.COSTINGMETHOD_StandardCosting.equals(costingMethod)) { if (!MCostElement.COSTINGMETHOD_StandardCosting.equals(costingMethod)) {
@ -111,8 +123,21 @@ public class CostAdjustmentCalloutFactory implements IColumnCalloutFactory {
MProduct product = MProduct.get(ctx, (Integer)productValue); MProduct product = MProduct.get(ctx, (Integer)productValue);
int M_ASI_ID = value != null ? (Integer)value : 0; int M_ASI_ID = value != null ? (Integer)value : 0;
int AD_Org_ID = inventory.getAD_Org_ID(); int AD_Org_ID = inventory.getAD_Org_ID();
int C_Currency_ID = inventory.getC_Currency_ID();
MClient client = MClient.get(ctx); MClient client = MClient.get(ctx);
MAcctSchema as = client.getAcctSchema(); 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); MCost cost = product.getCostingRecord(as, AD_Org_ID, M_ASI_ID, costingMethod);
if (cost != null) { if (cost != null) {
BigDecimal currentCost = (BigDecimal) mTab.getValue(I_M_InventoryLine.COLUMNNAME_CurrentCostPrice); BigDecimal currentCost = (BigDecimal) mTab.getValue(I_M_InventoryLine.COLUMNNAME_CurrentCostPrice);

View File

@ -81,16 +81,13 @@ public class Doc_Inventory extends Doc
m_DocStatus = inventory.getDocStatus(); m_DocStatus = inventory.getDocStatus();
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
parentDocSubTypeInv = dt.getDocSubTypeInv(); parentDocSubTypeInv = dt.getDocSubTypeInv();
if (MDocType.DOCSUBTYPEINV_CostAdjustment.equals(parentDocSubTypeInv))
{ // IDEMPIERE-3046 Add Currency Field to Cost Adjustment Window
MClient client = MClient.get(getCtx(), inventory.getAD_Client_ID()); if (!MDocType.DOCSUBTYPEINV_CostAdjustment.equals(parentDocSubTypeInv))
int C_Currency_ID = client.getAcctSchema().getC_Currency_ID();
setC_Currency_ID(C_Currency_ID);
}
else
{ {
setC_Currency_ID (NO_CURRENCY); setC_Currency_ID (NO_CURRENCY);
} }
// Contained Objects // Contained Objects
p_lines = loadLines(inventory); p_lines = loadLines(inventory);
if (log.isLoggable(Level.FINE)) log.fine("Lines=" + p_lines.length); if (log.isLoggable(Level.FINE)) log.fine("Lines=" + p_lines.length);
@ -175,7 +172,9 @@ public class Doc_Inventory extends Doc
{ {
// create Fact Header // create Fact Header
Fact fact = new Fact(this, as, Fact.POST_Actual); 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 // Line pointers
FactLine dr = null; FactLine dr = null;