details: https://code.openbravo.com/erp/devel/pi/rev/bce3ce144ae4 changeset: 32584:bce3ce144ae4 user: Mark <markmm82 <at> gmail.com> date: Mon Aug 21 19:09:24 2017 -0400 summary: Fixes issue 35427: Conversion of Valuation not correct in Pareto Product Report
The conversion of the currencies in Pareto Product Report is not the same as in the Valued Stock Report. The problem is that the total valuation is converted to the currency for today, instead of converting each Transaction in the day it happened. This fix uses the transaction's date instead of the current date to convert the valuation. Also is grouped by transaction's accounting date to have an homegeneous behaviour like in CostingUtils.getCurrentValuedStock() and CostAdjustmentUtils. getValuedStockOnTransactionDate() methods. details: https://code.openbravo.com/erp/devel/pi/rev/3e0bc2ad77c6 changeset: 32585:3e0bc2ad77c6 user: Mark <markmm82 <at> gmail.com> date: Tue Aug 15 15:00:49 2017 -0400 summary: Fixes issue 33397: Reactivate a reservation doesn't work in Oracle When you try to reactivate a reservation that is not linked to an order, the process fails with the error message. Problem is that procedure is always expecting an order linked to the reservation, and this doesn't happen always. diffstat: src-db/database/model/functions/M_RESERVATION_POST.xml | 41 +++++---- src/org/openbravo/erpCommon/ad_reports/ReportParetoProduct_data.xsql | 6 +- 2 files changed, 26 insertions(+), 21 deletions(-) diffs (95 lines): diff -r 120b7e711081 -r 3e0bc2ad77c6 src-db/database/model/functions/M_RESERVATION_POST.xml --- a/src-db/database/model/functions/M_RESERVATION_POST.xml Thu Aug 24 13:55:10 2017 +0200 +++ b/src-db/database/model/functions/M_RESERVATION_POST.xml Tue Aug 15 15:00:49 2017 -0400 @@ -25,7 +25,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU -* All portions are Copyright (C) 2012-2016 Openbravo SLU +* All portions are Copyright (C) 2012-2017 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************/ @@ -311,18 +311,6 @@ RAISE_APPLICATION_ERROR(-20000, '@ActionNotSupported@'); END IF; - UPDATE c_orderline - SET so_res_status = 'NR' - WHERE c_orderline_id = v_orderline_id; - - SELECT c_order_id INTO v_sales_order_id - FROM c_orderline - WHERE c_orderline_id = v_orderline_id; - SELECT COUNT(*) INTO v_reservedcount - FROM c_orderline - WHERE c_order_id = v_sales_order_id - AND so_res_status <> 'NR'; - -- Convert to pre-reserve reservations related to purchase orders that are not released. FOR cur_prereserve IN ( SELECT m_reservation_stock_id, quantity - COALESCE(releasedqty, 0) AS reservedqty, c_orderline_id @@ -366,11 +354,28 @@ AND quantity = 0 AND COALESCE(releasedqty, 0) = 0; - UPDATE c_order - SET so_res_status = CASE WHEN v_reservedcount > 0 THEN 'PR' - ELSE 'NR' - END - WHERE c_order_id = v_sales_order_id; + IF (v_orderline_id IS NOT NULL) THEN + + UPDATE c_orderline + SET so_res_status = 'NR' + WHERE c_orderline_id = v_orderline_id; + + SELECT c_order_id + INTO v_sales_order_id + FROM c_orderline + WHERE c_orderline_id = v_orderline_id; + + SELECT count(1) + INTO v_reservedcount + FROM c_orderline + WHERE c_order_id = v_sales_order_id + AND so_res_status <> 'NR'; + + UPDATE c_order + SET so_res_status = CASE WHEN v_reservedcount > 0 THEN 'PR' ELSE 'NR' END + WHERE c_order_id = v_sales_order_id; + + END IF; v_newstatus := 'DR'; v_newaction := 'PR'; diff -r 120b7e711081 -r 3e0bc2ad77c6 src/org/openbravo/erpCommon/ad_reports/ReportParetoProduct_data.xsql --- a/src/org/openbravo/erpCommon/ad_reports/ReportParetoProduct_data.xsql Thu Aug 24 13:55:10 2017 +0200 +++ b/src/org/openbravo/erpCommon/ad_reports/ReportParetoProduct_data.xsql Tue Aug 15 15:00:49 2017 -0400 @@ -46,7 +46,7 @@ sum(t.movementqty) as movementqty, case when tc.c_currency_id = ? then sum(case when t.movementqty>=0 then tc.cost else -tc.cost end) - else c_currency_convert_precision(sum(case when t.movementqty>=0 then tc.cost else -tc.cost end), tc.c_currency_id, ?, to_date(now()), null, ?, ?) + else c_currency_convert_precision(sum(case when t.movementqty>=0 then tc.cost else -tc.cost end), tc.c_currency_id, ?, tc.dateacct, null, ?, ?) end as value_per_orgwarehouseproduct from m_transaction_cost tc join m_transaction t on (tc.m_transaction_id = t.m_transaction_id) @@ -62,7 +62,7 @@ and t.ad_client_id = ? and 1=1 and ad_isorgincluded(w.AD_ORG_ID, ?, w.ad_client_id) <> -1 - group by w.ad_org_id, t.m_product_id, tc.c_currency_id ), + group by w.ad_org_id, t.m_product_id, tc.c_currency_id, tc.dateacct), org_prod_agg (ad_org_id, m_product_id, movementqty, value_per_orgwarehouseproduct) as (select wh.ad_org_id, @@ -70,7 +70,7 @@ agg.stock as movementqty, case when agg.c_currency_id = ? then agg.valuation - else c_currency_convert_precision(agg.valuation, agg.c_currency_id, ?, to_date(now()), null, agg.ad_client_id, agg.ad_org_id) + else c_currency_convert_precision(agg.valuation, agg.c_currency_id, ?, agg.dateto, null, agg.ad_client_id, agg.ad_org_id) end as value_per_orgwarehouseproduct from m_valued_stock_agg agg join m_locator l on (agg.m_locator_id = l.m_locator_id) ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits