details: https://code.openbravo.com/erp/devel/main/rev/923eda3047ad changeset: 25047:923eda3047ad user: Unai Martirena <unai.martirena <at> openbravo.com> date: Thu Oct 23 12:49:47 2014 +0200 summary: Fixes issue 27929: Landed Cost correctly manages multicurrency
Landed Cost adjustment was being created with currency of transaction instead of Landed Cost Cost currency. The transaction cost currency was being created on Landed Cost adjustment currency instead of transaction currency. details: https://code.openbravo.com/erp/devel/main/rev/dc303243e68f changeset: 25048:dc303243e68f user: Unai Martirena <unai.martirena <at> openbravo.com> date: Wed Oct 22 10:57:55 2014 +0200 summary: Fixes Bug 27926: Fixed process a Landed Cost with amt different than Matched amt A condition has been removed from m_lc_cost_chk_trg that was preventing to update m_lc_cost table. details: https://code.openbravo.com/erp/devel/main/rev/b3f260eaae0b changeset: 25049:b3f260eaae0b user: Unai Martirena <unai.martirena <at> openbravo.com> date: Tue Oct 21 18:58:30 2014 +0200 summary: Fixes Issue 27925: Match LC Cost Process P&E now processes correctly Matchings The problem was due to a missing OBDal.getInstance().flush(). Also LCCostMatchFromInvoiceHandler.java action handler has been improved to return correctly error messages. details: https://code.openbravo.com/erp/devel/main/rev/80785b0c736e changeset: 25050:80785b0c736e user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Wed Oct 22 09:04:25 2014 +0200 summary: Fixed bug 27924 be able to enter backdatedfrom while creating a costing rule details: https://code.openbravo.com/erp/devel/main/rev/aea6ec46de6a changeset: 25051:aea6ec46de6a user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Thu Oct 23 10:49:56 2014 +0200 summary: Related to issue 27924 Filter by organization in query should be by FinancialMgmtPeriodControl details: https://code.openbravo.com/erp/devel/main/rev/aca4de5656dc changeset: 25052:aca4de5656dc user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Mon Oct 27 13:24:18 2014 +0100 summary: Related to issue 27924 details: https://code.openbravo.com/erp/devel/main/rev/71aa38f9e8e3 changeset: 25053:71aa38f9e8e3 user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Mon Oct 27 17:01:34 2014 +0100 summary: Related to issue 27924 details: https://code.openbravo.com/erp/devel/main/rev/b4bce4c0c780 changeset: 25054:b4bce4c0c780 user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Fri Oct 24 09:57:22 2014 +0200 summary: Fixed bug 27950 Unit Cost of the Inventory Amount Update window is not calculated Currency is not mandatory in organization, if currency in organization is null the reference currency should be client currency. details: https://code.openbravo.com/erp/devel/main/rev/7e1b31c7b48d changeset: 25055:7e1b31c7b48d user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Fri Oct 24 09:39:25 2014 +0200 summary: Fixed bug 27971 Process matching should not be shown in Goods Receipt window details: https://code.openbravo.com/erp/devel/main/rev/8501ce6fff89 changeset: 25056:8501ce6fff89 user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Fri Oct 24 09:07:03 2014 +0200 summary: Fixed bug 27972 Landed cost field should be readonly in landed cost tab details: https://code.openbravo.com/erp/devel/main/rev/77c85316ca31 changeset: 25057:77c85316ca31 user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Fri Oct 24 11:34:12 2014 +0200 summary: Fixed bug 27968 set properly the organization when process a landed cost from receipt Costing background fails when a landed cost from receipt is pending to be calculated and the consting background process is sheduled in Organization "*" details: https://code.openbravo.com/erp/devel/main/rev/833c2d6183f2 changeset: 25058:833c2d6183f2 user: Gorka Ion Damián <gorkaion.damian <at> openbravo.com> date: Thu Oct 23 18:36:05 2014 +0200 summary: Fixed issue 27946.Add negative correction for basetrx when needed. In some cases like Price Difference Correction it is possible to have a base trx that also requires a negative stock correction adjustment. A check is added to insert an aditional negative correction line for the base transaction when needed. details: https://code.openbravo.com/erp/devel/main/rev/6b473d983be3 changeset: 25059:6b473d983be3 user: Gorka Ion Damián <gorkaion.damian <at> openbravo.com> date: Thu Oct 23 17:04:33 2014 +0200 summary: Fixed issue 27947.Use org id instead of object in OBQuery When filtering a OBCriteria or OBQuery by a BaseOBObject after a clear session can fail if the object is not correctly reattached to the session. Filtering by its id avoid this issue. details: https://code.openbravo.com/erp/devel/main/rev/0f865f3ef1da changeset: 25060:0f865f3ef1da user: Gorka Ion Damián <gorkaion.damian <at> openbravo.com> date: Fri Oct 24 14:05:00 2014 +0200 summary: Fixed 27879.Properly calculate adj amount on backdated inventory amt update. 3 changes have been applied to fix the issue: - Consider the possibility of having average costing not related to transactions. - Properly calculate the adjustment amount of closing inventories. The transaction that is being adjusted is already calculated and included in the currentBalanceAmount so no need to compare against it. - It was checking the fix backdated transactions flag using the fix backdated transactions process button property instead of the flag's property. details: https://code.openbravo.com/erp/devel/main/rev/6685962210b8 changeset: 25061:6685962210b8 user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Tue Oct 28 09:09:03 2014 +0100 summary: Fixed bug 27966 LandedCostCost should be re-initialized details: https://code.openbravo.com/erp/devel/main/rev/918a300ee3ae changeset: 25062:918a300ee3ae user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Mon Oct 27 11:34:20 2014 +0100 summary: Fixed bug 27969 landed cost from receipt should be created in status complete diffstat: src-db/database/model/triggers/M_LC_COST_CHK_TRG.xml | 1 - src-db/database/sourcedata/AD_COLUMN.xml | 1 + src-db/database/sourcedata/AD_FIELD.xml | 6 +- src-db/database/sourcedata/AD_MESSAGE.xml | 12 + src/org/openbravo/costing/AverageCostAdjustment.java | 25 ++- src/org/openbravo/costing/CostAdjustmentProcess.java | 2 +- src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java | 13 +- src/org/openbravo/costing/CostingRuleProcess.java | 4 +- src/org/openbravo/costing/CostingServer.java | 3 + src/org/openbravo/costing/CostingUtils.java | 4 +- src/org/openbravo/costing/FixBackdatedTransactionsProcess.java | 3 +- src/org/openbravo/costing/InventoryAmountUpdateProcess.java | 2 +- src/org/openbravo/costing/LCCostMatchFromInvoiceHandler.java | 18 +- src/org/openbravo/costing/LandedCostDistributionByAmount.java | 2 + src/org/openbravo/costing/LandedCostProcess.java | 1 + src/org/openbravo/erpCommon/ad_callouts/SL_InvAmtUpd_AmtUnitCost.java | 7 +- src/org/openbravo/event/CostingRuleEventHandler.java | 119 ++++++++++ 17 files changed, 199 insertions(+), 24 deletions(-) diffs (truncated from 465 to 300 lines): diff -r 11b2a675415d -r 918a300ee3ae src-db/database/model/triggers/M_LC_COST_CHK_TRG.xml --- a/src-db/database/model/triggers/M_LC_COST_CHK_TRG.xml Fri Oct 24 09:56:21 2014 +0200 +++ b/src-db/database/model/triggers/M_LC_COST_CHK_TRG.xml Mon Oct 27 11:34:20 2014 +0100 @@ -63,7 +63,6 @@ OR(COALESCE(:old.m_lc_distribution_alg_id, '0') <> COALESCE(:new.m_lc_distribution_alg_id, '0')) OR(COALESCE(:old.m_lc_type_id, '0') <> COALESCE(:new.m_lc_type_id, '0')) OR(COALESCE(:old.matching_amt, 0) <> COALESCE(:new.matching_amt, 0)) - OR(COALESCE(:old.matching_costadjustment_id, '0') <> COALESCE(:new.matching_costadjustment_id, '0')) OR(COALESCE(:old.AD_ORG_ID, '0') <> COALESCE(:new.AD_ORG_ID, '0')) OR(COALESCE(:old.AD_CLIENT_ID, '0') <> COALESCE(:new.AD_CLIENT_ID, '0')))) THEN RAISE_APPLICATION_ERROR(-20000, '@20501@') ; diff -r 11b2a675415d -r 918a300ee3ae src-db/database/sourcedata/AD_COLUMN.xml --- a/src-db/database/sourcedata/AD_COLUMN.xml Fri Oct 24 09:56:21 2014 +0200 +++ b/src-db/database/sourcedata/AD_COLUMN.xml Mon Oct 27 11:34:20 2014 +0100 @@ -287056,6 +287056,7 @@ <!--842AB447B9D1488EA42F3DACA71934F3--> <ISPARENT><![CDATA[N]]></ISPARENT> <!--842AB447B9D1488EA42F3DACA71934F3--> <ISMANDATORY><![CDATA[N]]></ISMANDATORY> <!--842AB447B9D1488EA42F3DACA71934F3--> <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE> +<!--842AB447B9D1488EA42F3DACA71934F3--> <READONLYLOGIC><![CDATA[@isvalidated@='Y']]></READONLYLOGIC> <!--842AB447B9D1488EA42F3DACA71934F3--> <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER> <!--842AB447B9D1488EA42F3DACA71934F3--> <SEQNO><![CDATA[200]]></SEQNO> <!--842AB447B9D1488EA42F3DACA71934F3--> <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED> diff -r 11b2a675415d -r 918a300ee3ae src-db/database/sourcedata/AD_FIELD.xml --- a/src-db/database/sourcedata/AD_FIELD.xml Fri Oct 24 09:56:21 2014 +0200 +++ b/src-db/database/sourcedata/AD_FIELD.xml Mon Oct 27 11:34:20 2014 +0100 @@ -176305,7 +176305,7 @@ <!--00568254CC048733E050007F01000513--> <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD> <!--00568254CC048733E050007F01000513--> <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED> <!--00568254CC048733E050007F01000513--> <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH> -<!--00568254CC048733E050007F01000513--> <ISREADONLY><![CDATA[N]]></ISREADONLY> +<!--00568254CC048733E050007F01000513--> <ISREADONLY><![CDATA[Y]]></ISREADONLY> <!--00568254CC048733E050007F01000513--> <SEQNO><![CDATA[80]]></SEQNO> <!--00568254CC048733E050007F01000513--> <ISSAMELINE><![CDATA[N]]></ISSAMELINE> <!--00568254CC048733E050007F01000513--> <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY> @@ -178524,7 +178524,7 @@ <!--023AA8E75FDB4274E050007F01005DB0--> <AD_TAB_ID><![CDATA[0F76B56EB2874C729ABE1665D5853E9D]]></AD_TAB_ID> <!--023AA8E75FDB4274E050007F01005DB0--> <AD_COLUMN_ID><![CDATA[022DB885E9665700E050007F01000846]]></AD_COLUMN_ID> <!--023AA8E75FDB4274E050007F01005DB0--> <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD> -<!--023AA8E75FDB4274E050007F01005DB0--> <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED> +<!--023AA8E75FDB4274E050007F01005DB0--> <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED> <!--023AA8E75FDB4274E050007F01005DB0--> <DISPLAYLOGIC><![CDATA[@IsMatched@='N']]></DISPLAYLOGIC> <!--023AA8E75FDB4274E050007F01005DB0--> <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH> <!--023AA8E75FDB4274E050007F01005DB0--> <ISREADONLY><![CDATA[N]]></ISREADONLY> @@ -197333,7 +197333,7 @@ <!--39932E6D9F234DE7BE28C602E43BD91D--> <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD> <!--39932E6D9F234DE7BE28C602E43BD91D--> <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED> <!--39932E6D9F234DE7BE28C602E43BD91D--> <DISPLAYLENGTH><![CDATA[19]]></DISPLAYLENGTH> -<!--39932E6D9F234DE7BE28C602E43BD91D--> <ISREADONLY><![CDATA[Y]]></ISREADONLY> +<!--39932E6D9F234DE7BE28C602E43BD91D--> <ISREADONLY><![CDATA[N]]></ISREADONLY> <!--39932E6D9F234DE7BE28C602E43BD91D--> <SEQNO><![CDATA[70]]></SEQNO> <!--39932E6D9F234DE7BE28C602E43BD91D--> <ISSAMELINE><![CDATA[N]]></ISSAMELINE> <!--39932E6D9F234DE7BE28C602E43BD91D--> <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY> diff -r 11b2a675415d -r 918a300ee3ae src-db/database/sourcedata/AD_MESSAGE.xml --- a/src-db/database/sourcedata/AD_MESSAGE.xml Fri Oct 24 09:56:21 2014 +0200 +++ b/src-db/database/sourcedata/AD_MESSAGE.xml Mon Oct 27 11:34:20 2014 +0100 @@ -18660,6 +18660,18 @@ <!--452669FBC6B44F90BD0FC29AFF79084B--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--452669FBC6B44F90BD0FC29AFF79084B--></AD_MESSAGE> +<!--45395544AF19476D82D2F38FF529F2BD--><AD_MESSAGE> +<!--45395544AF19476D82D2F38FF529F2BD--> <AD_MESSAGE_ID><![CDATA[45395544AF19476D82D2F38FF529F2BD]]></AD_MESSAGE_ID> +<!--45395544AF19476D82D2F38FF529F2BD--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--45395544AF19476D82D2F38FF529F2BD--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--45395544AF19476D82D2F38FF529F2BD--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--45395544AF19476D82D2F38FF529F2BD--> <VALUE><![CDATA[WrongFixBackdatedFrom]]></VALUE> +<!--45395544AF19476D82D2F38FF529F2BD--> <MSGTEXT><![CDATA[Fix backdated from date you have entered is invalid because it is part of a period closed, please ensure that date entered is not part of a period closed. ]]></MSGTEXT> +<!--45395544AF19476D82D2F38FF529F2BD--> <MSGTYPE><![CDATA[W]]></MSGTYPE> +<!--45395544AF19476D82D2F38FF529F2BD--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID> +<!--45395544AF19476D82D2F38FF529F2BD--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--45395544AF19476D82D2F38FF529F2BD--></AD_MESSAGE> + <!--4572743978F94C65969984E770B89172--><AD_MESSAGE> <!--4572743978F94C65969984E770B89172--> <AD_MESSAGE_ID><![CDATA[4572743978F94C65969984E770B89172]]></AD_MESSAGE_ID> <!--4572743978F94C65969984E770B89172--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/AverageCostAdjustment.java --- a/src/org/openbravo/costing/AverageCostAdjustment.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/AverageCostAdjustment.java Mon Oct 27 11:34:20 2014 +0100 @@ -129,6 +129,29 @@ } log.debug("Starting average cost {}", cost == null ? "not cost" : cost.toPlainString()); if (AverageAlgorithm.modifiesAverage(trxType) && cost != null) { + BigDecimal trxCost = CostAdjustmentUtils.getTrxCost(basetrx, false, getCostCurrency()); + BigDecimal trxPrice = trxCost.add(adjustmentBalance).divide( + basetrx.getMovementQuantity().abs(), costCurPrecission, RoundingMode.HALF_UP); + if (checkNegativeStockCorrection && currentStock.compareTo(basetrx.getMovementQuantity()) < 0 + && cost.compareTo(trxPrice) != 0) { + // stock was negative and cost different than trx price then Negative Stock Correction + // is added + BigDecimal trxSignMultiplier = new BigDecimal(basetrx.getMovementQuantity().signum()); + BigDecimal negCorrAmt = trxPrice.multiply(currentStock) + .setScale(stdCurPrecission, RoundingMode.HALF_UP).subtract(currentValueAmt) + .subtract(adjustmentBalance); + adjustmentBalance = adjustmentBalance.add(negCorrAmt.multiply(trxSignMultiplier)); + // If there is a difference insert a cost adjustment line. + CostAdjustmentLine newCAL = insertCostAdjustmentLine(basetrx, negCorrAmt, null); + newCAL.setNegativeStockCorrection(true); + newCAL.setRelatedTransactionAdjusted(true); + newCAL.setUnitCost(Boolean.FALSE); + OBDal.getInstance().save(newCAL); + cost = trxPrice; + log.debug("Negative stock correction. Amount: {}, new cost {}", negCorrAmt.toPlainString(), + cost.toPlainString()); + } + Costing curCosting = basetrx.getMaterialMgmtCostingList().get(0); if (curCosting.getCost().compareTo(cost) != 0) { // Update existing costing @@ -615,7 +638,7 @@ private void extendPreviousCosting(Costing bdCosting) { StringBuffer where = new StringBuffer(); where.append(" as c"); - where.append(" join c." + Costing.PROPERTY_INVENTORYTRANSACTION + " as trx"); + where.append(" left join c." + Costing.PROPERTY_INVENTORYTRANSACTION + " as trx"); where.append(" where c." + Costing.PROPERTY_PRODUCT + " = :product"); where.append(" and c." + Costing.PROPERTY_ORGANIZATION + " = :org"); where.append(" and c." + Costing.PROPERTY_COSTTYPE + " = 'AVA'"); diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/CostAdjustmentProcess.java --- a/src/org/openbravo/costing/CostAdjustmentProcess.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/CostAdjustmentProcess.java Mon Oct 27 11:34:20 2014 +0100 @@ -292,7 +292,7 @@ trx.getCurrency(), accountingDate, trx.getOrganization(), "C"); } trxCost.setCost(convertedAmt); - trxCost.setCurrency(line.getCurrency()); + trxCost.setCurrency(trx.getCurrency()); OBDal.getInstance().save(trxCost); OBDal.getInstance().flush(); diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java --- a/src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java Mon Oct 27 11:34:20 2014 +0100 @@ -531,12 +531,15 @@ private BigDecimal getInventoryClosingAmt(CostAdjustmentLine costAdjLine) { MaterialTransaction trx = costAdjLine.getInventoryTransaction(); - BigDecimal trxCalculatedCost = CostAdjustmentUtils.getTrxCost(trx, true, getCostCurrency()); - BigDecimal trxExpectedCost = CostAdjustmentUtils.getValuedStockOnMovementDateByAttrAndLocator( - trx.getProduct(), getCostOrg(), trx.getMovementDate(), getCostDimensions(), - trx.getStorageBin(), trx.getAttributeSetValue(), getCostCurrency(), true); + // currentBalanceOnDate already includes the cost of the inventory closing. The balance after an + // inventory closing should be zero, so the adjustment amount should be de current balance + // negated. + BigDecimal currentBalanceOnDate = CostAdjustmentUtils + .getValuedStockOnMovementDateByAttrAndLocator(trx.getProduct(), getCostOrg(), + trx.getMovementDate(), getCostDimensions(), trx.getStorageBin(), + trx.getAttributeSetValue(), getCostCurrency(), true); - return trxExpectedCost.subtract(trxCalculatedCost); + return currentBalanceOnDate.negate(); } /** diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/CostingRuleProcess.java --- a/src/org/openbravo/costing/CostingRuleProcess.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/CostingRuleProcess.java Mon Oct 27 11:34:20 2014 +0100 @@ -118,7 +118,9 @@ OBDal.getInstance().flush(); } createCostingRuleInits(ruleId, childOrgs, startingDate); - rule.setFixbackdatedfrom(startingDate); + if (rule.getFixbackdatedfrom() == null && rule.isBackdatedTransactionsFixed()) { + rule.setFixbackdatedfrom(startingDate); + } // Update cost of inventories and process starting physical inventories. updateInventoriesCostAndProcessInitInventories(ruleId, startingDate, existsPreviousRule); diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/CostingServer.java --- a/src/org/openbravo/costing/CostingServer.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/CostingServer.java Mon Oct 27 11:34:20 2014 +0100 @@ -194,12 +194,15 @@ LCReceipt lcReceipt = OBProvider.getInstance().get(LCReceipt.class); lcReceipt.setLandedCost(landedCost); + lcReceipt.setOrganization(organization); lcReceipt.setGoodsShipment(transaction.getGoodsShipmentLine().getShipmentReceipt()); OBDal.getInstance().save(lcReceipt); } final LandedCostCost landedCostCost = (LandedCostCost) lcLines.get()[0]; landedCostCost.setLandedCost(landedCost); + landedCost.getLandedCostCostList().add(landedCostCost); + OBDal.getInstance().save(landedCost); OBDal.getInstance().save(landedCostCost); } diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/CostingUtils.java --- a/src/org/openbravo/costing/CostingUtils.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/CostingUtils.java Mon Oct 27 11:34:20 2014 +0100 @@ -484,7 +484,7 @@ public static CostingRule getCostDimensionRule(Organization org, Date date) { StringBuffer where = new StringBuffer(); - where.append(CostingRule.PROPERTY_ORGANIZATION + " = :organization"); + where.append(CostingRule.PROPERTY_ORGANIZATION + ".id = :organization"); where.append(" and (" + CostingRule.PROPERTY_STARTINGDATE + " is null "); where.append(" or " + CostingRule.PROPERTY_STARTINGDATE + " <= :startdate)"); where.append(" and (" + CostingRule.PROPERTY_ENDINGDATE + " is null"); @@ -495,7 +495,7 @@ OBQuery<CostingRule> crQry = OBDal.getInstance().createQuery(CostingRule.class, where.toString()); crQry.setFilterOnReadableOrganization(false); - crQry.setNamedParameter("organization", org); + crQry.setNamedParameter("organization", org.getId()); crQry.setNamedParameter("startdate", date); crQry.setNamedParameter("enddate", date); crQry.setMaxResult(1); diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/FixBackdatedTransactionsProcess.java --- a/src/org/openbravo/costing/FixBackdatedTransactionsProcess.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/FixBackdatedTransactionsProcess.java Mon Oct 27 11:34:20 2014 +0100 @@ -68,7 +68,8 @@ rule.setBackdatedTransactionsFixed(Boolean.TRUE); OBDal.getInstance().save(rule); - if (jsonparams.has("fixbackdatedfrom")) { + if (jsonparams.has("fixbackdatedfrom") + && !jsonparams.getString("fixbackdatedfrom").equals("null")) { try { fixbackdatedfrom = JsonUtils.createDateFormat().parse( jsonparams.getString("fixbackdatedfrom")); diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/InventoryAmountUpdateProcess.java --- a/src/org/openbravo/costing/InventoryAmountUpdateProcess.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/InventoryAmountUpdateProcess.java Mon Oct 27 11:34:20 2014 +0100 @@ -173,7 +173,7 @@ InventoryAmountUpdateLine line = OBDal.getInstance().get(InventoryAmountUpdateLine.class, lineId); ScrollableResults stockLines = getStockLines(childOrgs, date, line.getProduct(), warehouse, - costRule.isFixBackdatedTransactions()); + costRule.isBackdatedTransactionsFixed()); // The key of the Map is the concatenation of orgId and warehouseId Map<String, String> inventories = new HashMap<String, String>(); Map<String, Long> maxLineNumbers = new HashMap<String, Long>(); diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/LCCostMatchFromInvoiceHandler.java --- a/src/org/openbravo/costing/LCCostMatchFromInvoiceHandler.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/LCCostMatchFromInvoiceHandler.java Mon Oct 27 11:34:20 2014 +0100 @@ -45,6 +45,7 @@ @Override protected JSONObject doExecute(Map<String, Object> parameters, String content) { JSONObject jsonResponse = new JSONObject(); + JSONObject jsonMessage = null; OBContext.setAdminMode(true); try { JSONObject jsonRequest = new JSONObject(content); @@ -58,11 +59,13 @@ } JSONArray selectedLines = jsonparams.getJSONObject("LCCosts").getJSONArray("_selection"); - processSelectedLines(il, selectedLines, existingMatchings); + jsonMessage = processSelectedLines(il, selectedLines, existingMatchings); - JSONObject jsonMessage = new JSONObject(); - jsonMessage.put("severity", "success"); - jsonMessage.put("text", OBMessageUtils.messageBD("Success")); + if (jsonMessage == null) { + jsonMessage = new JSONObject(); + jsonMessage.put("severity", "success"); + jsonMessage.put("text", OBMessageUtils.messageBD("Success")); + } jsonResponse.put("message", jsonMessage); } catch (JSONException e) { @@ -88,8 +91,9 @@ return jsonResponse; } - private void processSelectedLines(InvoiceLine il, JSONArray selectedLines, + private JSONObject processSelectedLines(InvoiceLine il, JSONArray selectedLines, List<String> existingMatchings) throws JSONException { + JSONObject message = null; for (int i = 0; i < selectedLines.length(); i++) { JSONObject line = selectedLines.getJSONObject(i); final String strLCMatchedId = line.getString("matchedLandedCost"); @@ -134,8 +138,9 @@ lcCost.setMatchingAdjusted(isMatchingAdjusted); OBDal.getInstance().save(lcCost); } + OBDal.getInstance().flush(); if (processMatching) { - LCMatchingProcess.doProcessLCMatching(lcCost); + message = LCMatchingProcess.doProcessLCMatching(lcCost); } } // Delete unselected matches @@ -157,5 +162,6 @@ } OBDal.getInstance().save(il); } + return message; } } diff -r 11b2a675415d -r 918a300ee3ae src/org/openbravo/costing/LandedCostDistributionByAmount.java --- a/src/org/openbravo/costing/LandedCostDistributionByAmount.java Fri Oct 24 09:56:21 2014 +0200 +++ b/src/org/openbravo/costing/LandedCostDistributionByAmount.java Mon Oct 27 11:34:20 2014 +0100 @@ -111,6 +111,8 @@ LCReceiptLineAmt lcrla = OBProvider.getInstance().get(LCReceiptLineAmt.class); lcrla.setLandedCostCost((LandedCostCost) OBDal.getInstance().getProxy( LandedCostCost.ENTITY_NAME, lcCost.getId())); + lcCost = (LandedCostCost) OBDal.getInstance().getProxy(LandedCostCost.ENTITY_NAME, + lcCost.getId()); lcrla.setLandedCostReceipt(lcrl); lcrla.setGoodsShipmentLine(receiptline); ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
