diff --git a/htdocs/product/class/priceexpression.class.php b/htdocs/product/class/priceexpression.class.php index 45fd9f9fa301167cd67f46d40d2ee7c902cf2461..c5e24d3a2288e8e528b9ecdd75ee37f42ba1392f 100755 --- a/htdocs/product/class/priceexpression.class.php +++ b/htdocs/product/class/priceexpression.class.php @@ -20,7 +20,7 @@ /** * \file htdocs/product/class/priceexpression.class.php * \ingroup product - * \brief Class for accesing price expression table + * \brief Class for accessing price expression table */ diff --git a/htdocs/product/class/priceparser.class.php b/htdocs/product/class/priceparser.class.php index f7d0bea2217fdb28a3efe2b034fc469b1a48db41..c2b047a7ae136595d9297fd88cb308012e71e5c2 100755 --- a/htdocs/product/class/priceparser.class.php +++ b/htdocs/product/class/priceparser.class.php @@ -21,7 +21,6 @@ * \brief File of class to calculate prices using expression */ require_once DOL_DOCUMENT_ROOT.'/includes/evalmath/evalmath.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/priceexpression.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -267,7 +266,7 @@ class PriceParser public function parseProductSupplierExpression($product_id, $expression, $quantity = null, $tva_tx = null, $extra_values = array()) { //Get the product data - $product = new Product($this->db); + $product = new ProductFournisseur($this->db); $product->fetch($product_id, '', '', 1); //Accessible values by expressions diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a25f10b37c1539843c7221bf18efc327accad772..bbdb9fa426da820508912235af81923461da6dc3 100755 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2014 Henry Florian <florian.henry@open-concept.pro> * Copyright (C) 2014 Philippe Grand <philippe.grand@atoo-net.com> - * Copyright (C) 2014 Ion agorria <ion@agorria.com> + * Copyright (C) 2014 Ion agorria <ion@agorria.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,7 +33,6 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/priceparser.class.php'; /** @@ -167,7 +166,7 @@ class Product extends CommonObject //note not visible on orders and invoices var $note; - + var $fk_price_expression; /** @@ -1175,7 +1174,6 @@ class Product extends CommonObject */ function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0) { - require_once DOL_DOCUMENT_ROOT.'/product/class/priceparser.class.php'; $result = 0; // We do select by searching with qty and prodfournprice @@ -1192,8 +1190,10 @@ class Product extends CommonObject $obj = $this->db->fetch_object($resql); if ($obj && $obj->quantity > 0) // If found { - if (!empty($obj->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); + if (!empty($obj->fk_supplier_price_expression)) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/priceparser.class.php'; + $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProductSupplier($obj->fk_product, $obj->fk_supplier_price_expression, $obj->quantity, $obj->tva_tx); if ($price_result >= 0) { $obj->price = $price_result; @@ -1225,8 +1225,10 @@ class Product extends CommonObject $obj = $this->db->fetch_object($resql); if ($obj && $obj->quantity > 0) // If found { - if (!empty($obj->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); + if (!empty($obj->fk_supplier_price_expression)) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/priceparser.class.php'; + $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProductSupplier($obj->fk_product, $obj->fk_supplier_price_expression, $obj->quantity, $obj->tva_tx); if ($result >= 0) { $obj->price = $price_result; @@ -1285,7 +1287,7 @@ class Product extends CommonObject // Clean parameters if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($newnpr)) $newnpr=0; - + // Check parameters if ($newvat == '') $newvat=$this->tva_tx; if (! empty($newminprice) && ($newminprice > $newprice)) @@ -1679,11 +1681,12 @@ class Product extends CommonObject } } - if (!empty($this->fk_price_expression) && empty($ignore_expression)) + if (!empty($this->fk_price_expression) && empty($ignore_expression)) { - $priceparser = new PriceParser($this->db); + require_once DOL_DOCUMENT_ROOT.'/product/class/priceparser.class.php'; + $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProduct($this); - if ($price_result >= 0) + if ($price_result >= 0) { $this->price = $price_result; //Calculate the VAT