From b5196b71641699b8e83ba6166a74a52081c0405e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Nov 2017 14:02:17 +0100 Subject: [PATCH] FIX A lot of several fix on local taxes and NPR tax --- htdocs/cashdesk/facturation_verif.php | 11 ++- htdocs/comm/propal/card.php | 3 + htdocs/commande/card.php | 11 ++- htdocs/compta/facture/card.php | 3 + htdocs/compta/facture/fiche-rec.php | 3 + htdocs/contrat/card.php | 3 + htdocs/core/class/commonobject.class.php | 1 + htdocs/expedition/class/expedition.class.php | 3 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 + htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/stocks.lang | 2 +- htdocs/product/price.php | 73 ++++++++++++++----- 12 files changed, 88 insertions(+), 28 deletions(-) diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 24876a0a8fb..25ddfd8c1f8 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -114,10 +114,13 @@ switch($action) { if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines [0]->price); - $pu_ttc = price($prodcustprice->lines [0]->price_ttc); - $price_base_type = $prodcustprice->lines [0]->price_base_type; - $tva_tx = $prodcustprice->lines [0]->tva_tx; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } else diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 839538f777e..c3be71c35a1 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -805,6 +805,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx . ' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 374ec0477fe..33048f8d470 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -766,10 +766,13 @@ if (empty($reshook)) { if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines [0]->price); - $pu_ttc = price($prodcustprice->lines [0]->price_ttc); - $price_base_type = $prodcustprice->lines [0]->price_base_type; - $tva_tx = $prodcustprice->lines [0]->tva_tx; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } else diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f438a5ab6b9..3bc4759e589 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1589,6 +1589,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 0bfdc134258..c748cb0a0e3 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -530,6 +530,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 39a708bcdad..43f086fbab4 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -509,6 +509,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines [0]->price_ttc); $price_base_type = $prodcustprice->lines [0]->price_base_type; $tva_tx = $prodcustprice->lines [0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a97b553aed4..83c38477f28 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3748,6 +3748,7 @@ abstract class CommonObject // VAT Rate $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); + $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')'; $this->tpl['price'] = price($line->subprice); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 879b5745db4..bccfba4446d 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1321,7 +1321,7 @@ class Expedition extends CommonObject $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type"; $sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; - $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; + $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; $sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc"; $sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; @@ -1418,6 +1418,7 @@ class Expedition extends CommonObject $line->tva_tx = $obj->tva_tx; $line->localtax1_tx = $obj->localtax1_tx; $line->localtax2_tx = $obj->localtax2_tx; + $line->info_bits = $obj->info_bits; $line->price = $obj->price; $line->subprice = $obj->subprice; $line->remise_percent = $obj->remise_percent; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 5da8799d7b3..8b68929864f 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -382,6 +382,8 @@ ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx d ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price double(24,8) DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL; +ALTER TABLE llx_product_customer_price_log ADD COLUMN default_vat_code varchar(10); + UPDATE llx_contrat SET ref = rowid WHERE ref IS NULL OR ref = ''; ALTER TABLE llx_contratdet ADD COLUMN vat_src_code varchar(10) DEFAULT ''; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 02f3f80982e..9c53b726544 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -366,6 +366,7 @@ TotalLT1IN=Total CGST TotalLT2IN=Total SGST HT=Net of tax TTC=Inc. tax +INCVATONLY=Inc. VAT INCT=Inc. all taxes VAT=Sales tax VATIN=IGST diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index f2115666a36..a4fb098f5ac 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -133,7 +133,7 @@ MovementLabel=Label of movement InventoryCode=Movement or inventory code IsInPackage=Contained into package WarehouseAllowNegativeTransfer=Stock can be negative -qtyToTranferIsNotEnough=You don't have enough stock from your source warehouse +qtyToTranferIsNotEnough=You don't have enough stock from your source warehouse and your setup does not allow negative stocks. ShowWarehouse=Show warehouse MovementCorrectStock=Stock correction for product %s MovementTransferStock=Stock transfer of product %s into another warehouse diff --git a/htdocs/product/price.php b/htdocs/product/price.php index f16b716c9cc..b38aa15a694 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1800,8 +1800,15 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '' . $langs->trans("PriceBase") . ''; 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") . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . $langs->trans("INCVATONLY") . ''; + print '' . $langs->trans("INCT") . ''; + } + else + { + print '' . $langs->trans("TTC") . ''; + } print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . ''; print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . ''; print '' . $langs->trans("ChangedBy") . ''; @@ -1843,20 +1850,28 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print "" . dol_print_date($line->datec, "dayhour") . ""; print '' . $langs->trans($line->price_base_type) . ""; print ''; -var_dump($prodcustprice);exit; + $positiverates=''; - if (price2num($objp->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($objp->tva_tx); - if (price2num($objp->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax1_tx); - if (price2num($objp->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax2_tx); + if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); + if (price2num($line->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); + if (price2num($line->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($objp->default_vat_code?' ('.$objp->default_vat_code.')':''), '%', $objp->tva_npr); + + echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', ($line->tva_npr?$line->tva_npr:$line->recuperableonly)); //. vatrate($tva_tx, true, $line->recuperableonly) . print ""; print '' . price($line->price) . ""; - print '' . price($line->price_ttc) . ""; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . price($resultarray[2]) . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . price($line->price_ttc) . ""; + print '' . price($resultarray[2]) . ''; + } + else + { + print '' . price($line->price_ttc) . ""; + } print '' . price($line->price_min) . ''; print '' . price($line->price_min_ttc) . ''; @@ -1902,7 +1917,7 @@ var_dump($prodcustprice);exit; if (count($prodcustprice->lines) > 0 || $search_soc) { $colspan=8; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; + //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; print ''; print ''; @@ -1921,8 +1936,16 @@ var_dump($prodcustprice);exit; print '' . $langs->trans("PriceBase") . ''; 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") . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . $langs->trans("INCVATONLY") . ''; + print '' . $langs->trans("INCT") . ''; + } + else + { + print '' . $langs->trans("TTC") . ''; + } + print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . ''; print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . ''; print '' . $langs->trans("ChangedBy") . ''; @@ -1969,9 +1992,17 @@ var_dump($prodcustprice);exit; print ""; print '' . price($object->price) . ""; - print '' . price($object->price_ttc) . ""; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . price($resultarray[2]) . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . price($object->price_ttc) . ""; + print '' . price($resultarray[2]) . ''; + } + else + { + print '' . price($object->price_ttc) . ""; + } + print '' . price($object->price_min) . ''; print '' . price($object->price_min_ttc) . ''; @@ -1992,7 +2023,6 @@ var_dump($prodcustprice);exit; } print "\n"; - if (count($prodcustprice->lines) > 0) { foreach ($prodcustprice->lines as $line) @@ -2037,13 +2067,20 @@ var_dump($prodcustprice);exit; if (price2num($line->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); if (price2num($line->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', $line->tva_npr); + echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', ($line->tva_npr?$line->tva_npr:$line->recuperableonly)); print ""; print '' . price($line->price) . ""; - print '' . price($line->price_ttc) . ""; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . price($resultarray[2]) . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . price($line->price_ttc) . ""; + print '' . price($resultarray[2]) . ''; + } + else + { + print '' . price($line->price_ttc) . ""; + } print '' . price($line->price_min) . ''; print '' . price($line->price_min_ttc) . '';