Skip to content

Commit

Permalink
More fixes regarding localtaxes not being diplayed in generated PDF a…
Browse files Browse the repository at this point in the history
…nd vat_src_code not being propagating properly when generating posts from type to type.
  • Loading branch information
loxK committed May 3, 2017
1 parent 421843e commit 909b489
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
8 changes: 7 additions & 1 deletion htdocs/commande/card.php
Expand Up @@ -373,7 +373,13 @@
$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);
$txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx . ' (' . $lines[$i]->vat_src_code . ')' : $lines[$i]->tva_tx;

// View third's localtaxes for now
$localtax1_tx = get_localtax($txtva, 1, $object->thirdparty);
$localtax2_tx = get_localtax($txtva, 2, $object->thirdparty);

$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $txtva, $localtax1_tx, $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++;
Expand Down
12 changes: 9 additions & 3 deletions htdocs/contrat/card.php
Expand Up @@ -332,14 +332,20 @@
else {
$desc = dol_htmlentitiesbr($lines[$i]->desc);
}

$txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx . ' (' . $lines[$i]->vat_src_code . ')' : $lines[$i]->tva_tx;

// View third's localtaxes for now
$localtax1_tx = get_localtax($txtva, 1, $object->thirdparty);
$localtax2_tx = get_localtax($txtva, 2, $object->thirdparty);

$result = $object->addline(
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
$lines[$i]->tva_tx,
$lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx,
$txtva,
$localtax1_tx,
$localtax2_tx,
$lines[$i]->fk_product,
$lines[$i]->remise_percent,
$lines[$i]->date_start,
Expand Down
8 changes: 7 additions & 1 deletion htdocs/contrat/class/contrat.class.php
Expand Up @@ -612,7 +612,7 @@ function fetch_lines()

// Selectionne les lignes contrats liees a un produit
$sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,";
$sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,";
$sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,";
$sql.= " d.total_ht,";
$sql.= " d.total_tva,";
$sql.= " d.total_localtax1,";
Expand Down Expand Up @@ -646,9 +646,12 @@ function fetch_lines()
$line->fk_contrat = $objp->fk_contrat;
$line->desc = $objp->description; // Description ligne
$line->qty = $objp->qty;
$line->vat_src_code q= $objp->vat_src_code ;
$line->tva_tx = $objp->tva_tx;
$line->localtax1_tx = $objp->localtax1_tx;
$line->localtax2_tx = $objp->localtax2_tx;
$line->localtax1_type = $objp->localtax1_type;
$line->localtax2_type = $objp->localtax2_type;
$line->subprice = $objp->subprice;
$line->statut = $objp->statut;
$line->remise_percent = $objp->remise_percent;
Expand Down Expand Up @@ -2715,6 +2718,7 @@ function update($user, $notrigger=0)
$this->statut=(int) $this->statut;
$this->label=trim($this->label);
$this->description=trim($this->description);
$this->vat_src_code=trim($this->vat_src_code);
$this->tva_tx=trim($this->tva_tx);
$this->localtax1_tx=trim($this->localtax1_tx);
$this->localtax2_tx=trim($this->localtax2_tx);
Expand Down Expand Up @@ -2786,6 +2790,7 @@ function update($user, $notrigger=0)
$sql.= " date_ouverture=".($this->date_ouverture!=''?"'".$this->db->idate($this->date_ouverture)."'":"null").",";
$sql.= " date_fin_validite=".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null").",";
$sql.= " date_cloture=".($this->date_cloture!=''?"'".$this->db->idate($this->date_cloture)."'":"null").",";
$sql.= " vat_src_code='".$this->vat_src_code."',";
$sql.= " tva_tx='".$this->tva_tx."',";
$sql.= " localtax1_tx='".$this->localtax1_tx."',";
$sql.= " localtax2_tx='".$this->localtax2_tx."',";
Expand Down Expand Up @@ -2914,6 +2919,7 @@ public function insert($notrigger = 0)
$sql.= ") VALUES ($this->fk_contrat, '', '" . $this->db->escape($this->description) . "',";
$sql.= ($this->fk_product>0 ? $this->fk_product : "null").",";
$sql.= " '".$this->qty."',";
$sql.= " '".$this->vat_src_code."',";

This comment has been minimized.

Copy link
@atm-arnaud

atm-arnaud Jun 2, 2017

Contributor

This fix crash all contratdet insert. There is no vat_src_code row matched in insert.

 $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet";
 $sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx,";
 $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,";
 $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,";
 $sql.= " info_bits,";
 $sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht";
 if ($this->date_ouverture_prevue > 0) { $sql.= ",date_ouverture_prevue"; }
 if ($this->date_fin_validite > 0)   { $sql.= ",date_fin_validite"; }
 $sql.= ")

As well, there is a PR waiting validation. But be careful next time. We are in a stable version all must be tested before ;-).

Mistakes allow us to develop and improve.

This comment has been minimized.

Copy link
@loxK

loxK Jun 15, 2017

Author Contributor

I think I have added it the vat_src_code sql field in another commit. If not it is just a matter of adding it.
Regarding the stable state, OK, but how a so half-baked feature as the second taxe is in v5 could have reached a stable release?

$sql.= " '".$this->tva_tx."',";
$sql.= " '".$this->localtax1_tx."',";
$sql.= " '".$this->localtax2_tx."',";
Expand Down

0 comments on commit 909b489

Please sign in to comment.