From 63230cce792d63cc953d4b51c80749d7835d3294 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 11 Oct 2018 20:04:25 +0200 Subject: [PATCH 01/42] For 7.2 , $p_value must be initialized to an array in ISelect --- include/lib/iselect.class.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/include/lib/iselect.class.php b/include/lib/iselect.class.php index 20087359c..1a910557c 100644 --- a/include/lib/iselect.class.php +++ b/include/lib/iselect.class.php @@ -29,6 +29,17 @@ require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; class ISelect extends HtmlInput { + function __construct($p_name="", $p_value="", $p_id="") + { + parent::__construct($p_name,$p_value,$p_id); + $this->name=$p_name; + if ( $p_value == "" || ! is_array($p_value)) { + $this->value=array(); + } else { + $this->value=$p_value; + } + $this->id=$p_id; + } /*!\brief show the html input of the widget*/ public function input($p_name=null,$p_value=null) { @@ -69,7 +80,7 @@ class ISelect extends HtmlInput } } // $r=''.$r.''; - if ( $this->table == 1 ) $a=''.$r.''; + if ( $this->table == 1 ) $r=''.$r.''; return $r; } /*!\brief print in html the readonly value of the widget*/ @@ -96,11 +107,10 @@ class ISelect extends HtmlInput * // will be turned into * array( array("value"=>'M,"label"=>"Mister")...) * @endcode - * @param type $p_array - * @return type + * @param array $p_array */ public function transform($p_array) { - if (count($p_array)==0) return array(); + if (! is_array($p_array) || count($p_array)==0) return ; $a_ret=array(); foreach ($p_array as $key=>$value) { $a_ret['value']=$key; From c40e55c8a8a787e9240bc89f4fa8991c8a57f1ba Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 11 Oct 2018 20:16:22 +0200 Subject: [PATCH 02/42] remove dead code --- include/lib/impress.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/lib/impress.class.php b/include/lib/impress.class.php index ea413a211..0a8beb32b 100644 --- a/include/lib/impress.class.php +++ b/include/lib/impress.class.php @@ -57,11 +57,8 @@ class Impress else $cond="( j_date >= to_date('$p_start','DD.MM.YYYY') and j_date <= to_date('$p_end','DD.MM.YYYY'))"; - include_once("class/acc_account_ledger.class.php"); - while (preg_match_all("(\[[0-9]*[A-Z]*%*c*d*s*\])",$p_formula,$e) == true) { - // remove the [ ] $x=$e[0]; foreach ($x as $line) From b57ab4348bdeeeb68fdd021401592b220083013c Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 26 Dec 2018 13:35:04 +0100 Subject: [PATCH 03/42] Esthetic with button "Add accounting" --- include/param_pcmn.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/param_pcmn.inc.php b/include/param_pcmn.inc.php index 8da1c483f..fdb03237c 100644 --- a/include/param_pcmn.inc.php +++ b/include/param_pcmn.inc.php @@ -79,7 +79,7 @@ echo $mtable->display_table(" where pcm_val::text like '{$g_start}%' order by pc From 0de24ee08ff340bf3db8e36aa5e4355c5701a4ff Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 26 Dec 2018 13:50:20 +0100 Subject: [PATCH 04/42] typo doc --- html/js/scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index d01ae04c4..59d78ad31 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -3411,7 +3411,7 @@ var progressIdx = 0; /** * Start the progress bar * @param {string} p_taskid id to monitor - * @param {int} p_dossier + * @param {int} p_message */ function progress_bar_start(p_taskid,p_message) { From 521135c8fe351082847981f6cdc1d2abfd354620 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 26 Dec 2018 13:35:04 +0100 Subject: [PATCH 05/42] Esthetic with button "Add accounting" --- include/param_pcmn.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/param_pcmn.inc.php b/include/param_pcmn.inc.php index 8da1c483f..fdb03237c 100644 --- a/include/param_pcmn.inc.php +++ b/include/param_pcmn.inc.php @@ -79,7 +79,7 @@ echo $mtable->display_table(" where pcm_val::text like '{$g_start}%' order by pc From 781efef7a6032b9428227032007b892f7995e63f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 26 Dec 2018 13:50:20 +0100 Subject: [PATCH 06/42] typo doc --- html/js/scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index af874cb4f..a2d95bf94 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -3411,7 +3411,7 @@ var progressIdx = 0; /** * Start the progress bar * @param {string} p_taskid id to monitor - * @param {int} p_dossier + * @param {int} p_message */ function progress_bar_start(p_taskid,p_message) { From 8555b69d4d1e9948a03b0d48f08f89fe7281148b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 28 Dec 2018 10:00:06 +0100 Subject: [PATCH 07/42] Translation + use of httpInput --- include/compta_ods.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/compta_ods.inc.php b/include/compta_ods.inc.php index cab936d30..0c15d15ff 100644 --- a/include/compta_ods.inc.php +++ b/include/compta_ods.inc.php @@ -40,8 +40,10 @@ global $g_user,$http; $cn = Dossier::connect(); -$id_predef = (isset($_REQUEST['p_jrn_predef'])) ? $_REQUEST['p_jrn_predef'] : -1; -$id_ledger = (isset($_REQUEST['p_jrn'])) ? $_REQUEST['p_jrn'] : $id_predef; + +$id_predef = $http->request('p_jrn_predef','number',-1); +$id_ledger = $http->request('p_jrn','number',$id_predef); + $ledger = new Acc_Ledger($cn, $id_ledger); $first_ledger = $ledger->get_first('ODS'); if ( empty ($first_ledger)) @@ -91,7 +93,7 @@ elseif (isset($_POST['save'])) $ledger->save($array); $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($ledger->internal)); - echo '

Opération enregistrée Piece ' . h($ledger->pj) . '

'; + echo '

'._("Opération enregistrée")._("Piece") . h($ledger->pj) . '

'; if (strcmp($ledger->pj, $_POST['e_pj']) != 0) { echo '

' . _('Attention numéro pièce existante, elle a du être adaptée') . '

'; From 1c0d74b98630c322ea181aa58844de3bc9297573 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 28 Dec 2018 10:01:29 +0100 Subject: [PATCH 08/42] Translation --- include/compta_ods.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/compta_ods.inc.php b/include/compta_ods.inc.php index 0c15d15ff..cbdabcb98 100644 --- a/include/compta_ods.inc.php +++ b/include/compta_ods.inc.php @@ -48,7 +48,7 @@ $ledger = new Acc_Ledger($cn, $id_ledger); $first_ledger = $ledger->get_first('ODS'); if ( empty ($first_ledger)) { - exit('Pas de journal disponible'); + exit(_('Pas de journal disponible')); } $ledger->id = ($ledger->id == -1) ? $first_ledger['jrn_def_id'] : $id_ledger; From a21adbc0dab91928dfda2fd164b28e571ad4608d Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 28 Dec 2018 10:19:26 +0100 Subject: [PATCH 09/42] Translation --- include/operation_ods_new.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/operation_ods_new.inc.php b/include/operation_ods_new.inc.php index 4dbeca255..8e97df638 100644 --- a/include/operation_ods_new.inc.php +++ b/include/operation_ods_new.inc.php @@ -88,7 +88,7 @@ echo ''; $iconcerned=new IConcerned('jrn_concerned'); $iconcerned->amount_id="totalDeb"; -echo "Opération rapprochée : ".$iconcerned->input(); +printf (_("Opération rapprochée : %s"),$iconcerned->input()); echo '

