From 29d329a1d2bcbe8f8ad5e8545a7c18b3f45cad9e Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 12 Aug 2013 15:34:09 +0200 Subject: [PATCH] ability to define margin rate on quotes, orders, invoices more to come : same on edit, user permissions --- htdocs/comm/propal.php | 13 +- htdocs/commande/fiche.php | 13 +- htdocs/compta/facture.php | 13 +- .../core/tpl/freeproductline_create.tpl.php | 118 ++++++++++++++++-- .../tpl/predefinedproductline_create.tpl.php | 113 +++++++++++++++-- 5 files changed, 246 insertions(+), 24 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 235e6e7ef9baf..e2504eca6aff9 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -7,7 +7,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2010-2011 Philippe Grand - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -724,9 +724,16 @@ $price_base_type = $prod->price_base_type; } + // if price ht is forced (ie: calculated by margin rate and cost price) + if (!empty($price_ht)) + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + } + // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) + elseif ($tva_tx != $prod->tva_tx) { if ($price_base_type != 'HT') { @@ -861,6 +868,8 @@ unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); // old method unset($_POST['np_desc']); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 8f710dadca490..05f60f9d8ebc9 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -6,7 +6,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2011 Philippe Grand -* Copyright (C) 2012 Christophe Battarel +* Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2012 Marcos GarcĂ­a * Copyright (C) 2013 Florian Henry * @@ -666,9 +666,16 @@ $price_base_type = $prod->price_base_type; } + // if price ht is forced (ie: calculated by margin rate and cost price) + if (!empty($price_ht)) + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + } + // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) + elseif ($tva_tx != $prod->tva_tx) { if ($price_base_type != 'HT') { @@ -806,6 +813,8 @@ unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); // old method unset($_POST['np_desc']); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 2cca7fa9a3ea2..b61d22a948a18 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2013 Jean-Francois FERRY * Copyright (C) 2013 Florian Henry * @@ -1227,9 +1227,16 @@ $price_base_type = $prod->price_base_type; } + // if price ht is forced (ie: calculated by margin rate and cost price) + if (!empty($price_ht)) + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + } + // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) + elseif ($tva_tx != $prod->tva_tx) { if ($price_base_type != 'HT') { @@ -1367,6 +1374,8 @@ unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); // old method unset($_POST['np_desc']); diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php index 2c5a90f6d4e59..85d310c39c7f0 100644 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2010-2013 Laurent Destailleur - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -61,8 +61,14 @@ ?> global->DISPLAY_MARGIN_RATES)) $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; + if(! empty($conf->global->DISPLAY_MARGIN_RATES)) + { + echo ''.$langs->trans('MarginRate').''; + } + if(! empty($conf->global->DISPLAY_MARK_RATES)) + { + echo ''.$langs->trans('MarkRate').''; + } } ?>   @@ -109,7 +115,7 @@ "> "> - % + remise_client); ?>" name="remise_percent">% global->DISPLAY_MARGIN_RATES)) { - $colspan++; - $coldisplay++; + echo '%'; } - if (! empty($conf->global->DISPLAY_MARK_RATES)) { - $colspan++; - $coldisplay++; + elseif (! empty($conf->global->DISPLAY_MARK_RATES)) { + echo '%'; } } ?> @@ -185,4 +189,100 @@ ?> + +margin->enabled) { ?> + + diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php index 214a03fd6e7e3..a3fd98b6322ac 100644 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2010-2012 Laurent Destailleur - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -63,8 +63,14 @@ $colspan = 4; if (! empty($usemargins)) { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; + if(! empty($conf->global->DISPLAY_MARGIN_RATES)) + { + echo ''.$langs->trans('MarginRate').''; + } + if(! empty($conf->global->DISPLAY_MARK_RATES)) + { + echo ''.$langs->trans('MarkRate').''; + } ?> Create(); ?> - + % global->DISPLAY_MARGIN_RATES)) { - $colspan++; - $coldisplay++; + echo '%'; } - if (! empty($conf->global->DISPLAY_MARK_RATES)) { - $colspan++; - $coldisplay++; + elseif (! empty($conf->global->DISPLAY_MARK_RATES)) { + echo '%'; } ?> @@ -200,6 +204,97 @@ { ?>