From d658a833c98fad5e2b21ca4c5f3ad44e51ad4717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 1 May 2017 12:05:52 +0200 Subject: [PATCH 01/15] FIX #6677 Expired contracts dashboard box does not show the name of the thirdparty Close #6677 --- htdocs/core/boxes/box_services_expired.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index f2bc86cdac5..52ccb694dd3 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -104,7 +104,7 @@ class box_services_expired extends ModeleBoxes 'logo' => 'company', 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); - $this->info_box_contents[$i][3] = array('td' => 'class="tdoverflow maxwidth100onsmartphone" align="left"', + $this->info_box_contents[$i][3] = array('td' => 'class="tdoverflowmax200 maxwidth100onsmartphone" align="left"', 'text' => $objp->name, 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); From 8c75fc0e52591c7463b8f4d01b3e25166dfef16a Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Sun, 7 May 2017 14:11:47 +1100 Subject: [PATCH 02/15] New-Caledonia uses the same bank accounts patterns than France --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7867f9bd753..7149d5a60a0 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1359,7 +1359,7 @@ class Account extends CommonObject { $country_code=$this->getCountryCode(); - if (in_array($country_code,array('CH','FR','ES','GA','IT'))) return 1; // France, Spain, Gabon, ... + if (in_array($country_code,array('CH','FR','ES','GA','IT','NC'))) return 1; // France, Spain, Gabon, ... if (in_array($country_code,array('AU','BE','CA','DE','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, England... return 0; } From 2b7dcfa56df90332ae589123177fd8e663cb358b Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Tue, 9 May 2017 21:07:32 +1100 Subject: [PATCH 03/15] Add missing vat_src_code field to predefined invoices table --- htdocs/install/mysql/migration/4.0.0-5.0.0.sql | 1 + htdocs/install/mysql/tables/llx_facturedet_rec.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index afda09aa785..8835f535d14 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -161,6 +161,7 @@ ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; ALTER TABLE llx_facturedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; +ALTER TABLE llx_facturedet_rec ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; ALTER TABLE llx_facture_fourn_det ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; ALTER TABLE llx_commandedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; ALTER TABLE llx_commande_fournisseurdet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; diff --git a/htdocs/install/mysql/tables/llx_facturedet_rec.sql b/htdocs/install/mysql/tables/llx_facturedet_rec.sql index cea176b2aa8..8b2c70b09f7 100644 --- a/htdocs/install/mysql/tables/llx_facturedet_rec.sql +++ b/htdocs/install/mysql/tables/llx_facturedet_rec.sql @@ -29,6 +29,7 @@ create table llx_facturedet_rec product_type integer DEFAULT 0, label varchar(255) DEFAULT NULL, description text, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3), -- taux tva localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_type varchar(10) NULL, -- localtax1 type From dbcb60433b5ca60bdb7d50d1a61fcf899edda716 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 9 May 2017 13:31:20 +0200 Subject: [PATCH 04/15] FIX: Correction with author and validator user on orders --- htdocs/commande/class/commande.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7c4176edac8..0ee6c49a485 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos GarcĂ­a - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -134,6 +134,7 @@ class Commande extends CommonOrder var $linked_objects=array(); var $user_author_id; + var $user_valid; /** * @var OrderLine[] @@ -1460,7 +1461,7 @@ class Commande extends CommonOrder // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut'; + $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql.= ', c.fk_account'; $sql.= ', c.date_commande'; @@ -1502,6 +1503,7 @@ class Commande extends CommonOrder $this->socid = $obj->fk_soc; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; + $this->user_valid = $obj->fk_user_valid; $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->total_localtax1; @@ -2692,8 +2694,8 @@ class Commande extends CommonOrder $sql.= " total_ht=".(isset($this->total_ht)?$this->total_ht:"null").","; $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").","; $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; - $sql.= " fk_user_author=".(isset($this->user_author)?$this->user_author:"null").","; - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").","; + $sql.= " fk_user_author=".(isset($this->user_author_id)?$this->user_author_id:"null").","; + $sql.= " fk_user_valid=".(isset($this->user_valid)?$this->user_valid:"null").","; $sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").","; $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").","; $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").","; From 6cac627117974495ebc0687a6dce55ee2a87fe4d Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Tue, 9 May 2017 23:19:16 +1100 Subject: [PATCH 05/15] Add support for localtaxes to predefined invoices --- .../facture/class/facture-rec.class.php | 94 ++++++++++++++++--- htdocs/compta/facture/fiche-rec.php | 20 +++- htdocs/filefunc.inc.php | 2 +- 3 files changed, 98 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 41c1171ccef..390e9999454 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -169,11 +169,16 @@ class FactureRec extends CommonInvoice $num=count($facsrc->lines); for ($i = 0; $i < $num; $i++) { - $result_insert = $this->addline( + $tva_tx = $facsrc->lines[$i]->tva_tx; + if (! empty($facsrc->lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; + + $result_insert = $this->addline( $facsrc->lines[$i]->desc, $facsrc->lines[$i]->subprice, $facsrc->lines[$i]->qty, - $facsrc->lines[$i]->tva_tx, + $tva_tx, + $facsrc->lines[$i]->localtax1_tx, + $facsrc->lines[$i]->localtax2_tx, $facsrc->lines[$i]->fk_product, $facsrc->lines[$i]->remise_percent, 'HT', @@ -243,7 +248,8 @@ class FactureRec extends CommonInvoice */ function fetch($rowid, $ref='', $ref_ext='', $ref_int='') { - $sql = 'SELECT f.rowid, f.entity, f.titre, f.fk_soc, f.amount, f.tva, f.total, f.total_ttc, f.remise_percent, f.remise_absolue, f.remise'; + $sql = 'SELECT f.rowid, f.entity, f.titre, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; + $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; $sql.= ', f.date_lim_reglement as dlr'; $sql.= ', f.note_private, f.note_public, f.fk_user_author'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet'; @@ -284,6 +290,8 @@ class FactureRec extends CommonInvoice $this->remise = $obj->remise; $this->total_ht = $obj->total; $this->total_tva = $obj->tva; + $this->total_localtax1 = $obj->localtax1; + $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total_ttc; $this->paye = $obj->paye; $this->close_code = $obj->close_code; @@ -364,8 +372,8 @@ class FactureRec extends CommonInvoice { $this->lines=array(); - $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, '; - $sql.= ' l.remise, l.remise_percent, l.subprice,'; + $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, '; + $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; //$sql.= ' l.situation_percent, l.fk_prev_id,'; //$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; @@ -404,7 +412,13 @@ class FactureRec extends CommonInvoice $line->fk_product_type = $objp->fk_product_type; // Type of product $line->qty = $objp->qty; $line->subprice = $objp->subprice; + + $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; + $line->localtax1_type = $objp->localtax1_type; + $line->localtax2_type = $objp->localtax2_type; $line->remise_percent = $objp->remise_percent; $line->fk_remise_except = $objp->fk_remise_except; $line->fk_product = $objp->fk_product; @@ -506,29 +520,40 @@ class FactureRec extends CommonInvoice * @param string $fk_unit Unit * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; $facid=$this->id; - dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); + dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Check parameters if ($type < 0) return -1; + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + if ($this->brouillon) { // Clean parameters $remise_percent=price2num($remise_percent); if (empty($remise_percent)) $remise_percent=0; $qty=price2num($qty); - if (! $qty) $qty=1; if (! $info_bits) $info_bits=0; $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); $txtva=price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); if ($price_base_type=='HT') { @@ -543,10 +568,14 @@ class FactureRec extends CommonInvoice // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits, $type, $mysoc); + + + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; + $total_localtax1=$tabprice[9]; + $total_localtax2=$tabprice[10]; $product_type=$type; if ($fk_product) @@ -563,6 +592,11 @@ class FactureRec extends CommonInvoice $sql.= ", price"; $sql.= ", qty"; $sql.= ", tva_tx"; + $sql.= ", vat_src_code"; + $sql.= ", localtax1_tx"; + $sql.= ", localtax1_type"; + $sql.= ", localtax2_tx"; + $sql.= ", localtax2_type"; $sql.= ", fk_product"; $sql.= ", product_type"; $sql.= ", remise_percent"; @@ -570,6 +604,8 @@ class FactureRec extends CommonInvoice $sql.= ", remise"; $sql.= ", total_ht"; $sql.= ", total_tva"; + $sql.= ", total_localtax1"; + $sql.= ", total_localtax2"; $sql.= ", total_ttc"; $sql.= ", rang"; $sql.= ", special_code"; @@ -581,6 +617,11 @@ class FactureRec extends CommonInvoice $sql.= ", ".price2num($pu_ht); $sql.= ", ".price2num($qty); $sql.= ", ".price2num($txtva); + $sql.= ", '".$this->db->escape($vat_src_code)."'"; + $sql.= ", ".price2num($txlocaltax1); + $sql.= ", '".$this->db->escape($localtaxes_type[0])."'"; + $sql.= ", ".price2num($txlocaltax2); + $sql.= ", '".$this->db->escape($localtaxes_type[2])."'"; $sql.= ", ".(! empty($fk_product)?"'".$fk_product."'":"null"); $sql.= ", ".$product_type; $sql.= ", ".price2num($remise_percent); @@ -588,6 +629,8 @@ class FactureRec extends CommonInvoice $sql.= ", null"; $sql.= ", ".price2num($total_ht); $sql.= ", ".price2num($total_tva); + $sql.= ", ".price2num($total_localtax1); + $sql.= ", ".price2num($total_localtax2); $sql.= ", ".price2num($total_ttc); $sql.= ", ".$rang; $sql.= ", ".$special_code; @@ -629,28 +672,39 @@ class FactureRec extends CommonInvoice * @param string $fk_unit Unit * @return int <0 if KO, Id of line if OK */ - function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) + function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; $facid=$this->id; - dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); + dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Check parameters if ($type < 0) return -1; - + + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + if ($this->brouillon) { // Clean parameters $remise_percent=price2num($remise_percent); $qty=price2num($qty); - if (! $qty) $qty=1; if (! $info_bits) $info_bits=0; $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); $txtva=price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); if ($price_base_type=='HT') { @@ -665,10 +719,13 @@ class FactureRec extends CommonInvoice // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits, $type, $mysoc); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); + $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; + $total_localtax1=$tabprice[9]; + $total_localtax2=$tabprice[10]; $product_type=$type; if ($fk_product) @@ -685,18 +742,25 @@ class FactureRec extends CommonInvoice $sql.= ", price=".price2num($pu_ht); $sql.= ", qty=".price2num($qty); $sql.= ", tva_tx=".price2num($txtva); + $sql.= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; + $sql.= ", localtax1_tx=".price2num($txlocaltax1); + $sql.= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; + $sql.= ", localtax2_tx=".price2num($txlocaltax2); + $sql.= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; $sql.= ", fk_product=".(! empty($fk_product)?"'".$fk_product."'":"null"); $sql.= ", product_type=".$product_type; $sql.= ", remise_percent='".price2num($remise_percent)."'"; $sql.= ", subprice='".price2num($pu_ht)."'"; $sql.= ", total_ht='".price2num($total_ht)."'"; $sql.= ", total_tva='".price2num($total_tva)."'"; + $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; + $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; $sql.= ", total_ttc='".price2num($total_ttc)."'"; $sql.= ", rang=".$rang; $sql.= ", special_code=".$special_code; $sql.= ", fk_unit=".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); $sql.= " WHERE rowid = ".$rowid; - + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); if ($this->db->query($sql)) { diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 4adfc24b4dc..d04b4b9e8e6 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -612,7 +612,7 @@ if (empty($reshook)) else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit); if ($result > 0) { @@ -784,7 +784,9 @@ if (empty($reshook)) $description, $pu_ht, $qty, - $vat_rate, + $vat_rate, + $localtax1_rate, + $localtax1_rate, GETPOST('productid'), GETPOST('remise_percent'), 'HT', @@ -1180,9 +1182,23 @@ else print ''.$langs->trans("AmountVAT").''.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).''; print ''; + + // Amount Local Taxes + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 + { + print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; + print '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . ''; + } + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 + { + print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; + print '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . ''; + } + print ''.$langs->trans("AmountTTC").''.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).''; print ''; + // Payment term print ''; print ''; // Show file size @@ -1498,16 +1498,17 @@ class FormFile * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs * @param string $ruleforpicto Rule for picto: 0=Preview picto, 1=Use picto of mime type of file) + * @param string $param More param on http links * @return string $out Output string with HTML */ - public function showPreview($file, $modulepart, $relativepath, $ruleforpicto=0) + public function showPreview($file, $modulepart, $relativepath, $ruleforpicto=0, $param='') { global $langs, $conf; $out=''; if ($conf->browser->layout != 'phone') { - $urladvancedpreview=getAdvancedPreviewUrl($modulepart, $relativepath); // Return if a file is qualified for preview + $urladvancedpreview=getAdvancedPreviewUrl($modulepart, $relativepath, $param); // Return if a file is qualified for preview if ($urladvancedpreview) { $out.= ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index facc685d234..2db8ecdb111 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5839,9 +5839,10 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') * * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs + * @param string $param More param on http links * @return string Output string with HTML */ -function getAdvancedPreviewUrl($modulepart, $relativepath) +function getAdvancedPreviewUrl($modulepart, $relativepath, $param='') { global $conf; @@ -5852,7 +5853,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath) //$mime_preview[]='archive'; $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview); - if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.$relativepath).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js('Preview').'\')'; + if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.$relativepath.($param?'&'.$param:'')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js('Preview').'\')'; else return ''; } diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 9412f3f6270..d571e218e51 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -657,7 +657,7 @@ if ($socid && $action != 'edit' && $action != "create") $var=true; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, '', 0, '', $object->default_lang); + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); print '
'; From d410a320d72e569b5148b0a9a0da39831a4912e9 Mon Sep 17 00:00:00 2001 From: jfefe Date: Wed, 10 May 2017 20:32:54 +0200 Subject: [PATCH 13/15] WIP #6504: CVE-2017-7886 'defaultlang' attribute was not filtered before database request which cause an SQL injection. --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 89ab0019865..5c5c1062d25 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -439,7 +439,7 @@ class Translate if (! $found) { // Overwrite translation with database read - $sql="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$this->defaultlang."'"; + $sql="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."'"; $resql=$db->query($sql); if ($resql) From ec4e416a6c1075e1c68d146d95fdd5c7f4e85685 Mon Sep 17 00:00:00 2001 From: Benoit Date: Fri, 5 May 2017 22:21:46 +0200 Subject: [PATCH 14/15] Fix bug xhen insert new bankline --- htdocs/compta/bank/class/account.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7867f9bd753..08925f722d7 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -471,9 +471,9 @@ class Account extends CommonObject if ($accline->insert() > 0) { - if ($categorie) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_account ("; - $sql .= "fk_account, fk_categorie"; + if ($categorie>0) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; + $sql .= "lineid, fk_categ; $sql .= ") VALUES ("; $sql .= " ".$accline->id.", ".$categorie; $sql .= ")"; From 23af50ad2a276618c0e1319c12f51feb51053cfa Mon Sep 17 00:00:00 2001 From: Benoit Date: Fri, 5 May 2017 22:33:34 +0200 Subject: [PATCH 15/15] Add fk_facture_fourn element to fetch lines objects --- htdocs/fourn/class/fournisseur.facture.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 009f765e5cd..38d0fcd5bfb 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -636,7 +636,7 @@ class FactureFournisseur extends CommonInvoice function fetch_lines() { $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx'; - $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; + $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; $sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; @@ -645,6 +645,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ' WHERE fk_facture_fourn='.$this->id; $sql.= ' ORDER BY f.rang, f.rowid'; + dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql_rows = $this->db->query($sql); if ($resql_rows) @@ -683,6 +684,7 @@ class FactureFournisseur extends CommonInvoice $line->total_tva = $obj->total_tva; $line->total_localtax1 = $obj->total_localtax1; $line->total_localtax2 = $obj->total_localtax2; + $line->fk_facture_fourn = $obj->fk_facture_fourn; $line->total_ttc = $obj->total_ttc; $line->fk_product = $obj->fk_product; $line->product_type = $obj->product_type;
'; diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 427f428d652..b3d7fca0726 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','5.0.2'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','5.0.3'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From c88656edb4ef5e6cf8024716b94140fa0d7b0eb5 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Tue, 9 May 2017 23:59:37 +1100 Subject: [PATCH 06/15] Fix PHPDOC comments --- htdocs/compta/facture/class/facture-rec.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 390e9999454..ef23a30b878 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -507,6 +507,8 @@ class FactureRec extends CommonInvoice * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) * @param double $qty Quantite * @param double $txtva Taux de tva force, sinon -1 + * @param double $txlocaltax1 Local tax 1 rate (deprecated) + * @param double $txlocaltax2 Local tax 2 rate (deprecated) * @param int $fk_product Id du produit/service predefini * @param double $remise_percent Pourcentage de remise de la ligne * @param string $price_base_type HT or TTC @@ -659,6 +661,8 @@ class FactureRec extends CommonInvoice * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) * @param double $qty Quantite * @param double $txtva Taux de tva force, sinon -1 + * @param double $txlocaltax1 Local tax 1 rate (deprecated) + * @param double $txlocaltax2 Local tax 2 rate (deprecated) * @param int $fk_product Id du produit/service predefini * @param double $remise_percent Pourcentage de remise de la ligne * @param string $price_base_type HT or TTC From fb561bae1bdd268bb3781c9b4720fde8060ddbd9 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Wed, 10 May 2017 00:58:48 +1100 Subject: [PATCH 07/15] Fix recurring invoices generation when using the cron url --- htdocs/public/cron/cron_run_jobs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index fc8e15aeed6..e62e176ac6e 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -26,7 +26,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOLOGIN')) define('NOLOGIN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); From e48ba067303107b476979527f4a414da7e800795 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2017 18:13:38 +0200 Subject: [PATCH 08/15] Fix generation of sepa mandate with multicompany --- htdocs/societe/rib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 122c5282a40..9412f3f6270 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -293,13 +293,13 @@ if (empty($reshook)) $action = 'builddoc'; $moreparams = array( 'use_companybankid'=>GETPOST('companybankid'), - 'force_dir_output'=>$conf->societe->dir_output.'/'.dol_sanitizeFileName($object->id) + 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id) ); $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid')); $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid')); } $id = $socid; - $upload_dir = $conf->societe->dir_output; + $upload_dir = $conf->societe->multidir_output[$object->entity]; $permissioncreate=$user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; From 002bebd83796f3cbee250a393da734c90d1384dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2017 18:15:01 +0200 Subject: [PATCH 09/15] Fix missing extraparams make sql syntax error --- htdocs/install/mysql/migration/4.0.0-5.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_bank_account.sql | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index afda09aa785..75f9b38f34b 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -32,6 +32,8 @@ UPDATE llx_const SET name = __ENCRYPT('THIRDPARTY_DEFAULT_CREATE_CONTACT')__ WHE ALTER TABLE llx_product_lot MODIFY COLUMN entity integer DEFAULT 1; UPDATE llx_product_lot SET entity = 1 WHERE entity IS NULL; +ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); + ALTER TABLE llx_societe ALTER COLUMN fk_stcomm SET DEFAULT 0; ALTER TABLE llx_c_actioncomm ADD COLUMN picto varchar(48); diff --git a/htdocs/install/mysql/tables/llx_bank_account.sql b/htdocs/install/mysql/tables/llx_bank_account.sql index 7730ab79ef6..0faebbf64d1 100644 --- a/htdocs/install/mysql/tables/llx_bank_account.sql +++ b/htdocs/install/mysql/tables/llx_bank_account.sql @@ -58,5 +58,6 @@ create table llx_bank_account comment text, -- TODO rename in note_private note_public text, model_pdf varchar(255), - import_key varchar(14) + import_key varchar(14), + extraparams varchar(255) -- for other parameters with json format )ENGINE=innodb; From d570df50899d105d01f8db97f5633be2554d5052 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 22 Feb 2017 15:59:10 +0100 Subject: [PATCH 10/15] inverted value between FRST & RECUR --- htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 396e89afb56..915883cbdaa 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -326,14 +326,14 @@ class pdf_sepamandate extends ModeleBankAccountDoc $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); $pdf->Rect(80, $posY, 5, 5); $pdf->SetXY(80, $posY); - if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L'); + if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L'); $pdf->SetXY(86, $posY); $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or"); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); $posY+=6; $pdf->Rect(80, $posY, 5, 5); $pdf->SetXY(80, $posY); - if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L'); + if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L'); $pdf->SetXY(86, $posY); $txt = $langs->transnoentitiesnoconv("ModeFRST"); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); From 823e5b48e3e39e1de59d88fdbb387df8e8c232f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2017 18:56:18 +0200 Subject: [PATCH 11/15] Code comment --- htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 915883cbdaa..3dc615d9deb 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** - * Classe permettant de generer les projets au modele Baleine + * Classe permettant de generer les projets au modele SEPAMandate */ class pdf_sepamandate extends ModeleBankAccountDoc From 5a96ae54b9edde7df8be5a39dea4701f281aae69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 May 2017 19:08:07 +0200 Subject: [PATCH 12/15] FIX Link to files on bank account tab broken with multicompany FIX Link to preview on thirdparty broken with multicompany --- htdocs/core/class/html.formfile.class.php | 7 ++++--- htdocs/core/lib/functions.lib.php | 5 +++-- htdocs/societe/rib.php | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 99dee355333..6e46efe3fdf 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -680,7 +680,7 @@ class FormFile $out.= ' target="_blank">'; $out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]).' '.dol_trunc($file["name"],$maxfilenamelength); $out.= ''."\n"; - $out.= $this->showPreview($file,$modulepart,$relativepath); + $out.= $this->showPreview($file,$modulepart,$relativepath,0,$param); $out.= '