details: https://code.openbravo.com/erp/devel/pi/rev/a6bc45531368 changeset: 29670:a6bc45531368 user: Sanjota <sanjota.nelagi <at> promantia.com> date: Tue Jun 21 02:37:36 2016 +0530 summary: Fixes issue 33302: Related to costing of purchase price lists including taxes
Fix to the issue Costing engine is not taken into account that purchase price list can be setup to include taxes, while cost should not include taxes. details: https://code.openbravo.com/erp/devel/pi/rev/49000d1b6292 changeset: 29671:49000d1b6292 user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Tue Jun 21 11:48:41 2016 +0200 summary: Related to issue 33302: Code review improvements - Add new usePriceIncludeTax parameter to getProductPrice method documentation. - Check usePriceIncludeTax flag only once in getProductPrice query. - Send usePriceIncludeTax parameter correctly in CostingAlgorithm.getPriceListCost method. - Send usePriceIncludeTax parameter in CostingAlgorithm.getReceiptDefaultCost method. diffstat: src/org/openbravo/costing/CostingAlgorithm.java | 6 +++--- src/org/openbravo/costing/CostingUtils.java | 4 ++-- src/org/openbravo/financial/FinancialUtils.java | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diffs (97 lines): diff -r a745d6a99abb -r 49000d1b6292 src/org/openbravo/costing/CostingAlgorithm.java --- a/src/org/openbravo/costing/CostingAlgorithm.java Mon Jun 20 11:25:12 2016 -0400 +++ b/src/org/openbravo/costing/CostingAlgorithm.java Tue Jun 21 11:48:41 2016 +0200 @@ -11,7 +11,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-2015 Openbravo SLU + * All portions are Copyright (C) 2012-2016 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************* @@ -274,7 +274,7 @@ PriceList pricelist = bp.getPurchasePricelist(); ProductPrice pp = FinancialUtils.getProductPrice(transaction.getProduct(), - transaction.getTransactionProcessDate(), false, pricelist, false); + transaction.getTransactionProcessDate(), false, pricelist, false, false); OrderLine orderLine = CostingUtils.getOrderLine(transaction.getProduct(), bp, costOrg); if (stdCost == null && pp == null && orderLine == null) { @@ -592,7 +592,7 @@ pricelist = bp.getPurchasePricelist(); } ProductPrice pp = FinancialUtils.getProductPrice(transaction.getProduct(), - transaction.getMovementDate(), false, pricelist); + transaction.getMovementDate(), false, pricelist, true, false); BigDecimal cost = pp.getStandardPrice().multiply(transaction.getMovementQuantity().abs()); if (DalUtil.getId(pp.getPriceListVersion().getPriceList().getCurrency()).equals( costCurrency.getId())) { diff -r a745d6a99abb -r 49000d1b6292 src/org/openbravo/costing/CostingUtils.java --- a/src/org/openbravo/costing/CostingUtils.java Mon Jun 20 11:25:12 2016 -0400 +++ b/src/org/openbravo/costing/CostingUtils.java Tue Jun 21 11:48:41 2016 +0200 @@ -148,8 +148,8 @@ if (bp != null) { pricelist = bp.getPurchasePricelist(); } - ProductPrice pp = FinancialUtils - .getProductPrice(product, movementDate, false, pricelist, false); + ProductPrice pp = FinancialUtils.getProductPrice(product, movementDate, false, pricelist, + false, false); if (stdCost == null && pp == null) { throw new OBException("@NoPriceListOrStandardCostForProduct@ @Organization@: " + org.getName() + ", @Product@: " + product.getName() + ", @Date@: " diff -r a745d6a99abb -r 49000d1b6292 src/org/openbravo/financial/FinancialUtils.java --- a/src/org/openbravo/financial/FinancialUtils.java Mon Jun 20 11:25:12 2016 -0400 +++ b/src/org/openbravo/financial/FinancialUtils.java Tue Jun 21 11:48:41 2016 +0200 @@ -11,7 +11,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-2015 Openbravo SLU + * All portions are Copyright (C) 2012-2016 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************* @@ -122,6 +122,14 @@ } /** + * @see #getProductPrice(Product, Date, boolean, PriceList, boolean, boolean) + */ + public static ProductPrice getProductPrice(Product product, Date date, boolean useSalesPriceList, + PriceList priceList, boolean throwException) throws OBException { + return getProductPrice(product, date, useSalesPriceList, priceList, throwException, true); + } + + /** * Method to get a valid ProductPrice for the given Product. It only considers PriceList versions * valid on the given date. If a PriceList is given it searches on that one. If PriceList null is * passed it search on any Sales or Purchase PriceList based on the useSalesPriceList. @@ -136,12 +144,14 @@ * PriceList to get its ProductPrice * @param throwException * boolean to determine if an exception has to be thrown when no pricelist is found. + * @param usePriceIncludeTax + * boolean to set if price lists including taxes should be considered or not. * @return a valid ProductPrice for the given parameters. Null is no exception is to be thrown. * @throws OBException * when no valid ProductPrice is found and throwException is true. */ public static ProductPrice getProductPrice(Product product, Date date, boolean useSalesPriceList, - PriceList priceList, boolean throwException) throws OBException { + PriceList priceList, boolean throwException, boolean usePriceIncludeTax) throws OBException { StringBuffer where = new StringBuffer(); where.append(" as pp"); where.append(" join pp." + ProductPrice.PROPERTY_PRICELISTVERSION + " as plv"); @@ -153,6 +163,9 @@ } else { where.append(" and pl." + PriceList.PROPERTY_SALESPRICELIST + " = :salespricelist"); } + if (!usePriceIncludeTax) { + where.append(" and pl." + PriceList.PROPERTY_PRICEINCLUDESTAX + " = false"); + } where.append(" order by pl." + PriceList.PROPERTY_DEFAULT + " desc, plv." + PriceListVersion.PROPERTY_VALIDFROMDATE + " desc"); ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits