diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8c1c579b0c24b399c315c98814e979c62bb3fafb..150abdf5f46c45ba0cea9400a9c85bdc935a6dfb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -492,7 +492,10 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); if ($result > 0) { $lineid = $result; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b63c59ecad4c2a124929dc43a5fa9d2b048e58e2..4587e960c4ced0c86918e59434b3d5b2b7bb3f3c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -253,6 +253,8 @@ class Propal extends CommonObject $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; + $vat_src_code = ''; // May be defined into tva_tx + $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->thirdparty,$tva_npr); $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->thirdparty,$tva_npr); @@ -273,6 +275,7 @@ class Propal extends CommonObject $line->qty=$qty; $line->subprice=$price; $line->remise_percent=$remise_percent; + $line->vat_src_code=$vat_src_code; $line->tva_tx=$tva_tx; $line->fk_unit=$prod->fk_unit; if ($tva_npr) $line->info_bits = 1; @@ -315,6 +318,7 @@ class Propal extends CommonObject $line->fk_propal=$this->id; $line->fk_remise_except=$remise->id; $line->desc=$remise->description; // Description ligne + $line->vat_src_code=$remise->vat_src_code; $line->tva_tx=$remise->tva_tx; $line->subprice=-$remise->amount_ht; $line->fk_product=0; // Id produit predefined @@ -698,7 +702,8 @@ class Propal extends CommonObject $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; - $this->line->product_type = $type; + $this->line->product_type = $type; + $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; @@ -708,7 +713,6 @@ class Propal extends CommonObject $this->line->subprice = $pu_ht; $this->line->info_bits = $info_bits; - $this->line->vat_src_code = $vat_src_code; $this->line->total_ht = $total_ht; $this->line->total_tva = $total_tva; $this->line->total_localtax1 = $total_localtax1; @@ -1368,7 +1372,7 @@ class Propal extends CommonObject /* * Lignes propales liees a un produit ou non */ - $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= " d.fk_unit,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; @@ -1404,6 +1408,7 @@ class Propal extends CommonObject $line->label = $objp->custom_label; $line->desc = $objp->description; // Description ligne $line->qty = $objp->qty; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -3591,7 +3596,7 @@ class PropaleLigne extends CommonObjectLine */ function fetch($rowid) { - $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.fk_unit,'; @@ -3617,6 +3622,7 @@ class PropaleLigne extends CommonObjectLine $this->qty = $objp->qty; $this->price = $objp->price; // deprecated $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->remise = $objp->remise; // deprecated $this->remise_percent = $objp->remise_percent; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 749f40fef4e3a407d26d61c0c3cb6a1a0010dd8f..d99aa6a4f46baf543c93b706998ce7873afc6ba7 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -373,7 +373,10 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); if ($result < 0) { $error++; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 462ba4756c529ad41d5783be8ff7852a6c4c093d..c89fc8d11da73b5e3c1a974db5bbaef851b56919 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1103,6 +1103,7 @@ class Commande extends CommonOrder $line->desc = $object->lines[$i]->desc; $line->price = $object->lines[$i]->price; $line->subprice = $object->lines[$i]->subprice; + $line->vat_src_code = $object->lines[$i]->vat_src_code; $line->tva_tx = $object->lines[$i]->tva_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx; @@ -1466,7 +1467,8 @@ class Commande extends CommonOrder $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - + $vat_src_code = ''; // May be defined into tva_tx + $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr); $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr); @@ -1485,6 +1487,7 @@ class Commande extends CommonOrder $line->qty=$qty; $line->subprice=$price; $line->remise_percent=$remise_percent; + $line->vat_src_code=$vat_src_code; $line->tva_tx=$tva_tx; $line->localtax1_tx=$localtax1_tx; $line->localtax2_tx=$localtax2_tx; @@ -1703,6 +1706,7 @@ class Commande extends CommonOrder $line->fk_commande=$this->id; $line->fk_remise_except=$remise->id; $line->desc=$remise->description; // Description ligne + $line->vat_src_code=$remise->vat_src_code; $line->tva_tx=$remise->tva_tx; $line->subprice=-$remise->amount_ht; $line->price=-$remise->amount_ht; @@ -3809,6 +3813,7 @@ class OrderLine extends CommonOrderLine $this->qty = $objp->qty; $this->price = $objp->price; $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; $this->localtax2_tx = $objp->localtax2_tx; @@ -4120,6 +4125,7 @@ class OrderLine extends CommonOrderLine $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; $sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); + $sql.= " , vat_src_code=".(! empty($this->vat_src_code)?"'".$this->db->escape($this->vat_src_code)."'":"''"); $sql.= " , tva_tx=".price2num($this->tva_tx); $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b71dbe0cc708b60229eee1c007a5df426e99ac7a..05174fd940b15b93d3c16b618646eb5747e6c32d 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1050,11 +1050,14 @@ if (empty($reshook)) } } + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + $result = $object->addline( $langs->trans('Deposit'), $amountdeposit, // subprice 1, // quantity - $lines[$i]->tva_tx, // vat rate + $tva_tx, // vat rate 0, // localtax1_tx 0, // localtax2_tx (empty($conf->global->INVOICE_PRODUCTID_DEPOSIT)?0:$conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product @@ -1150,11 +1153,15 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - // View third's localtaxes for now - $localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $object->thirdparty); - $localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $object->thirdparty); + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + // View third's localtaxes for NOW and do not use value from origin. + // TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? + $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit); if ($result > 0) { $lineid = $result; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b80919c48b4abc24d9d817d8f78c0459f63e975e..bc4cf3626a4f35af659340c7a540272495fcb5f4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -952,6 +952,7 @@ class Facture extends CommonInvoice $line->total_ht = $object->lines[$i]->total_ht; $line->total_tva = $object->lines[$i]->total_tva; $line->total_ttc = $object->lines[$i]->total_ttc; + $line->vat_src_code = $object->lines[$i]->vat_src_code; $line->tva_tx = $object->lines[$i]->tva_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx; @@ -1551,6 +1552,7 @@ class Facture extends CommonInvoice $facligne->fk_facture=$this->id; $facligne->fk_remise_except=$remise->id; $facligne->desc=$remise->description; // Description ligne + $facligne->vat_src_code=$remise->vat_src_code; $facligne->tva_tx=$remise->tva_tx; $facligne->subprice=-$remise->amount_ht; $facligne->fk_product=0; // Id produit predefini @@ -2399,7 +2401,7 @@ class Facture extends CommonInvoice * @param string $desc Description of line * @param double $pu_ht Unit price without tax (> 0 even for credit note) * @param double $qty Quantity - * @param double $txtva Force Vat rate, -1 for auto + * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') * @param double $txlocaltax1 Local tax 1 rate (deprecated) * @param double $txlocaltax2 Local tax 2 rate (deprecated) * @param int $fk_product Id of predefined product/service @@ -4276,7 +4278,7 @@ class FactureLigne extends CommonInvoiceLine */ function fetch($rowid) { - $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.tva_tx,'; + $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; @@ -4304,6 +4306,7 @@ class FactureLigne extends CommonInvoiceLine $this->desc = $objp->description; $this->qty = $objp->qty; $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; $this->localtax2_tx = $objp->localtax2_tx; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 05cf0b4c3cbcc691a520c6810ef3669c5b38da21..4dc330544ee66321aef52e90c7bcd65299a8e233 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -471,6 +471,12 @@ abstract class CommonInvoiceLine extends CommonObjectLine */ public $fk_product; + /** + * VAT code + * @var string + */ + public $vat_src_code; + /** * VAT % * @var float diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c9acc1f310ea49ad59ee71ed029df96f169b8031..1bf4a95a2c9e3ef563b2210d970f0832c42f24b5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3567,7 +3567,7 @@ abstract class CommonObject print '<tr class="liste_titre">'; print '<td>'.$langs->trans('Ref').'</td>'; print '<td>'.$langs->trans('Description').'</td>'; - print '<td align="right">'.$langs->trans('VAT').'</td>'; + print '<td align="right">'.$langs->trans('VATRate').'</td>'; print '<td align="right">'.$langs->trans('PriceUHT').'</td>'; if (!empty($conf->multicurrency->enabled)) print '<td align="right">'.$langs->trans('PriceUHTCurrency').'</td>'; print '<td align="right">'.$langs->trans('Qty').'</td>'; @@ -3698,7 +3698,10 @@ abstract class CommonObject $this->tpl['description'] = ' '; } + // VAT Rate $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); + 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); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b5bda51b4ba6cbb5cf94791d94a81c2cea678ae6..b9c962a5168fab10d5f3ae0db8771a9c8452e07d 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1743,7 +1743,7 @@ else //TODO: Place into a function to control showing by country or study better option if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") { - print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').'</td><td colspan="3">'; + print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').'</td><td>'; print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1); if(! isOnlyOneLocalTax(1)) { @@ -1752,7 +1752,7 @@ else print '</span>'; } - print '</td><td>'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').'</td><td colspan="3">'; + print '</td><td>'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').'</td><td>'; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if (! isOnlyOneLocalTax(2)) {