Related to Issue
28389: Fixed Posting of LC Cost with Invoice Line
While processing a Landed Cost with an Invoice in a Landed Cost Cost it, if the invoice has an exchange rate different from the system, a new Cost Adjustment is created with that difference between the rates. But this difference it was not taking into account while setting the matched amount in Landed Cost Cost, so the Post process it was not working well.
--- a/src/org/openbravo/costing/LandedCostProcess.java Tue Dec 16 18:34:37 2014 +0100
+++ b/src/org/openbravo/costing/LandedCostProcess.java Thu Dec 18 18:36:08 2014 +0100
@@ -33,6 +33,7 @@
import org.hibernate.Query;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
+import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.openbravo.base.exception.OBException;
import org.openbravo.base.provider.OBProvider;
@@ -318,7 +319,11 @@
lcc.setMatched(Boolean.TRUE);
lcc.setProcessed(Boolean.TRUE);
- lcc.setMatchingAmount(lcc.getAmount());
+ OBCriteria<LCMatched> critMatched = OBDal.getInstance().createCriteria(LCMatched.class);
+ critMatched.add(Restrictions.eq(LCMatched.PROPERTY_LANDEDCOSTCOST, lcc));
+ critMatched.setProjection(Projections.sum(LCMatched.PROPERTY_AMOUNT));
+ BigDecimal matchedAmt = (BigDecimal) critMatched.uniqueResult();
+ lcc.setMatchingAmount(matchedAmt);
OBDal.getInstance().save(lcc);
}
}