From 6959ccf627c9a5a949cb3a0dd1488cbb519111b0 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Sun, 15 Sep 2013 11:41:41 +0200 Subject: [PATCH] Fix: Supplier price displayed on document lines didnt take discount --- ChangeLog | 1 + htdocs/fourn/ajax/getSupplierPrices.php | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index a36fbe60139..3ab27db8be6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,7 @@ Fix: Edit propal line was losing product supplier price id Fix: Delete linked element to supplier invoice when deleted Fix: [ bug #1061 ] Bad info shipped products Fix: [ bug #1062 ] Documents lost in propals and contracts validating +Fix: Supplier price displayed on document lines didnt take discount Qual: Add travis-ci integration diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 3953bce6caf..65f3eb9ee79 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -48,7 +48,7 @@ if (! empty($idprod)) { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,"; $sql.= " pfp.ref_fourn,"; - $sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice, pfp.charges, pfp.unitcharges,"; + $sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice, pfp.charges, pfp.unitcharges,"; $sql.= " s.nom"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product"; @@ -72,14 +72,15 @@ if (! empty($idprod)) { $objp = $db->fetch_object($result); + $price = $objp->fprice * (1 - $objp->remise_percent / 100); + $unitprice = $objp->unitprice * (1 - $objp->remise_percent / 100); + $title = $objp->nom.' - '.$objp->ref_fourn.' - '; if ($objp->quantity == 1) { - $title.= price($objp->fprice); + $title.= price($price); $title.= $langs->getCurrencySymbol($conf->currency)."/"; - - $price = $objp->fprice; } $title.= $objp->quantity.' '; @@ -95,9 +96,9 @@ if (! empty($idprod)) if ($objp->quantity > 1) { $title.=" - "; - $title.= price($objp->unitprice).$langs->getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit")); + $title.= price($unitprice).$langs->getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit")); - $price = $objp->unitprice; + $price = $unitprice; } if ($objp->unitcharges > 0 && ($conf->global->MARGIN_TYPE == "2")) { $title.=" + ";