Index: Doc_MatchPO.java =================================================================== --- Doc_MatchPO.java (revision 7272) +++ Doc_MatchPO.java (working copy) @@ -103,6 +103,15 @@ public ArrayList createFacts (MAcctSchema as) { ArrayList facts = new ArrayList(); + return facts; + + /** + * Bayu Cahya, Sistematika + * Complete remove this logic + * Move logic to Doc_InOut + */ + /* + ArrayList facts = new ArrayList(); // if (getM_Product_ID() == 0 // Nothing to do if no Product || getQty().signum() == 0 @@ -183,6 +192,7 @@ m_oLine.getDescription(), getTrxName()); // end MZ */ + /* // Calculate PPV for standard costing MProduct product = MProduct.get(getCtx(), getM_Product_ID()); String costingMethod = product.getCostingMethod(as); @@ -199,9 +209,33 @@ log.log(Level.SEVERE, p_Error); return null; } + + // Bayu, Sistematika + // Check if transaction cost currency equals with accounting schema currency + // convert it if not using the same currency + MOrder order = m_oLine.getParent(); + int C_Currency_ID = 0; + C_Currency_ID = order.getC_Currency_ID(); + if (C_Currency_ID != as.getC_Currency_ID()) + { + Timestamp dateAcct = inOut.getDateAcct(); //Movement Date + BigDecimal rate = MConversionRate.getRate( + as.getC_Currency_ID(), C_Currency_ID, + dateAcct, order.getC_ConversionType_ID(), + m_oLine.getAD_Client_ID(), m_oLine.getAD_Org_ID()); + if (rate == null) + { + p_Error = "Purchase Order not convertible - " + as.getName(); + return null; + } + costs = costs.multiply(rate); + if (costs.scale() > as.getCostingPrecision()) + costs = costs.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); + } + // end Bayu // Difference - BigDecimal difference = poCost.subtract(costs); + BigDecimal difference = poCost.multiply(getQty()).subtract(costs); // Nothing to post if (difference.signum() == 0) { @@ -212,7 +246,11 @@ // Product PPV FactLine cr = fact.createLine(null, m_pc.getAccount(ProductCost.ACCTTYPE_P_PPV, as), - as.getC_Currency_ID(), isReturnTrx ? difference.negate() : difference); + // Bayu + // ensure to using transactional currency + // as.getC_Currency_ID(), isReturnTrx ? difference.negate() : difference); + C_Currency_ID, isReturnTrx ? difference.negate() : difference); + // end Bayu if (cr != null) { cr.setQty(isReturnTrx ? getQty().negate() : getQty()); @@ -228,7 +266,11 @@ // PPV Offset FactLine dr = fact.createLine(null, getAccount(Doc.ACCTTYPE_PPVOffset, as), - as.getC_Currency_ID(), isReturnTrx ? difference : difference.negate()); + // Bayu + // ensure to using transactional currency + // as.getC_Currency_ID(), isReturnTrx ? difference : difference.negate()); + C_Currency_ID, isReturnTrx ? difference : difference.negate()); + // end Bayu if (dr != null) { dr.setQty(isReturnTrx ? getQty() : getQty().negate()); @@ -249,6 +291,7 @@ { return facts; } + */ } // createFact /**