From 18d5ec77509f489d7a7a8d77ccb8f96482fd0f31 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Tue, 16 Jun 2020 10:56:10 +0200 Subject: [PATCH 1/3] 11.0 - FIX - missing currency columns in supplier exports (copy-pasted from modFacture.class.php) --- htdocs/core/modules/modFournisseur.class.php | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index b8539ad41c1..316000293e7 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -297,6 +297,14 @@ class modFournisseur extends DolibarrModules 'p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode','project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef','project.title'=>'ProjectLabel' ); + if (! empty($conf->multicurrency->enabled)) + { + $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + } //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text', // 's.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric", @@ -423,6 +431,14 @@ class modFournisseur extends DolibarrModules 'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment', 'p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','p.fk_bank'=>'IdTransaction','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel' ); + if (! empty($conf->multicurrency->enabled)) + { + $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + } //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text', // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date", @@ -508,6 +524,14 @@ class modFournisseur extends DolibarrModules 'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.ref'=>'RefSupplier','fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef','p.label'=>'ProductLabel','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel' ); + if (! empty($conf->multicurrency->enabled)) + { + $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + } if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) { unset($this->export_fields_array['f.date_approve2']); From e50d23932254fa1f26772a9920dd1b3c4d81186c Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 16 Jun 2020 11:40:01 +0200 Subject: [PATCH 2/3] FIX : force rounding 2 on export ld compta --- htdocs/accountancy/class/accountancyexport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 8ecef4cde05..e7ec48944e1 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -985,7 +985,7 @@ class AccountancyExport print $racine_subledger_account . $separator; // deprecated CPTG & CPTA use instead // MONT - print price(abs($line->montant), 0, '', 1, 2).$separator; + print price(abs($line->montant), 0, '', 1, 2, 2).$separator; // CODC print $line->sens.$separator; // CPTG From 3d69a1dc70687da340c373d5d340fbd28fe7cbc5 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Wed, 17 Jun 2020 11:06:31 +0200 Subject: [PATCH 3/3] FIX 11.0 - multicurrency amount not fetched when fetching payments from llx_paiement or llx_paiementfourn --- .../compta/paiement/class/paiement.class.php | 38 ++++++++++--------- htdocs/fourn/class/paiementfourn.class.php | 37 +++++++++--------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 71c8596e00a..7294274d26b 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -68,9 +68,10 @@ class Paiement extends CommonObject */ public $montant; - public $amount; // Total amount of payment - public $amounts=array(); // Array of amounts - public $multicurrency_amounts=array(); // Array of amounts + public $amount; // Total amount of payment (in the main currency) + public $multicurrency_amount; // Total amount of payment (in the currency of the bank account) + public $amounts=array(); // array: invoice ID => amount for that invoice (in the main currency)> + public $multicurrency_amounts=array(); // array: invoice ID => amount for that invoice (in the invoice's currency)> public $author; public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement public $paiementcode; // Code of payment. @@ -159,7 +160,7 @@ class Paiement extends CommonObject */ public function fetch($id, $ref = '', $fk_bank = '') { - $sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank,'; + $sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,'; $sql.= ' c.code as type_code, c.libelle as type_label,'; $sql.= ' p.num_paiement as num_payment, p.note,'; $sql.= ' b.fk_account'; @@ -179,20 +180,21 @@ class Paiement extends CommonObject if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->ref?$obj->ref:$obj->rowid; - $this->date = $this->db->jdate($obj->dp); - $this->datepaye = $this->db->jdate($obj->dp); - $this->num_paiement = $obj->num_payment; // deprecated - $this->num_payment = $obj->num_payment; - $this->montant = $obj->amount; // deprecated - $this->amount = $obj->amount; - $this->note = $obj->note; - $this->type_label = $obj->type_label; - $this->type_code = $obj->type_code; - $this->statut = $obj->statut; - $this->ext_payment_id = $obj->ext_payment_id; - $this->ext_payment_site = $obj->ext_payment_site; + $this->id = $obj->rowid; + $this->ref = $obj->ref?$obj->ref:$obj->rowid; + $this->date = $this->db->jdate($obj->dp); + $this->datepaye = $this->db->jdate($obj->dp); + $this->num_paiement = $obj->num_payment; // deprecated + $this->num_payment = $obj->num_payment; + $this->montant = $obj->amount; // deprecated + $this->amount = $obj->amount; + $this->multicurrency_amount = $obj->multicurrency_amount; + $this->note = $obj->note; + $this->type_label = $obj->type_label; + $this->type_code = $obj->type_code; + $this->statut = $obj->statut; + $this->ext_payment_id = $obj->ext_payment_id; + $this->ext_payment_site = $obj->ext_payment_site; $this->bank_account = $obj->fk_account; // deprecated $this->fk_account = $obj->fk_account; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index b18b054a65b..f8f1c0735b6 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -89,7 +89,7 @@ class PaiementFourn extends Paiement { $error=0; - $sql = 'SELECT p.rowid, p.ref, p.entity, p.datep as dp, p.amount, p.statut, p.fk_bank,'; + $sql = 'SELECT p.rowid, p.ref, p.entity, p.datep as dp, p.amount, p.statut, p.fk_bank, p.multicurrency_amount,'; $sql.= ' c.code as paiement_code, c.libelle as paiement_type,'; $sql.= ' p.num_paiement as num_payment, p.note, b.fk_account'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; @@ -111,23 +111,24 @@ class PaiementFourn extends Paiement if ($num > 0) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->entity = $obj->entity; - $this->date = $this->db->jdate($obj->dp); - $this->datepaye = $this->db->jdate($obj->dp); - $this->num_paiement = $obj->num_payment; - $this->num_payment = $obj->num_payment; - $this->bank_account = $obj->fk_account; - $this->fk_account = $obj->fk_account; - $this->bank_line = $obj->fk_bank; - $this->montant = $obj->amount; - $this->amount = $obj->amount; - $this->note = $obj->note; - $this->note_private = $obj->note; - $this->type_code = $obj->paiement_code; - $this->type_label = $obj->paiement_type; - $this->statut = $obj->statut; + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->entity = $obj->entity; + $this->date = $this->db->jdate($obj->dp); + $this->datepaye = $this->db->jdate($obj->dp); + $this->num_paiement = $obj->num_payment; + $this->num_payment = $obj->num_payment; + $this->bank_account = $obj->fk_account; + $this->fk_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; + $this->montant = $obj->amount; + $this->amount = $obj->amount; + $this->multicurrency_amount = $obj->multicurrency_amount; + $this->note = $obj->note; + $this->note_private = $obj->note; + $this->type_code = $obj->paiement_code; + $this->type_label = $obj->paiement_type; + $this->statut = $obj->statut; $error = 1; } else