Merge pull request #5928 from bomuux/patch-1
Fix: price not properly rounded, VAT inconsistencies
This commit is contained in:
commit
ff3a14319a
@ -980,10 +980,8 @@ if (empty($reshook))
|
|||||||
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors');
|
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='')
|
else if ($price_ht !== '' || GETPOST('price_ttc') !== '') // $price_ht is already set
|
||||||
{
|
{
|
||||||
$pu_ht = price2num($price_ht, 'MU');
|
|
||||||
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
|
|
||||||
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
|
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
|
||||||
$tva_tx = str_replace('*', '', $tva_tx);
|
$tva_tx = str_replace('*', '', $tva_tx);
|
||||||
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
|
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
|
||||||
@ -998,19 +996,18 @@ if (empty($reshook))
|
|||||||
$localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty);
|
$localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty);
|
||||||
$localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty);
|
$localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty);
|
||||||
|
|
||||||
if (!empty($_POST['price_ht']))
|
if ($price_ht !== '')
|
||||||
{
|
|
||||||
$ht = price2num($_POST['price_ht']);
|
|
||||||
$price_base_type = 'HT';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
$ttc = price2num($_POST['price_ttc']);
|
$pu_ht = price2num($price_ht, 'MU'); // $pu_ht must be rounded according to settings
|
||||||
$ht = $ttc / (1 + ($tva_tx / 100));
|
}
|
||||||
$price_base_type = 'HT';
|
else
|
||||||
}
|
{
|
||||||
|
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
|
||||||
|
$pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings
|
||||||
|
}
|
||||||
|
$price_base_type = 'HT';
|
||||||
|
|
||||||
$result=$object->addline($product_desc, $ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit);
|
$result=$object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
//print "xx".$tva_tx; exit;
|
//print "xx".$tva_tx; exit;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user