FIX Bad cleaning of VAT rate when numbers are into code

This commit is contained in:
Laurent Destailleur 2021-01-02 16:51:34 +01:00
parent d46eb08083
commit fd4dab495f
8 changed files with 32 additions and 12 deletions

View File

@ -602,6 +602,7 @@ class Propal extends CommonObject
// Clean vat code
$vat_src_code = '';
$reg = array();
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
@ -779,7 +780,9 @@ class Propal extends CommonObject
$qty = price2num($qty);
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);

View File

@ -3120,7 +3120,9 @@ class Commande extends CommonOrder
$pu = price2num($pu);
$pa_ht = price2num($pa_ht);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -849,7 +849,9 @@ class FactureRec extends CommonInvoice
$qty = price2num($qty);
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
if (empty($txtva)) $txtva = 0;
@ -1031,8 +1033,10 @@ class FactureRec extends CommonInvoice
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txlocaltax1);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
if (empty($txlocaltax1)) $txlocaltax1 = 0;
if (empty($txlocaltax2)) $txlocaltax2 = 0;
@ -1059,6 +1063,7 @@ class FactureRec extends CommonInvoice
// Clean vat code
$vat_src_code = '';
$reg = array();
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];

View File

@ -3311,7 +3311,9 @@ class Facture extends CommonInvoice
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
$pa_ht = price2num($pa_ht);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -1502,7 +1502,6 @@ class Contrat extends CommonObject
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -473,7 +473,9 @@ class FichinterRec extends Fichinter
if (!$info_bits) $info_bits = 0;
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
if ($price_base_type == 'HT') {
$pu = $pu_ht;

View File

@ -2633,7 +2633,9 @@ class CommandeFournisseur extends CommonOrder
if (!$qty) $qty = 1;
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -423,10 +423,13 @@ class SupplierProposal extends CommonObject
$qty = price2num($qty);
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);
$pa_ht = price2num($pa_ht);
if ($price_base_type == 'HT')
{
$pu = $pu_ht;
@ -682,7 +685,9 @@ class SupplierProposal extends CommonObject
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
$pu = price2num($pu);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);