From 5ec52548ab49b2db00cb14819b95dab173345914 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Mar 2023 20:25:27 +0100 Subject: [PATCH] For countries using the 2nd or 3rd tax, we force MAIN_NO_INPUT_PRICE_WITH_TAX to disable input/edit of lines using the price including tax (because 2nb and 3rd tax not yet taken into account). Work In Progress to support all taxes into unit price entry when MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES is set. --- htdocs/comm/propal/card.php | 2 ++ htdocs/comm/propal/class/propal.class.php | 2 ++ htdocs/core/tpl/objectline_edit.tpl.php | 6 +++++- htdocs/core/tpl/objectline_view.tpl.php | 8 +++++++- htdocs/master.inc.php | 6 ++++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index e14a2c05246..6589587a8f6 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -923,6 +923,8 @@ if (empty($reshook)) { $price_ttc = ''; $price_ttc_devise = ''; + // TODO Implement if (getDolGlobalInt('MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES')) + if (GETPOST('price_ht') !== '') { $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8606b9df87d..4bfe37810ed 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -865,6 +865,8 @@ class Propal extends CommonObject $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } + // TODO Implement if (getDolGlobalInt('MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES')) ? + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index b2914c455a0..605634dab67 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -225,7 +225,11 @@ $coldisplay++; if (!empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) { $coldisplay++; - print 'pu_ttc) ? $line->pu_ttc : null; + if (getDolGlobalInt('MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES')) { + $upinctax = price2num($line->total_ttc / $line->qty, 'MU'); + } + print 'fk_prev_id != null) { print ' readonly'; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index b2213862d62..153773a6519 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -326,7 +326,13 @@ print $tooltiponpriceend; - pu_ttc) ? price($sign * $line->pu_ttc) : price($sign * $line->subprice)); ?> + pu_ttc) ? $line->pu_ttc : null; + if (getDolGlobalInt('MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES')) { + $upinctax = price2num($line->total_ttc / $line->qty, 'MU'); + } + print (isset($upinctax) ? price($sign * $upinctax) : price($sign * $line->subprice)); + ?> diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 03515c9a2e2..69ce82e5657 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -218,6 +218,12 @@ if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC')) { // For FR, default value of option to show profid SIRET is on by default $conf->global->MAIN_PROFID1_IN_ADDRESS = 1; } + + if ($mysoc->localtax1_assuj || $mysoc->localtax2_assuj) { + // For countries using the 2nd or 3rd tax, we disable input/edit of lines using the price including tax (because 2nb and 3rd tax not yet taken into account). + // Work In Progress to support all taxes into unit price entry when MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES is set. + $conf->global->MAIN_NO_INPUT_PRICE_WITH_TAX = 1; + } }