'; echo HtmlInput::button('add', _('Ajout d\'une ligne'), 'onClick="quick_writing_add_row()"'); From 1974dfcee3397b0659200d7b6d4bd3581d5c3921 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 28 Dec 2018 10:22:23 +0100 Subject: [PATCH 10/42] use of httpInput --- include/operation_ods_new.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/operation_ods_new.inc.php b/include/operation_ods_new.inc.php index 8e97df638..1c6f96f3d 100644 --- a/include/operation_ods_new.inc.php +++ b/include/operation_ods_new.inc.php @@ -31,8 +31,9 @@ require_once NOALYSS_INCLUDE.'/lib/iconcerned.class.php'; global $g_user,$g_parameter; $cn=Dossier::connect(); -$id_predef = (isset($_REQUEST['p_jrn_predef'])) ? $_REQUEST['p_jrn_predef'] : -1; -$id_ledger = (isset($_REQUEST['p_jrn'])) ? $_REQUEST['p_jrn'] : $id_predef; +$id_predef = $http->request('p_jrn_predef','number',-1); +$id_ledger = $http->request('p_jrn','number',$id_predef); + $ledger = new Acc_Ledger($cn, $id_ledger); $first_ledger=$ledger->get_first('ODS'); $ledger->id = ($ledger->id == -1) ? $first_ledger['jrn_def_id'] : $id_ledger; From b3ada4106f531fac32525ee2a56ef298d34db2ad Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 28 Dec 2018 10:40:48 +0100 Subject: [PATCH 11/42] Translation --- include/class/acc_ledger.class.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 0d6b9a91b..2d1534486 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -762,6 +762,7 @@ class Acc_Ledger extends jrn_def_sql function input($p_array=null, $p_readonly=0) { global $g_parameter, $g_user; + $http=new HttpInput(); $this->nb=$this->get_min_row(); if ($p_readonly==1) return $this->confirm($p_array); @@ -787,7 +788,8 @@ class Acc_Ledger extends jrn_def_sql $wLedger=$this->select_ledger('ODS', 2,FALSE); if ($wLedger==null) throw new Exception(_('Pas de journal disponible')); - $wLedger->javascript="onChange='update_name();update_predef(\"ods\",\"t\",\"".$_REQUEST['ac']."\");$add_js'"; + $ac=$http->request("ac"); + $wLedger->javascript="onChange='update_name();update_predef(\"ods\",\"t\",\"".$ac."\");$add_js'"; $label=" Journal ".Icon_Action::infobulle(2); $ret.=""; @@ -803,8 +805,11 @@ class Acc_Ledger extends jrn_def_sql $op->set('ledger', $this->id); $op->set('ledger_type', "ODS"); $op->set('direct', 't'); - $url=http_build_query(array('action'=>'use_opd', 'p_jrn_predef'=>$this->id, - 'ac'=>$_REQUEST['ac'], 'gDossier'=>dossier::id())); + $url=http_build_query( + array('action'=>'use_opd', + 'p_jrn_predef'=>$this->id, + 'ac'=>$ac, + 'gDossier'=>dossier::id())); echo $op->form_get('do.php?'.$url); echo ''; @@ -1047,12 +1052,12 @@ class Acc_Ledger extends jrn_def_sql /* check for a double reload */ if (isset($mt)&&$this->db->count_sql('select jr_mt from jrn where jr_mt=$1', array($mt))!=0) - throw new Exception('Double Encodage', 5); + throw new Exception(_('Double Encodage'), 5); // Check the periode and the date if (isDate($e_date)==null) { - throw new Exception('Date invalide', 2); + throw new Exception(_('Date invalide'), 2); } $periode=new Periode($this->db); /* find the periode if we have enabled the check_periode @@ -1076,7 +1081,7 @@ class Acc_Ledger extends jrn_def_sql // Periode ferme if ($this->is_closed($periode->p_id)==1) { - throw new Exception('Periode fermee', 6); + throw new Exception(_('Periode fermee'), 6); } /* check if we are using the strict mode */ if ($this->check_strict()==true) From 45a72808a3605f275e05ccdd6ad8fdcc748926f6 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 28 Dec 2018 10:47:25 +0100 Subject: [PATCH 12/42] Translation --- include/class/acc_ledger.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 2d1534486..7aaecf32c 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1090,8 +1090,10 @@ class Acc_Ledger extends jrn_def_sql operation */ $last_date=$this->get_last_date(); if ($last_date!=null&&cmpDate($e_date, $last_date)<0) - throw new Exception(_('Vous utilisez le mode strict la dernière operation est la date du ') - .$last_date.' '._('vous ne pouvez pas encoder à une date antérieure'), + throw new Exception( + sprintf ( + _('Vous utilisez le mode strict la dernière operation est la date du %s + vous ne pouvez pas encoder à une date antérieure',$last_date)), 15); } From 2873d62abac33aa4eb7e3db81b644f429a873562 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 28 Dec 2018 10:49:51 +0100 Subject: [PATCH 13/42] Translation --- include/class/acc_ledger.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 7aaecf32c..99ae70583 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1118,7 +1118,7 @@ class Acc_Ledger extends jrn_def_sql throw new Exception("La fiche quick_code = ". $f->quick_code." n'est pas dans ce journal", 4); if (strlen(trim(${'qc_'.$i}))!=0&&isNumber(${'amount'.$i})==0) - throw new Exception('Montant invalide', 3); + throw new Exception(_('Montant invalide'), 3); $strPoste=$f->strAttribut(ATTR_DEF_ACCOUNT); if ($strPoste=='') @@ -1135,9 +1135,11 @@ class Acc_Ledger extends jrn_def_sql if (isset(${'poste'.$i})&&strlen(trim(${'poste'.$i}))!=0) { $p=new Acc_Account_Ledger($this->db, ${'poste'.$i}); - if ($p->belong_ledger($p_jrn)<0) - throw new Exception(_("Le poste")." ".$p->id." "._("n'est pas dans ce journal"), + if ($p->belong_ledger($p_jrn)<0) { + throw new Exception(sprintf ( + _("Le poste %s n'est pas dans ce journal",$p->id)), 5); + } if (strlen(trim(${'poste'.$i}))!=0&&isNumber(${'amount'.$i})==0) throw new Exception(_('Poste invalide ['.${'poste'.$i}.']'), 3); @@ -1147,7 +1149,7 @@ class Acc_Ledger extends jrn_def_sql $card_id=$p->find_card(); if (!empty($card_id)) { - $str_msg=" Le poste ".$p->id." appartient à ".count($card_id)." fiche(s) dont :"; + $str_msg=sprintf(_(" Le poste %s appartient à fiche(s) dont :"),$str_msg,count($card_id)); $max=(count($card_id)>MAX_COMPTE_CARD)?MAX_COMPTE_CARD:count($card_id); for ($x=0; $x<$max; $x++) { From 431f41bcf7805cb567fe5d61f03fa30f2b5d904b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 28 Dec 2018 15:35:32 +0100 Subject: [PATCH 14/42] Translation --- include/class/acc_ledger.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 99ae70583..fe75e80a3 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1149,7 +1149,7 @@ class Acc_Ledger extends jrn_def_sql $card_id=$p->find_card(); if (!empty($card_id)) { - $str_msg=sprintf(_(" Le poste %s appartient à fiche(s) dont :"),$str_msg,count($card_id)); + $str_msg=sprintf(_(" Le poste %s appartient à fiche(s) dont : %s"),$str_msg,count($card_id)); $max=(count($card_id)>MAX_COMPTE_CARD)?MAX_COMPTE_CARD:count($card_id); for ($x=0; $x<$max; $x++) { From 602f65fda26b67079b054ac61265777a1bb5b1f9 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 28 Dec 2018 15:36:17 +0100 Subject: [PATCH 15/42] Translation --- include/class/acc_ledger.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index fe75e80a3..52ca1bfbf 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1163,7 +1163,7 @@ class Acc_Ledger extends jrn_def_sql } $account=new Acc_Account($this->db,${"poste".$i}); if ( $account->get_parameter("pcm_direct_use") == "N") { - throw new Exception(_("Utilisation directe interdite du poste comptable ${"poste".$i}")); + throw new Exception(sprinff (_("Utilisation directe interdite du poste comptable %s"), ${"poste".$i})); } } } From 99e4b16345db958e3bdab344032cf40fb27e6d9e Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 29 Dec 2018 18:53:47 +0100 Subject: [PATCH 16/42] Misc. Operation : input : Missing tag TR --- include/operation_ods_new.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/operation_ods_new.inc.php b/include/operation_ods_new.inc.php index 1c6f96f3d..f3dcacdc7 100644 --- a/include/operation_ods_new.inc.php +++ b/include/operation_ods_new.inc.php @@ -83,7 +83,9 @@ echo '
'; echo '
'. ''.td(_('Débit')) . '' . td(_('Crédit')) . ' ' . - td(_('Difference')) . ' '; + td(_('Difference')) . ' '. + ''; + echo '
'; echo ''; From 656b1cfb88006a94620fa9f94fb4313457e41226 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 2 Jan 2019 11:18:03 +0100 Subject: [PATCH 17/42] Currency : for misc. operation --- html/js/acc_currency.js | 75 +++++++- html/js/compute_direct.js | 10 ++ include/class/acc_ledger.class.php | 168 ++++++++++++++++-- include/class/acc_ledger_purchase.class.php | 4 +- include/class/acc_ledger_sold.class.php | 2 +- include/class/fiche.class.php | 6 +- .../class/noalyss_parameter_folder.class.php | 5 +- include/operation_ods_confirm.inc.php | 2 +- include/operation_ods_new.inc.php | 22 ++- include/template/form_ledger_detail.php | 3 +- 10 files changed, 269 insertions(+), 28 deletions(-) diff --git a/html/js/acc_currency.js b/html/js/acc_currency.js index 51ff8ecc0..0fb6fdf71 100644 --- a/html/js/acc_currency.js +++ b/html/js/acc_currency.js @@ -96,7 +96,7 @@ function CurrencyUpdateCode(p_dossier,p_code,p_update) }); } /** - * Update the field Update with the amount in EUR + * Update the field Update with the amount in EUR (= default currency), ledger sale or purchase * @param DOMID p_rate where the rate is stored * @param DOMID p_update element to update with the rate */ @@ -121,12 +121,50 @@ function CurrencyCompute(p_rate,p_update) } /** - * - * @param {type} p_dossier - * @param {type} p_code - * @param {type} p_update - * @param {type} p_rate - * @param {type} p_eur_amount + * Update the field Update with the amount in EUR (= default currency) for Miscealleneous Operation + * amount for DEB (domid : default_currency_deb , totalDeb) + * amount for CRED ( domid = default_currency_cred , totalCred), + * @param DOMID p_rate where the rate is stored + * @param DOMID p_update element to update with the rate + */ +function CurrencyComputeMisc(p_rate,p_update) +{ + var debAmount=$('totalDeb').innerHTML; + var credAmount=$('totalCred').innerHTML; + + console.log("debAmount= "+debAmount); + console.log("credAmount= "+credAmount); + if ( isNaN(debAmount)) { + console.log("debAmount is nan" + debAmount); + debAmount=0; + } + if ( isNaN(credAmount)) { + console.log("credAmount is nan" + credAmount); + credAmount=0; + } + var rate=$(p_rate).value; + console.log("rate = "+rate); + if ( isNaN(rate) || parseFloat(rate) == 0) { + console.log("rate is nan" + rate); + rate=1; + } + var totDeb=debAmount*rate; + totDeb=Math.round(totDeb*100)/100; + $('default_currency_deb').innerHTML=totDeb; + + var totCred=credAmount*rate; + totCred=Math.round(totCred*100)/100; + $('default_currency_cred').innerHTML=totCred; + +} + +/** + * Update the screen of input for Purchase and Sale + * @param {type} p_dossier + * @param {type} p_code name of the SELECT containing the currency code + * @param {type} p_update Domid of the element to update + * @param {type} p_rate domid of the element containing the currency rate + * @param {type} p_eur_amount domid of the amount in default currency to update * @returns {undefined} */ function LedgerCurrencyUpdate(p_dossier,p_code,p_update,p_rate,p_eur_amount) @@ -142,4 +180,27 @@ function LedgerCurrencyUpdate(p_dossier,p_code,p_update,p_rate,p_eur_amount) // Compute all the fields compute_all_ledger (); +} +/** + * Update the screen of input for Misc. Operation + * @param {type} p_dossier + * @param {type} p_code name of the SELECT containing the currency code + * @param {type} p_update Domid of the element to update + * @param {type} p_rate domid of the element containing the currency rate + * @param {type} p_eur_amount domid of the amount in default currency to update + * @returns {undefined} + */ +function LedgerCurrencyUpdateMisc(p_dossier,p_code,p_update,p_rate,p_eur_amount) +{ + // Hide or show the row of the table with the amount in EUR (= default currency) + if ($(p_code).value != -1) { + $('row_currency').show(); + }else { + $('row_currency').hide(); + } + CurrencyUpdateValue(p_dossier,p_code,p_rate); + CurrencyUpdateCode(p_dossier,p_code,p_update); + // Compute all the fields + checkTotalDirect(); + } \ No newline at end of file diff --git a/html/js/compute_direct.js b/html/js/compute_direct.js index 8773ace98..f145cc789 100644 --- a/html/js/compute_direct.js +++ b/html/js/compute_direct.js @@ -18,6 +18,12 @@ /*!\file *\brief common function for "Ecriture directe" */ +/** + * Compute the sum of the debit and credit of the operation in the input screen for misceallenous operation + * Call CurrencyComputeMisc to update the amount in default currency for DEB (domid = default_currency_deb) + * and CRED ( domid = default_currency_cred), + * @returns {Boolean} true if ok + */ function checkTotalDirect() { var ie4=false; @@ -77,6 +83,10 @@ function checkTotalDirect() r_total_deb=Math.round(total_deb*100)/100; document.getElementById('totalDeb').innerHTML=r_total_deb; document.getElementById('totalCred').innerHTML=r_total_cred; + // Currency , update the amount in default currency for DEB (domid = default_currency_deb) + // and CRED ( domid = default_currency_cred), + CurrencyComputeMisc('p_currency_rate','p_currency_euro'); + var diff=0; if ( r_total_deb != r_total_cred ) { diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 52ca1bfbf..7dfcd0e5d 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -586,6 +586,7 @@ class Acc_Ledger extends jrn_def_sql function confirm($p_array, $p_readonly=false) { global $g_parameter; + $http=new HttpInput(); $msg=array(); if (!$p_readonly) $msg=$this->verify($p_array); @@ -737,8 +738,26 @@ class Acc_Ledger extends jrn_def_sql $ret.=""; } - $ret.=tr(td('').td(_('Totaux')).td($total_deb, 'class="num"').td($total_cred, + $currency_code=$http->extract($p_array,"p_currency_code","number"); + $currency_rate=$http->extract($p_array,"p_currency_rate","number"); + $currency=new Acc_Currency($this->db,$currency_code); + $msg_currency= ($currency_code != 0 )?sprintf(_("Totaux %s (%s)"),$currency->get_code(),$currency_rate):_("Totaux"); + + $ret.=tr(td('').td($msg_currency).td($total_deb, 'class="num"').td($total_cred, 'class="num"'), 'class="highlight"'); + // Currency + if ( $currency_code != 0) + { + $currency_rate=$http->extract($p_array,"p_currency_rate","number"); + $default_currency=new Acc_Currency($this->db,0); + + $ret.=tr(td(''). + td(_('Totaux')." ".$default_currency->get_code()). + td(bcdiv($total_deb,$currency_rate), 'class="num"'). + td(bcdiv($total_cred,$currency_rate), 'class="num"'), + 'class="highlight"'); + } + $ret.=""; if ($g_parameter->MY_ANALYTIC!='nu'&&$p_readonly==false) $ret.=''; @@ -889,6 +908,21 @@ class Acc_Ledger extends jrn_def_sql $ret.=''; $ret.=''; + + // Currency + $currency_select = $this->CurrencyInput("currency_code", "p_currency_rate" , "p_currency_euro"); + $currency_select->selected=$http->request('p_currency_code','string',0); + + $currency_input=new INum("p_currency_rate",6); + $currency_input->id="p_currency_rate"; + $currency_input->value=$http->request('p_currency_rate','string',1); + $currency_input->javascript='onchange="format_number(this,6);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; + $ret.=_("Devise")." ".$currency_select->input(); + $ret.=$currency_input->change(); + $currency=new Acc_Currency($this->db,0); + $ret.=$currency->get_code(); + + $nb_row=(isset($nb_item) )?$nb_item:$this->nb; $ret.=HtmlInput::hidden('nb_item', $nb_row); @@ -1032,6 +1066,8 @@ class Acc_Ledger extends jrn_def_sql */ function verify($p_array) { + global $g_parameter; + $http=new HttpInput(); if (is_array($p_array)==false||empty($p_array)) throw new Exception("Array empty"); /* @@ -1044,7 +1080,40 @@ class Acc_Ledger extends jrn_def_sql $tot_cred=0; $tot_deb=0; $msg=array(); + /* Check currency : rate cannot be equal to 0 */ + $currency_rate=$http->extract($p_array,"p_currency_rate","number"); + if ( $currency_rate <=0 ) { + throw new Exception(_("Taux de conversion doit être supérieur à 0"),3); + } + /* Check currency : Does the currency parameter exist */ + $currency_code=$http->extract($p_array,"p_currency_code","number"); + $currency=new Acc_Currency($this->db,$currency_code); + if ( $currency->get_code() == -1 ) + { + throw new Exception(_('Devise inconnue'), 3); + } + + /* -- check the accounting for error of exchange -*/ + if ( $currency->get_code() == 0 ) + { + $poste=new Acc_Account($this->db,$g_parameter->MY_DEFAULT_ROUND_ERROR_DEB); + if ($poste->get_parameter("id") == -1 ) + { + throw new Exception( + sprintf(_("Dans COMPANY, vous n'avez pas paramétré correctement ". + " le compte de débit %s pour les erreurs de conversion"),$g_parameter->MY_DEFAULT_ROUND_ERROR_DEB), 3); + } + $poste=new Acc_Account($this->db,$g_parameter->MY_DEFAULT_ROUND_ERROR_CRED); + if ($poste->get_parameter("id") == -1 ) + { + throw new Exception( + sprintf(_("Dans COMPANY, vous n'avez pas paramétré correctement ". + " le compte de crédit %s pour les erreurs de conversion"),$g_parameter->MY_DEFAULT_ROUND_ERROR_CRED), 3); + } + + } + /* check if we can write into this ledger */ if ($g_user->check_jrn($p_jrn)!='W') throw new Exception(_('Accès interdit'), 20); @@ -1211,8 +1280,12 @@ class Acc_Ledger extends jrn_def_sql function save($p_array=null) { if ($p_array==null) + { throw new Exception('save cannot use a empty array'); + } global $g_parameter; + bcscale(4); + $http=new HttpInput(); extract($p_array, EXTR_SKIP); try { @@ -1243,6 +1316,12 @@ class Acc_Ledger extends jrn_def_sql } $count=0; + + // currency + $currency_code=$http->extract($p_array, "p_currency_code","number"); + $currency_rate=$http->extract($p_array, "p_currency_rate","number"); + $currency_rate_ref=new Acc_Currency($this->db, $currency_code); + for ($i=0; $i<$nb_item; $i++) { if (!isset(${'qc_'.$i})&&!isset(${'poste'.$i})) @@ -1282,14 +1361,25 @@ class Acc_Ledger extends jrn_def_sql $acc_op->desc=null; if (strlen(trim(${'ld'.$i}))!=0) $acc_op->desc=${'ld'.$i}; - $acc_op->amount=round(${'amount'.$i}, 2); + + // Amount in default currency , usually EUR + $acc_op->amount=round(bcdiv(${'amount'.$i},$p_currency_rate),2); $acc_op->grpt=$seq; $acc_op->poste=$poste; $acc_op->jrn=$this->id; $acc_op->type=(isset(${'ck'.$i}))?'d':'c'; $acc_op->qcode=$quick_code; $j_id=$acc_op->insert_jrnx(); - $tot_amount+=round($acc_op->amount, 2); + + // Save in currency + $operation_currency=new Operation_currency_SQL($this->db); + $operation_currency->oc_amount=round(${'amount'.$i}, 2); + $operation_currency->oc_vat_amount=0; + $operation_currency->oc_price_unit=0; + $operation_currency->j_id=$j_id; + $operation_currency->insert(); + + $tot_amount=bcadd($tot_amount,round($acc_op->amount, 2)); $tot_deb+=($acc_op->type=='d')?$acc_op->amount:0; $tot_cred+=($acc_op->type=='c')?$acc_op->amount:0; if ($g_parameter->MY_ANALYTIC!="nu") @@ -1304,22 +1394,62 @@ class Acc_Ledger extends jrn_def_sql $op->oa_date=$e_date; $op->oa_debit=($acc_op->type=='d' )?'t':'f'; $op->oa_description=$desc; - $op->save_form_plan($p_array, $count, $j_id); + + // send the amount in default currency to analytic + $an_array=$p_array; + $an_array['amount'.$i]=$acc_op->amount; + $op->save_form_plan($an_array, $count, $j_id); $count++; } } }// loop for each item $acc_end=new Acc_Operation($this->db); + // Check the balance + if ( $tot_deb != $tot_cred ) { + + $diff=bcsub($tot_cred, $tot_deb); + // store the difference in currency_rounded_delta + $poste_cred = $g_parameter->MY_DEFAULT_ROUND_ERROR_CRED; + $side="c"; + if ( $diff > 0 ) + { + $poste=$g_parameter->MY_DEFAULT_ROUND_ERROR_DEB; + $side="d"; + + } + + // insert difference of change + $acc_change=new Acc_Operation($this->db); + $acc_change->amount=abs($diff); + $acc_change->grpt=$seq; + $acc_change->poste=$poste; + $acc_change->jrn=$this->id; + $acc_change->type=$side; + $acc_change->date=$e_date; + $acc_change->desc=_("Différence de change"); + + $change_j_id=$acc_change->insert_jrnx(); + + $tot_deb=bcadd($tot_deb,$diff); + + } $acc_end->amount=$tot_deb; if ($check_periode==false) + { $acc_end->periode=$oPeriode->p_id; + } $acc_end->date=$e_date; $acc_end->desc=$desc; $acc_end->grpt=$seq; $acc_end->jrn=$this->id; $acc_end->mt=$mt; $acc_end->jr_optype=$jr_optype; + $acc_end->currency_id=$currency_code; + $acc_end->currency_rate=$currency_rate; + $acc_end->currency_rate_ref=$currency_rate_ref->get_rate(); + $jr_id=$acc_end->insert_jrn(); + $this->jr_id=$jr_id; if ($jr_id==false) throw new Exception(_('Balance incorrecte')); @@ -2967,19 +3097,37 @@ class Acc_Ledger extends jrn_def_sql } /** * Create a select from value for currency and add javascript to update $p_currency_rate and - * $p_eur_amount + * $p_eur_amount * @param string DOMID $p_currency_code * @param string DOMID $p_currency_rate * @param string DOMID $p_eur_amount */ - function CurrencyInput($p_currency_code,$p_currency_rate,$p_eur_amount) + function CurrencyInput($p_currency_code, $p_currency_rate, $p_eur_amount) { - $currency = new Acc_Currency($this->db); - $select=$currency->select_currency(); - $select->javascript=sprintf('onchange="LedgerCurrencyUpdate(\'%s\',\'%s\',\'%s\',\'%s\',\'%s\');$(\'update_p_currency_rate\').innerHTML=$(\'p_currency_rate\').value;"', - Dossier::id(),$select->name,$p_currency_code,$p_currency_rate,$p_eur_amount); + $type=$this->get_type(); + $currency=new Acc_Currency($this->db); + $select=$currency->select_currency(); + if ($type =='ODS') + { + + $select->javascript=sprintf('onchange="LedgerCurrencyUpdateMisc(\'%s\',\'%s\',\'%s\',\'%s\',\'%s\');'. + '$(\'update_p_currency_rate\').innerHTML=$(\'p_currency_rate\').value;"', + Dossier::id(), $select->name, $p_currency_code, $p_currency_rate, $p_eur_amount); + } + elseif ($type == 'ACH' || $type == 'VEN') + { + + $select->javascript=sprintf('onchange="LedgerCurrencyUpdate(\'%s\',\'%s\',\'%s\',\'%s\',\'%s\');'. + '$(\'update_p_currency_rate\').innerHTML=$(\'p_currency_rate\').value;"', + Dossier::id(), $select->name, $p_currency_code, $p_currency_rate, $p_eur_amount); + } + else + { + throw new Exception(_("Journal type non déterminé")); + } return $select; } + /** * @brief returns the code iso of the default currency for this ledger */ diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index af6f33e3b..fefced5d6 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -1400,8 +1400,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger $currency_input->id="p_currency_rate"; $currency_input->value=$http->request('p_currency_rate','string',1); $currency_input->javascript='onchange="format_number(this,4);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; - - + + $currency=new Acc_Currency($this->db,0); // // Button for template operation diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index 0640e1009..e55ae9bfc 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -1493,7 +1493,7 @@ EOF; $currency_input->value=$http->request('p_currency_rate','string',1); $currency_input->javascript='onchange="format_number(this,4);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; - + $currency=new Acc_Currency($this->db,0); // // Button for template operation diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index fc02a9e31..91aaae84c 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -1276,7 +1276,11 @@ class Fiche sum_oc_amount as oc_amount, sum_oc_vat_amount as oc_vat_amount from jrnx as j1 left join jrn_def on jrn_def_id=j_jrn_def - left join v_all_card_currency as v1 on (v1.j_id=j1.j_id ) + left join (select j_id, + coalesce(oc_amount,0) as sum_oc_amount , + coalesce(oc_vat_amount,0) as sum_oc_vat_amount + from jrnx left join operation_currency using (j_id) + ) as v1 on (v1.j_id=j1.j_id ) left join jrn on jr_grpt_id=j_grpt". " left join parm_periode on (p_id=jr_tech_per) ". " where j_qcode=$1 and ". diff --git a/include/class/noalyss_parameter_folder.class.php b/include/class/noalyss_parameter_folder.class.php index 31b79b893..4d32dd558 100644 --- a/include/class/noalyss_parameter_folder.class.php +++ b/include/class/noalyss_parameter_folder.class.php @@ -45,6 +45,8 @@ class Noalyss_Parameter_Folder var $MY_ALPHANUM; var $MY_UPDLAB; var $MY_STOCK; + var $MY_DEFAULT_ROUND_ERROR_DEB; + var $MY_DEFAULT_ROUND_ERROR_CRED; // constructor function __construct($p_cn) @@ -124,7 +126,8 @@ class Noalyss_Parameter_Folder $this->save('MY_ALPHANUM'); $this->save('MY_UPDLAB'); $this->save('MY_STOCK'); - $this->save('MY_CURRENCY'); + $this->save('MY_DEFAULT_ROUND_ERROR_DEB'); + $this->save('MY_DEFAULT_ROUND_ERROR_CRED'); } diff --git a/include/operation_ods_confirm.inc.php b/include/operation_ods_confirm.inc.php index 8007ef472..98c3d645d 100644 --- a/include/operation_ods_confirm.inc.php +++ b/include/operation_ods_confirm.inc.php @@ -38,7 +38,7 @@ echo h2(_("Attention, cette opération n'est pas encore sauvée : vous devez enc echo ''; echo '

