diff --git a/html/ajax_misc.php b/html/ajax_misc.php index c4d89c5e3..e111760f4 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -133,7 +133,7 @@ $html = var_export($_REQUEST, true); set_language(); if ( LOGINPUT) { - $file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+'); + $file_loginput=fopen($_ENV['TMP'].'/scenario-ajax-'.$_SERVER['REQUEST_TIME'].'.php','a+'); fwrite ($file_loginput,"db->start(); @@ -282,6 +283,8 @@ class Acc_Ledger extends jrn_def_sql ////////////////////////////////////////////////// $a_jid=$this->db->get_array("select j_id,j_debit from jrnx where j_grpt=$1", array($this->jr_grpt_id)); + $anc_group_id=0; + // for each item in JRNX for ($l=0; $lMY_ANALYTIC != 'nu') { + // if there is the first operation_analytic to insert , compute the group_id (operation_analytic.oa_group) + if ($anc_group_id == 0 ) $anc_group_id=$this->db->get_next_seq('s_oa_group'); + $this->db->exec_sql(" + insert into operation_analytique (po_id,oa_amount + ,oa_description + ,oa_debit + ,j_id + , oa_date + , oa_row + , oa_positive + , f_id + ,oa_jrnx_id_source + ,oa_group) + select po_id + ,oa_amount + ,oa_description + ,case oa_debit when true then false else true end + , $j_id + , to_date($2,'DD.MM.YYYY') + , oa_row + , oa_positive + , f_id + ,oa_jrnx_id_source + ,$anc_group_id from operation_analytique + where + j_id=$1 + ",[$row, $p_date]); + + } - } + } // end for each item in JRNX $old_receipt=$this->db->get_row("select jr_pj_number,jr_def_id from jrn where jr_id=$1",[$this->jr_id]); $sql="insert into jrn ( jr_id, @@ -405,7 +439,7 @@ class Acc_Ledger extends jrn_def_sql // Add a "concerned operation to bound these op.together // - $rec=new Acc_Reconciliation($this->db); + $rec=new Acc_Reconciliation($this->db); $rec->set_jr_id($seq); $rec->insert($this->jr_id); @@ -415,17 +449,19 @@ class Acc_Ledger extends jrn_def_sql throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]")); } - - // the table stock must updated // also in the stock table $sql="delete from stock_goods where sg_id = any ( select sg_id - from stock_goods natural join jrnx where j_grpt=".$this->jr_grpt_id.")"; - $Res=$this->db->exec_sql($sql); + from stock_goods natural join jrnx where j_grpt=$1)"; + $Res=$this->db->exec_sql($sql,array($this->jr_grpt_id)); if ($Res==false) { throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]")); } + /** + * reverse also in analytic account; + */ + $this->db->commit(); } catch (Exception $e) @@ -1259,7 +1295,11 @@ class Acc_Ledger extends jrn_def_sql if (isset(${'qc_'.$i})&&trim(${'qc_'.$i})!="") { $f=new Fiche($this->db); + $f->get_by_qcode(${'qc_'.$i}); $f->quick_code=${'qc_'.$i}; + + if ($f->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),${'qc_'.$i}), 50); if ($f->belong_ledger($p_jrn) < 1 ) throw new Exception("La fiche quick_code = ". $f->quick_code." n'est pas dans ce journal", 4); @@ -2874,7 +2914,7 @@ class Acc_Ledger extends jrn_def_sql } /** - * display screen to enter a new ledger + * @brief display FORM to enter parameters to create a new ledger. */ function input_new() { diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index de3a2ea72..808d625ed 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -133,6 +133,11 @@ class Acc_Ledger_Fin extends Acc_Ledger { if (noalyss_strlentrim(${'e_other'.$i})==0) continue; + /* check if all card has a ATTR_DEF_ACCOUNT */ + $fiche=new Fiche($this->db); + $fiche->get_by_qcode(${'e_other'.$i}); + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),${'e_other'.$i}), 50); /* check if amount are numeric and */ if (isNumber(${'e_other'.$i.'_amount'})==0) throw new Exception('La fiche '.${'e_other'.$i}.'a un montant invalide ['.${'e_other'.$i.'_amount'}.']', @@ -140,9 +145,7 @@ class Acc_Ledger_Fin extends Acc_Ledger /* compute the total */ $tot_amount+=round(${'e_other'.$i.'_amount'}, 2); - /* check if all card has a ATTR_DEF_ACCOUNT */ - $fiche=new Fiche($this->db); - $fiche->get_by_qcode(${'e_other'.$i}); + if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT)==true) throw new Exception('La fiche '.${'e_other'.$i}.'n\'a pas de poste comptable', 8); diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index c5b36ca87..d9a5ff7af 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -111,10 +111,14 @@ class Acc_Ledger_Purchase extends Acc_Ledger /* check the account */ $fiche=new Fiche($this->db); $fiche->get_by_qcode($e_client); + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),$e_client), 50); if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) throw new Exception(_('La fiche ').$e_client._('n\'a pas de poste comptable'),8); + + /* get the account and explode if necessary */ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT); // if 2 accounts, take only the credit one for supplier @@ -158,6 +162,13 @@ class Acc_Ledger_Purchase extends Acc_Ledger for ($i=0;$i< $nb_item;$i++) { if ( noalyss_strlentrim(${'e_march'.$i})== 0) continue; + + /* check if all card has a ATTR_DEF_ACCOUNT*/ + $fiche=new Fiche($this->db); + $fiche->get_by_qcode(${'e_march'.$i}); + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"), ${'e_march' . $i}), 50); + /* check if amount are numeric and */ if ( isNumber(${'e_march'.$i.'_price'}) == 0 ) throw new Exception(_('La fiche ').${'e_march'.$i}._('a un montant invalide').' ['.${'e_march'.$i}.']',6); @@ -181,9 +192,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger throw new Exception(_(" La TVA ".$tva_rate->tva_label." utilise des postes comptables inexistants")); } - /* check if all card has a ATTR_DEF_ACCOUNT*/ - $fiche=new Fiche($this->db); - $fiche->get_by_qcode(${'e_march'.$i}); + if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) throw new Exception(_('La fiche ').${'e_march'.$i}._('n\'a pas de poste comptable'),8); @@ -1366,7 +1375,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $W1->label=""; $W1->name="e_march".$i; $W1->value=$march; - $W1->table=1; + $W1->table=0; $W1->set_dblclick("fill_ipopcard(this);"); $W1->set_attribute('ipopup','ipopcard'); @@ -1803,27 +1812,32 @@ class Acc_Ledger_Purchase extends Acc_Ledger EOF; - if ($p_currency_code !=0) { - $rate=_("Taux "); -$r.=<< - {$decalage} - - - - - - - - {$rate} {$p_currency_rate} - - - {$tot_eur} EUR - - -EOF; + if ($p_currency_code !=0) { + $sql_currency=new Currency_SQL($this->cn,0); + $iso_code=$sql_currency->getp("cr_code_iso"); + $rate=_("Taux "); + $r.=<< + {$decalage} + + + + + + + + {$rate} {$p_currency_rate} + + + {$tot_eur} {$iso_code} + + + EOF; } // if ($p_currency_code !=0 - }else { // if $g_parameter->MY_TVA_USE=='Y' + }else // if $g_parameter->MY_TVA_USE=='Y' + { + $sql_currency=new Currency_SQL($this->cn,0); + $iso_code=$sql_currency->getp("cr_code_iso"); $r.=<< {$decalage} @@ -1849,7 +1863,7 @@ EOF; - {$tot_str} {$str_code} + {$tot_str} {$iso_code} EOF; diff --git a/include/class/acc_ledger_sale.class.php b/include/class/acc_ledger_sale.class.php index bde50793d..c567bd3f3 100644 --- a/include/class/acc_ledger_sale.class.php +++ b/include/class/acc_ledger_sale.class.php @@ -108,9 +108,15 @@ class Acc_Ledger_Sale extends Acc_Ledger { $fiche = new Fiche($this->db); $fiche->get_by_qcode($e_client); + + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),$e_client), 50); + if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) throw new Exception(_('La fiche ') . $e_client . _('n\'a pas de poste comptable'), 8); + + /* get the account and explode if necessary */ $sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT); // if 2 accounts, take only the debit one for customer @@ -142,14 +148,19 @@ class Acc_Ledger_Sale extends Acc_Ledger { for ($i = 0; $i < $nb_item; $i++) { if (! isset (${'e_march' . $i}) || noalyss_strlentrim(${'e_march' . $i}) == 0) continue; + /* check if all card has a ATTR_DEF_ACCOUNT */ + $fiche = new Fiche($this->db); + $fiche->get_by_qcode(${'e_march' . $i}); + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"), ${'e_march' . $i}), 50); + + /* check if amount are numeric and */ if (isNumber(${'e_march' . $i . '_price'}) == 0) throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a un montant invalide [') . ${'e_march' . $i} . ']', 6); if (isNumber(${'e_quant' . $i}) == 0) throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a une quantité invalide [') . ${'e_quant' . $i} . ']', 7); - /* check if all card has a ATTR_DEF_ACCOUNT */ - $fiche = new Fiche($this->db); - $fiche->get_by_qcode(${'e_march' . $i}); + if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('n\'a pas de poste comptable'), 8); @@ -1064,9 +1075,9 @@ if ( $g_parameter->MY_TVA_USE=="Y") { EOF; - $sql_currency=new Currency_SQL($this->cn,$p_currency_code); - $iso_code=$sql_currency->getp("cr_code_iso"); if ($p_currency_code !=0) { + $sql_currency=new Currency_SQL($this->cn,0); + $iso_code=$sql_currency->getp("cr_code_iso"); $r.=<< @@ -1089,7 +1100,9 @@ EOF; } else { $sql_currency=new Currency_SQL($this->cn,$p_currency_code); - $iso_code=$sql_currency->getp("cr_code_iso"); + $str_code=$sql_currency->getp("cr_code_iso"); + $sql_currencydefault=new Currency_SQL($this->cn,0); + $iso_code=$sql_currencydefault->getp("cr_code_iso"); // without VAT $r.=<< @@ -1104,7 +1117,7 @@ EOF; - {$tot_str} + {$tot_str} {$str_code} @@ -1487,7 +1500,7 @@ EOF; $W1->label = ""; $W1->name = "e_march" . $i; $W1->value = $march; - $W1->table = 1; + $W1->table = 0; $W1->set_attribute('typecard', 'cred'); $W1->set_dblclick("fill_ipopcard(this);"); $W1->set_attribute('ipopup', 'ipopcard'); diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php index bc236d354..0811cfff0 100644 --- a/include/class/acc_operation.class.php +++ b/include/class/acc_operation.class.php @@ -266,7 +266,8 @@ EOF; return $sum; } - /*!\brief set the pj of a operation in jrn. the jr_id must be set + /*! + *\brief set the pj of a operation in jrn. the jr_id must be set *\note if the jr_id it fails */ function set_pj() @@ -394,7 +395,8 @@ EOF; $this->jr_internal= $l_line['jr_internal']; return $this->jr_internal; } - /*!\brief search an operation thankx it internal code + /*! + * \brief search an operation thankx it internal code * \param internal code * \return 0 ok -1 nok */ @@ -406,10 +408,11 @@ EOF; $this->jr_id=Database::fetch_result($res,0,0); return 0; } - /*!\brief retrieve data from jrnx - *\note the data are filtered by the access of the current user - * \return an array or FALSE if nothing found - */ + /*! + * \brief retrieve data from jrnx + *\note the data are filtered by the access of the current user + * \return an array or FALSE if nothing found + */ function get_jrnx_detail() { global $g_user; @@ -848,8 +851,6 @@ EOF; } static function test_me() { - $_SESSION[SESSION_KEY.'g_user']=NOALYSS_ADMINISTRATOR; - $_SESSION[SESSION_KEY.'g_pass']='dany'; global $g_user; $cn=Dossier::connect(); $g_user=new Noalyss_user($cn); @@ -881,7 +882,12 @@ EOF; return $type_operation; } /** - * @brief create a form to recreate the operation and returns it, just like a correct + * @brief create a form to recreate the operation and returns it, + * it works the same as when you want to correct an operation instead of confirming + * + * @see compta_ach.inc.php + * @see compta_ven.inc.php + * * @param $p_id string DOMID of the form */ function form_clone_operation($p_id) { @@ -903,12 +909,22 @@ EOF; "ac"=>$a_code[0]['code'],"gDossier"=>Dossier::id() ])); $r.=Dossier::hidden(); + $default_currency=new Acc_Currency($this->db,0); // select the menu where the operation will be duplicated + $r.="

"; $r.="

    "; - $r.=sprintf("
  • %s
  • ",$operation->det->jr_pj_number); - $r.=sprintf("
  • %s
  • ",$operation->det->jr_comment); - $r.=sprintf("
  • %s
  • ",$operation->det->jr_montant); + $r.=sprintf("
  • %s %s
  • ",_("Date"),$operation->det->jr_pj_number); + $r.=sprintf("
  • %s %s
  • ",_("Libellé"),$operation->det->jr_comment); + $r.=sprintf("
  • %s %s %s
  • ",_("Montant "),nbm($operation->det->jr_montant),$default_currency->get_code()); + // Add info if the operation using a currency + if ( $operation->det->currency_id != 0 ) { + $currency=$this->db->get_value("select cr_code_iso from currency where id=$1",[$operation->det->currency_id]); + $r.=sprintf("
  • %s %s
  • ",_('Devise'),$currency); + $r.=sprintf("
  • %s %s
  • ",_("Taux"),$operation->det->currency_rate); + $array['p_currency_code']=$operation->det->currency_id; + $array['p_currency_rate']=$operation->det->currency_rate; + } $r.="
"; $r.="

"; if (count($a_code) == 1 ) { @@ -930,31 +946,57 @@ EOF; $r.="

"; // For Misc Operation , if a card is given then there is no accounting + // modify amount with currency if not in default currency if ( $operation->signature==="ODS") { $nb_array = count($array); for ($i = 0; $i < $nb_array; $i++) { if (isset ($array["qc_" . $i]) && $array["qc_" . $i] != "") { $array["poste" . $i] = ""; } - } - } - if ( $operation->signature==="ACH" || $operation->signature=="VEN") { + } $idx=0; foreach ($operation->det->array as $item) { + if ($operation->det->currency_id != 0) { + $array['amount'. $idx] = $item['oc_amount']; + $idx++; + } + } + + }elseif ( $operation->signature==="ACH" || $operation->signature=="VEN") { + $idx=0; + foreach ($operation->det->array as $item) { + + // currency replace amount + if ($operation->det->currency_id != 0 ) { + $array['e_march'.$idx.'_tva_amount']=$item['oc_vat_amount']; + $array['e_march'.$idx.'_tva_amount']=$item['oc_amount']; + $array['e_march'.$idx.'_price']=$item['oc_price_unit']; + } + if ( isset ($item['qs_vat_sided']) && $item['qs_vat_sided'] != 0 ) { $array['e_march'.$idx.'_tva_amount']=0; }elseif (isset ($item['qp_vat_sided']) && $item['qp_vat_sided'] != 0 ){ $array['e_march'.$idx.'_tva_amount']=0; } + $idx++; } - if ( DEBUGNOALYSS>1) { - echo \Noalyss\Dbg::hidden_info("operation->det_array", $operation->det->array); - echo \Noalyss\Dbg::hidden_info("array", $array); + }elseif ($operation->signature=='FIN') { + $idx=0; + foreach ($operation->det->array as $item) { + if ($operation->det->currency_id != 0) { + $array['e_other' . $idx . '_amount'] = $item['oc_amount']; + $idx++; + } } } + if ( DEBUGNOALYSS>1) { + echo \Noalyss\Dbg::hidden_info("operation->det_array", $operation->det->array); + echo \Noalyss\Dbg::hidden_info("operation->det", $operation->det); + echo \Noalyss\Dbg::hidden_info("array", $array); + } // transform the operation into hidden element $r.=HtmlInput::simple_array_to_hidden($array); $r.=HtmlInput::hidden("e_comm",$operation->det->jr_comment); @@ -1018,7 +1060,7 @@ class Acc_Detail extends Acc_Operation $array['e_ech']=""; $array['p_jrn']=$this->det->jr_def_id; return $array; - + } } ///////////////////////////////////////////////////////////////////////////// @@ -1041,10 +1083,30 @@ class Acc_Misc extends Acc_Detail function get() { parent::get(); - $sql="SELECT j_id, j_date, j_montant, j_poste, j_grpt, j_rapt, j_jrn_def, - j_debit, j_text, j_centralized, j_internal, j_tech_user, j_tech_date, - j_tech_per, j_qcode,f_id - FROM jrnx where j_grpt = $1 order by j_debit desc,j_poste"; + $sql=" +SELECT jx1.j_id + ,jx1.j_date + ,jx1.j_montant + ,jx1.j_poste + ,jx1.j_grpt + ,jx1.j_rapt + ,jx1.j_jrn_def + ,jx1.j_debit + ,jx1.j_text + ,jx1.j_centralized + ,jx1.j_internal + ,jx1.j_tech_user + ,jx1.j_tech_date + ,jx1.j_tech_per + ,jx1.j_qcode + ,jx1.f_id + ,oc1.oc_amount + FROM jrnx jx1 + left join operation_currency oc1 using(j_id) + where + jx1.j_grpt = $1 + order by jx1.j_debit desc,jx1.j_poste +"; $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id)); } /*** @@ -1090,13 +1152,33 @@ class Acc_Sold extends Acc_Detail function get() { parent::get(); - $sql="SELECT qs_id, qs_internal, qs_fiche, qs_quantite, qs_price, qs_vat, - qs_vat_code, qs_client, qs_valid, j_id,j_text,qs_vat_sided , qs_unit , j_debit - FROM quant_sold join jrnx using(j_id) where j_grpt=$1 order by j_id"; + $sql=" + select qs_id, qs_internal +, jx1.j_id +, qs1.qs_fiche +, qs1.qs_quantite +, qs1.qs_price +, qs1.qs_vat +, qs1.qs_vat_code +, qs1.qs_client +, qs1.qs_valid +, jx1.j_text +, qs_vat_sided +, qs_unit +, jx1.j_debit +,oc1.oc_amount +,oc1.oc_vat_amount +,oc1.oc_price_unit +from quant_sold qs1 +join jrnx jx1 using(j_id) +left join operation_currency oc1 using(j_id) +where jx1.j_grpt = $1 +order by jx1.j_id; + "; $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id)); } /*** - * Compute an array for using with Acc_Ledger::insert + * @brief Compute an array for using with Acc_Ledger::insert * */ function compute_array() @@ -1145,14 +1227,39 @@ class Acc_Purchase extends Acc_Detail function get() { parent::get(); - $sql="SELECT qp_id, qp_internal, j_id, qp_fiche, qp_quantite, qp_price, qp_vat, - qp_vat_code, qp_nd_amount, qp_nd_tva, qp_nd_tva_recup, qp_supplier, - qp_valid, qp_dep_priv,j_text,qp_vat_sided,qp_unit , j_debit - FROM quant_purchase join jrnx using(j_id) where j_grpt=$1 order by j_id"; + $sql=" + select qp_id, qp_internal +, jx1.j_id +, qp1.qp_fiche +, qp1.qp_quantite +, qp1.qp_price +, qp1.qp_vat +, qp1.qp_vat_code +, qp1.qp_nd_amount +, qp1.qp_nd_tva +, qp1.qp_nd_tva_recup +, qp1.qp_supplier +, qp1.qp_valid +, qp1.qp_dep_priv +, jx1.j_text +, qp1.qp_vat_sided +, qp1.qp_unit +, jx1.j_debit +,oc1.oc_amount +,oc1.oc_vat_amount +,oc1.oc_price_unit +from quant_purchase qp1 +join jrnx jx1 using(j_id) +left join operation_currency oc1 using(j_id) +where jx1.j_grpt = $1 +order by jx1.j_id + "; $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id)); } + + /*** - * Compute an array for using with Acc_Ledger::insert + * @brief Compute an array for using with Acc_Ledger::insert * */ function compute_array() @@ -1175,9 +1282,11 @@ class Acc_Purchase extends Acc_Detail $array["e_march".$i."_tva_id"]=$this->det->array[$i]['qp_vat_code']; $array["e_march".$i."_tva_amount"]=$this->det->array[$i]['qp_vat']; $array["e_quant".$i]=$this->det->array[$i]['qp_quantite']; + } $array['correct']=1; - return $array; + + return $array; } @@ -1201,8 +1310,18 @@ class Acc_Fin extends Acc_Detail function get() { parent::get(); - $sql="SELECT qf_id, qf_bank, jr_id, qf_other, qf_amount,j_id - FROM quant_fin where jr_id = $1"; + $sql="SELECT qf_id + ,qf_bank + ,jr_id + ,qf_other + ,qf_amount,j_id + ,oc1.oc_amount + ,oc1.oc_vat_amount + ,oc1.oc_price_unit + FROM quant_fin + left join operation_currency oc1 using(j_id) + where + jr_id = $1"; $this->det->array=$this->db->get_array($sql,array($this->jr_id)); } /*** diff --git a/include/class/acc_reconciliation.class.php b/include/class/acc_reconciliation.class.php index 52d0f7abc..6b4cf8439 100644 --- a/include/class/acc_reconciliation.class.php +++ b/include/class/acc_reconciliation.class.php @@ -121,8 +121,9 @@ class Acc_Reconciliation ==0) { // Ok we can insert - $Res=$this->db->exec_sql("insert into jrn_rapt(jr_id,jra_concerned) values ". - "(".$this->jr_id.",$jr_id2)"); + $Res=$this->db->exec_sql("insert into jrn_rapt(jr_id,jra_concerned) values ($1,$2)", + array($this->jr_id,$jr_id2) + ); // try to letter automatically same account from both operation $this->auto_letter($jr_id2); diff --git a/include/class/lettering.class.php b/include/class/lettering.class.php index 63e9a9a5c..579f1fac1 100644 --- a/include/class/lettering.class.php +++ b/include/class/lettering.class.php @@ -161,20 +161,23 @@ class Lettering return; // already linked - if ($let1!=0&&$let2!=0&&$let1!=$let2) + /* if ($let1!=0&&$let2!=0&&$let1!=$let2) return; - +*/ // none is linked if ($let1==0&&$let2==0) { $jl_id=$this->db->get_next_seq("jnt_letter_jl_id_seq"); $this->db->exec_sql('insert into jnt_letter(jl_id) values($1)', array($jl_id)); - } - // one is linked but not the other - if ($let1==0&&$let2!=0) + } elseif ($let1==0&&$let2!=0) + { + // one is linked but not the other $jl_id=$let2; - if ($let1!=0&&$let2==0) + }elseif ($let1!=0&&$let2==0) { $jl_id=$let1; + } else { + throw new \Exception ("LET179 invalid"); + } /* insert */ if ($first=='t') diff --git a/include/class/noalyss_appearance.class.php b/include/class/noalyss_appearance.class.php index 635d62a09..ec306dd42 100644 --- a/include/class/noalyss_appearance.class.php +++ b/include/class/noalyss_appearance.class.php @@ -153,16 +153,25 @@ class Noalyss_Appearance h2.title { background-color: {$inner_box_title} ; } - .nav-fill .nav-item { - background: {$menu1}; - color: {$menu1_font}; + .nav-fill .nav-item { + background: {$menu1} !important; + color: {$menu1_font} !important; } + .nav-fill:hover { + color: {$menu1_font} !important; + } .nav-level2 { background-color: {$menu2}; color:{$menu2_font}; } .nav-pills .nav-link.active { background-color: {$menu1_selected} !important; + } + .nav-pills .nav-link { + color: {$menu1_font} !important; + } + .nav-link:hover { + background-color:{$menu1_selected}; } table.sortable, table.table_large, table.result ,table.resultfooter { color:{$font_table} !important; diff --git a/include/class/pdf_operation.class.php b/include/class/pdf_operation.class.php index ac17fe082..b8178e673 100644 --- a/include/class/pdf_operation.class.php +++ b/include/class/pdf_operation.class.php @@ -363,9 +363,9 @@ class PDF_Operation extends PDF { $width=25; $this->pdf->SetFillColor(220,221,255); for ($i = 0; $i<$nb; $i++) { - $this->pdf->write_cell($width,8,$pa_plan[$i]['pa_name'],1,"C",1); + $this->pdf->write_cell($width,8,$pa_plan[$i]['pa_name']); } - $this->pdf->write_cell($width,8,_('Montant'),1,"C",1); + $this->pdf->write_cell($width,8,_('Montant'),0,0,'R'); $this->pdf->SetFillColor(0,0,0); $this->pdf->line_new(8); } @@ -411,10 +411,10 @@ class PDF_Operation extends PDF { if ($old_row['oa_row']!=$current_row['oa_row']) { if($idx_plan!=0) { for ($e = $idx_plan; $e<$cnt_plan; $e++) - $this->pdf->write_cell($width, 8, "", 1, "C", 0); + $this->pdf->write_cell($width, 8, "", 1,0, "c", 0); } // print last column - $this->pdf->write_cell($width, 8, nbm($old_row["signed_amount"],2), 1, "R", 0); + $this->pdf->write_cell($width, 8, nbm($old_row["signed_amount"],2), 1,0, "R", 0); // Add to total $tot_anc= bcadd($tot_anc, $old_row["signed_amount"]); // we start a new line @@ -423,17 +423,17 @@ class PDF_Operation extends PDF { $idx_plan = 0; } if ($current_row['pa_id']==$pa_plan[$idx_plan]['pa_id']) { - $this->pdf->write_cell($width, 8, $current_row['po_name'], 1, "L", 0); + $this->pdf->write_cell($width, 8, $current_row['po_name'], 1,0, "L", 0); } else { // print the post code in the right column for ($e = $idx_plan; $e<$cnt_plan; $e++) { if ($current_row['pa_id']==$pa_plan[$e]['pa_id']) { - $this->pdf->write_cell($width, 8, $current_row['po_name'], 1, "L", 0); + $this->pdf->write_cell($width, 8, $current_row['po_name'], 1, 0,"L", 0); $idx_plan=$e; // $idx_plan--; break; } else { - $this->pdf->write_cell($width, 8, "", 1, "C", 0); + $this->pdf->write_cell($width, 8, "", 1,0, "c", 0); } } } @@ -444,9 +444,9 @@ class PDF_Operation extends PDF { // End // print last column if($idx_plan!=0) { - $this->pdf->write_cell($width, 8, "", 1, "C", 0); + $this->pdf->write_cell($width, 8, "", 1,0, "C", 0); } - $this->pdf->write_cell($width, 8,nbm($old_row["signed_amount"],2), 1, "R", 0); + $this->pdf->write_cell($width, 8,nbm($old_row["signed_amount"],2), 1, 0,"R", 0); $this->pdf->line_new(8); // Add to total @@ -454,14 +454,14 @@ class PDF_Operation extends PDF { // Total $this->pdf->write_cell(40, 6,_("Comptabilité")); - $this->pdf->write_cell(40, 6,nbm($row_jrnx["j_montant"],2),"","R",0); + $this->pdf->write_cell(40, 6,nbm($row_jrnx["j_montant"],2),0,0,"r",0); $this->pdf->line_new(); $this->pdf->write_cell(40, 6,_("Analytique")); - $this->pdf->write_cell(40, 6,nbm($tot_anc,2),"","R",0); + $this->pdf->write_cell(40, 6,nbm($tot_anc,2),0,0,"r",0); $this->pdf->line_new(); $this->pdf->write_cell(40, 6,_("Diff")); - $this->pdf->write_cell(40, 6,nbm( bcsub($row_jrnx['j_montant'], $tot_anc),2),0,"R",0); + $this->pdf->write_cell(40, 6,nbm( bcsub($row_jrnx['j_montant'], $tot_anc),2),0,0,"R",0); $this->pdf->line_new(); } diff --git a/include/class/tva_rate_mtable.class.php b/include/class/tva_rate_mtable.class.php index 38b035cbb..09c59821a 100644 --- a/include/class/tva_rate_mtable.class.php +++ b/include/class/tva_rate_mtable.class.php @@ -226,6 +226,7 @@ class Tva_Rate_MTable extends Manage_Table_SQL $tva_rate=new Tva_rate_SQL($cn); $tva_rate->setp("tva_id",$new_tva_id); $tva_rate->setp("tva_rate", $this->table->tva_rate); + $tva_rate->setp("tva_code", $this->table->tva_code); $tva_rate->setp("tva_label", $this->table->tva_label); $tva_rate->setp("tva_comment", $this->table->tva_comment); $tva_rate->setp("tva_both_side", $this->table->tva_both_side); @@ -336,6 +337,9 @@ class Tva_Rate_MTable extends Manage_Table_SQL if (strlen($this->table->tva_code)>5){ $this->set_error("tva_code", _("code tva : Maximum 5 caractères")); } + if (isNumber($this->table->tva_code) == 1){ + $this->set_error("tva_code", _("code tva : doit aussi contenir des lettres")); + } if ($this->count_error()!=0) return false; return true; diff --git a/include/compta_ach.inc.php b/include/compta_ach.inc.php index 83e645191..7b60dc67b 100644 --- a/include/compta_ach.inc.php +++ b/include/compta_ach.inc.php @@ -151,8 +151,9 @@ if (isset($_POST['record'])) } catch (Exception $e) { - echo '

'. + echo '

'. _('Opération non extournée'). + " ". $e->getMessage(). '

'; } diff --git a/include/constant.php b/include/constant.php index c11fd1351..81b85cf0f 100644 --- a/include/constant.php +++ b/include/constant.php @@ -25,10 +25,10 @@ global $version_noalyss; // version -define('NOALYSS_VERSION', 9205 ); +define('NOALYSS_VERSION', 9206 ); // Database schema version -define("DBVERSION", 197); +define("DBVERSION", 198); // version for MONO_DATABASE define("MONO_DATABASE", 25); @@ -100,6 +100,8 @@ $g_failed = ""; $g_succeed = ""; define('SMALLX', '#xe816;'); define('BUTTONADD', "✚"); +define('ICON_SEARCH', '🔎'); +define('ICON_CLEAN', '✕'); // If noalyss_version is not defined it is likely directly taken from // git and so this variable is not set, this cause some issue diff --git a/include/database/tva_rate_sql.class.php b/include/database/tva_rate_sql.class.php index 2ff4ff48e..5fc0593da 100644 --- a/include/database/tva_rate_sql.class.php +++ b/include/database/tva_rate_sql.class.php @@ -50,6 +50,7 @@ class Tva_Rate_SQL extends Table_Data_SQL , "tva_both_side"=>"tva_both_side" ,"tva_payment_purchase"=>"tva_payment_purchase" ,"tva_payment_sale"=>"tva_payment_sale" + ,"tva_code"=>"tva_code" ); /* * Type of columns @@ -63,7 +64,7 @@ class Tva_Rate_SQL extends Table_Data_SQL , "tva_both_side"=>"numeric" ,"tva_payment_purchase"=>"text" ,"tva_payment_sale"=>"text" - + ,"tva_code"=>"text" ); diff --git a/include/impress_rapport.inc.php b/include/impress_rapport.inc.php index b3a4acfda..fe3bd0cf2 100644 --- a/include/impress_rapport.inc.php +++ b/include/impress_rapport.inc.php @@ -322,10 +322,11 @@ function ShowReportResult($p_array) { $i++; $class= ( $i % 2 == 0 )?' class="odd"':' class="even"'; - + $style='style="text-align:right;"'; + if ($op['montant']<0) { $style='style="color:red;text-align:right;"';} echo "". "".h($op['desc'])."". - "".nbm($op['montant'])."". + "".nbm($op['montant'])."". ""; } echo ""; diff --git a/include/lib/icon_action.class.php b/include/lib/icon_action.class.php index d189cc3e1..42fe5d19d 100644 --- a/include/lib/icon_action.class.php +++ b/include/lib/icon_action.class.php @@ -40,8 +40,8 @@ class Icon_Action static function icon_magnifier($id, $p_javascript, $p_style="") { $r=""; - $r.=sprintf('', - $id, $p_style, $p_javascript); + $r.=sprintf('%s', + $id, $p_style, $p_javascript,ICON_SEARCH); return $r; } /** @@ -54,8 +54,8 @@ class Icon_Action static function button_magnifier($id, $p_javascript, $p_style="") { $r=""; - $r.=sprintf('', - $id, $p_style, $p_javascript); + $r.=sprintf('', + $id, $p_style, $p_javascript,ICON_SEARCH); return $r; } @@ -82,8 +82,8 @@ class Icon_Action */ static function clean_zone($id, $p_javascript, $p_style="") { - $r=sprintf('', - $p_javascript, $id, $p_style + $r=sprintf('', + $p_javascript, $id, ICON_CLEAN,$p_style ); return $r; } diff --git a/include/lib/idate.class.php b/include/lib/idate.class.php index 8d74f80e6..1a131b16f 100644 --- a/include/lib/idate.class.php +++ b/include/lib/idate.class.php @@ -143,6 +143,7 @@ class IDate extends HtmlInput %s />  diff --git a/include/lib/itva_popup.class.php b/include/lib/itva_popup.class.php index f23b05a4a..6e248ffba 100644 --- a/include/lib/itva_popup.class.php +++ b/include/lib/itva_popup.class.php @@ -77,21 +77,21 @@ class ITva_Popup extends HtmlInput $r=""; switch ($this->filter) { case 'none': - $sql="select tva_code + $sql="select tva_code,tva_label from v_tva_rate where tva_purchase <> '#' and tva_sale <> '#' order by tva_code "; break; case 'sale': - $sql="select tva_code + $sql="select tva_code,tva_label from v_tva_rate where tva_sale <> '#' order by tva_code "; break; case 'purchase': - $sql="select tva_code + $sql="select tva_code,tva_label from v_tva_rate where tva_purchase <> '#' @@ -100,9 +100,11 @@ class ITva_Popup extends HtmlInput } $a_tva_code=$cn->get_array($sql); if ( empty($a_tva_code)) return ""; - $r.=sprintf('',$this->id); + $r.=sprintf('',$this->id); foreach ($a_tva_code as $item) { - $r.=sprintf('',$item['tva_code']); + $r.=sprintf('' + ,$item['tva_code'],$item['tva_code'] + ,htmlentities($item['tva_label'])); } $r.=''; return $r; @@ -137,9 +139,11 @@ class ITva_Popup extends HtmlInput $strAttribut = $this->get_node_attribute(); - $str = ''; + $str = ''; $r = sprintf($str, $this->name, $this->value, $this->id, _("C.TVA"),$this->js, $strAttribut,$this->id); $r.=$code; + $r.=$this->make_datalist(); if ($this->in_table) $table = '' . '' . td($r); @@ -183,7 +187,8 @@ class ITva_Popup extends HtmlInput // button $bt = new ISmallButton('bt_' . $this->id); $bt->tabindex = "-1"; - $bt->label = _(' TVA '); + $bt->label = ICON_SEARCH; + $bt->set_attribute('gDossier', dossier::id()); $bt->set_attribute('ctl', $this->id); $bt->set_attribute('popup', 'popup_tva'); diff --git a/include/sql/patch/upgrade197.sql b/include/sql/patch/upgrade197.sql new file mode 100644 index 000000000..8863e4d60 --- /dev/null +++ b/include/sql/patch/upgrade197.sql @@ -0,0 +1,89 @@ +begin; + +update menu_ref set me_menu='Navigateur 🧭' where me_code ~ 'NAVI'; + +update menu_ref set me_menu='Configuration 🔧' where me_code='CFG'; + +update menu_ref set me_menu='Recherche 🔎' where me_code='SEARCH'; + +update menu_ref set me_menu='Agenda 📅' where me_code='AGENDA'; + + +ALTER TABLE public.tva_rate ADD CONSTRAINT tva_code_number_check CHECK (tva_code::text !~ '^([0-9]+)$'); + +-- drop view if exists public.vw_fiche_attr; + +CREATE OR REPLACE VIEW public.vw_fiche_attr +AS SELECT a.f_id, + a.fd_id, + a.ad_value AS vw_name, + k.ad_value AS vw_first_name, + b.ad_value AS vw_sell, + c.ad_value AS vw_buy, + d.ad_value AS tva_code, + tva_rate.tva_id, + tva_rate.tva_rate, + tva_rate.tva_label, + e.ad_value AS vw_addr, + f.ad_value AS vw_cp, + j.ad_value AS quick_code, + h.ad_value AS vw_description, + i.ad_value AS tva_num, + fiche_def.frd_id, + l.ad_value AS accounting, + a.f_enable + FROM ( SELECT fiche.f_id, + fiche.fd_id, + fiche.f_enable, + fiche_detail.ad_value + FROM fiche + LEFT JOIN fiche_detail USING (f_id) + WHERE fiche_detail.ad_id = 1) a + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 6) b ON a.f_id = b.f_id + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 7) c ON a.f_id = c.f_id + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 2) d ON a.f_id = d.f_id + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 14) e ON a.f_id = e.f_id + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 15) f ON a.f_id = f.f_id + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 23) j ON a.f_id = j.f_id + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 9) h ON a.f_id = h.f_id + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 13) i ON a.f_id = i.f_id + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 32) k ON a.f_id = k.f_id + LEFT JOIN tva_rate ON d.ad_value = tva_rate.tva_id::text + JOIN fiche_def USING (fd_id) + LEFT JOIN ( SELECT fiche_detail.f_id, + fiche_detail.ad_value + FROM fiche_detail + WHERE fiche_detail.ad_id = 5) l ON a.f_id = l.f_id; + +COMMENT ON VIEW public.vw_fiche_attr IS 'Some attribute for all cards'; + + +insert into version (val,v_description) values (198,'Cosmetic and VAT'); +commit; \ No newline at end of file diff --git a/include/template/acc_ledger_history_purchase_extended.php b/include/template/acc_ledger_history_purchase_extended.php index 5d77428b6..86b669bcd 100644 --- a/include/template/acc_ledger_history_purchase_extended.php +++ b/include/template/acc_ledger_history_purchase_extended.php @@ -136,8 +136,8 @@ $a_detail=Database::fetch_all($det);
- + diff --git a/include/template/dashboard.php b/include/template/dashboard.php index cd32f25cd..558ccc9b3 100644 --- a/include/template/dashboard.php +++ b/include/template/dashboard.php @@ -74,8 +74,10 @@ if ( $report != 0 ) : ?> $class=($ix%2==0)?' class="even" ':' class="odd" '; echo ''; - echo ''. - '"; + echo ''; + $style='style="text-align:right;"'; + if ($row['montant']<0) { $style='style="color:red;text-align:right;"';} + echo ""; echo ''; } echo '
'.$row['desc'].''.nbm($row['montant'])." € '.$row['desc'].'".nbm($row['montant'])."
'; diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index c072650ce..ce06927ef 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -104,7 +104,7 @@ $hidden=($this->has_quantity()==0)?'d-none':'';

- + @@ -124,10 +124,10 @@ $hidden=($this->has_quantity()==0)?'d-none':''; '; -// echo ""; -echo ''; +echo $item['bt'].$item['card_add'].''; ?> '; - - + @@ -166,13 +165,13 @@ echo ''; + - - + '; $amount_idx++; - } else { - $row.=td(''); } } $class=($e%2==0)?' class="even"':'class="odd"'; diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 92014f93a..e69de29bb 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,65 +0,0 @@ -begin; -with correct_periode as (select jr_tech_per, jr_grpt_id from jrn) -update jrnx set j_tech_per = jr_tech_per from correct_periode where correct_periode.jr_grpt_id=j_grpt and correct_periode.jr_tech_per != j_tech_per; - - - -ALTER TABLE public.tva_rate ADD tva_code text ; -ALTER TABLE public.tva_rate ADD CONSTRAINT tva_code_unique UNIQUE (tva_code); -update tva_rate set tva_code=null; - - -drop VIEW public.v_tva_rate; - -CREATE OR REPLACE VIEW public.v_tva_rate -AS SELECT tva_rate.tva_id, - tva_rate.tva_rate, - tva_rate.tva_code, - tva_rate.tva_label, - tva_rate.tva_comment, - split_part(tva_rate.tva_poste, ','::text, 1) AS tva_purchase, - split_part(tva_rate.tva_poste, ','::text, 2) AS tva_sale, - tva_rate.tva_both_side, - tva_rate.tva_payment_purchase, - tva_rate.tva_payment_sale - FROM tva_rate; - -CREATE OR REPLACE FUNCTION update_tva_code () - returns int4 -AS -$BODY$ -declare -/* - * Section for variables - */ - counter int:=0; - letter int; - x record; - e record; - str_tva_code text; -begin - -- basic loop - for x in select distinct tva_rate from public.tva_rate order by tva_rate - loop - letter :=65; - for e in select * from public.tva_rate where tva_rate = x.tva_rate loop - str_tva_code := round(e.tva_rate*1000)::text||chr(letter); - update tva_rate set tva_code=str_tva_code where tva_id=e.tva_id; - letter := letter+1; - counter := counter+1; - end loop; - - end loop; - return counter; -end; -$BODY$ -LANGUAGE plpgsql; - -select update_tva_code(); - -drop function update_tva_code(); -alter table public.tva_rate alter tva_code set not null; - -ALTER TABLE public.op_predef_detail ALTER COLUMN opd_tva_id TYPE text USING opd_tva_id::text; -insert into version (val,v_description) values (197,'Adapt for VAT CODE'); -commit; diff --git a/unit-test/include/Ajax/ajax_miscTest.php b/unit-test/include/Ajax/ajax_miscTest.php new file mode 100644 index 000000000..dc8204a80 --- /dev/null +++ b/unit-test/include/Ajax/ajax_miscTest.php @@ -0,0 +1,164 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * Author : Dany De Bontridder danydb@noalyss.eu $(DATE) + */ + +/** + * @file + * @brief noalyss + */ + +use PHPUnit\Framework\TestCase; + +require DIRTEST . '/global.php'; + +/** + * @testdox Class Ajax_MiscTest : used for testing the AJAX calls from ajax_misc + * @backupGlobals enabled + */ +class Ajax_MiscTest extends TestCase +{ + + /** + * @var Fiche + */ +// protected $object; +// protected $connection; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test method is executed. + */ +// protected function setUp(): void +// { +// +// +// } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test method is executed. + */ +// protected function tearDown(): void +// { +// /** +// * example +// * if ( ! is_object($this->object->fiche_def)) return; +// * include_once DIRTEST.'/global.php'; +// * $g_connection=Dossier::connect(); +// * $sql=new ArrayObject(); +// * $sql->append("delete from fiche_detail where f_id in (select f_id from fiche where fd_id =\$1 )"); +// * $sql->append("delete from fiche where f_id not in (select f_id from fiche_detail where \$1=\$1)"); +// * $sql->append("delete from jnt_fic_attr where fd_id = \$1 "); +// * $sql->append("delete from fiche_def where fd_id = \$1"); +// * foreach ($sql as $s) { +// * $g_connection->exec_sql($s,[$this->object->fiche_def->id]); +// * } +// */ +// } + + /** + * the setUpBeforeClass() template methods is called before the first test of the test case + * class is run + */ +// public static function setUpBeforeClass(): void +// { +// // include 'global.php'; +// } + + /** + * tearDownAfterClass() template methods is calleafter the last test of the test case class is run, + * + */ +// static function tearDownAfterClass(): void +// { +// // include 'global.php'; +// } + + private function createCard_MA1() + { + global $g_user, $g_connection; + + $fiche_id = $g_connection->get_value("select f_id from fiche_detail where ad_id=$1 and ad_value=$2", + array(ATTR_DEF_QUICKCODE, 'MA1')); + if (!empty ($fiche_id)) { + $this->cleanCard($fiche_id); + } + + + $g_user = new Noalyss_User($g_connection); + //insert a card + $fiche = new Fiche($g_connection); + // card for Merchandise + $fiche->set_fiche_def(1); + Card_Property::load($fiche); + $fiche->setAttribut(1, "Inserted by PHPUNIT-" . __CLASS__ . ":" . __FUNCTION__); + $fiche->setAttribut(ATTR_DEF_TVA, '210A'); + $fiche->setAttribut(ATTR_DEF_QUICKCODE, 'MA1'); + $fiche->insert(1, $fiche->to_array()); + return $fiche; + } + + private function cleanCard($fiche_id) + { + global $g_connection; + $g_connection->exec_sql("delete from fiche_detail where f_id = $1", array($fiche_id)); + $g_connection->exec_sql("delete from fiche where f_id = $1", array($fiche_id)); + } + /** + * @testdox Call fid.php + * @covers ajax call to fid.php + * @backupGlobals enabled + */ + public function testAJAX_retrieveCard() + { + global $g_user, $g_connection; + $fiche=$this->createCard_MA1(); + + $query = array( + 'gDossier' => DOSSIER, + 'FID' => 'MA1', + 'l' => 'e_march4_label', + 't' => 'e_march4_tva_id', + 'p' => 'e_march4_price', + 'b' => 'e_march4_price', + 'd' => 'deb', + 'j' => '3', + 'ctl' => 'undefined' + ); + + $_REQUEST = $_POST = $_GET = $query; + ob_start(); + require NOALYSS_HOME . '/fid.php'; + $content = ob_get_contents(); + ob_end_clean(); + + $expected = <<assertEquals($expected, $content, "Incorrect answer"); + + // clean card + $this->cleanCard($fiche->id); + } + +} \ No newline at end of file diff --git a/unit-test/include/class/Acc_TVATest.php b/unit-test/include/class/Acc_TVATest.php index be5f8a856..5956f4de5 100644 --- a/unit-test/include/class/Acc_TVATest.php +++ b/unit-test/include/class/Acc_TVATest.php @@ -88,7 +88,7 @@ class Acc_TVATest extends TestCase return array( ['abc',true] ,['13A',true] - ,['1',true] + ,['1',false] ,['1-A',false] ,['+a',false] ,['abcdefg',false] @@ -96,7 +96,7 @@ class Acc_TVATest extends TestCase } /** - * @testdox check TVA_CODE value + * @testdox check TVA_CODE value must constains digit and letter * @dataProvider dataCheck * @return void */ diff --git a/unit-test/include/class/acc_ledgerTest.php b/unit-test/include/class/acc_ledgerTest.php index a236e316a..4b0ee2e35 100644 --- a/unit-test/include/class/acc_ledgerTest.php +++ b/unit-test/include/class/acc_ledgerTest.php @@ -18,9 +18,9 @@ class Acc_LedgerTest extends TestCase return $dataSet; } /** - * Get an operation + * @brief Get an operation * @global type $g_connection - * @return type20 + * @return int */ private function get_jrn_id($p_ledger='ODS') { @@ -886,7 +886,10 @@ class Acc_LedgerTest extends TestCase */ public function testInput_new() { + global $g_connection; put_global([["key"=>"ac","value"=>"ODS"]]); + $check_fichedef=$g_connection->get_value("select count(*) from fiche_def"); + $this->assertEquals(7, $check_fichedef,"too many fiche_def"); ob_start(); echo \Noalyss\Facility::page_start(); @@ -896,7 +899,7 @@ class Acc_LedgerTest extends TestCase ob_end_clean(); \Noalyss\Facility::save_file(__DIR__."/file", "acc_ledger-input_new.html", $result); $size=filesize(__DIR__."/file/acc_ledger-input_new.html"); - $this->assertTrue($size == 16320 || $size == 15644 ," output input_new is not what it is expected"); + $this->assertTrue($size == 15653 ," output input_new is not what it is expected"); } diff --git a/unit-test/include/class/acc_ledger_searchTest.php b/unit-test/include/class/acc_ledger_searchTest.php index a36e0020e..ab7128388 100644 --- a/unit-test/include/class/acc_ledger_searchTest.php +++ b/unit-test/include/class/acc_ledger_searchTest.php @@ -89,7 +89,7 @@ class Acc_Ledger_searchTest extends TestCase $r=$ledger->display_search_form(); \Noalyss\Facility::save_file(__DIR__."/file", "acc_ledger_search-test_display_search_form.html", $r); $filesize=strlen($r); - $this->assertTrue($filesize==10345||$filesize==9678,"Size of the html string for display_search_form see " + $this->assertTrue($filesize==11288,"Size of the html string for display_search_form see " . __DIR__."/file/acc_ledger_search-test_display_search_form.html "); } /** diff --git a/unit-test/include/class/acc_operationTest.php b/unit-test/include/class/acc_operationTest.php index 0d9c5dfb0..5bfbf27da 100644 --- a/unit-test/include/class/acc_operationTest.php +++ b/unit-test/include/class/acc_operationTest.php @@ -134,7 +134,9 @@ class Acc_OperationTest extends TestCase function testForm_clone_operation_sale() { global $g_connection; + //----------------------------------- // use jr_id=160 : 5 rows + //----------------------------------- $duplicate = new Acc_Operation($g_connection); $duplicate->jr_id=160; ob_start(); @@ -142,8 +144,10 @@ class Acc_OperationTest extends TestCase $result=$duplicate->form_clone_operation("test"); ob_end_clean(); - $this->assertTrue(stripos($result,'')>0, "sale : HTML doesn't contain nb_item = 5"); + $this->assertTrue(stripos($result,'')>0, "jr_id = ".$duplicate->jr_id." sale : HTML doesnt contain nb_item = 5"); + //----------------------------------- // use jr_id=910 : 1 rows + //----------------------------------- $duplicate = new Acc_Operation($g_connection); $duplicate->jr_id=910; ob_start(); @@ -152,9 +156,11 @@ class Acc_OperationTest extends TestCase $this->assertStringContainsString(strtoupper(''), strtoupper($result)); $this->assertStringContainsString( strtoupper('') - ,strtoupper($result)); + ,strtoupper($result),"jr_id = ".$duplicate->jr_id.""); + //----------------------------------- // use jr_id=659 VAT_SIDED + //----------------------------------- $duplicate = new Acc_Operation($g_connection); $duplicate->jr_id=659; ob_start(); @@ -162,14 +168,31 @@ class Acc_OperationTest extends TestCase ob_end_clean(); $this->assertStringContainsString( strtoupper('') - , strtoupper($result)); + , strtoupper($result),"jr_id = ".$duplicate->jr_id.""); $this->assertStringContainsString( strtoupper('') - , strtoupper($result)); + , strtoupper($result),"jr_id = ".$duplicate->jr_id.""); $this->assertStringContainsString( - strtoupper( '') - , strtoupper($result)); + strtoupper( '') + , strtoupper($result),"jr_id = ".$duplicate->jr_id.""); + //----------------------------------- + // use jr_id=in another currency + //----------------------------------- + $duplicate = new Acc_Operation($g_connection); + $duplicate->jr_id=657; + ob_start(); + $result=$duplicate->form_clone_operation("test"); + ob_end_clean(); + $this->assertStringContainsString( + strtoupper('') + , strtoupper($result),"jr_id = ".$duplicate->jr_id.""); + $this->assertStringContainsString( + strtoupper('') + , strtoupper($result),"jr_id = ".$duplicate->jr_id.""); + $this->assertStringContainsString( + strtoupper( '') + , strtoupper($result),"jr_id = ".$duplicate->jr_id.""); } /** @@ -178,7 +201,9 @@ class Acc_OperationTest extends TestCase */ function testForm_clone_operation_purchase() { global $g_connection; + //----------------------------------- // use jr_id 158 4 rows + //----------------------------------- $duplicate = new Acc_Operation($g_connection); $duplicate->jr_id=158; ob_start(); @@ -196,8 +221,9 @@ class Acc_OperationTest extends TestCase $this->assertStringContainsString( strtoupper('') ,strtoupper($result)); - + //----------------------------------- // use jr_id 680 VAT_SIDED + //----------------------------------- $duplicate = new Acc_Operation($g_connection); $duplicate->jr_id=680; ob_start(); @@ -213,6 +239,23 @@ class Acc_OperationTest extends TestCase $this->assertStringContainsString( strtoupper(''),$result); + //----------------------------------- + // use jr_id=in another currency + //----------------------------------- + $duplicate = new Acc_Operation($g_connection); + $duplicate->jr_id=683; + ob_start(); + $result=$duplicate->form_clone_operation("test"); + ob_end_clean(); + $this->assertStringContainsString( + strtoupper('') + , strtoupper($result)); + $this->assertStringContainsString( + strtoupper('') + , strtoupper($result)); + $this->assertStringContainsString( + strtoupper( '') + , strtoupper($result)); } /** * @testDox Test form_clone_operation MISC OP @@ -253,6 +296,20 @@ class Acc_OperationTest extends TestCase $this->assertStringContainsString( strtoupper('') , $result); + //----------------------------------- + // use jr_id=in another currency + //---------------------------------- + $duplicate->jr_id=658; + ob_start(); + + $result=strtoupper($duplicate->form_clone_operation("test")); + ob_end_clean(); + $this->assertStringContainsString( + strtoupper('') , + $result); + $this->assertStringContainsString( + strtoupper('') , + $result); } } diff --git a/unit-test/include/class/followupTest.php b/unit-test/include/class/followupTest.php index c1fabef38..becff0b7d 100644 --- a/unit-test/include/class/followupTest.php +++ b/unit-test/include/class/followupTest.php @@ -150,8 +150,6 @@ class FollowupTest extends TestCase { global $g_user; $g_user=new Noalyss_User($this->connection); - $array_search= - $query=Follow_Up::create_query($this->connection,array( "ag_dest_query" => "-2", "qcode" => "CLIENT1", diff --git a/unit-test/include/class/pdf_anc_acc_listTest.php b/unit-test/include/class/pdf_anc_acc_listTest.php index cec1792fd..1ce5a4a61 100644 --- a/unit-test/include/class/pdf_anc_acc_listTest.php +++ b/unit-test/include/class/pdf_anc_acc_listTest.php @@ -124,7 +124,7 @@ EOF; $pdf_anc_acc=new PDF_Anc_Acc_List($anc_acc_list); $pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-card-activity.pdf","F"); $filesize=filesize(__DIR__."/file/pdf_anc_acc_list-card-activity.pdf"); - $this->assertTrue($filesize >= 77104 && $filesize <= 77289, + $this->assertTrue($filesize >= 77102 && $filesize <= 77289, __DIR__."/file/pdf_anc_acc_list-card-activity.pdf $filesize incorrect"); // By Account / Activity @@ -157,7 +157,7 @@ EOF; $anc_acc_list->card_poste=4; $pdf_anc_acc=new PDF_Anc_Acc_List($anc_acc_list); $pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-activity-account.pdf","F"); - $this->assertGreaterThan(76400,filesize(__DIR__."/file/pdf_anc_acc_list-activity-account.pdf"), + $this->assertGreaterThan(76500,filesize(__DIR__."/file/pdf_anc_acc_list-activity-account.pdf"), __DIR__."/file/pdf_anc_acc_list-activity-account.pdf incorrect"); } diff --git a/unit-test/test-complet-9.ods b/unit-test/test-complet-9.ods new file mode 100644 index 000000000..d2365bb30 Binary files /dev/null and b/unit-test/test-complet-9.ods differ
Code Code
"; + echo ""; echo $item['quick_code']; // echo "'.$item['bt'].$item['card_add'].' 0.0
diff --git a/include/template/ledger_detail_misc.php b/include/template/ledger_detail_misc.php index 15944d7f7..91b868809 100644 --- a/include/template/ledger_detail_misc.php +++ b/include/template/ledger_detail_misc.php @@ -210,8 +210,6 @@ $amount_idx=0; $sum_prod_currency=0; $str_anc.=$anc_op->display_table(1,$q[$e]['j_montant'],$div); $str_anc.='