From d6a9da57e11d64ecb68f21437c50fd2e0c0e7d44 Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 1 Oct 2018 14:11:19 +0200 Subject: [PATCH 1/4] FIX : need to round with 2 decimals to avoid movements not correctly balanced --- htdocs/accountancy/bookkeeping/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 9dcb924779e..50af8a6855d 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -651,8 +651,8 @@ if ($action == 'create') print "\n"; } - $total_debit = price2num($total_debit); - $total_credit = price2num($total_credit); + $total_debit = price2num($total_debit, 2); + $total_credit = price2num($total_credit, 2); if ($total_debit != $total_credit) { From 2142ccee8a6490257e06135d87aef8a6f38b7f94 Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 8 Feb 2019 15:17:40 +0100 Subject: [PATCH 2/4] FIX : better method --- htdocs/accountancy/bookkeeping/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 50af8a6855d..67217954467 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -651,8 +651,8 @@ if ($action == 'create') print "\n"; } - $total_debit = price2num($total_debit, 2); - $total_credit = price2num($total_credit, 2); + $total_debit = price2num($total_debit, 'MT'); + $total_credit = price2num($total_credit, 'MT'); if ($total_debit != $total_credit) { From ab781c32c7bcdf9e5028ae7d0a276a4ec5a4077d Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 11 Mar 2019 11:19:32 +0100 Subject: [PATCH 3/4] Wrong vat if deposit from propal with multiple vat --- htdocs/compta/facture/card.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b379bf31602..0f6820e1859 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1196,15 +1196,15 @@ if (empty($reshook)) $qualified=1; if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...) - if ($qualified) $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? + if ($qualified){ + $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? + $tva_tx = $lines[$i]->tva_tx; + $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $valuedeposit) / 100; + } + } - if ($totalamount != 0) { - if ($numlines > 0) $numlines = $numlines-1; - $tva_tx = $lines[$numlines]->tva_tx; - if (! empty($lines[$numlines]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$numlines]->vat_src_code.')'; - $amountdeposit[$tva_tx] = ($totalamount * $valuedeposit) / 100; - } else { + if($totalamount == 0) { $amountdeposit[0] = 0; } } else { @@ -1215,7 +1215,6 @@ if (empty($reshook)) $amount_ttc_diff = $amountdeposit[0]; } - foreach ($amountdeposit as $tva => $amount) { $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); @@ -1226,6 +1225,7 @@ if (empty($reshook)) } elseif ($typeamount=='variable') { $descline.= ' ('. $valuedeposit.'%)'; } + $descline.= ' - '.$srcobject->ref; $result = $object->addline( $descline, From 57091f08b0da5735676ddc54445405fcabaec222 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 18 Mar 2019 10:53:43 +0100 Subject: [PATCH 4/4] FIX missing entity filter and wrong var name --- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/core/class/html.form.class.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a6e979cdd10..d303e6edf21 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1605,7 +1605,7 @@ class Facture extends CommonInvoice $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; - $sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter)); + $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final)); $sql.= " WHERE rowid=".$this->id; $this->db->begin(); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c451a83a4fb..8f0af0a5004 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3324,7 +3324,10 @@ class Form $langs->load('bills'); $opt = ''; - $sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1'; + $sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc'; + $sql.= ' FROM ' . MAIN_DB_PREFIX . 'facture'; + $sql.= ' WHERE entity IN ('.getEntity('facture').')'; + $sql.= ' AND situation_counter>=1'; $sql.= ' ORDER by situation_cycle_ref, situation_counter desc'; $resql = $this->db->query($sql); if ($resql && $this->db->num_rows($resql) > 0) {