'; -echo HtmlInput::request_to_hidden(array('ac')); +echo HtmlInput::request_to_hidden(array('ac','p_currency_code','p_currency_rate')); echo $ledger->confirm($_POST,false); diff --git a/include/operation_ods_new.inc.php b/include/operation_ods_new.inc.php index f3dcacdc7..d0263842b 100644 --- a/include/operation_ods_new.inc.php +++ b/include/operation_ods_new.inc.php @@ -74,6 +74,8 @@ echo '' echo dossier::hidden(); echo HtmlInput::request_to_hidden(array('ac','jr_optype')); +$default_currency=new Acc_Currency($cn,0); + echo $ledger->input($p_post); @@ -81,12 +83,24 @@ echo $ledger->input($p_post); echo '
'; echo ''. - ''.td(_('Débit')) . '' . - td(_('Crédit')) . ' ' . - td(_('Difference')) . ' '. + ''.td(''). + td(_('Débit')) . + '' . + td(_('Crédit')) . + ' ' . + td(_('Difference')) . + ' '. + ''; +// For currency +echo ''.td($default_currency->get_code()). + td(_('Débit')) . + '' . + td(_('Crédit')) . + ' ' . + td(). ''; - echo '
'; + echo '
'; $iconcerned=new IConcerned('jrn_concerned'); diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index 6c3543922..b337c9d57 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -67,7 +67,8 @@ input()?> - change()?>EUR + change()?> + get_code();?> From cc5c5abd6e99977530ced6f8bf5105294b3877eb Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 4 Jan 2019 16:44:14 +0100 Subject: [PATCH 18/42] Currency : Precision 6 --- include/class/acc_compute.class.php | 4 ++-- include/class/acc_ledger.class.php | 6 +++--- include/class/acc_ledger_purchase.class.php | 3 ++- include/class/acc_ledger_sold.class.php | 1 + include/lib/manage_table_sql.class.php | 20 +++++++++++++++++++- include/template/form_ledger_detail.php | 2 +- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/include/class/acc_compute.class.php b/include/class/acc_compute.class.php index 49ba34d5c..a6a33d384 100644 --- a/include/class/acc_compute.class.php +++ b/include/class/acc_compute.class.php @@ -89,13 +89,13 @@ class Acc_Compute function convert_euro() { $local_amount=$this->amount; - $this->amount=bcmul($this->amount,$this->currency_rate); + $this->amount=bcmul($this->amount,$this->currency_rate,6); $this->amount_currency=$local_amount; } function convert_euro_vat() { $local_amount=$this->amount_vat; - $this->amount_vat=bcmul($this->amount_vat,$this->currency_rate); + $this->amount_vat=bcmul($this->amount_vat,$this->currency_rate,6); $this->amount_vat_currency=$local_amount; } public function get_parameter($p_string) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 7dfcd0e5d..f128d9968 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -913,12 +913,12 @@ class Acc_Ledger extends jrn_def_sql $currency_select = $this->CurrencyInput("currency_code", "p_currency_rate" , "p_currency_euro"); $currency_select->selected=$http->request('p_currency_code','string',0); - $currency_input=new INum("p_currency_rate",6); + $currency_input=new INum("p_currency_rate"); + $currency_input->prec=6; $currency_input->id="p_currency_rate"; $currency_input->value=$http->request('p_currency_rate','string',1); - $currency_input->javascript='onchange="format_number(this,6);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; $ret.=_("Devise")." ".$currency_select->input(); - $ret.=$currency_input->change(); + $ret.=$currency_input->change('CurrencyComputeMisc(\'p_currency_rate\',\'p_currency_euro\');'); $currency=new Acc_Currency($this->db,0); $ret.=$currency->get_code(); diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index fefced5d6..504cd24bd 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -1397,9 +1397,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger $currency_select->selected=$http->request('p_currency_code','string',0); $currency_input=new INum("p_currency_rate"); + $currency_input->prec=6; $currency_input->id="p_currency_rate"; $currency_input->value=$http->request('p_currency_rate','string',1); - $currency_input->javascript='onchange="format_number(this,4);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; + $currency_input->javascript='onchange="format_number(this,6);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; $currency=new Acc_Currency($this->db,0); diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index e55ae9bfc..ba973c007 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -1490,6 +1490,7 @@ EOF; $currency_input=new INum("p_currency_rate"); $currency_input->id="p_currency_rate"; + $currency_input->prec=6; $currency_input->value=$http->request('p_currency_rate','string',1); $currency_input->javascript='onchange="format_number(this,4);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index 2982c4d94..b642c5dae 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -893,7 +893,7 @@ function check() $text->size=$min_size; echo $text->input(); } - elseif ($this->a_type[$key]=="numeric") + elseif ($this->a_type[$key]=="numeric") // number 2 decimale { $text=new INum($key); $text->value=$value; @@ -901,6 +901,24 @@ function check() $text->size=$min_size; echo $text->input(); } + elseif ($this->a_type[$key]=="numeric4") // number 4 decimale + { + $text=new INum($key); + $text->prec=4; + $text->value=$value; + $min_size=(strlen($value)<10)?10:strlen($value)+1; + $text->size=$min_size; + echo $text->input(); + } + elseif ($this->a_type[$key]=="numeric6") // number 6 decimale + { + $text=new INum($key); + $text->prec=6; + $text->value=$value; + $min_size=(strlen($value)<10)?10:strlen($value)+1; + $text->size=$min_size; + echo $text->input(); + } elseif ($this->a_type[$key]=="date") { $text=new IDate($key); diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index b337c9d57..ab315cf77 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -67,7 +67,7 @@ input()?> - change()?> + change('CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');')?> get_code();?> From 5c40f5f5f035d5d255a7ea829d4a2830bc0ad83e Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 4 Jan 2019 17:11:35 +0100 Subject: [PATCH 19/42] Currency : precision 6, display default currency , protect used currency against delete --- include/class/currency_mtable.class.php | 45 +++++++++++++++++++------ 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/include/class/currency_mtable.class.php b/include/class/currency_mtable.class.php index 89ddf5afc..fa6203e1f 100644 --- a/include/class/currency_mtable.class.php +++ b/include/class/currency_mtable.class.php @@ -29,7 +29,7 @@ require_once NOALYSS_INCLUDE.'/database/currency_history_sql.class.php'; /** * Manage the configuration of currency , add currency, rate, remove and update - * Concerned tables are v_currency_last_value _SQL , Currency_SQL , Currency_History_SQL + * Concerned tables are v_currency_last_value_SQL , Currency_SQL , Currency_History_SQL * currency_id = 0 for the default currency , -1 for a new one */ class Currency_MTable extends Manage_Table_SQL @@ -40,12 +40,12 @@ class Currency_MTable extends Manage_Table_SQL * @param Data $p_table * @example test_currency_mtable.php */ - function __construct(Data_SQL $p_table) + function __construct(V_Currency_Last_Value_SQL $p_table) { parent::__construct($p_table); // If currency , cannot be deleted - if ($this->is_currency_used()==TRUE) + if ($this->is_currency_used($p_table->currency_id)==TRUE) { $this->set_delete_row(FALSE); } @@ -68,11 +68,17 @@ class Currency_MTable extends Manage_Table_SQL /** * returns TRUE the currency is used otherwise FALSE. We cannot delete a currency which is used in a * operation + * @param integer $p_id currency_id * @returns boolean true if currency is used - * @todo Currency_MTable.is_currency_used to implement */ - function is_currency_used() + function is_currency_used($p_id) { + global $cn; + $cnt_used=$cn->get_value(" select count(*) from jrn where currency_id=$1",[$p_id]); + if ($cnt_used > 0) + { + return TRUE; + } return FALSE; } /** @@ -92,7 +98,7 @@ class Currency_MTable extends Manage_Table_SQL currency_id=$1", array($record->currency_id)); $new_rate_date=new IDate("new_rate_date"); $new_rate_value=new INum("new_rate_value"); - $new_rate_value->prec=4; + $new_rate_value->prec=6; if ($record->currency_id!=-1) { require NOALYSS_TEMPLATE."/currency_mtable_input.php"; @@ -286,23 +292,42 @@ class Currency_MTable extends Manage_Table_SQL function from_request() { $http=new HttpInput(); - $this->table->cr_code_iso=mb_strtoupper(strip_tags($http->request("cr_code_iso"))); - $this->table->cr_name=strip_tags($http->request("cr_name")); + $this->table->cr_code_iso=mb_strtoupper($http->request("cr_code_iso")); + $this->table->cr_name=$http->request("cr_name"); $this->table->currency_id=$http->request("p_id", "number"); $this->table->ch_value=$http->request("new_rate_value"); $this->table->str_from=$http->request("new_rate_date"); } /** - * We don't display the default currency (id := -1) + * + * We cannot modify the default currency (id := 0) */ function display_row($p_row) { if ($p_row['currency_id']==0) { + $this->set_update_row(FALSE); + $this->set_delete_row(FALSE); + parent::display_row($p_row); return; } + if ($this->is_currency_used($p_row['currency_id'])==TRUE) + { + $this->set_delete_row(FALSE); + } else { + $this->set_delete_row(TRUE); + + } + $this->set_update_row(TRUE); parent::display_row($p_row); } - + /** + * Delete after checking the currency is not used + */ + function delete() + { + $id=$this->get_table()->currency_id; + if ( $this->is_currency_used($id) == FALSE) $this->table->delete(); + } } From 3d45f187a63a2c3b6b40f3b0a809b527f032c6f3 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 4 Jan 2019 17:33:09 +0100 Subject: [PATCH 20/42] Currency : meaning 1 EUR is worth x currency for Sales --- html/js/acc_currency.js | 6 +++--- include/class/acc_ledger_sold.class.php | 11 ++++++----- include/class/anc_operation.class.php | 2 +- include/template/form_ledger_detail.php | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/html/js/acc_currency.js b/html/js/acc_currency.js index 0fb6fdf71..fdf49ab2a 100644 --- a/html/js/acc_currency.js +++ b/html/js/acc_currency.js @@ -115,7 +115,7 @@ function CurrencyCompute(p_rate,p_update) console.log("rate is nan" + rate); rate=1; } - var tot=tvac*rate; + var tot=tvac/rate; tot=Math.round(tot*100)/100; $(p_update).innerHTML=tot; @@ -148,11 +148,11 @@ function CurrencyComputeMisc(p_rate,p_update) console.log("rate is nan" + rate); rate=1; } - var totDeb=debAmount*rate; + var totDeb=debAmount/rate; totDeb=Math.round(totDeb*100)/100; $('default_currency_deb').innerHTML=totDeb; - var totCred=credAmount*rate; + var totCred=credAmount/rate; totCred=Math.round(totCred*100)/100; $('default_currency_cred').innerHTML=totCred; diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index ba973c007..0714584f4 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -309,7 +309,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $amount_currency = bcmul(${'e_march' . $i . '_price'}, ${'e_quant' . $i}); // convert amount to currency - $amount=bcmul($amount_currency,$p_currency_rate); + $amount=bcdiv($amount_currency,$p_currency_rate); $tot_amount = bcadd($tot_amount, $amount); $tot_amount = round($tot_amount, 2); @@ -363,7 +363,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $l->load(); $tva_item_currency = bcmul($amount, $l->get_parameter('rate')); } - $tva_item=bcmul($tva_item_currency,$p_currency_rate); + $tva_item=bcdiv($tva_item_currency,$p_currency_rate); $tva_item=round($tva_item,2); if (isset($tva[$idx_tva])) { @@ -413,7 +413,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $op->save_form_plan($_POST, $i, $j_id); } - $price_euro=bcmul(${'e_march'.$i.'_price'}, $p_currency_rate); + $price_euro=bcdiv(${'e_march'.$i.'_price'}, $p_currency_rate); if ($g_parameter->MY_TVA_USE == 'Y') { /* save into quant_sold */ $r = $this->db->exec_sql("select insert_quant_sold ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)", array(null, /* 1 */ @@ -942,12 +942,13 @@ class Acc_Ledger_Sold extends Acc_Ledger { // Add the sum $decalage=($g_parameter->MY_TVA_USE == 'Y')?'':''; $tot = bcadd($tot_amount, $tot_tva, 2); - $tot_eur=round(bcmul($tot, $p_currency_rate),2); + $tot_eur=round(bcdiv($tot, $p_currency_rate),2); $tot=nbm($tot); $str_tot=_('Totaux'); // Get currency code - $str_code='EUR'; + $default_currency=new Acc_Currency($this->db,0); + $str_code=$default_currency->get_code(); if ( $p_currency_code != 0 ) { $acc_currency=new Acc_Currency($this->db); $acc_currency->set_id($p_currency_code); diff --git a/include/class/anc_operation.class.php b/include/class/anc_operation.class.php index 13445271f..aa3b19d3b 100644 --- a/include/class/anc_operation.class.php +++ b/include/class/anc_operation.class.php @@ -799,7 +799,7 @@ class Anc_Operation $op->oa_group=$this->oa_group; $op->j_id=$p_j_id; // convert oa_amount to EUR - $op->oa_amount=bcmul($val[$p_item][$row],$this->currency_rate); + $op->oa_amount=bcdiv($val[$p_item][$row],$this->currency_rate); $op->oa_debit=$this->oa_debit; $op->oa_date=$this->oa_date; diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index ab315cf77..9f2bd1ff3 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -68,7 +68,7 @@ input()?> change('CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');')?> - get_code();?> + get_code();?> From c953d43fd2b5a082e28b334c7697ea4c7c108e1d Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 5 Jan 2019 11:37:03 +0100 Subject: [PATCH 21/42] Currency : the meaning is : 1 euro is worth xxx Currency , so we divide the amount with the currency rate to compute the EUR value --- html/js/acc_ledger.js | 6 +++--- include/class/acc_compute.class.php | 4 ++-- include/class/acc_ledger.class.php | 2 +- include/class/acc_ledger_fin.class.php | 4 ++-- include/class/acc_ledger_purchase.class.php | 11 ++++++----- include/class/acc_ledger_sold.class.php | 8 ++++---- include/template/form_ledger_detail.php | 1 - 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index e488708d4..e51e7cce6 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -490,8 +490,8 @@ function success_compute_ledger(request, json) g('htva_march' + ctl).value = rhtva; g('tvac_march' + ctl).value = rtvac; g('sum').show(); - CurrencyCompute('p_currency_rate','p_currency_euro'); refresh_ledger(); + CurrencyCompute('p_currency_rate','p_currency_euro'); return; } @@ -500,7 +500,6 @@ function success_compute_ledger(request, json) g('sum').show(); - CurrencyCompute('p_currency_rate','p_currency_euro'); if (g('e_march' + ctl + '_tva_amount').value == "" || g('e_march' + ctl + '_tva_amount').value == 0) { g('tva_march' + ctl).value = rtva; @@ -514,8 +513,9 @@ function success_compute_ledger(request, json) var tmp1 = Math.round(parseFloat(g('htva_march' + ctl).value) * 100) / 100; var tmp2 = Math.round(parseFloat(g('tva_march' + ctl).value) * 100) / 100; g('tvac_march' + ctl).value = Math.round((tmp1 + tmp2) * 100) / 100; - refresh_ledger(); + CurrencyCompute('p_currency_rate','p_currency_euro'); + } /** diff --git a/include/class/acc_compute.class.php b/include/class/acc_compute.class.php index a6a33d384..d9c8e0df6 100644 --- a/include/class/acc_compute.class.php +++ b/include/class/acc_compute.class.php @@ -89,13 +89,13 @@ class Acc_Compute function convert_euro() { $local_amount=$this->amount; - $this->amount=bcmul($this->amount,$this->currency_rate,6); + $this->amount=bcdiv($this->amount,$this->currency_rate,6); $this->amount_currency=$local_amount; } function convert_euro_vat() { $local_amount=$this->amount_vat; - $this->amount_vat=bcmul($this->amount_vat,$this->currency_rate,6); + $this->amount_vat=bcdiv($this->amount_vat,$this->currency_rate,6); $this->amount_vat_currency=$local_amount; } public function get_parameter($p_string) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index f128d9968..13f69dd18 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -920,7 +920,6 @@ class Acc_Ledger extends jrn_def_sql $ret.=_("Devise")." ".$currency_select->input(); $ret.=$currency_input->change('CurrencyComputeMisc(\'p_currency_rate\',\'p_currency_euro\');'); $currency=new Acc_Currency($this->db,0); - $ret.=$currency->get_code(); $nb_row=(isset($nb_item) )?$nb_item:$this->nb; @@ -1389,6 +1388,7 @@ class Acc_Ledger extends jrn_def_sql // for each item, insert into operation_analytique */ $op=new Anc_Operation($this->db); + $op->set_currency_rate($currency_rate); $op->oa_group=$group; $op->j_id=$j_id; $op->oa_date=$e_date; diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index 9d7b682ab..a27e22204 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -647,7 +647,7 @@ class Acc_Ledger_Fin extends Acc_Ledger $r.='
'.sprintf(_("Taux = %s"),$cur_rate); - $r.='
'.sprintf(_("Nouveau solde = %f %s"),bcmul($new_solde,$cur_rate),$default_currency->get_code()); + $r.='
'.sprintf(_("Nouveau solde = %f %s"),bcdiv($new_solde,$cur_rate),$default_currency->get_code()); } else { $cur=$acc_currency->get_code(); @@ -803,7 +803,7 @@ class Acc_Ledger_Fin extends Acc_Ledger // convert to EUR if needed and round it $amount_input=${"e_other$i" . "_amount"} = round(${"e_other$i" . "_amount"}, 2); - $amount_eur=bcmul($amount_input,$currency_rate); + $amount_eur=bcdiv($amount_input,$currency_rate); diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 504cd24bd..90911debd 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -706,7 +706,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger } // insert into quant_purchase //----- - $price_euro=bcmul(${'e_march'.$i.'_price'}, $p_currency_rate); + $price_euro=bcdiv(${'e_march'.$i.'_price'}, $p_currency_rate); if ( $g_parameter->MY_TVA_USE=='Y') { @@ -933,7 +933,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $cust_amount=bcsub($cust_amount, $tot_tva_reversed); // Convert paid amount in EUR - $acompte=bcmul($acompte, $p_currency_rate); + $acompte=bcdiv($acompte, $p_currency_rate); $famount=bcsub($cust_amount,$acompte); @@ -1686,10 +1686,11 @@ class Acc_Ledger_Purchase extends Acc_Ledger $decalage=($g_parameter->MY_TVA_USE == 'Y')?'':''; $tot = round(bcadd($tot_amount, $tot_tva), 2); $str_tot=_('Totaux'); - $tot_eur=round(bcmul($tot, $p_currency_rate),2); + $tot_eur=round(bcdiv($tot, $p_currency_rate),2); - // Get currency code - $str_code='EUR'; + // Get currency code + $default_currency=new Acc_Currency($this->db,0); + $str_code=$default_currency->get_code(); if ( $p_currency_code != 0 ) { $acc_currency=new Acc_Currency($this->db); $acc_currency->set_id($p_currency_code); diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index 0714584f4..ba65074ec 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -619,7 +619,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $poste_val = $sposte; } // Convert paid amount in EUR - $acompte_eur=bcmul($acompte, $p_currency_rate); + $acompte_eur=bcdiv($acompte, $p_currency_rate); $famount=bcsub($cust_amount,$acompte_eur); $acc_pay->poste = $poste_val; @@ -1449,7 +1449,7 @@ EOF; $Price = new INum(); $Price->setReadOnly(false); $Price->size = 9; - $Price->javascript = "onBlur='format_number(this,4);clean_tva($i);compute_ledger($i)'"; + $Price->javascript = "onBlur=\"format_number(this,4);clean_tva($i);compute_ledger($i);\""; $array[$i]['pu'] = $Price->input("e_march" . $i . "_price", $march_price); $array[$i]['tva'] = ''; $array[$i]['amount_tva'] = ''; @@ -1462,7 +1462,7 @@ EOF; $Tva->set_attribute('compute', $i); $Tva->set_filter("sale"); - $Tva->js = 'onblur="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . ')"'; + $Tva->js = 'onblur="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . ');"'; $Tva->value = $march_tva_id; $array[$i]['tva'] = $Tva->input("e_march$i" . "_tva_id"); // vat amount @@ -1480,7 +1480,7 @@ EOF; $Quantity = new INum(); $Quantity->setReadOnly(false); $Quantity->size = 8; - $Quantity->javascript = "onChange='format_number(this);clean_tva($i);compute_ledger($i)'"; + $Quantity->javascript = "onChange=\"format_number(this);clean_tva($i);compute_ledger($i);\""; $array[$i]['quantity'] = $Quantity->input("e_quant" . $i, $quant); }// foreach article $f_type = _('Client'); diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index 9f2bd1ff3..c2df339c2 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -68,7 +68,6 @@ input()?> change('CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');')?> - get_code();?> From d4d72149c3076b2a870563874d7f358af01cf348 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 6 Jan 2019 13:08:17 +0100 Subject: [PATCH 22/42] Currency : history for accounting , correct amount in currency --- include/class/acc_account_ledger.class.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/include/class/acc_account_ledger.class.php b/include/class/acc_account_ledger.class.php index 640a4b1d8..b381a9f0e 100644 --- a/include/class/acc_account_ledger.class.php +++ b/include/class/acc_account_ledger.class.php @@ -190,10 +190,10 @@ class Acc_Account_Ledger ,jrn.currency_id ,(select cr_code_iso from currency where id=jrn.currency_id) as cr_code_iso ,j_montant - ,sum_oc_amount as oc_amount - ,sum_oc_vat_amount as oc_vat_amount + ,oc_amount + ,oc_vat_amount from jrnx as j1 - left join v_all_account_currency as va on (j1.j_id = va.j_id and j1.j_poste=va.j_poste) + left join operation_currency as va on (j1.j_id = va.j_id ) join jrn_def on (jrn_def_id=j_jrn_def ) join jrn on (jr_grpt_id=j_grpt) join tmp_pcmn on (j1.j_poste=pcm_val) @@ -407,7 +407,7 @@ class Acc_Account_Ledger ""._('Description')."". ""._('Type')."". ""._('ISO')."". - ""._('Dev.')."". + ""._('Dev.')."". ""._('Débit')."". ""._("Crédit")."". th('Prog.','style="text-align:right"'). @@ -464,8 +464,8 @@ class Acc_Account_Ledger $side=" ".$this->get_amount_side($progress); $sum_cred=bcadd($sum_cred,$op['cred_montant']); $sum_deb=bcadd($sum_deb,$op['deb_montant']); - if ($idx%2 == 0) $class='class="odd"'; else $class=' class="even"'; - $idx++; + $class=($idx%2 == 0)?'class="odd"':$class=' class="even"'; + $idx++; echo "" . "".smaller_date(format_date($op['j_date']))."". @@ -476,10 +476,13 @@ class Acc_Account_Ledger "".h($op['description'])."". td($op['jr_optype']); /// If the currency is not the default one , then show the amount - if ( $op['currency_id'] > 0 && $op['oc_amount'] != 0) + if ( $op['currency_id'] > 0 ) { - echo td($op['cr_code_iso']). - td(nbm($op['oc_amount'],4),'style="text-align:right;padding-left:10px;"'); + // some amount are not directly recorded into operation_currency, like VAT + $currency_val=($op['oc_amount'] == 0)?round(bcmul ($op['j_montant'],$op['currency_rate']),2):$op['oc_amount'] ; + + echo td($op['cr_code_iso']). + td(nbm($currency_val,2),'style="text-align:right;padding-left:10px;"'); } else { echo td().td(); } From 4e1d598870ae68b4650363e1b8b0098b6cc4f291 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 6 Jan 2019 13:09:29 +0100 Subject: [PATCH 23/42] Currency : detail operation Purchase , the amount in currency were wrong in the summary --- include/template/ledger_detail_ach.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/template/ledger_detail_ach.php b/include/template/ledger_detail_ach.php index 176c5717d..1cf72cf81 100644 --- a/include/template/ledger_detail_ach.php +++ b/include/template/ledger_detail_ach.php @@ -164,6 +164,7 @@ $str_anc=""; } echo ''; + $sum_charge_euro=0; for ($e = 0; $e < count($obj->det->array); $e++) { $row = ''; @@ -251,7 +252,8 @@ $str_anc=""; */ if ( $obj->det->currency_id != 0 ) { $value=$obj->db->get_value("select oc_amount+oc_vat_amount from operation_currency where j_id=$1",[$q['j_id']]); - $row.=td(nbm($value,4),' class="num"'); + $row.=td(nbm($value,2),' class="num"'); + $sum_charge_euro=bcadd($sum_charge_euro,$value,2); } echo tr($row,$class); @@ -268,7 +270,7 @@ $str_anc=""; if ( $obj->det->currency_id != "" && $obj->det->currency_id > 0) { $currency=new Acc_Currency($obj->db, $obj->det->currency_id); - $row.= td(nbm($currency->sum_amount($obj->jr_id),4),' class="num" style="font-style:italic;font-weight: bolder;"'); + $row.= td(nbm($sum_charge_euro),' class="num" style="font-style:italic;font-weight: bolder;"'); } echo tr($row); @@ -287,7 +289,7 @@ $str_anc=""; echo $currency->get_code(),$four_space; echo _("Taux utilisé")," ", $obj->det->currency_rate,$four_space; echo _("Taux Réf"), " ",$obj->det->currency_rate_ref.$four_space; - echo _("Montant en devise"), " ",$currency->sum_amount($obj->jr_id).$four_space; + echo _("Montant en devise"), " ",nbm($sum_charge_euro).$four_space; } ?> From cf6a135a0852da14b2b42aefb23fb60a625d3704 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 6 Jan 2019 15:10:08 +0100 Subject: [PATCH 24/42] remove commented code --- html/js/anc_script.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/html/js/anc_script.js b/html/js/anc_script.js index 50d255705..97e524de2 100644 --- a/html/js/anc_script.js +++ b/html/js/anc_script.js @@ -108,8 +108,6 @@ function anc_refresh_remain(p_table, p_seq) var tot_table = compute_total_table(p_table, p_seq); var remain = tot_line - tot_table; remain = Math.round(remain * 100) / 100; - // var popup_table = p_table.toString(); -// p_table = popup_table.replace("popup", ""); $('remain' + p_table).innerHTML = remain; if (remain == 0) { From 2601b09570195d2643ed6c0b90acd62fafb0bcb4 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 6 Jan 2019 15:22:36 +0100 Subject: [PATCH 25/42] Currency : purchase, save all detail also in currency, fix problem with the advance payment --- include/class/acc_ledger_purchase.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 90911debd..f93bbae98 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -788,7 +788,14 @@ class Acc_Ledger_Purchase extends Acc_Ledger } $let_client=$acc_operation->insert_jrnx(); - + // --- insert also the currency amount for the customer + $operation_currency=new Operation_currency_SQL($this->db); + $operation_currency->oc_amount=$tot_amount_cur; + $operation_currency->oc_vat_amount=0; + $operation_currency->oc_price_unit=0; + $operation_currency->j_id=$let_client ; + $operation_currency->insert(); + if ( $g_parameter->MY_TVA_USE=='Y') { /* save all vat @@ -933,9 +940,9 @@ class Acc_Ledger_Purchase extends Acc_Ledger $cust_amount=bcsub($cust_amount, $tot_tva_reversed); // Convert paid amount in EUR - $acompte=bcdiv($acompte, $p_currency_rate); + $acompte_defcur=bcdiv($acompte, $p_currency_rate); - $famount=bcsub($cust_amount,$acompte); + $famount=bcsub($cust_amount,$acompte_defcur); $acc_pay->poste=$poste_val; $acc_pay->qcode=$fqcode; From 0395ed1d66431f239836acefa49b562776a851a1 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 6 Jan 2019 21:10:43 +0100 Subject: [PATCH 26/42] Currency : detail operation Sale , the amount in currency were wrong in the summary --- include/template/ledger_detail_ven.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/template/ledger_detail_ven.php b/include/template/ledger_detail_ven.php index 6ff97197a..fb37c8e5d 100644 --- a/include/template/ledger_detail_ven.php +++ b/include/template/ledger_detail_ven.php @@ -122,6 +122,7 @@ echo $ipaid->input(); bcscale(2); $total_htva = 0; $total_tvac = 0; + $sum_prod_currency=0; echo th(_('Quick Code')); echo th(_('Description')); echo th(_('Prix/Un'), 'style="text-align:right"'); @@ -256,7 +257,8 @@ echo $ipaid->input(); */ if ( $obj->det->currency_id != 0 ) { $value=$obj->db->get_value("select oc_amount+oc_vat_amount from operation_currency where j_id=$1",[$q['j_id']]); - $row.=td(nbm($value,4),' class="num"'); + $sum_prod_currency=bcadd($sum_prod_currency,$value,2); + $row.=td(nbm($value,2),' class="num"'); } echo tr($row,$class); @@ -273,8 +275,7 @@ echo $ipaid->input(); //Display total in currency if ( $obj->det->currency_id != "" && $obj->det->currency_id > 0) { - $currency=new Acc_Currency($obj->db, $obj->det->currency_id); - $row.= td(nbm($currency->sum_amount($obj->jr_id),4),' class="num" style="font-style:italic;font-weight: bolder;"'); + $row.= td(nbm($sum_prod_currency,2),' class="num" style="font-style:italic;font-weight: bolder;"'); } echo tr($row); ?> @@ -298,7 +299,7 @@ echo $ipaid->input(); echo $currency->get_code(),$four_space; echo _("Taux utilisé")," ", $obj->det->currency_rate,$four_space; echo _("Taux Réf"), " ",$obj->det->currency_rate_ref.$four_space; - echo _("Montant en devise"), " ",$currency->sum_amount($obj->jr_id).$four_space; + echo _("Montant en devise"), " ",$sum_prod_currency,$four_space; } ?> Date: Mon, 7 Jan 2019 13:12:49 +0100 Subject: [PATCH 27/42] Task #1660 : place the button for the inventory on the top --- include/template/stock_inv.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/template/stock_inv.php b/include/template/stock_inv.php index 2c1bdea34..556dcc66c 100644 --- a/include/template/stock_inv.php +++ b/include/template/stock_inv.php @@ -27,6 +27,8 @@ * */ ?> + +
" class="content"> ')"> @@ -104,7 +106,6 @@ -
'; diff --git a/include/lib/iconcerned.class.php b/include/lib/iconcerned.class.php index c296804d2..d43fa3e4c 100644 --- a/include/lib/iconcerned.class.php +++ b/include/lib/iconcerned.class.php @@ -28,6 +28,7 @@ require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; class IConcerned extends HtmlInput { + private $hideOperation; //!< string of j_id to hide, separated by comma to avoid to reconcile an operation with itself public function __construct($p_name='',$p_value='',$p_id="") { @@ -36,8 +37,9 @@ class IConcerned extends HtmlInput $this->amount_id=null; $this->paid=''; $this->id=$p_id; - $this->tiers=""; // id of the field for the tiers to be updated - $this->div=""; // Dom Element to show the search result + $this->tiers=""; // id of the field for the tiers to be updated + $this->div=""; // Dom Element to show the search result + $this->hideOperation=""; // string of j_id to hide, separated by comma to avoid to reconcile an operation with itself } /*!\brief show the html input of the widget*/ public function input($p_name=null,$p_value=null) @@ -55,17 +57,27 @@ class IConcerned extends HtmlInput $this->tiers ); $r=Icon_Action::icon_magnifier(uniqid(), $javascript); $r.=sprintf(" - + ", $this->name, $this->id, $this->value, + $this->hideOperation, $this->id ); return $r; } + + /** + * setter + * @param $p_string + */ + function set_hideOperation($p_string) + { + $this->hideOperation=strip_tags($p_string); + } /*!\brief print in html the readonly value of the widget*/ public function display() { diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index 91b4f7c9c..85c93f19e 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -26,9 +26,9 @@ $aRap=$oRap->get(); // find out exercice $periode_id=new Periode($cn,$detail->det->jr_tech_per); $exercice=$periode_id->get_exercice(); - - - $nb_document=($detail->det->jr_pj_name != "")?1:0; + + +$nb_document=($detail->det->jr_pj_name != "")?1:0; $nb_aRap=(is_array($aRap))?count($aRap):0; // Array of tab @@ -225,6 +225,7 @@ if ( $access=='W') { $wConcerned=new IConcerned("rapt".$div); $wConcerned->amount_id=$obj->det->jr_montant; $wConcerned->div="search_reconcile"; + $wConcerned->set_hideOperation( $obj->jr_id); echo $wConcerned->input(); } From 6a6322bd438cadfe059ef7d9898cf8b72bfbae69 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 9 Jan 2019 09:26:14 +0100 Subject: [PATCH 32/42] Currency : because of Misc Operation, the tiers must also be saved into operation_currency. Fix also PRINTJRN for currency --- include/class/acc_ledger.class.php | 6 ++++-- include/class/acc_ledger_fin.class.php | 18 +++++++++++++----- include/class/acc_ledger_sold.class.php | 12 ++++++++++-- include/class/print_ledger_fin.class.php | 20 ++++++++++---------- include/class/print_ledger_misc.class.php | 2 +- include/database/jrn_def_sql.class.php | 1 + include/template/ledger_detail_fin.php | 2 +- 7 files changed, 40 insertions(+), 21 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 13f69dd18..744911e8e 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1927,8 +1927,10 @@ class Acc_Ledger extends jrn_def_sql "jr_pj_number as pj,jr_grpt_id,". " to_char(jr_date,'DDMMYY') as date_fmt, ". " jr_comment as comment, jr_montant as montant ,". - " jr_grpt_id,jr_def_id". - " from jrn join jrn_def on (jr_def_id=jrn_def_id) where ". + " jr_grpt_id,jr_def_id,jrn.currency_id,currency_rate,currency_rate_ref,cr_code_iso ". + " from jrn join jrn_def on (jr_def_id=jrn_def_id) ". + " left join currency on (currency.id=jrn.currency_id) ". + " where ". " jr_date >= (select p_start from parm_periode where p_id = $1) and jr_date <= (select p_end from parm_periode where p_id = $2)". ' '.$jrn.' order by jr_date,substring(jr_pj_number,\'[0-9]+$\')::numeric asc'; diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index a27e22204..df743a42e 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -852,7 +852,7 @@ class Acc_Ledger_Fin extends Acc_Ledger $operation_currency = new Operation_currency_SQL($this->db); $operation_currency->oc_amount=$amount_input; $operation_currency->oc_vat_amount=0; - $operation_currency->oc_price_unit=$amount_input; + $operation_currency->oc_price_unit=0; $operation_currency->j_id=$j_id_currency; $operation_currency->insert(); @@ -883,18 +883,26 @@ class Acc_Ledger_Fin extends Acc_Ledger $acc_operation->qcode = $e_bank_account; $j_id=$acc_operation->insert_jrnx(); - + // -- Insert into Operation Currency + $operation_currency = new Operation_currency_SQL($this->db); + $operation_currency->oc_amount=$amount_input; + $operation_currency->oc_vat_amount=0; + $operation_currency->oc_price_unit=0; + $operation_currency->j_id=$j_id; + $operation_currency->insert(); if (sql_string(${"e_other$i" . "_comment"}) == null) { // if comment is blank set a default one - $comment = " compte : " . $fBank->strAttribut(ATTR_DEF_NAME) . ' a ' . - $fPoste->strAttribut(ATTR_DEF_NAME); + $comment = sprintf(_(" compte : %s a %s "), + $fBank->strAttribut(ATTR_DEF_NAME), + $fPoste->strAttribut(ATTR_DEF_NAME) + ); } else { - $comment = ${'e_other' . $i . '_comment'}; + $comment =strip_tags(${'e_other' . $i . '_comment'}); } diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index ba65074ec..cf76ce982 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -478,8 +478,16 @@ class Acc_Ledger_Sold extends Acc_Ledger { $tot_debit=round($tot_debit, 2); } $let_tiers = $acc_operation->insert_jrnx(); - - + + // --- insert also the currency amount for the customer + $operation_currency=new Operation_currency_SQL($this->db); + $operation_currency->oc_amount=$tot_amount_cur; + $operation_currency->oc_vat_amount=0; + $operation_currency->oc_price_unit=0; + $operation_currency->j_id=$let_tiers ; + $operation_currency->insert(); + + /** save all vat * $i contains the tva_id and value contains the vat amount * if if ($g_parameter->MY_TVA_USE == 'Y' ) diff --git a/include/class/print_ledger_fin.class.php b/include/class/print_ledger_fin.class.php index 1f3b82b0d..931da51a2 100644 --- a/include/class/print_ledger_fin.class.php +++ b/include/class/print_ledger_fin.class.php @@ -100,12 +100,10 @@ class Print_Ledger_Financial extends PDF if ( $a_jrn == null ) return; bcscale(2); $this->ledger->load(); - $currency=$this->ledger->get_currency()->get_code(); - $currency_id=$this->ledger->get_currency()->get_id(); + $this->cn->prepare("amount_cur", "select jrn2.jr_id , - sum(coalesce(oc_amount,0)) as sum_ocamount, - sum(coalesce(oc_vat_amount,0)) as sum_ocvat_amount + sum(coalesce(oc_amount,0)) as sum_ocamount from operation_currency join jrnx using (j_id) join jrn as jrn2 on (j_grpt=jrn2.jr_grpt_Id) @@ -126,13 +124,15 @@ class Print_Ledger_Financial extends PDF $this->LongLine(60,5,$row['comment'],0,'L'); $amount=$this->cn->get_value('select qf_amount from quant_fin where jr_id=$1',array( $row['id'])); - if ( $currency_id != 0) { - $ret_amount_cur=$this->cn->execute("amount_cur",array($row['id'])); + $ret_amount_cur=$this->cn->execute("amount_cur",array($row['id'])); + + if ( $this->cn->count($ret_amount_cur) == 1) { - if ( $this->cn->count($ret_amount_cur) == 1) { - $amount_cur=Database::fetch_result($ret_amount_cur, 0,1); - $this->write_cell(20,5,sprintf('%s %s',nbm($amount_cur),$currency),0,0,'R'); - } + $amount_cur=Database::fetch_result($ret_amount_cur, 0,1); + $this->write_cell(20,5,sprintf('%s %s',nbm($amount_cur),$row['cr_code_iso']),0,0,'R'); + } else { + + $this->write_cell(20,5,"",0,0,'R'); } $this->write_cell(20,5,sprintf('%s',nbm($amount)),0,0,'R'); $this->line_new(5); diff --git a/include/class/print_ledger_misc.class.php b/include/class/print_ledger_misc.class.php index ece4cc653..6773b7417 100644 --- a/include/class/print_ledger_misc.class.php +++ b/include/class/print_ledger_misc.class.php @@ -93,7 +93,7 @@ class Print_Ledger_Misc extends PDF $positive = $this->cn->get_value("select qf_amount from quant_fin ". " where jr_id=".$row['jr_id']); } - $this->write_cell(20,5,nbm(bcadd($row['sum_ocvat_amount'],$row['sum_ocamount']),4).$row['cr_code_iso'],0,0,'R'); + $this->write_cell(20,5,nbm(bcadd($row['sum_ocvat_amount'],$row['sum_ocamount']),2).$row['cr_code_iso'],0,0,'R'); $this->write_cell(15,5,nbm($positive),0,0,'R'); $this->line_new(5); diff --git a/include/database/jrn_def_sql.class.php b/include/database/jrn_def_sql.class.php index 818248f6d..3f77f534b 100644 --- a/include/database/jrn_def_sql.class.php +++ b/include/database/jrn_def_sql.class.php @@ -55,6 +55,7 @@ class Jrn_Def_sql , "jrn_def_bank" => "jrn_def_bank" , "jrn_def_num_op" => "jrn_def_num_op" , "jrn_def_description" => "jrn_def_description" + , "jrn_enable"=>"jrn_enable" , "currency_id"=>"currency_id" ); diff --git a/include/template/ledger_detail_fin.php b/include/template/ledger_detail_fin.php index 57f7d42be..7025651aa 100644 --- a/include/template/ledger_detail_fin.php +++ b/include/template/ledger_detail_fin.php @@ -103,7 +103,7 @@ if ($obj->det->currency_id!=0) [$obj->det->array[0]['j_id']]); $currency_rate=$obj->db->get_value("select currency_rate from jrn where jr_id=$1",[$obj->jr_id]); $currency_code=$obj->db->get_value("select cr_code_iso from currency where id=$1",[$obj->det->currency_id]); - printf ("%s Taux utilisé %s Montant en devise %s",$currency_code,$currency_rate,$currency_amount); + printf (_("%s Taux utilisé %s Montant en devise %s"),$currency_code,$currency_rate,$currency_amount); } ?>
From 57bb44c85fffab96fac0f0432432adf7a244570a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 Jan 2019 13:39:48 +0100 Subject: [PATCH 33/42] Protect parameters --- html/fid_card.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/html/fid_card.php b/html/fid_card.php index 1ee5d07ac..57577bb18 100644 --- a/html/fid_card.php +++ b/html/fid_card.php @@ -27,6 +27,7 @@ require_once '../include/constant.php'; require_once NOALYSS_INCLUDE.'/lib/database.class.php'; +require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; /*!\brief * Received parameters are @@ -41,11 +42,12 @@ require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; * - list of fd_id * */ +$http=new HttpInput(); -$jrn= ( ! isset($_REQUEST['j']))?-1:$_REQUEST['j']; +$jrn= $http->request("j","number",-1); $filter_card=""; $cn=Dossier::connect(); -$d=$_REQUEST['e']; +$d=$http->request('e'); $filter_card=''; require_once('class/user.class.php'); @@ -107,8 +109,8 @@ else { $get_cred='jrn_def_fiche_cred'; $get_deb='jrn_def_fiche_deb'; - - $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_type=$1",array($_REQUEST['type'])); + $type=$http->request("type"); + $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_type=$1",array($type)); $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; } @@ -125,9 +127,12 @@ else $sql_str="select distinct f_id from fiche join fiche_detail using (f_id) where ad_id in (9,1,23) and ad_value ilike '%'||$1||'%' ".$filter_card.' limit 12'; -$sql=$cn->get_array($sql_str ,array($_REQUEST['FID'])); -if (sizeof($sql) != 0 ) +$fid=$http->request("FID"); + +$sql=$cn->get_array($sql_str ,array($fid)); + +if ($sql != false && sizeof($sql) != 0 ) { echo "
    "; $sql_get=$cn->prepare('get_name',"select ad_value from fiche_detail where f_id = $1 and ad_id=$2"); @@ -146,12 +151,12 @@ if (sizeof($sql) != 0 ) $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],23)); if (Database::num_row($sql_name) == 1) $quick_code=Database::fetch_result($sql_name,0,0); - $fid=htmlentities($_REQUEST['FID']); + $fid=htmlentities($fid); /* Highlight the found pattern with bold format */ - $name=str_ireplace($_REQUEST['FID'],''.$fid.'',h($name)); - $qcode=str_ireplace($_REQUEST['FID'],''.$fid.'',h($quick_code)); - $desc=str_ireplace($_REQUEST['FID'],''.$fid.'',h($desc)); + $name=str_ireplace($fid,''.$fid.'',h($name)); + $qcode=str_ireplace($fid,''.$fid.'',h($quick_code)); + $desc=str_ireplace($fid,''.$fid.'',h($desc)); printf('
  • %s %s %s
  • ', $quick_code, $quick_code, From 46b4cdf0aac472f5ebe355e34077460d1181a3c5 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 Jan 2019 13:40:12 +0100 Subject: [PATCH 34/42] PHP 7.2 incomptability : sizeof of not array --- include/class/follow_up.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index 471b7ebd0..39d9a004f 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -769,7 +769,7 @@ class Follow_Up // if there are no records return a message - if (sizeof($a_row)==0 or $a_row==false) + if ($a_row==false || sizeof($a_row)==0 ) { $r='
    '; $r.='
    Aucun enregistrement trouvé'; From 588442f9336997e9ff61f0dca9394c5fb7c146e1 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 Jan 2019 13:44:37 +0100 Subject: [PATCH 35/42] Currency - fix view --- include/sql/patch/upgrade131.sql | 4 +++- sql/upgrade.sql | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/sql/patch/upgrade131.sql b/include/sql/patch/upgrade131.sql index 17dd1c86f..9a004b575 100644 --- a/include/sql/patch/upgrade131.sql +++ b/include/sql/patch/upgrade131.sql @@ -1,6 +1,6 @@ begin; -drop VIEW public.v_detail_sale; +drop VIEW if exists public.v_detail_sale; CREATE OR REPLACE VIEW public.v_detail_sale as WITH m AS ( @@ -145,6 +145,8 @@ join operation_currency as oc on (oc.j_id=q1.j_id) group by x.j_poste,x.j_id ; +drop view if exists v_all_card_currency; + create or replace view v_all_card_currency as select sum(oc_amount) as sum_oc_amount,sum(oc_vat_amount) as sum_oc_vat_amount,x.f_id,x.j_id from diff --git a/sql/upgrade.sql b/sql/upgrade.sql index e69de29bb..e8af5a3d7 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -0,0 +1,13 @@ +begin; +insert into "parameter" (pr_id ) values ('MY_DEFAULT_ROUND_ERROR_DEB'); +insert into "parameter" (pr_id ) values ('MY_DEFAULT_ROUND_ERROR_CRED'); +drop view if exists v_all_card_currency; + +create or replace view v_all_card_currency as +select sum(oc_amount) as sum_oc_amount,sum(oc_vat_amount) as sum_oc_vat_amount,f_id,j_id +from +operation_currency +join jrnx using (j_id) +group by f_id,j_id; + +commit ; \ No newline at end of file From d6b736ad7f13992c666171e8f97c61ea783c7ddf Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 Jan 2019 14:33:48 +0100 Subject: [PATCH 36/42] PHP 7.2 mistyped command --- include/class/acc_ledger.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 744911e8e..c195fb90c 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1231,7 +1231,7 @@ class Acc_Ledger extends jrn_def_sql } $account=new Acc_Account($this->db,${"poste".$i}); if ( $account->get_parameter("pcm_direct_use") == "N") { - throw new Exception(sprinff (_("Utilisation directe interdite du poste comptable %s"), ${"poste".$i})); + throw new Exception(sprintf (_("Utilisation directe interdite du poste comptable %s"), ${"poste".$i})); } } } From 51550b445677d735bc5e7039b978441a0f73da7a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 Jan 2019 14:56:14 +0100 Subject: [PATCH 37/42] Currency Show currency info for MISC --- include/template/ledger_detail_misc.php | 26 ++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/include/template/ledger_detail_misc.php b/include/template/ledger_detail_misc.php index 27ce89814..fa82e7207 100644 --- a/include/template/ledger_detail_misc.php +++ b/include/template/ledger_detail_misc.php @@ -112,7 +112,7 @@ echo th(_('Crédit'), 'style="text-align:right"'); $str_anc.= Anc_Plan::hidden($a_anc); } echo ''; -$amount_idx=0; +$amount_idx=0; $sum_prod_currency=0; for ($e=0;$edet->array);$e++) { $row=''; $q=$obj->det->array; $view_history = HtmlInput::history_account($q[$e]['j_poste'], $q[$e]['j_poste'], "", $exercice); @@ -159,6 +159,14 @@ $amount_idx=0; $montant=td(nbm($q[$e]['j_montant']),'class="num"'); $row.=($q[$e]['j_debit']=='t')?$montant:td(''); $row.=($q[$e]['j_debit']=='f')?$montant:td(''); + /* + * Compute total in currency if not default one + */ + if ( $obj->det->currency_id != 0 && $q[$e]['j_debit']=='f' ) { + $value=$obj->db->get_value("select oc_amount+oc_vat_amount from operation_currency where j_id=$1",[$q[$e]['j_id']]); + $sum_prod_currency=bcadd($sum_prod_currency,$value,2); + + } /* Analytic accountancy */ if ( $owner->MY_ANALYTIC != "nu" /*&& $div=='popup'*/){ if ( preg_match('/^(6|7)/',$q[$e]['j_poste'])) { @@ -188,6 +196,22 @@ $amount_idx=0; } ?> +det->currency_id != "" && $obj->det->currency_id > 0) + { + $currency=new Acc_Currency($obj->db, $obj->det->currency_id); + $four_space=" "." "." "." "; + + echo $currency->get_code(),$four_space; + echo _("Taux utilisé")," ", $obj->det->currency_rate,$four_space; + echo _("Taux Réf"), " ",$obj->det->currency_rate_ref.$four_space; + echo _("Montant en devise"), " ",$sum_prod_currency,$four_space; + } +?>
    Date: Sat, 12 Jan 2019 15:11:35 +0100 Subject: [PATCH 38/42] Database upgrade --- include/constant.php | 2 +- include/sql/patch/upgrade132.sql | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 include/sql/patch/upgrade132.sql diff --git a/include/constant.php b/include/constant.php index 8202fec6c..c6bea47ef 100644 --- a/include/constant.php +++ b/include/constant.php @@ -108,7 +108,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",132); +define ("DBVERSION",133); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",18); define ('NOTFOUND','--not found--'); diff --git a/include/sql/patch/upgrade132.sql b/include/sql/patch/upgrade132.sql new file mode 100644 index 000000000..4565200de --- /dev/null +++ b/include/sql/patch/upgrade132.sql @@ -0,0 +1,15 @@ +begin; +insert into "parameter" (pr_id ) values ('MY_DEFAULT_ROUND_ERROR_DEB'); +insert into "parameter" (pr_id ) values ('MY_DEFAULT_ROUND_ERROR_CRED'); +drop view if exists v_all_card_currency; + +create or replace view v_all_card_currency as +select sum(oc_amount) as sum_oc_amount,sum(oc_vat_amount) as sum_oc_vat_amount,f_id,j_id +from +operation_currency +join jrnx using (j_id) +group by f_id,j_id; + +commit ; +insert into version (val,v_description) values (133,'Currency : default accounting for currency difference '); +commit ; \ No newline at end of file From 994bbd7fe823f85b774334b82749806eb7367e16 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 Jan 2019 15:11:54 +0100 Subject: [PATCH 39/42] Typo --- include/class/acc_ledger.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index c195fb90c..52d3e1f97 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1217,7 +1217,7 @@ class Acc_Ledger extends jrn_def_sql $card_id=$p->find_card(); if (!empty($card_id)) { - $str_msg=sprintf(_(" Le poste %s appartient à fiche(s) dont : %s"),$str_msg,count($card_id)); + $str_msg=sprintf(_(" Le poste %s appartient à fiche(s) dont : %s"),$p->id,count($card_id)); $max=(count($card_id)>MAX_COMPTE_CARD)?MAX_COMPTE_CARD:count($card_id); for ($x=0; $x<$max; $x++) { From fb7505ffd4dd334ac8edee366523d098518b1f37 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 Jan 2019 15:21:58 +0100 Subject: [PATCH 40/42] Currency : set default accounting for change difference when using currency --- include/company.inc.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/include/company.inc.php b/include/company.inc.php index 1dfaf3ecb..f433c3108 100644 --- a/include/company.inc.php +++ b/include/company.inc.php @@ -49,7 +49,8 @@ if (isset($_POST['record_company'])) $m->MY_UPDLAB = $http->post("p_updlab"); $m->MY_STOCK =$http->post("p_stock"); $m->MY_CURRENCY =$http->post("p_currency"); - + $m->MY_DEFAULT_ROUND_ERROR_DEB=$http->post("p_round_error_deb"); + $m->MY_DEFAULT_ROUND_ERROR_CRED=$http->post("p_round_error_cred"); $m->Update(); } @@ -117,6 +118,18 @@ $use_currency->table = 1; $use_currency->value = $updlab_array; $use_currency->selected = $my->MY_CURRENCY; +$default_error_deb=new IPoste("p_round_error_deb",$my->MY_DEFAULT_ROUND_ERROR_DEB); +$default_error_deb->name = 'p_round_error_deb'; +$default_error_deb->set_attribute('gDossier',Dossier::id()); +$default_error_deb->set_attribute('jrn',0); +$default_error_deb->set_attribute('account','p_round_error_deb'); + +$default_error_cred=new IPoste("p_round_error_deb",$my->MY_DEFAULT_ROUND_ERROR_CRED); +$default_error_cred->name = 'p_round_error_cred'; +$default_error_cred->set_attribute('gDossier',Dossier::id()); +$default_error_cred->set_attribute('jrn',0); +$default_error_cred->set_attribute('account','p_round_error_cred'); + // other parameters $all = new IText(); $all->table = 1; @@ -151,7 +164,18 @@ echo "" . td(_("Suggérer la date"), 'style="text-align:right"') . $date_sug echo '' . td(_('Afficher la période comptable pour éviter les erreurs de date'), 'style="text-align:right"') . $check_periode->input('p_check_periode', $strict_array) . ''; echo '' . td(_('Utilisez des postes comptables alphanumérique'), 'style="text-align:right"') . $alpha_num->input('p_alphanum') . ''; echo '' . td(_('Changer le libellé des détails'), 'style="text-align:right"') . $updlab->input('p_updlab') . ''; - +echo '' . + td(_("Poste comptable de CHARGE (D) pour les différences d'arrondi pour les opérations en devise")). + ''.$default_error_deb->input(). + ''. + ''; + +echo '' . + td(_("Poste comptable en PRODUIT (C) pour les différences d'arrondi pour les opérations en devise")). + ''.$default_error_cred->input(). + ''. + ''; + echo ""; echo HtmlInput::submit("record_company", _("Sauve")); echo ""; From 5d939a9118ea0ee5e9889b172a6ec699732ea4d5 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 23 Jan 2019 20:51:58 +0100 Subject: [PATCH 41/42] translation --- include/compta_fin.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/compta_fin.inc.php b/include/compta_fin.inc.php index 2dce3f620..c3c1b3c11 100644 --- a/include/compta_fin.inc.php +++ b/include/compta_fin.inc.php @@ -46,7 +46,7 @@ if ( $ledger_id == 0) $def_ledger=$Ledger->get_first('fin'); if ( empty ($def_ledger)) { - exit('Pas de journal disponible'); + exit(_('Pas de journal disponible')); } $ledger_id=$def_ledger['jrn_def_id']; } From 5f55c2731c9ee8b6e0e9912d9ef68806b7935b40 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 23 Jan 2019 21:03:55 +0100 Subject: [PATCH 42/42] =?UTF-8?q?Mantis=20#0001688:=20Affichage=20centime?= =?UTF-8?q?=20dans=20l'=C3=A9cran=20de=20confirmation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/acc_ledger_fin.class.php | 52 ++++++++++++++++++++------ 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index df743a42e..f07d5ce4c 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -639,24 +639,54 @@ class Acc_Ledger_Fin extends Acc_Ledger $cur_rate=$acc_currency->get_rate_date($e_date); $default_currency=new Acc_Currency($this->db , 0); // saldo - - $r.='
    '.sprintf(_("Ancien solde = %f %s"),$solde, $cur); + $r .= ""; + $r .= tr( + td(_("Ancien solde")) . + td(nbm($solde).$cur, 'class="num"') + ); $new_solde=bcadd($solde,$tot_amount); - $r.='
    '.sprintf(_("Nouveau solde = %f %s"),$new_solde, $cur); - $r.='
    '.sprintf(_("Difference = %f %s"), $tot_amount, $cur); + $r .= tr( + td(_("Nouveau solde")) . + td(nbm($new_solde).$cur, ' class="num"') + ); + $r .= tr( + td(_("Difference")) . + td(nbm($tot_amount).$cur, ' class="num"') + ); + $r.=tr( + td(_("Taux")). + td($cur_rate) + ); + $r.=tr( + td(_("Nouveau solde")). + td(bcdiv($new_solde,$cur_rate).$default_currency->get_code(), ' class="num"') + ); + $r.='
    '; + - $r.='
    '.sprintf(_("Taux = %s"),$cur_rate); - $r.='
    '.sprintf(_("Nouveau solde = %f %s"),bcdiv($new_solde,$cur_rate),$default_currency->get_code()); + } else { $cur=$acc_currency->get_code(); // saldo - - $r.='
    '.sprintf(_("Ancien solde = %f %s"),$solde, $cur); - $new_solde=bcadd($new_solde,$tot_amount); - $r.='
    '.sprintf(_("Nouveau solde = %f %s"),$new_solde, $cur); - $r.='
    '.sprintf(_("Difference = %f %s"), $tot_amount, $cur); + $r .= ""; + $r .= tr( + td(_("Ancien solde")) . + td(nbm($solde).$cur, 'class="num"') + ); + $new_solde=bcadd($solde,$tot_amount); + $r .= tr( + td(_("Nouveau solde")) . + td(nbm($new_solde).$cur, ' class="num"') + ); + $r .= tr( + td(_("Difference")) . + td(nbm($tot_amount).$cur, ' class="num"') + ); + + $r.='
    '; + } // check for upload piece