details: https://code.openbravo.com/erp/devel/pi/rev/5d6156c121d6 changeset: 17398:5d6156c121d6 user: Gorka Ion Damián <gorkaion.damian <at> openbravo.com> date: Mon Jul 02 15:27:54 2012 +0200 summary: [Costing]fix issue in valuation stock rpt.Do not group by org.
details: https://code.openbravo.com/erp/devel/pi/rev/f313b3335867 changeset: 17399:f313b3335867 user: Gorka Ion Damián <gorkaion.damian <at> openbravo.com> date: Mon Jul 02 16:27:37 2012 +0200 summary: [Costing]Fix issue in migration process.setMaxResult to 1. diffstat: src/org/openbravo/costing/CostingMigrationProcess.java | 2 +- src/org/openbravo/erpCommon/ad_reports/ReportValuationStock.java | 15 ++++++--- src/org/openbravo/erpCommon/ad_reports/ReportValuationStock_data.xsql | 9 +++-- 3 files changed, 16 insertions(+), 10 deletions(-) diffs (90 lines): diff -r 0f7d2b1391ac -r f313b3335867 src/org/openbravo/costing/CostingMigrationProcess.java --- a/src/org/openbravo/costing/CostingMigrationProcess.java Mon Jul 02 12:18:03 2012 +0200 +++ b/src/org/openbravo/costing/CostingMigrationProcess.java Mon Jul 02 16:27:37 2012 +0200 @@ -460,7 +460,7 @@ whereQry.setNamedParameter("minDate", minDate); whereQry.setNamedParameter("maxDate", maxDate); - whereQry.setMaxResult(0); + whereQry.setMaxResult(1); return whereQry.uniqueResult() != null; } diff -r 0f7d2b1391ac -r f313b3335867 src/org/openbravo/erpCommon/ad_reports/ReportValuationStock.java --- a/src/org/openbravo/erpCommon/ad_reports/ReportValuationStock.java Mon Jul 02 12:18:03 2012 +0200 +++ b/src/org/openbravo/erpCommon/ad_reports/ReportValuationStock.java Mon Jul 02 16:27:37 2012 +0200 @@ -29,6 +29,7 @@ import org.openbravo.base.secureApp.VariablesSecureApp; import org.openbravo.costing.CostingStatus; import org.openbravo.dal.core.DalUtil; +import org.openbravo.dal.core.OBContext; import org.openbravo.dal.service.OBDal; import org.openbravo.erpCommon.businessUtility.WindowTabs; import org.openbravo.erpCommon.utility.ComboTableData; @@ -39,6 +40,7 @@ import org.openbravo.erpCommon.utility.ToolBar; import org.openbravo.erpCommon.utility.Utility; import org.openbravo.financial.FinancialUtils; +import org.openbravo.model.common.enterprise.Organization; import org.openbravo.model.common.enterprise.Warehouse; import org.openbravo.xmlEngine.XmlDocument; @@ -90,9 +92,6 @@ // Checks if there is a conversion rate for each of the transactions of // the report ReportValuationStockData[] data = null; - Warehouse wh = OBDal.getInstance().get(Warehouse.class, strWarehouse); - String strBaseCurrencyId = (String) DalUtil.getId(FinancialUtils.getLegalEntityCurrency(wh - .getOrganization())); OBError myMessage = null; myMessage = new OBError(); String strConvRateErrorMsg = ""; @@ -103,9 +102,15 @@ } if (vars.commandIn("FIND")) { try { + Warehouse wh = OBDal.getInstance().get(Warehouse.class, strWarehouse); + Organization legalEntity = OBContext.getOBContext() + .getOrganizationStructureProvider(wh.getClient().getId()) + .getLegalEntity(wh.getOrganization()); + String strBaseCurrencyId = (String) DalUtil.getId(FinancialUtils.getLegalEntityCurrency(wh + .getOrganization())); data = ReportValuationStockData.select(this, vars.getLanguage(), strBaseCurrencyId, - strCurrencyId, strDate, DateTimeData.nDaysAfter(this, strDate, "1"), strWarehouse, - strCategoryProduct); + strCurrencyId, strDate, legalEntity.getId(), + DateTimeData.nDaysAfter(this, strDate, "1"), strWarehouse, strCategoryProduct); } catch (ServletException ex) { myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); } diff -r 0f7d2b1391ac -r f313b3335867 src/org/openbravo/erpCommon/ad_reports/ReportValuationStock_data.xsql --- a/src/org/openbravo/erpCommon/ad_reports/ReportValuationStock_data.xsql Mon Jul 02 12:18:03 2012 +0200 +++ b/src/org/openbravo/erpCommon/ad_reports/ReportValuationStock_data.xsql Mon Jul 02 16:27:37 2012 +0200 @@ -31,15 +31,15 @@ SELECT CATEGORY_NAME, M_PRODUCT_ID, PRODUCT_NAME, QTY, UOM_NAME, AVERAGE_COST, TOTAL_COST FROM ( SELECT M_PRODUCT_CATEGORY.NAME AS CATEGORY_NAME, A.M_PRODUCT_ID, AD_COLUMN_IDENTIFIER(TO_CHAR('M_Product'), TO_CHAR(M_PRODUCT.M_PRODUCT_ID), TO_CHAR(?)) AS PRODUCT_NAME, A.QTY, C_UOM.NAME AS UOM_NAME, - C_CURRENCY_ROUND(C_CURRENCY_CONVERT(Suma, ?, ?, TO_DATE(?), NULL, A.AD_CLIENT_ID, A.AD_ORG_ID)/A.QTY, ?, NULL) AS AVERAGE_COST, - C_CURRENCY_CONVERT(Suma, ?, ?, TO_DATE(?), NULL, A.AD_CLIENT_ID, A.AD_ORG_ID) AS TOTAL_COST + C_CURRENCY_ROUND(C_CURRENCY_CONVERT(Suma, ?, ?, TO_DATE(?), NULL, A.AD_CLIENT_ID, ?)/A.QTY, ?, NULL) AS AVERAGE_COST, + C_CURRENCY_CONVERT(Suma, ?, ?, TO_DATE(?), NULL, A.AD_CLIENT_ID) AS TOTAL_COST FROM M_PRODUCT_CATEGORY, - (SELECT M_PRODUCT_ID, SUM(MOVEMENTQTY) AS QTY, SUM(CASE WHEN MOVEMENTQTY<0 THEN transactioncost *-1 ELSE transactioncost END) as Suma, C_UOM_ID, m_transaction.AD_CLIENT_ID, m_transaction.AD_ORG_ID + (SELECT M_PRODUCT_ID, SUM(MOVEMENTQTY) AS QTY, SUM(CASE WHEN MOVEMENTQTY<0 THEN transactioncost *-1 ELSE transactioncost END) as Suma, C_UOM_ID, m_transaction.AD_CLIENT_ID FROM M_TRANSACTION, M_LOCATOR WHERE M_TRANSACTION.M_LOCATOR_ID = M_LOCATOR.M_LOCATOR_ID AND MOVEMENTDATE < to_date(?) AND M_LOCATOR.M_WAREHOUSE_ID = ? - GROUP BY M_PRODUCT_ID, C_UOM_ID, m_transaction.AD_CLIENT_ID, m_transaction.AD_ORG_ID) A, C_UOM, + GROUP BY M_PRODUCT_ID, C_UOM_ID, m_transaction.AD_CLIENT_ID) A, C_UOM, M_PRODUCT WHERE A.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID AND A.C_UOM_ID = C_UOM.C_UOM_ID @@ -54,6 +54,7 @@ <Parameter name="cCurrencyBase"/> <Parameter name="cCurrencyConv"/> <Parameter name="date"/> + <Parameter name="legalEntity"/> <Parameter name="cCurrencyConv"/> <Parameter name="cCurrencyBase"/> <Parameter name="cCurrencyConv"/> ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
