From 4c0fcb2b9a45dbd39fc0cc6b7215649cb1816739 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jul 2017 14:58:57 +0200 Subject: [PATCH] Fix total with tax does not include local taxes. To solve, i show both totals. --- htdocs/product/price.php | 73 ++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index a701a637aa8..e296d44bd33 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1606,9 +1606,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print ''; print ''; + + dol_fiche_head(); + print ''; print ''; - print ''; + print ''; $staticsoc = new Societe($db); $staticsoc->fetch($prodcustprice->fk_soc); print ""; @@ -1620,7 +1623,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; // Price base - print ''; print ''; // Price - print ''; // Update all child soc - print ''; print '
' . $langs->trans('ThirdParty') . '' . $langs->trans('ThirdParty') . '" . $staticsoc->getNomUrl(1) . "
'; + print '
'; print $langs->trans('PriceBase'); print ''; @@ -1629,7 +1632,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '
'; + print '
'; $text = $langs->trans('SellingPrice'); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; @@ -1658,7 +1661,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '
'; + print '
'; print $langs->trans('ForceUpdateChildPriceSoc'); print ''; @@ -1668,7 +1671,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '
'; - print '
'; + dol_fiche_end(); + + print '
'; print ''; print '     '; print ''; @@ -1678,7 +1683,10 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) } elseif ($action == 'showlog_customer_price') { - $filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int')); + // List of all log of prices by customers + print ''."\n"; + + $filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int')); // Count total nb of records $nbtotalofrecords = ''; @@ -1705,7 +1713,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) if (count($prodcustprice->lines) > 0) { - print '
'; print ''; @@ -1718,6 +1725,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '' . $langs->trans("VATRate") . ''; print '' . $langs->trans("HT") . ''; print '' . $langs->trans("TTC") . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . $langs->trans("INCT") . ''; print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . ''; print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . ''; print '' . $langs->trans("ChangedBy") . ''; @@ -1726,21 +1734,44 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) foreach ($prodcustprice->lines as $line) { - print ''; - // Date - $staticsoc = new Societe($db); - $staticsoc->fetch($line->fk_soc); - - print "" . $staticsoc->getNomUrl(1) . ""; - print "" . dol_print_date($line->datec, "dayhour") . ""; + // Date + $staticsoc = new Societe($db); + $staticsoc->fetch($line->fk_soc); $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; - print '' . $langs->trans($line->price_base_type) . ""; + // Line for default price + if ($line->price_base_type=='HT') + { + $pu=$line->price; + } + else + { + $pu=$line->price_ttc; + } + + // Local tax is not saved into table of product. We use value linked to VAT code. + $localtaxarray=getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), 0, $staticsoc, $mysoc); + // Define part of HT, VAT, TTC + $resultarray=calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); + // Calcul du total ht sans remise + $total_ht = $resultarray[0]; + $total_vat = $resultarray[1]; + $total_localtax1 = $resultarray[9]; + $total_localtax2 = $resultarray[10]; + $total_ttc = $resultarray[2]; + + print ''; + + print "" . $staticsoc->getNomUrl(1) . ""; + print "" . dol_print_date($line->datec, "dayhour") . ""; + print '' . $langs->trans($line->price_base_type) . ""; print '' . vatrate($tva_tx, true, $line->recuperableonly) . ""; print '' . price($line->price) . ""; print '' . price($line->price_ttc) . ""; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . price($resultarray[2]) . ''; + print '' . price($line->price_min) . ''; print '' . price($line->price_min_ttc) . ''; @@ -1760,7 +1791,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) else if ($action != 'showlog_default_price' && $action != 'edit_price') { // List of all prices by customers - print ''."\n"; + print ''."\n"; // Count total nb of records $nbtotalofrecords = ''; @@ -1872,8 +1903,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { foreach ($prodcustprice->lines as $line) { - print ''; - // Date $staticsoc = new Societe($db); $staticsoc->fetch($line->fk_soc); @@ -1881,7 +1910,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; // Line for default price - if ($object->price_base_type=='HT') + if ($line->price_base_type=='HT') { $pu=$line->price; } @@ -1891,9 +1920,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) } // Local tax is not saved into table of product. We use value linked to VAT code. - $localtaxarray=getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code?' ('.$object->default_vat_code.')':''), 0, $mysoc, $mysoc); + $localtaxarray=getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), 0, $staticsoc, $mysoc); // Define part of HT, VAT, TTC - $resultarray=calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray); + $resultarray=calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; @@ -1901,6 +1930,8 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $total_localtax2 = $resultarray[10]; $total_ttc = $resultarray[2]; + print ''; + print "" . $staticsoc->getNomUrl(1) . ""; print "" . dol_print_date($line->datec, "dayhour") . "";