details: https://code.openbravo.com/erp/devel/pi/rev/8b4b108ad325 changeset: 25155:8b4b108ad325 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Wed Oct 29 10:53:10 2014 +0100 summary: Fixes issue 27988: Currency field at landed cost header has been removed
Now, if there is a Landed Cost with Landed Cost lines with different currencies, the cost adjustment will be created with a line per each goods receipt line and each currency, instead of converting from Landed Cost Cost currency to the header one and grouping them, it will leave in the original currency. details: https://code.openbravo.com/erp/devel/pi/rev/aaadf192b66c changeset: 25156:aaadf192b66c user: Unai Martirena <unai.martirena <at> openbravo.com> date: Wed Oct 29 13:29:18 2014 +0100 summary: Related to Issue 27988 Remove setCurrency to a Landed Cost header in CostingServer. Fix callout of Landed Cost Cost of Invoice Line column to not to set Currency of Landed Cost Header. details: https://code.openbravo.com/erp/devel/pi/rev/f107db775c71 changeset: 25157:f107db775c71 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Wed Oct 29 17:39:58 2014 +0100 summary: Fixes bug 27847: Dont allow the creation of Landed Cost for not Legal Entity org The Window Type of Landed Cost window has been changed from 'Maintain' to 'Transaction'. So this window only could be used for transactional organizations. diffstat: src-db/database/model/tables/M_LANDEDCOST.xml | 7 - src-db/database/sourcedata/AD_COLUMN.xml | 36 ---------- src-db/database/sourcedata/AD_FIELD.xml | 28 ------- src-db/database/sourcedata/AD_WINDOW.xml | 2 +- src/org/openbravo/costing/CostingServer.java | 1 - src/org/openbravo/costing/LandedCostDistributionByAmount.java | 9 +- src/org/openbravo/costing/LandedCostProcess.java | 11 ++- src/org/openbravo/erpCommon/ad_callouts/SL_LandedCost_InvoiceLine.java | 6 +- src/org/openbravo/erpCommon/ad_forms/DocLandedCost_data.xsql | 4 +- 9 files changed, 15 insertions(+), 89 deletions(-) diffs (259 lines): diff -r 7a398be57eab -r f107db775c71 src-db/database/model/tables/M_LANDEDCOST.xml --- a/src-db/database/model/tables/M_LANDEDCOST.xml Tue Oct 28 00:38:28 2014 -0500 +++ b/src-db/database/model/tables/M_LANDEDCOST.xml Wed Oct 29 17:39:58 2014 +0100 @@ -57,10 +57,6 @@ <default><![CDATA[DR]]></default> <onCreateDefault/> </column> - <column name="C_CURRENCY_ID" primaryKey="false" required="true" type="VARCHAR" size="32" autoIncrement="false"> - <default/> - <onCreateDefault/> - </column> <column name="POSTED" primaryKey="false" required="false" type="VARCHAR" size="60" autoIncrement="false"> <default><![CDATA[N]]></default> <onCreateDefault/> @@ -87,9 +83,6 @@ <foreign-key foreignTable="M_COSTADJUSTMENT" name="M_LANDEDCOST_COSTADJ"> <reference local="M_COSTADJUSTMENT_ID" foreign="M_COSTADJUSTMENT_ID"/> </foreign-key> - <foreign-key foreignTable="C_CURRENCY" name="M_LANDEDCOST_CURRENCY"> - <reference local="C_CURRENCY_ID" foreign="C_CURRENCY_ID"/> - </foreign-key> <foreign-key foreignTable="C_DOCTYPE" name="M_LANDEDCOST_DOCTYPE"> <reference local="C_DOCTYPE_ID" foreign="C_DOCTYPE_ID"/> </foreign-key> diff -r 7a398be57eab -r f107db775c71 src-db/database/sourcedata/AD_COLUMN.xml --- a/src-db/database/sourcedata/AD_COLUMN.xml Tue Oct 28 00:38:28 2014 -0500 +++ b/src-db/database/sourcedata/AD_COLUMN.xml Wed Oct 29 17:39:58 2014 +0100 @@ -221349,42 +221349,6 @@ <!--00568254CB3C8733E050007F01000513--> <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE> <!--00568254CB3C8733E050007F01000513--></AD_COLUMN> -<!--00568254CB3D8733E050007F01000513--><AD_COLUMN> -<!--00568254CB3D8733E050007F01000513--> <AD_COLUMN_ID><![CDATA[00568254CB3D8733E050007F01000513]]></AD_COLUMN_ID> -<!--00568254CB3D8733E050007F01000513--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> -<!--00568254CB3D8733E050007F01000513--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> -<!--00568254CB3D8733E050007F01000513--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> -<!--00568254CB3D8733E050007F01000513--> <NAME><![CDATA[Currency]]></NAME> -<!--00568254CB3D8733E050007F01000513--> <DESCRIPTION><![CDATA[An accepted medium of monetary exchange that may vary across countries.]]></DESCRIPTION> -<!--00568254CB3D8733E050007F01000513--> <HELP><![CDATA[Indicates the currency to be used when processing this document.]]></HELP> -<!--00568254CB3D8733E050007F01000513--> <COLUMNNAME><![CDATA[C_Currency_ID]]></COLUMNNAME> -<!--00568254CB3D8733E050007F01000513--> <AD_TABLE_ID><![CDATA[082F967CDF7245EB9A150941F326C45C]]></AD_TABLE_ID> -<!--00568254CB3D8733E050007F01000513--> <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID> -<!--00568254CB3D8733E050007F01000513--> <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH> -<!--00568254CB3D8733E050007F01000513--> <ISKEY><![CDATA[N]]></ISKEY> -<!--00568254CB3D8733E050007F01000513--> <ISPARENT><![CDATA[N]]></ISPARENT> -<!--00568254CB3D8733E050007F01000513--> <ISMANDATORY><![CDATA[Y]]></ISMANDATORY> -<!--00568254CB3D8733E050007F01000513--> <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE> -<!--00568254CB3D8733E050007F01000513--> <READONLYLOGIC><![CDATA[@Processed@='Y']]></READONLYLOGIC> -<!--00568254CB3D8733E050007F01000513--> <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER> -<!--00568254CB3D8733E050007F01000513--> <SEQNO><![CDATA[150]]></SEQNO> -<!--00568254CB3D8733E050007F01000513--> <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED> -<!--00568254CB3D8733E050007F01000513--> <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED> -<!--00568254CB3D8733E050007F01000513--> <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN> -<!--00568254CB3D8733E050007F01000513--> <AD_ELEMENT_ID><![CDATA[193]]></AD_ELEMENT_ID> -<!--00568254CB3D8733E050007F01000513--> <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR> -<!--00568254CB3D8733E050007F01000513--> <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY> -<!--00568254CB3D8733E050007F01000513--> <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE> -<!--00568254CB3D8733E050007F01000513--> <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS> -<!--00568254CB3D8733E050007F01000513--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID> -<!--00568254CB3D8733E050007F01000513--> <POSITION><![CDATA[15]]></POSITION> -<!--00568254CB3D8733E050007F01000513--> <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT> -<!--00568254CB3D8733E050007F01000513--> <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE> -<!--00568254CB3D8733E050007F01000513--> <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW> -<!--00568254CB3D8733E050007F01000513--> <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION> -<!--00568254CB3D8733E050007F01000513--> <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE> -<!--00568254CB3D8733E050007F01000513--></AD_COLUMN> - <!--00568254CB5F8733E050007F01000513--><AD_COLUMN> <!--00568254CB5F8733E050007F01000513--> <AD_COLUMN_ID><![CDATA[00568254CB5F8733E050007F01000513]]></AD_COLUMN_ID> <!--00568254CB5F8733E050007F01000513--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff -r 7a398be57eab -r f107db775c71 src-db/database/sourcedata/AD_FIELD.xml --- a/src-db/database/sourcedata/AD_FIELD.xml Tue Oct 28 00:38:28 2014 -0500 +++ b/src-db/database/sourcedata/AD_FIELD.xml Wed Oct 29 17:39:58 2014 +0100 @@ -175649,34 +175649,6 @@ <!--0056819E5150679FE050007F01000569--> <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY> <!--0056819E5150679FE050007F01000569--></AD_FIELD> -<!--0056819E5151679FE050007F01000569--><AD_FIELD> -<!--0056819E5151679FE050007F01000569--> <AD_FIELD_ID><![CDATA[0056819E5151679FE050007F01000569]]></AD_FIELD_ID> -<!--0056819E5151679FE050007F01000569--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> -<!--0056819E5151679FE050007F01000569--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> -<!--0056819E5151679FE050007F01000569--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> -<!--0056819E5151679FE050007F01000569--> <NAME><![CDATA[Currency]]></NAME> -<!--0056819E5151679FE050007F01000569--> <DESCRIPTION><![CDATA[An accepted medium of monetary exchange that may vary across countries.]]></DESCRIPTION> -<!--0056819E5151679FE050007F01000569--> <HELP><![CDATA[Indicates the currency to be used when processing this document.]]></HELP> -<!--0056819E5151679FE050007F01000569--> <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED> -<!--0056819E5151679FE050007F01000569--> <AD_TAB_ID><![CDATA[F25CBC61CDD64F5E8A6FDC41C6E23C96]]></AD_TAB_ID> -<!--0056819E5151679FE050007F01000569--> <AD_COLUMN_ID><![CDATA[00568254CB3D8733E050007F01000513]]></AD_COLUMN_ID> -<!--0056819E5151679FE050007F01000569--> <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD> -<!--0056819E5151679FE050007F01000569--> <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED> -<!--0056819E5151679FE050007F01000569--> <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH> -<!--0056819E5151679FE050007F01000569--> <ISREADONLY><![CDATA[N]]></ISREADONLY> -<!--0056819E5151679FE050007F01000569--> <SEQNO><![CDATA[60]]></SEQNO> -<!--0056819E5151679FE050007F01000569--> <ISSAMELINE><![CDATA[N]]></ISSAMELINE> -<!--0056819E5151679FE050007F01000569--> <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY> -<!--0056819E5151679FE050007F01000569--> <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED> -<!--0056819E5151679FE050007F01000569--> <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION> -<!--0056819E5151679FE050007F01000569--> <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD> -<!--0056819E5151679FE050007F01000569--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID> -<!--0056819E5151679FE050007F01000569--> <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN> -<!--0056819E5151679FE050007F01000569--> <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE> -<!--0056819E5151679FE050007F01000569--> <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR> -<!--0056819E5151679FE050007F01000569--> <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY> -<!--0056819E5151679FE050007F01000569--></AD_FIELD> - <!--0056819E5164679FE050007F01000569--><AD_FIELD> <!--0056819E5164679FE050007F01000569--> <AD_FIELD_ID><![CDATA[0056819E5164679FE050007F01000569]]></AD_FIELD_ID> <!--0056819E5164679FE050007F01000569--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff -r 7a398be57eab -r f107db775c71 src-db/database/sourcedata/AD_WINDOW.xml --- a/src-db/database/sourcedata/AD_WINDOW.xml Tue Oct 28 00:38:28 2014 -0500 +++ b/src-db/database/sourcedata/AD_WINDOW.xml Wed Oct 29 17:39:58 2014 +0100 @@ -3302,7 +3302,7 @@ <!--D1B11CBC0FEF4CA0B44D3BECEBA219BC--> <NAME><![CDATA[Landed Cost]]></NAME> <!--D1B11CBC0FEF4CA0B44D3BECEBA219BC--> <DESCRIPTION><![CDATA[Landed cost window allows to create, edit and process a landed cost]]></DESCRIPTION> <!--D1B11CBC0FEF4CA0B44D3BECEBA219BC--> <HELP><![CDATA[Landed cost window allows to create, edit and process a landed cost]]></HELP> -<!--D1B11CBC0FEF4CA0B44D3BECEBA219BC--> <WINDOWTYPE><![CDATA[M]]></WINDOWTYPE> +<!--D1B11CBC0FEF4CA0B44D3BECEBA219BC--> <WINDOWTYPE><![CDATA[T]]></WINDOWTYPE> <!--D1B11CBC0FEF4CA0B44D3BECEBA219BC--> <ISSOTRX><![CDATA[N]]></ISSOTRX> <!--D1B11CBC0FEF4CA0B44D3BECEBA219BC--> <PROCESSING><![CDATA[N]]></PROCESSING> <!--D1B11CBC0FEF4CA0B44D3BECEBA219BC--> <ISDEFAULT><![CDATA[N]]></ISDEFAULT> diff -r 7a398be57eab -r f107db775c71 src/org/openbravo/costing/CostingServer.java --- a/src/org/openbravo/costing/CostingServer.java Tue Oct 28 00:38:28 2014 -0500 +++ b/src/org/openbravo/costing/CostingServer.java Wed Oct 29 17:39:58 2014 +0100 @@ -188,7 +188,6 @@ landedCost.setReferenceDate(new Date()); landedCost.setDocumentType(docType); landedCost.setDocumentNo(docNo); - landedCost.setCurrency(currency); landedCost.setOrganization(organization); OBDal.getInstance().save(landedCost); diff -r 7a398be57eab -r f107db775c71 src/org/openbravo/costing/LandedCostDistributionByAmount.java --- a/src/org/openbravo/costing/LandedCostDistributionByAmount.java Tue Oct 28 00:38:28 2014 -0500 +++ b/src/org/openbravo/costing/LandedCostDistributionByAmount.java Wed Oct 29 17:39:58 2014 +0100 @@ -46,20 +46,17 @@ public void distributeAmount(LandedCostCost lcCost, boolean isMatching) { // Calculate total amount of all receipt lines assigned to the landed cost. LandedCost landedCost = lcCost.getLandedCost(); - String strCurId = landedCost.getCurrency().getId(); + // Get the currency of the Landed Cost Cost + String strCurId = lcCost.getCurrency().getId(); String strOrgId = landedCost.getOrganization().getId(); Date dateReference = landedCost.getReferenceDate(); - int precission = landedCost.getCurrency().getStandardPrecision().intValue(); + int precission = lcCost.getCurrency().getStandardPrecision().intValue(); BigDecimal baseAmt; if (isMatching) { baseAmt = lcCost.getMatchingAmount().subtract(lcCost.getAmount()); } else { baseAmt = lcCost.getAmount(); } - if (!lcCost.getCurrency().getId().equals(strCurId)) { - baseAmt = FinancialUtils.getConvertedAmount(baseAmt, lcCost.getCurrency(), - landedCost.getCurrency(), dateReference, landedCost.getOrganization(), "C"); - } BigDecimal totalAmt = BigDecimal.ZERO; diff -r 7a398be57eab -r f107db775c71 src/org/openbravo/costing/LandedCostProcess.java --- a/src/org/openbravo/costing/LandedCostProcess.java Tue Oct 28 00:38:28 2014 -0500 +++ b/src/org/openbravo/costing/LandedCostProcess.java Wed Oct 29 17:39:58 2014 +0100 @@ -42,6 +42,7 @@ import org.openbravo.dal.service.OBDal; import org.openbravo.dal.service.OBQuery; import org.openbravo.erpCommon.utility.OBMessageUtils; +import org.openbravo.model.common.currency.Currency; import org.openbravo.model.materialmgmt.cost.CostAdjustment; import org.openbravo.model.materialmgmt.cost.CostAdjustmentLine; import org.openbravo.model.materialmgmt.cost.LCDistributionAlgorithm; @@ -196,11 +197,14 @@ StringBuffer hql = new StringBuffer(); hql.append(" select sum(rla." + LCReceiptLineAmt.PROPERTY_AMOUNT + ") as amt"); + hql.append(" , rla." + LCReceiptLineAmt.PROPERTY_LANDEDCOSTCOST + + ".currency.id as lcCostCurrency"); hql.append(" , rla." + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id as receipt"); hql.append(" from " + LCReceiptLineAmt.ENTITY_NAME + " as rla"); hql.append(" join rla." + LCReceiptLineAmt.PROPERTY_LANDEDCOSTRECEIPT + " as rl"); hql.append(" where rl." + LCReceipt.PROPERTY_LANDEDCOST + " = :lc"); - hql.append(" group by rla." + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id"); + hql.append(" group by rla." + LCReceiptLineAmt.PROPERTY_LANDEDCOSTCOST + ".currency.id"); + hql.append(" , rla." + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id"); Query qryLCRLA = OBDal.getInstance().getSession().createQuery(hql.toString()); qryLCRLA.setParameter("lc", landedCost); @@ -211,15 +215,16 @@ log.debug("Process receipt amounts"); Object[] receiptAmt = receiptamts.get(); BigDecimal amt = (BigDecimal) receiptAmt[0]; + Currency lcCostCurrency = OBDal.getInstance().get(Currency.class, (String) receiptAmt[1]); ShipmentInOutLine receiptLine = OBDal.getInstance().get(ShipmentInOutLine.class, - (String) receiptAmt[1]); + (String) receiptAmt[2]); // MaterialTransaction receiptLine = (MaterialTransaction) record[1]; MaterialTransaction trx = receiptLine.getMaterialMgmtMaterialTransactionList().get(0); CostAdjustmentLine cal = CostAdjustmentUtils.insertCostAdjustmentLine(trx, ca, amt, true, referenceDate); cal.setNeedsPosting(Boolean.FALSE); cal.setUnitCost(Boolean.FALSE); - cal.setCurrency(landedCost.getCurrency()); + cal.setCurrency(lcCostCurrency); OBDal.getInstance().save(cal); if (i % 100 == 0) { diff -r 7a398be57eab -r f107db775c71 src/org/openbravo/erpCommon/ad_callouts/SL_LandedCost_InvoiceLine.java --- a/src/org/openbravo/erpCommon/ad_callouts/SL_LandedCost_InvoiceLine.java Tue Oct 28 00:38:28 2014 -0500 +++ b/src/org/openbravo/erpCommon/ad_callouts/SL_LandedCost_InvoiceLine.java Wed Oct 29 17:39:58 2014 +0100 @@ -28,7 +28,6 @@ import org.openbravo.dal.core.OBContext; import org.openbravo.dal.service.OBDal; import org.openbravo.model.common.invoice.InvoiceLine; -import org.openbravo.model.materialmgmt.cost.LandedCost; public class SL_LandedCost_InvoiceLine extends SimpleCallout { @@ -37,7 +36,6 @@ @Override protected void execute(CalloutInfo info) throws ServletException { VariablesSecureApp vars = info.vars; - String strLCId = vars.getStringParameter("inpmLandedcostId"); String strInvLineId = vars.getStringParameter("inpcInvoicelineId"); String strAmount = ""; String strCurrencyId = ""; @@ -45,13 +43,11 @@ InvoiceLine invoiceLine = OBDal.getInstance().get(InvoiceLine.class, strInvLineId); strAmount = getAmount(invoiceLine); strCurrencyId = invoiceLine.getInvoice().getCurrency().getId(); + info.addResult("inpcCurrencyId", strCurrencyId); } else { strAmount = "0"; - LandedCost landedCost = OBDal.getInstance().get(LandedCost.class, strLCId); - strCurrencyId = landedCost.getCurrency().getId(); } info.addResult("inpamount", strAmount); - info.addResult("inpcCurrencyId", strCurrencyId); } private String getAmount(InvoiceLine invoiceLine) { diff -r 7a398be57eab -r f107db775c71 src/org/openbravo/erpCommon/ad_forms/DocLandedCost_data.xsql --- a/src/org/openbravo/erpCommon/ad_forms/DocLandedCost_data.xsql Tue Oct 28 00:38:28 2014 -0500 +++ b/src/org/openbravo/erpCommon/ad_forms/DocLandedCost_data.xsql Wed Oct 29 17:39:58 2014 +0100 @@ -26,7 +26,7 @@ <![CDATA[ SELECT '' AS M_LANDEDCOST_ID, '' AS AD_CLIENT_ID, '' AS AD_ORG_ID, '' AS ISACTIVE, '' AS CREATED, '' AS CREATEDBY, '' AS UPDATED, '' AS UPDATEDBY, '' AS DATETRX, '' AS PROCESSING, - '' AS PROCESSED, '' AS POSTED, '' AS DATEACCT, '' AS DATEDOC, '' AS C_CURRENCY_ID + '' AS PROCESSED, '' AS POSTED, '' AS DATEACCT, '' AS DATEDOC FROM DUAL ]]> </Sql> @@ -37,7 +37,7 @@ <![CDATA[ SELECT LC.M_LANDEDCOST_ID, LC.AD_CLIENT_ID, LC.AD_ORG_ID, LC.ISACTIVE, LC.CREATED, LC.CREATEDBY, LC.UPDATED, LC.UPDATEDBY, LC.REFERENCEDATE AS DATETRX, LC.PROCESSING, - LC.PROCESSED, LC.POSTED, LC.REFERENCEDATE AS DATEACCT, LC.REFERENCEDATE AS DATEDOC, LC.C_CURRENCY_ID + LC.PROCESSED, LC.POSTED, LC.REFERENCEDATE AS DATEACCT, LC.REFERENCEDATE AS DATEDOC FROM M_LANDEDCOST LC WHERE LC.AD_Client_ID=? AND LC.M_LANDEDCOST_ID=? ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits