Merge branch 'pre-stable' into unstable

* pre-stable: (27 commits)
  test unit : pdf activity
  Database upgrade
  ODS : duplicate in currency
  ODS : cosmetic detail operation, not aligned
  VEN - ACH fix default currency
  SQL : menu cosmetic
  PRINTJRN Cosmetic : 2 columns reversed
  Block new operation with deactivated card
  allow many-to-many lettering + cosmetic
  Bug : ven-3 duplicate does not work with currency : incorrect amount
  REPORT Put the amount in red if negative
  Fix Bug Cosmetic: appearance : color of menu1
  Fix cosmetic : export Operation PDF: anc not printed properly
  ACH-13 : extourne also analytic
  Fix Bug : tva_code not retrieve from search
  PHPUNIT Acc_TVA : tva_code must contains at least one letter Acc_Ledger : input_new PDF_Anc_Acc_ListTest:testPdf_Card Fix bug sizIe
  cosmetic : improve appearance
  Menu not printable
  PHP8.2 Allow Dynamic Properties
  PRINTTVA : display tva_code
  ...
This commit is contained in:
sparkyx 2024-07-15 17:54:26 +02:00
commit 26a3f802db
34 changed files with 685 additions and 220 deletions

View file

@ -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,"<?php \n");
fwrite ($file_loginput,'//@description:'.$op."\n");
fwrite($file_loginput, '$_GET='.var_export($_GET,true));

View file

@ -115,7 +115,7 @@ if ( isset($_SESSION[SESSION_KEY.'isValid']) && $_SESSION[SESSION_KEY.'isValid']
$filter_card=$d;
$filter_card=noalyss_str_replace('[sql]','',$d);
}
$sql="select vw_name,vw_first_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id
$sql="select vw_name,vw_first_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id,tva_code
from vw_fiche_attr
where quick_code=upper($1)". $filter_card;
@ -129,10 +129,11 @@ if ( isset($_SESSION[SESSION_KEY.'isValid']) && $_SESSION[SESSION_KEY.'isValid']
$name=$array[0]['vw_name'];
// use for followup
$sell=(isNumber($array[0]['vw_sell']) == 1) ? $array[0]['vw_sell'] : 0 ;
$buy=(isNumber($array[0]['vw_buy']) == 1) ?$array[0]['vw_buy']:0;
$tva_id=$array[0]['tva_id'];
$tva_id=(empty($array[0]['tva_id']))?$array[0]['tva_code']:$array[0]['tva_id'];
// Check null
$name=($name==null)?" ":noalyss_str_replace('"','',$name);

View file

@ -530,9 +530,11 @@ case 'fs':
$array[$i]['javascript'].=sprintf("set_value('%s','%s');",
$price,$amount);
}
$array[$i]['javascript'].=sprintf("set_value('%s','%s');",
$tvaid,$aFound[$i]['tva_id']);
$array[$i]['javascript'].="removeDiv('search_card');";
// if there is no TVA_ID in the view, it is possible we have a TVA_CODE
$tva_code=(empty($aFound[$i]['tva_id']))?$aFound[$i]['tva_code']:$aFound[$i]['tva_id'];
$array[$i]['javascript'].=sprintf("set_value('%s','%s');",
$tvaid,$tva_code);
$array[$i]['javascript'].="removeDiv('search_card');";
}//foreach

View file

@ -223,6 +223,7 @@ class Acc_Ledger extends jrn_def_sql
function reverse($p_date,$p_label)
{
global $g_user;
global $g_parameter;
try
{
$this->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; $l<count($a_jid); $l++)
{
// jrnx.j_id to reverse
@ -350,9 +353,40 @@ class Acc_Ledger extends jrn_def_sql
select $j_id,pcm_val,ac_id from jrn_tax where j_id=$1 returning jt_id",
[$row]);
// if we use analytic , extourne also in operation_analytic
if ($g_parameter->MY_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()
{

View file

@ -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);

View file

@ -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
</td>
</tr>
EOF;
if ($p_currency_code !=0) {
$rate=_("Taux ");
$r.=<<<EOF
<tr class="highlight">
{$decalage}
<td>
</td>
<td class="num">
</td>
<td class="num">
{$rate} {$p_currency_rate}
</td>
<td class="num">
{$tot_eur} EUR
</td>
</tr>
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.=<<<EOF
<tr class="highlight">
{$decalage}
<td>
</td>
<td class="num">
</td>
<td class="num">
{$rate} {$p_currency_rate}
</td>
<td class="num">
{$tot_eur} {$iso_code}
</td>
</tr>
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.=<<<EOF
<tr class="highlight">
{$decalage}
@ -1849,7 +1863,7 @@ EOF;
<td>
</td>
<td class="num">
{$tot_str} {$str_code}
{$tot_str} {$iso_code}
</td>
</tr>
EOF;

View file

@ -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") {
</td>
</tr>
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.=<<<EOF
<tr class="highlight">
@ -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.=<<<EOF
<tr class="highlight">
@ -1104,7 +1117,7 @@ EOF;
</td>
<td class="num">
{$tot_str}
{$tot_str} {$str_code}
</td>
</tr>
<tr class="highlight">
@ -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');

View file

@ -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.="<p>";
$r.="<ul style=\"margin-left:2rem;padding-left:0;list-style:none;\">";
$r.=sprintf("<li>%s</li>",$operation->det->jr_pj_number);
$r.=sprintf("<li>%s</li>",$operation->det->jr_comment);
$r.=sprintf("<li>%s</li>",$operation->det->jr_montant);
$r.=sprintf("<li>%s %s</li>",_("Date"),$operation->det->jr_pj_number);
$r.=sprintf("<li>%s %s</li>",_("Libellé"),$operation->det->jr_comment);
$r.=sprintf("<li>%s %s %s</li>",_("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("<li>%s %s</li>",_('Devise'),$currency);
$r.=sprintf("<li>%s %s</li>",_("Taux"),$operation->det->currency_rate);
$array['p_currency_code']=$operation->det->currency_id;
$array['p_currency_rate']=$operation->det->currency_rate;
}
$r.="</ul>";
$r.="</p>";
if (count($a_code) == 1 ) {
@ -930,31 +946,57 @@ EOF;
$r.="</p>";
// 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));
}
/***

View file

@ -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);

View file

@ -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')

View file

@ -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;

View file

@ -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();
}

View file

@ -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;

View file

@ -151,8 +151,9 @@ if (isset($_POST['record']))
}
catch (Exception $e)
{
echo '<p class="notice">'.
echo '<p class="error">'.
_('Opération non extournée').
" ".
$e->getMessage().
'</p>';
}

View file

@ -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 = "<span style=\"font-size:18px;color:red\">&#x2716;</span>";
$g_succeed = "<span style=\"font-size:18px;color:green\">&#x2713;</span>";
define('SMALLX', '#xe816;');
define('BUTTONADD', "&#10010;");
define('ICON_SEARCH', '&#x1F50E;');
define('ICON_CLEAN', '&#x2715;');
// If noalyss_version is not defined it is likely directly taken from
// git and so this variable is not set, this cause some issue

View file

@ -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"
);

View file

@ -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 "<TR $class>".
"<TD>".h($op['desc'])."</TD>".
"<TD align=\"right\">".nbm($op['montant'])."</TD>".
"<TD $style>".nbm($op['montant'])."</TD>".
"</TR>";
}
echo "</table>";

View file

@ -40,8 +40,8 @@ class Icon_Action
static function icon_magnifier($id, $p_javascript, $p_style="")
{
$r="";
$r.=sprintf('<span id="%s" class=" smallbutton icon" style="%s" onclick="%s">&#xf50d;</span>',
$id, $p_style, $p_javascript);
$r.=sprintf('<span id="%s" class=" smallbutton icon" style="%s" onclick="%s">%s</span>',
$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('<input type="button" id="%s" class=" smallbutton icon" style="%s" onclick="%s" value="&#xf50d;">',
$id, $p_style, $p_javascript);
$r.=sprintf('<input type="button" id="%s" class=" smallbutton icon" style="%s" onclick="%s" value="%s">',
$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('<input class="smallbutton " onclick="%s" id="%s" value="X" %s type="button" style="">',
$p_javascript, $id, $p_style
$r=sprintf('<input class="smallbutton " onclick="%s" id="%s" value="%s" %s type="button" style="">',
$p_javascript, $id, ICON_CLEAN,$p_style
);
return $r;
}

View file

@ -143,6 +143,7 @@ class IDate extends HtmlInput
%s
/>
<span class="smallbutton icon"
style="color:cornflowerblue"
id="%s_trigger"
/>
&#xe811;

View file

@ -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('<datalist id="dl_tva_%s">',$this->id);
$r.=sprintf('<datalist id="dl_tva_%s"">',$this->id);
foreach ($a_tva_code as $item) {
$r.=sprintf('<option value="%s"></option>',$item['tva_code']);
$r.=sprintf('<option value="%s">%s %s</option>'
,$item['tva_code'],$item['tva_code']
,htmlentities($item['tva_label']));
}
$r.='</datalist>';
return $r;
@ -137,9 +139,11 @@ class ITva_Popup extends HtmlInput
$strAttribut = $this->get_node_attribute();
$str = '<input type="TEXT" class="input_text" name="%s" value="%s" id="%s" placeholder="%s" size="3" %s %s list="dl_tva_%s">';
$str = '<input type="TEXT" class="input_text" name="%s" value="%s" id="%s" placeholder="%s" size="6" %s %s
list="dl_tva_%s" autocomplete="off">';
$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 = '<table>' . '<tr>' . 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');

View file

@ -0,0 +1,89 @@
begin;
update menu_ref set me_menu='Navigateur &#x1F9ED;' where me_code ~ 'NAVI';
update menu_ref set me_menu='Configuration &#x1F527;' where me_code='CFG';
update menu_ref set me_menu='Recherche &#x1F50E;' where me_code='SEARCH';
update menu_ref set me_menu='Agenda &#x1f4c5;' 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;

View file

@ -136,8 +136,8 @@ $a_detail=Database::fetch_all($det);
<table style="width: 100%">
<tr>
<th><?=_("Item")?></th>
<th class="num"><?=_("Prix Unit")?></th>
<th class="num"><?=_("Quantité")?></th>
<th class="num"><?=_("Prix Unit")?></th>
<th class="num"><?=_("HTVA")?></th>
<th class="num"><?=_("TVA")?></th>
<th class="num"><?=_("Code TVA")?></th>

View file

@ -74,8 +74,10 @@ if ( $report != 0 ) : ?>
$class=($ix%2==0)?' class="even" ':' class="odd" ';
echo '<tr '.$class.'>';
echo '<td> '.$row['desc'].'</td>'.
'<td style="text-align:right">'.nbm($row['montant'])." &euro;</td>";
echo '<td> '.$row['desc'].'</td>';
$style='style="text-align:right;"';
if ($row['montant']<0) { $style='style="color:red;text-align:right;"';}
echo "<td $style>".nbm($row['montant'])."</td>";
echo '</tr>';
}
echo '</table>';

View file

@ -104,7 +104,7 @@ $hidden=($this->has_quantity()==0)?'d-none':'';
<h2><?php echo $f_legend_detail?></h2>
<table id="sold_item" >
<tr>
<th style="width:auto"colspan="2">Code <?php echo Icon_Action::infobulle(0)?></th>
<th style="width:auto"colspan="1">Code <?php echo Icon_Action::infobulle(0)?></th>
<th class="visible_gt800 visible_gt1155"><?php echo _('Dénomination')?></th>
<?php if ($flag_tva =='Y') : ?>
<th class="text-center" ><?php echo _('prix/unité htva')?><?php echo Icon_Action::infobulle(6)?></th>
@ -124,10 +124,10 @@ $hidden=($this->has_quantity()==0)?'d-none':'';
</tr>
<?php foreach ($array as $item) {
echo '<tr>';
// echo "<td>";
echo "<td>";
echo $item['quick_code'];
// echo "</td>";
echo '<td>'.$item['bt'].$item['card_add'].'</td>';
echo $item['bt'].$item['card_add'].'</td>';
?>
<td class="visible_gt800 visible_gt1155"><?php echo $item['denom'] ?></td>
<?php
@ -151,8 +151,7 @@ echo '</tr>';
</td>
<td> </td>
<td class="visible_gt800 visible_gt1155"> </td>
<td> </td>
<td> </td>
<td class="col_quant <?=$hidden?> text-center"'> </td>
<td style="text-align:center" class="visible_gt800"> <span id="htva">0.0</span></td>
<?php if ( $flag_tva=='Y' ) : ?>
<td> </td>
@ -166,13 +165,13 @@ echo '</tr>';
</td>
<td class="num visible_gt800"></td>
<td class="col_quant <?=$hidden?> text-center"'> </td>
<?php if ($flag_tva=='Y') {?>
<td style="text-align:center" class="visible_gt800 visible_gt1155"></td>
<td></td>
<td class="visible_gt800"></td>
<?php } ?>
<td></td>
<td></td>
<td></td>
<td style="text-align:center">
<span id="p_currency_euro"></span>

View file

@ -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.='</tr>';
$amount_idx++;
} else {
$row.=td('');
}
}
$class=($e%2==0)?' class="even"':'class="odd"';

View file

@ -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;

View file

@ -0,0 +1,164 @@
<?php
/*
* * Copyright (C) 2022 Dany De Bontridder <dany@alchimerys.be>
*
* 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 = <<<EOF
{"flabel":"e_march4_label","name":"Inserted by PHPUNIT-Ajax_MiscTest:createCard_MA1 ","ftva_id":"e_march4_tva_id","tva_id":"210A","fPrice_sale":"e_march4_price","sell":"0","fPrice_purchase":"e_march4_price","buy":"0","answer":"ok"}
EOF;
$this->assertEquals($expected, $content, "Incorrect answer");
// clean card
$this->cleanCard($fiche->id);
}
}

View file

@ -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
*/

View file

@ -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");
}

View file

@ -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 ");
}
/**

View file

@ -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,'<input type="hidden" id="nb_item" name="nb_item" value="5">')>0, "sale : HTML doesn't contain nb_item = 5");
$this->assertTrue(stripos($result,'<input type="hidden" id="nb_item" name="nb_item" value="5">')>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('<input type="hidden" id="nb_item" name="nb_item" value="1">'), strtoupper($result));
$this->assertStringContainsString(
strtoupper('<input type="hidden" id="e_march0" name="e_march0" value="DEPLAC">')
,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('<input type="hidden" id="e_march0_tva_id" name="e_march0_tva_id" value="5">')
, strtoupper($result));
, strtoupper($result),"jr_id = ".$duplicate->jr_id."");
$this->assertStringContainsString(
strtoupper('<input type="hidden" id="e_march0_tva_amount" name="e_march0_tva_amount" value="0">')
, strtoupper($result));
, strtoupper($result),"jr_id = ".$duplicate->jr_id."");
$this->assertStringContainsString(
strtoupper( '<input type="hidden" id="e_march1_tva_amount" name="e_march1_tva_amount" value="17.3500">')
, strtoupper($result));
strtoupper( '<input type="hidden" id="e_march1_tva_amount" name="e_march1_tva_amount" value="88.392500">')
, 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('<input type="hidden" id="p_currency_code" name="p_currency_code" value="1">')
, strtoupper($result),"jr_id = ".$duplicate->jr_id."");
$this->assertStringContainsString(
strtoupper('<input type="hidden" id="p_currency_rate" name="p_currency_rate" value="1.090000">')
, strtoupper($result),"jr_id = ".$duplicate->jr_id."");
$this->assertStringContainsString(
strtoupper( '<input type="hidden" id="e_march0_price" name="e_march0_price" value="20.000000">')
, 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('<input type="hidden" id="e_march3" name="e_march3" value="DOCUME">')
,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('<input type="hidden" id="e_march1_tva_id" name="e_march1_tva_id" value="4">'),$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('<input type="hidden" id="p_currency_code" name="p_currency_code" value="1">')
, strtoupper($result));
$this->assertStringContainsString(
strtoupper('<input type="hidden" id="p_currency_rate" name="p_currency_rate" value="1.090000">')
, strtoupper($result));
$this->assertStringContainsString(
strtoupper( '<INPUT TYPE="HIDDEN" ID="E_MARCH0_PRICE" NAME="E_MARCH0_PRICE" VALUE="18.250000">')
, strtoupper($result));
}
/**
* @testDox Test form_clone_operation MISC OP
@ -253,6 +296,20 @@ class Acc_OperationTest extends TestCase
$this->assertStringContainsString(
strtoupper('<input type="hidden" id="e_other0_amount" name="e_other0_amount" value="3500.7800">') ,
$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('<input type="hidden" id="e_other0_amount" name="e_other0_amount" value="146.950000">') ,
$result);
$this->assertStringContainsString(
strtoupper('<INPUT TYPE="HIDDEN" ID="P_CURRENCY_RATE" NAME="P_CURRENCY_RATE" VALUE="1.090000">') ,
$result);
}
}

View file

@ -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",

View file

@ -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");
}

Binary file not shown.