21require_once NOALYSS_INCLUDE.
'/lib/ac_common.php';
22require_once NOALYSS_INCLUDE.
'/database/jrn_def_sql.class.php';
23require_once NOALYSS_INCLUDE.
'/database/operation_currency_sql.class.php';
53 parent::__construct($p_cn,
$p_id);
60 $this->is_loaded=
false;
64 $this->is_loaded=
true;
82 $this->
db->get_value(
"select currency_id from jrn_def where jrn_def_id=$1",
84 if ( $this->currency_id ==
"") {
92 throw new Exception(_(
"Paramètre invalide"));
94 if ($this->
db->exist_sequence(
"s_jrn_pj".$this->id))
96 $ret=$this->
db->get_array(
"select last_value,is_called from s_jrn_pj".$this->
id);
102 if (
$ret[0][
'is_called']==
'f')
108 $this->
db->create_sequence(
"s_jrn_pj".$this->
id);
137 $this->ledger_name=_(
" Tous les journaux");
138 $this->ledger_type=
"GL";
142 $Res=$this->
db->exec_sql(
"select jrn_def_type from ".
143 " jrn_def where jrn_def_id=".
149 $this->ledger_type=
$ret[
'jrn_def_type'];
150 return $ret[
'jrn_def_type'];
174 $grpt_id=$this->
db->get_value(
'select jr_grpt_id from jrn where jr_id=$1',
175 array($this->
jr_id));
176 if ($this->
db->count()==0)
180 $this->
db->exec_sql(
'delete from jrnx where j_grpt=$1', array($grpt_id));
181 $this->
db->exec_sql(
'delete from jrn where jr_id=$1',
182 array($this->
jr_id));
192 $str=
'<p class="notice"> '.$p_warning;
193 $str.=
"<ol class=\"notice\">";
194 for (
$i=0;
$i<count($pa_msg);
$i++)
196 $str.=
"<li>".$pa_msg[
$i].
"</li>";
231 throw new Exception(_(
"this->jr_id is not set ou opération inconnue"));
237 throw new Exception(_(
'Date invalide').
$p_date);
242 $grp_new=$this->
db->get_next_seq(
's_grpt');
243 $seq=$this->
db->get_next_seq(
"s_jrn");
245 $this->jr_grpt_id=$this->
db->get_value(
'select jr_grpt_id from jrn where jr_id=$1',
246 array($this->
jr_id));
247 if ($this->
db->count()==0)
248 throw new Exception(_(
"Cette opération n'existe pas"));
249 $this->jr_internal=$this->
db->get_value(
'select jr_internal from jrn where jr_id=$1',
250 array($this->
jr_id));
251 if ($this->
db->count()==0||trim($this->jr_internal)==
'')
252 throw new Exception(_(
"Cette opération n'existe pas"));
259 if (
$per->is_open()==0)
261 throw new Exception(_(
'PERIODE FERMEE').
" $p_date ");
266 if ($this->
db->get_value(
"select count(*) from jrn_note where jr_id=$1",[$this->jr_id])>0){
267 $sql=
"update jrn_note set n_text=$2||n_text where jr_id=$1";
270 $sql=
"insert into jrn_note(n_text,jr_id) values ($1,$2)";
277 throw new Exception(__FILE__.__LINE__.
"sql a echoue [ $sql ]");
283 $a_jid=$this->
db->get_array(
"select j_id,j_debit from jrnx where j_grpt=$1",
284 array($this->jr_grpt_id));
285 for (
$l=0;
$l<count($a_jid);
$l++)
291 $sql=
"insert into jrnx (
292 j_date,j_montant,j_poste,j_grpt,
293 j_jrn_def,j_debit,j_text,j_internal,j_tech_user,j_tech_per,j_qcode
294 ) select to_date($1,'DD.MM.YYYY'),j_montant,j_poste,$2,
295 j_jrn_def,not (j_debit),j_text,$3,$4,$5,
299 where j_id=$6 returning j_id";
306 throw (
new Exception(__FILE__.__LINE__.
"SQL ERROR [ $sql ]"));
308 $aj_id=$this->
db->fetch(0);
311 $j_id=$aj_id[
'j_id'];
318 $Res=$this->
db->exec_sql(
"INSERT INTO quant_sold(
319 qs_internal, qs_fiche, qs_quantite, qs_price, qs_vat,
320 qs_vat_code, qs_client, qs_valid, j_id,qs_vat_sided,qs_unit)
321 SELECT $1, qs_fiche, qs_quantite*(-1), qs_price*(-1), qs_vat*(-1),
322 qs_vat_code, qs_client, qs_valid, $2,qs_vat_sided*(-1),qs_unit*(-1)
323 FROM quant_sold where j_id=$3",
328 throw new Exception(__FILE__.__LINE__.
"sql a echoue [ $sql ]");
330 $Res=$this->
db->exec_sql(
"INSERT INTO quant_purchase(
331 qp_internal, j_id, qp_fiche, qp_quantite, qp_price, qp_vat,
332 qp_vat_code, qp_nd_amount, qp_nd_tva, qp_nd_tva_recup, qp_supplier,
333 qp_valid, qp_dep_priv,qp_vat_sided,qp_unit)
334 SELECT $1, $2, qp_fiche, qp_quantite*(-1), qp_price*(-1), qp_vat*(-1),
335 qp_vat_code, qp_nd_amount*(-1), qp_nd_tva*(-1), qp_nd_tva_recup*(-1), qp_supplier,
336 qp_valid, qp_dep_priv*(-1),qp_vat_sided*(-1),qp_unit*(-1)
337 FROM quant_purchase where j_id=$3",
342 throw new Exception(__FILE__.__LINE__.
"SQL ERROR [ $sql ]");
345 $this->
db->exec_sql(
"insert into operation_currency (oc_amount,oc_vat_amount,oc_price_unit,j_id) "
346 .
" select oc_amount,oc_vat_amount,oc_price_unit,$j_id from operation_currency where j_id=$1",
349 $jrn_tax_id=$this->
db->exec_sql(
"insert into jrn_tax(j_id,pcm_val,ac_id)
350 select $j_id,pcm_val,ac_id from jrn_tax where j_id=$1 returning jt_id",
356 $old_receipt=$this->
db->get_row(
"select jr_pj_number,jr_def_id from jrn where jr_id=$1",[$this->
jr_id]);
357 $sql=
"insert into jrn (
372 select $1,jr_def_id,jr_montant,$7,
373 to_date($2,'DD.MM.YYYY'),$3,$4,
374 $5, true,'EXT',currency_id,currency_rate,currency_rate_ref
377 where jr_id=$6 returning jr_id";
380 $reverse_id=$this->
db->get_value(
$sql,
381 array(
$seq,
$p_date, $grp_new, $p_internal,
$per->p_id, $this->jr_id,$p_label));
383 $reverse_accOp->set_id($reverse_id);
384 $reverse_accOp->pj=$old_receipt[
'jr_pj_number'];
385 $reverse_accOp->jrn=$old_receipt[
'jr_def_id'];
386 $reverse_accOp->set_pj();
388 }
catch (\Exception
$e){
389 throw new \Exception(
'Echec extourne');
396 $Res=$this->
db->exec_sql(
" INSERT INTO quant_fin(
397 qf_bank, qf_other, qf_amount,jr_id,j_id)
398 SELECT qf_bank, qf_other, qf_amount*(-1),$1,$3
399 FROM quant_fin where jr_id=$2",
403 throw (
new Exception(__FILE__.__LINE__.
"SQL ERROR[ $sql ]"));
409 $rec->set_jr_id(
$seq);
410 $rec->insert($this->
jr_id);
415 throw (
new Exception(__FILE__.__LINE__.
"SQL ERROR [ $sql ]"));
422 $sql=
"delete from stock_goods where sg_id = any ( select sg_id
423 from stock_goods natural join jrnx where j_grpt=".$this->jr_grpt_id.
")";
427 throw (
new Exception(__FILE__.__LINE__.
"SQL ERROR [ $sql ]"));
434 $this->
db->rollback();
447 $this->ledger_name=_(
"Grand Livre");
451 $Res=$this->
db->exec_sql(
"select jrn_def_name from ".
452 " jrn_def where jrn_def_id=$1", array($this->
id));
459 $this->ledger_name=
$ret[
'jrn_def_name'];
460 return $ret[
'jrn_def_name'];
474 $pj_pref=
$prop[
"jrn_def_pj_pref"];
476 return $pj_pref.$pj_seq;
496 $Res=$this->
db->get_row(
"select *
498 where jrn_def_id=$1", array($this->
id));
501 echo
'<DIV="redcontent"><H2 class="error">'._(
'Parametres journaux non trouves').
'</H2> </DIV>';
519 $ledger=
" and j_jrn_def = ".$this->id;
523 $sql=
'select j_montant as montant,j_debit as deb from jrnx where '
534 if (
$line[
'deb']==
't')
588 $sql=
"select jrn_def_fiche_deb as deb,jrn_def_fiche_cred as cred ".
589 " from jrn_def where ".
592 $r=$this->
db->exec_sql(
$sql, array($this->
id));
609 $sql=
"select jrn_def_class_deb ".
610 " from jrn_def where ".
613 $r=$this->
db->exec_sql(
$sql, array($this->
id));
638 return _(
"Aucun résultat");
645 $lPeriode->p_id=$period;
649 $lPeriode->find_periode(
$e_date);
659 _(
"Attention : il vaut mieux utiliser les fiches que les postes comptables"));
662 $ret.=
"<tr><td>"._(
'Date').
" : </td><td>$e_date</td></tr>";
666 $ret.=
"<tr><td>"._(
'Libellé').
" </td><td>".
h(
$desc).
"</td></tr>";
668 $ret.=_(
'Note').
'</td><td><pre>'.
h(
$p_array[
'jrn_note_input']).
'</pre>';
676 if (
$p_readonly ==
false)
$ret.=
"<tr><td>"._(
'PJ Num').
" </td><td>".
h($e_pj).$span.
"</td></tr>";
677 if (
$p_readonly ==
true )
$ret.=
"<tr><td>"._(
'PJ Num').
" </td><td>".
h($this->pj).$span.
"</td></tr>";
679 $ret.=
"<table class=\"result\">";
681 $ret.=
"<th>"._(
'Quick Code ou ');
682 $ret.=_(
"Poste").
" </th>";
683 $ret.=
"<th style=\"text-align:left\"> "._(
"Libellé").
" </th>";
684 $ret.=
"<th style=\"text-align:right\">"._(
"Débit").
"</th>";
685 $ret.=
"<th style=\"text-align:right\">"._(
"Crédit").
"</th>";
690 $a_anc=
$anc->get_list();
693 $ret.=
'<th colspan="'.$x.
'" style="width:auto;text-align:center" >'._(
'Compt. Analytique').
'</th>';
718 $ret.=dossier::hidden();
720 for (
$i=0;
$i<$nb_item;
$i++)
724 if (!isset(${
'qc_'.$i}))
726 if (!isset(${
'poste'.$i}))
728 if (!isset(${
'amount'.$i}))
731 $class=(
$i%2==0)?
' class="even" ':
' class="odd" ';
732 $ret.=
"<tr $class> ";
733 if (trim(${
'qc_'.$i})!=
"")
736 $oqc->get_by_qcode(${
'qc_'.$i},
false);
745 if (trim(${
'qc_'.$i})==
""&&trim(${
'poste'.$i})!=
"")
748 $strPoste=$oposte->id;
749 $ret.=
"<td>".h(${
"poste".$i}.
" - ".
750 $oposte->get_name()).HtmlInput::hidden(
'poste'.
$i,
755 if (trim(${
'qc_'.$i})==
""&&trim(${
'poste'.$i})==
"")
760 if (isset(${
"ck$i"}))
763 ${
'amount'.$i}).
"</td>".
td(
"");
764 $total_deb=bcadd($total_deb, ${
'amount'.$i});
769 ${
'amount'.$i}).
"</td>";
770 $total_cred=bcadd($total_cred, ${
"amount".$i});
784 $ret.=
'<td style="text-align:center">';
787 round(${
'amount'.$i}, 2));
798 $currency_code=
$http->extract(
"p_currency_code",
"number");
799 $currency_rate=
$http->extract(
"p_currency_rate",
"number");
801 $msg_currency= ($currency_code != 0 )?sprintf(_(
"Totaux %s (%s)"),
$currency->get_code(),$currency_rate):_(
"Totaux");
803 $ret.=
tr(
td(
'').
td($msg_currency).
td($total_deb,
'class="num"').
td($total_cred,
804 'class="num"'),
'class="highlight"');
806 if ( $currency_code != 0)
808 $currency_rate=
$http->extract(
"p_currency_rate",
"number");
813 td(bcdiv($total_deb,$currency_rate),
'class="num"').
814 td(bcdiv($total_cred,$currency_rate),
'class="num"'),
815 'class="highlight"');
820 $ret.=
'<input type="button" class="button" value="'._(
'verifie Imputation Analytique').
821 '" onClick="verify_ca(\'\');">';
829 $row=$this->
db->get_value(
"select jrn_deb_max_line from jrn_def where jrn_def_id=$1",
854 $add_js=
"update_pj();";
858 $add_js.=
'get_last_date();';
860 $add_js.=
'update_row("quick_item");';
870 throw new Exception(_(
'Pas de journal disponible'));
872 $wLedger->javascript=
"onChange='update_name();update_predef(\"ods\",\"t\",\"".$ac.
"\");$add_js'";
873 $label=
" Journal ".Icon_Action::infobulle(2);
882 echo
'<div id="predef_form">';
885 $op->set_p_jrn($this->
id);
886 $op->set_jrn_type(
"ODS");
888 $url=http_build_query(
889 array(
'action'=>
'use_opd',
890 'p_jrn_predef'=>$this->
id,
893 echo
$op->form_get(
'do.php?'.
$url);
896 $str_op_template=ob_get_contents();
899 $ret.=
"<td>"._(
"Modèle d'opération").
"</td>";
900 $ret.=
"<td>".$str_op_template.
"</td>";
916 $l_user_per=
$g_user->get_periode();
926 $l_form_per=$period->input();
931 if (
$e->getCode()==1)
933 echo _(
"Aucune période ouverte");
938 $f_periode=
td(_(
"Période comptable").
" $label ").td($l_form_per);
941 $wPJ=
new IText(
'e_pj');
942 $wPJ->readonly=
false;
953 $wPJ->setReadOnly(
true);
954 $wPJ->value=$default_pj;
957 $wPJ->value=(isset($e_pj))?$e_pj:$default_pj;
961 $ret.=
'<td style="width:auto"> '._(
'Pièce').
' </td> ';
969 $wDescription=
new IText(
'desc');
971 $wDescription->size = (empty(
$desc))?60:strlen(
$desc)+5;
972 $wDescription->size = ($wDescription->size<60)?60:$wDescription->size;
974 $ret.=$wDescription->input();
983 $ret.=
'<td> <pre id="jrn_note_td"></pre></td>';
985 $currency_select = $this->
CurrencyInput(
"currency_code",
"p_currency_rate" ,
"p_currency_euro");
986 $currency_select->selected=
$http->request(
'p_currency_code',
'string',0);
988 $currency_input=
new INum(
"p_currency_rate");
989 $currency_input->prec=8;
990 $currency_input->id=
"p_currency_rate";
991 $currency_input->value=
$http->request(
'p_currency_rate',
'string',1);
992 $ret.=
tr(
td(_(
"Devise")).
td($currency_select->input().
993 $currency_input->change(
'CurrencyComputeMisc(\'p_currency_rate\',\'p_currency_euro\');')));
1000 $note = (isset(
$p_array[
'jrn_note_input'])) ?
$p_array[
'jrn_note_input'] :
'';
1003 $ret.=ob_get_contents();
1010 $nb_row=(isset($nb_item) )?$nb_item:$this->
nb;
1013 $ret.=dossier::hidden();
1017 $ret.=
'<table id="quick_item" style="width:100%">';
1019 '<th style="text-align:left">Quickcode'.$info.
'</th>'.
1020 '<th style="text-align:left">'._(
'Poste').$info_poste.
'</th>'.
1021 '<th class="visible_gt800 visible_gt1155" style="text-align:left">'._(
'Libellé').
'</th>'.
1022 '<th style="text-align:left">'._(
'Montant').
'</th>'.
1023 '<th style="text-align:left">'._(
'Côté').
'</th>'.
1031 $quick_code->set_dblclick(
"fill_ipopcard(this);");
1043 $quick_code->javascript=sprintf(
' onchange="fill_data_onchange(\'%s\');" ',
1046 $quick_code->value=(isset(${
'qc_'.$i}))?${
'qc_'.$i}:
"";
1062 $poste->set_attribute(
'ipopup',
'ipop_account');
1063 $poste->set_attribute(
'label',
'ld'.
$i);
1064 $poste->set_attribute(
'account',
'poste'.
$i);
1067 $poste->value=(isset(${
'poste'.$i}))?${
"poste".$i}:
''
1069 $poste->dbl_click_history();
1076 $label=$Poste->get_lib();
1080 $line_desc=
new IText();
1081 $line_desc->name=
'ld'.$i;
1082 $line_desc->size=30;
1083 $line_desc->value=(isset(${
"ld".$i}))?${
"ld".$i}:
1090 $amount->value=(isset(${
'amount'.$i}))?${
"amount".$i}:
''
1093 $amount->javascript=
'onChange="format_number(this);checkTotalDirect()"';
1097 $deb->selected=(isset(${
'ck'.$i}))?
true:
false;
1099 $deb->javascript=
'class="debit-credit" onChange="checkTotalDirect()"';
1100 $str_add_button=($add_card==
true)?$this->
add_card(
"-1",
1103 $ret.=
'<td>'.$quick_code->input().$quick_code->search().$str_add_button.
'</td>';
1104 $ret.=
'<td>'.$poste->input().
1106 'document.getElementById(\'poste'.$i.
'\').onblur=
function(){
'.
1107 'if (trim(this.
value) !=\
'\')
'.
1108 '{document.getElementById(\
'qc_'.
$i.
'\').value=
"";}}
'.
1111 $ret.='<
td class=
"visible_gt800 visible_gt1155">
'.$line_desc->input().'</
td>
';
1112 $ret.='<
td>
'.$amount->input().'</
td>
';
1113 $ret.='<
td>
'.$deb->input()
1114 .'<
span id=
"txt'.$deb->id.'"></
span>
'
1117 // If readonly == 1 then show CA
1120 if (isset($this->with_concerned)&&$this->with_concerned==true)
1122 $oRapt=new Acc_Reconciliation($this->db);
1123 $w=$oRapt->widget();
1124 $w->name='jrn_concerned
';
1125 $w->value=(isset($jrn_concerned))?$jrn_concerned:"";
1126 $ret.=sprintf(_("Réconciliation/rapprochements : %s"), $w->input());
1128 $ret.=create_script("$('".$wDate->id."').focus()");
1129 // for displaying Credit or Debit
1130 $ret.=create_script("(function(){activate_checkbox_side()})();");
1141 function is_closed($p_periode)
1143 $per=new Periode($this->db);
1144 $per->set_ledger($this->id);
1145 $per->set_periode($p_periode);
1146 $ret=$per->is_closed();
1160 function verify_operation($p_array)
1162 global $g_parameter;
1163 $http=new HttpInput();
1164 if (is_array($p_array)==false||empty($p_array))
1165 throw new Exception("Array empty");
1167 * Check needed value
1169 check_parameter($p_array, 'p_jrn,e_date
');
1171 extract($p_array, EXTR_SKIP);
1176 $http->set_array($p_array);
1177 /* Check currency : rate cannot be equal to 0 */
1178 $currency_rate=$http->extract("p_currency_rate","number");
1179 if ( $currency_rate <=0 ) {
1180 throw new Exception(_("Taux de conversion doit être supérieur à 0"),3);
1182 /* Check currency : Does the currency parameter exist */
1183 $currency_code=$http->extract("p_currency_code","number");
1184 $currency=new Acc_Currency($this->db,$currency_code);
1186 $this->check_currency_setting($currency_code);
1188 /* check if we can write into this ledger */
1189 if ($g_user->check_jrn($p_jrn)!='W
')
1190 throw new Exception(_('Accès interdit
'), 20);
1192 /* check for a double reload */
1193 if (isset($mt)&&$this->db->count_sql('select jr_mt
from jrn where jr_mt=$1
',
1195 throw new Exception(_('Double Encodage
'), 5);
1197 // Check the periode and the date
1198 if (isDate($e_date)==null)
1200 throw new Exception(_('Date invalide
'), 2);
1202 $periode=new Periode($this->db);
1203 /* find the periode if we have enabled the check_periode
1204 * or if period is not set
1206 if ($this->check_periode()==false||!isset($p_array['period
']))
1209 $periode->find_periode($e_date);
1210 } catch (Exception $e) {
1211 throw new Exception(_("Période inexistante"), 6, $e);
1216 $periode->p_id=$p_array['period
'];
1217 list ($min, $max)=$periode->get_date_limit();
1218 if (cmpDate($e_date, $min)<0||
1219 cmpDate($e_date, $max)>0)
1220 throw new Exception(_('Date et periode ne correspondent pas
'), 6);
1226 if ($this->is_closed($periode->p_id)==1)
1228 throw new Exception(_('Periode fermee
'), 6);
1230 /* check if we are using the strict mode */
1231 if ($this->check_strict()==true)
1233 /* if we use the strict mode, we get the date of the last
1235 $last_date=$this->get_last_date();
1236 if ($last_date!=null&&cmpDate($e_date, $last_date)<0)
1237 throw new Exception(
1239 _('Vous utilisez le mode strict la dernière operation est la date du %s
1240 vous ne pouvez pas encoder à une date antérieure
'),$last_date),
1244 for ($i=0; $i<$nb_item; $i++)
1248 // compatibily php 8.0 , if $amount is not a number then skip
1249 if (!isset(${'amount
'.$i}) || isNumber(${'amount
'.$i})==0) {
1253 // Check the balance
1254 $amount=round(${'amount
'.$i}, 2);
1255 $tot_deb+=(isset(${'ck
'.$i}))?$amount:0;
1256 $tot_cred+=(!isset(${'ck
'.$i}))?$amount:0;
1258 // Check if the card is permitted
1259 if (isset(${'qc_
'.$i})&&trim(${'qc_
'.$i})!="")
1261 $f=new Fiche($this->db);
1262 $f->quick_code=${'qc_
'.$i};
1263 if ($f->belong_ledger($p_jrn) < 1 )
1264 throw new Exception("La fiche quick_code = ".
1265 $f->quick_code." n'est pas dans ce journal
", 4);
1266 if (noalyss_strlentrim(${'qc_'.$i})!=0&&isNumber(${'amount'.$i})==0)
1267 throw new Exception(_('Montant invalide'), 3);
1269 $strPoste=$f->strAttribut(ATTR_DEF_ACCOUNT);
1271 throw new Exception(sprintf(_("La fiche %s
n'a pas de poste comptable"),
1274 $p=new Acc_Account_Ledger($this->db, $strPoste);
1275 if ($p->do_exist()==0)
1276 throw new Exception(_('Poste Inexistant pour la fiche [
'.${'qc_
'.$i}.']
'),
1280 // Check if the account is permitted
1281 if (isset(${'poste
'.$i})&&noalyss_strlentrim(${'poste
'.$i})!=0)
1283 $p=new Acc_Account_Ledger($this->db, ${'poste
'.$i});
1284 if ($p->belong_ledger($p_jrn)<0) {
1285 throw new Exception(sprintf (
1286 _("Le poste %s n'est pas dans ce journal
",$p->id)),
1289 if (noalyss_strlentrim(${'poste'.$i})!=0&&isNumber(${'amount'.$i})==0)
1290 throw new Exception(_('Poste invalide ['.${'poste'.$i}.']'),
1292 if ($p->do_exist()==0)
1293 throw new Exception(_('Poste Inexistant ['.${'poste'.$i}.']'),
1295 $card_id=$p->find_card();
1296 if (!empty($card_id))
1298 $str_msg=sprintf(_(" Le poste %s appartient à fiche(s) dont : %s
"),$p->id,count($card_id));
1299 $max=(count($card_id)>MAX_COMPTE_CARD)?MAX_COMPTE_CARD:count($card_id);
1300 for ($x=0; $x<$max; $x++)
1302 $card=new Fiche($this->db, $card_id[$x]['f_id']);
1303 $str_msg.=HtmlInput::card_detail($card->strAttribut(ATTR_DEF_QUICKCODE),
1304 $card->strAttribut(ATTR_DEF_NAME),
1305 'style="color:red;
display:
inline;text-decoration:underline
"');
1310 $account=new Acc_Account($this->db,${"poste
".$i});
1311 if ( $account->get_parameter("pcm_direct_use
") == "N
") {
1312 throw new Exception(sprintf (_("Utilisation directe interdite du poste comptable %s
"), ${"poste
".$i}));
1316 $tot_deb=round($tot_deb, 4);
1317 $tot_cred=round($tot_cred, 4);
1318 if ($tot_deb!=$tot_cred)
1320 throw new Exception(_("Balance incorrecte
")." debit =
$tot_deb credit=
$tot_cred ",
1337 function compute_internal_code($p_grpt)
1341 $num=$this->db->get_next_seq('s_internal');
1342 $atype=$this->get_propertie();
1343 $type=substr($atype['jrn_def_code'], 0, 1);
1344 $internal_code=sprintf("%s%06X
", $type, $num);
1345 $this->jr_internal=$internal_code;
1346 return $internal_code;
1357 function save($p_array=null)
1361 throw new Exception('save cannot use a empty array');
1363 global $g_parameter;
1365 $http=new HttpInput();
1366 extract($p_array, EXTR_SKIP);
1367 if ( !isset($p_array['jrn_note_input'])) {$p_array['jrn_note_input']='';}
1370 $msg=$this->verify($p_array);
1373 echo $this->display_warning($msg,
1374 _("Attention : il vaut mieux utiliser les fiches que les postes comptables
"));
1378 $seq=$this->db->get_next_seq('s_grpt');
1379 $internal=$this->compute_internal_code($seq);
1381 $group=$this->db->get_next_seq("s_oa_group
");
1385 $oPeriode=new Periode($this->db);
1386 $check_periode=$this->check_periode();
1387 if ($check_periode==false||!isset($p_array['period']))
1389 $oPeriode->find_periode($e_date);
1393 $oPeriode->id=$period;
1399 $http->set_array($p_array);
1400 $currency_code=$http->extract( "p_currency_code
","number
",0);
1401 $currency_rate=$http->extract( "p_currency_rate
","number
",1);
1402 $currency_rate_ref=new Acc_Currency($this->db, $currency_code);
1404 for ($i=0; $i<$nb_item; $i++)
1406 if (!isset(${'qc_'.$i})&&!isset(${'poste'.$i}))
1408 $acc_op=new Acc_Operation($this->db);
1410 // First we save the jrnx
1411 if (isset(${'qc_'.$i}))
1413 $qc=new Fiche($this->db);
1414 $qc->get_by_qcode(${'qc_'.$i}, false);
1415 $sposte=$qc->strAttribut(ATTR_DEF_ACCOUNT);
1416 /* if there are 2 accounts take following the deb or cred */
1417 if (strpos($sposte, ',')!=0)
1419 $array=explode(",
", $sposte);
1420 $poste=(isset(${'ck'.$i}))?$array[0]:$array[1];
1426 throw new Exception(sprintf(_("La fiche %s
n'a pas de poste comptable"),
1429 $quick_code=${'qc_
'.$i};
1433 $poste=${'poste
'.$i};
1436 $acc_op->date=$e_date;
1437 // compute the periode is do not check it
1438 if ($check_periode==false)
1439 $acc_op->periode=$oPeriode->p_id;
1441 if (noalyss_strlentrim(${'ld
'.$i})!=0)
1442 $acc_op->desc=${'ld
'.$i};
1444 // Amount in default currency , usually EUR
1445 $acc_op->amount=round(bcdiv(${'amount
'.$i},$currency_rate),2);
1447 $acc_op->poste=$poste;
1448 $acc_op->jrn=$this->id;
1449 $acc_op->type=(isset(${'ck
'.$i}))?'d
':'c
';
1450 $acc_op->qcode=$quick_code;
1451 $j_id=$acc_op->insert_jrnx();
1454 $operation_currency=new Operation_currency_SQL($this->db);
1455 if (isNumber(${'amount
'.$i}) == 0) {
1456 $operation_currency->oc_amount=0;
1458 $operation_currency->oc_amount=round(${'amount
'.$i}, 2);
1460 $operation_currency->oc_vat_amount=0;
1461 $operation_currency->oc_price_unit=0;
1462 $operation_currency->j_id=$j_id;
1463 $operation_currency->insert();
1465 $tot_amount=bcadd($tot_amount,round($acc_op->amount, 2));
1467 if ( $acc_op->type == 'd
') {
1468 $tot_deb=bcadd($tot_deb, $acc_op->amount);
1469 }elseif ( $acc_op->type == 'c
') {
1470 $tot_cred=bcadd($tot_cred,$acc_op->amount);
1473 if ($g_parameter->MY_ANALYTIC!="nu")
1475 if ($g_parameter->match_analytic( $poste)==TRUE)
1478 // for each item, insert into operation_analytique */
1479 $op=new Anc_Operation($this->db);
1480 $op->set_currency_rate($currency_rate);
1481 $op->oa_group=$group;
1483 $op->oa_date=$e_date;
1484 $op->oa_debit=($acc_op->type=='d
' )?'t
':'f
';
1485 $op->oa_description=$desc;
1487 // send the amount in default currency to analytic
1489 $an_array['amount
'.$i]=$acc_op->amount;
1490 $op->save_form_plan($an_array, $count, $j_id);
1494 }// loop for each item
1495 $acc_end=new Acc_Operation($this->db);
1496 // Check the balance
1497 if ( bcsub($tot_deb,$tot_cred,2) != 0 && $currency_code != 0)
1500 $diff=bcsub($tot_cred, $tot_deb);
1501 // store the difference in currency_rounded_delta
1502 $poste_cred = $g_parameter->MY_DEFAULT_ROUND_ERROR_CRED;
1506 $poste=$g_parameter->MY_DEFAULT_ROUND_ERROR_DEB;
1511 // insert difference of change
1512 $acc_change=new Acc_Operation($this->db);
1513 $acc_change->amount=abs($diff);
1514 $acc_change->grpt=$seq;
1515 $acc_change->poste=$poste;
1516 $acc_change->jrn=$this->id;
1517 $acc_change->type=$side;
1518 $acc_change->date=$e_date;
1519 $acc_change->desc=_("Différence de change");
1521 $change_j_id=$acc_change->insert_jrnx();
1523 $tot_deb=bcadd($tot_deb,$diff);
1526 $acc_end->amount=$tot_deb;
1527 if ($check_periode==false)
1529 $acc_end->periode=$oPeriode->p_id;
1531 $acc_end->date=$e_date;
1532 $acc_end->desc=$desc;
1533 $acc_end->grpt=$seq;
1534 $acc_end->jrn=$this->id;
1536 $acc_end->jr_optype=$jr_optype;
1537 $acc_end->currency_id=$currency_code;
1538 $acc_end->currency_rate=$currency_rate;
1539 $acc_end->currency_rate_ref=$currency_rate_ref->get_rate();
1541 $jr_id=$acc_end->insert_jrn();
1543 $this->jr_id=$jr_id;
1545 throw new Exception(_('Balance incorrecte
'));
1547 $this->pj=$acc_end->set_pj();
1548 /* if e_suggest != e_pj then do not increment sequence */
1549 if ($this->pj == $e_pj_suggest &&noalyss_strlentrim($e_pj)!=0)
1551 $this->inc_seq_pj();
1556 $this->db->exec_sql("update jrn set jr_internal=$1
1557 where jr_grpt_id = $2",array($internal,$seq));
1559 $this->internal=$internal;
1560 // Save now the predef op
1561 //------------------------
1562 if (isset($opd_name)&&trim($opd_name)!="")
1564 $opd=new Pre_operation($this->db);
1565 $opd->set_od_direct('t
');
1570 if (isset($this->with_concerned)&&$this->with_concerned==true)
1572 $orap=new acc_reconciliation($this->db);
1573 $orap->jr_id=$jr_id;
1575 $orap->insert($jrn_concerned);
1580 if (isset($_FILES["pj"]))
1582 $this->db->save_receipt($seq);
1584 /*----------------------------------------------
1586 ----------------------------------------------*/
1587 if (isset($p_array['jrn_note_input
']) && !empty($p_array['jrn_note_input
'])) {
1588 $acc_operation_note=Acc_Operation_Note::build_jrn_id(-1);
1589 $acc_operation_note->setNote($p_array['jrn_note_input
']);
1590 $acc_operation_note->setOperation_id( $jr_id);
1591 $acc_operation_note->save();
1594 catch (Exception $e)
1597 $this->db->rollback();
1598 echo _('OPERATION ANNULEE
');
1600 echo __FILE__.__LINE__.$e->getMessage();
1603 $this->db->commit();
1616 static function next_number($p_cn, $p_type)
1619 $Ret=$p_cn->count_sql("select * from jrn_def where jrn_def_type='
".$p_type."'");
1628 public function get_first($p_type, $p_access=3)
1631 $all=$g_user->get_ledger($p_type, $p_access,false);
1632 if (empty ($all)) return NULL;
1640 function update_paid($p_array)
1642 // reset all the paid flag because the checkbox is post only
1644 foreach ($p_array as $name=> $paid)
1646 list($ad)=sscanf($name, "set_jr_id%d");
1649 $sql="update jrn set jr_rapt='
' where jr_id=$ad";
1650 $Res=$this->db->exec_sql($sql);
1652 // set a paid flag for the checked box
1653 foreach ($p_array as $name=> $paid)
1655 list ($id)=sscanf($name, "rd_paid%d");
1659 $sql="update jrn set jr_rapt='paid
' where jr_id=$id";
1660 $Res=$this->db->exec_sql($sql);
1664 function update_internal_code($p_internal)
1666 if (!isset($this->grpt_id))
1667 throw new Exception(('ERREUR
'.__FILE__.":".__LINE__));
1668 $Res=$this->db->exec_sql("update jrn set jr_internal=$1 where
1669 jr_grpt_id = $2 ",array($p_internal,$this->grpt_id));
1678 function get_default_card($p_ledger_type, $p_side)
1681 $fiche_def_ref=new Fiche_Def_Ref($this->db);
1682 // ----- for FINANCIAL ----
1683 if ($p_ledger_type=='FIN
')
1685 $array=$fiche_def_ref->get_by_modele(FICHE_TYPE_CLIENT);
1686 $array=array_merge($array,
1687 $fiche_def_ref->get_by_modele(FICHE_TYPE_FOURNISSEUR));
1688 $array=array_merge($array,
1689 $fiche_def_ref->get_by_modele(FICHE_TYPE_FIN));
1690 $array=array_merge($array,
1691 $fiche_def_ref->get_by_modele(FICHE_TYPE_ADM_TAX));
1692 $array=array_merge($array,
1693 $fiche_def_ref->get_by_modele(FICHE_TYPE_EMPL));
1695 // --- for miscellaneous ----
1696 if ($p_ledger_type=='ODS
')
1698 $result=$this->db->get_array('select fd_id
from fiche_def
');
1699 for ($i=0; $i<count($result); $i++)
1701 $array[$i]=$result[$i]['fd_id
'];
1706 switch ($p_ledger_type)
1709 $array=$fiche_def_ref->get_by_modele(FICHE_TYPE_CLIENT);
1712 $array=$fiche_def_ref->get_by_modele(FICHE_TYPE_ACH_SER);
1713 $array=array_merge($array,
1714 $fiche_def_ref->get_by_modele(FICHE_TYPE_ACH_MAR));
1715 $array=array_merge($array,
1716 $fiche_def_ref->get_by_modele(FICHE_TYPE_ACH_MAT));
1719 throw new Exception(_('get_default_card p_ledger_side is invalide [
'.$p_ledger_type.']
'));
1722 elseif ($p_side=='C
')
1724 switch ($p_ledger_type)
1727 $array=$fiche_def_ref->get_by_modele(FICHE_TYPE_VENTE);
1730 $array=array_merge($array,
1731 $fiche_def_ref->get_by_modele(FICHE_TYPE_ADM_TAX));
1732 $array=array_merge($array,
1733 $fiche_def_ref->get_by_modele(FICHE_TYPE_FOURNISSEUR));
1736 throw new Exception(_('get_default_card p_ledger_side is invalide [
'.$p_ledger_type.']
'));
1742 $return = array_values($array);
1743 for ($i = 0;$i<count($array);$i++ )
1745 $return[$i]=$array[$i]['fd_id
'];
1757 function get_all_fiche_def()
1759 $sql="select jrn_def_fiche_deb as deb,jrn_def_fiche_cred as cred ".
1760 " from jrn_def where ".
1761 " jrn_def_id = $1 ";
1763 $r=$this->db->exec_sql($sql, array($this->id));
1765 $res=Database::fetch_all($r);
1770 foreach ($res as $item)
1772 if (noalyss_strlentrim($item['deb
'])!=0)
1774 $card.=$comma.$item['deb
'];
1777 if (strlen(noalyss_trim($item['cred
']))!=0)
1779 $card.=$comma.$item['cred
'];
1791 function check_strict()
1793 global $g_parameter;
1794 if ($g_parameter->MY_STRICT=='Y
')
1796 if ($g_parameter->MY_STRICT=='N
')
1798 throw new Exception("Valeur invalid ".__FILE__.':
'.__LINE__);
1806 function check_periode()
1808 global $g_parameter;
1809 if ($g_parameter->MY_CHECK_PERIODE=='Y
')
1811 if ($g_parameter->MY_CHECK_PERIODE=='N
')
1813 throw new Exception("Valeur invalid ".__FILE__.':
'.__LINE__);
1821 function check_currency_setting ($p_currency_code)
1823 global $g_parameter;
1824 if ( $p_currency_code == -1 )
1826 throw new Exception(_('Devise inconnue
'), 3);
1828 /* -- check the accounting for error of exchange -*/
1829 if ($p_currency_code > 0 )
1831 $poste=new Acc_Account($this->db,$g_parameter->MY_DEFAULT_ROUND_ERROR_DEB);
1833 if ($poste->get_parameter("id") == -1 )
1835 throw new Exception(
1836 sprintf(_("Dans COMPANY, vous n'avez pas paramétré correctement
".
1837 " le compte de débit %s pour les erreurs de conversion
"),
1838 $g_parameter->MY_DEFAULT_ROUND_ERROR_DEB), 3);
1841 $poste=new Acc_Account($this->db,$g_parameter->MY_DEFAULT_ROUND_ERROR_CRED);
1842 if ($poste->get_parameter("id") == -1 )
1844 throw new Exception(
1845 sprintf(_("Dans COMPANY, vous
n'avez pas paramétré correctement ".
1846 " le compte de crédit %s pour les erreurs de conversion"),
1847 $g_parameter->MY_DEFAULT_ROUND_ERROR_CRED), 3);
1861 function check_currency($p_qcode_payment, $p_currency_id)
1863 $card=new Fiche($this->db);
1864 $card->get_by_qcode($p_qcode_payment);
1865 if ( $card->id == 0) throw new Exception (_("Fiche invalide"));
1867 $ledger = $card->get_bank_ledger();
1868 if ( $ledger != NULL )
1870 $ledger_currency_id=$ledger->get_currency()->get_id();
1871 // if sale and payment are not the same currency and the
1872 if ($ledger_currency_id != 0 && $p_currency_id != $ledger_currency_id )
1874 throw new Exception (_("Devise de la banque doit être identique à l'opération
"));
1881 function get_last_date()
1884 throw new Exception(__FILE__.":
".__LINE__."Journal incorrect
");
1885 $sql="select to_char(max(jr_date),
'DD.MM.YYYY')
from jrn where jr_def_id=$1";
1886 $date=$this->
db->get_value(
$sql, array($this->
id));
1898 $sql=
'select jr_id from jrn where jr_internal=$1';
1899 $value=$this->
db->get_value($sql, array($p_internal));
1916 $doc->f_id=$e_client;
1917 $doc->md_id=$gen_doc;
1923 $doc->moveDocumentPj($internal);
1927 $sql=
"update jrn set jr_comment=' document ".$doc->d_number.
"' where jr_internal='$internal'";
1928 $this->
db->exec_sql(
$sql);
1930 return h(
$doc->d_name.
' ('.
$doc->d_filename.
')');
1945 $empl->get_by_qcode($e_mp_qcode);
1948 throw new Exception(_(
"Le moyen de paiement choisi n'a pas de poste comptable"),
1954 if (strpos($sposte,
',')!=0)
1956 $array=explode(
',', $sposte);
1964 if (
$poste->load()==
false)
1966 throw new Exception(sprintf(_(
"Pour la fiche %s le poste comptable [%s] n'existe pas"),
1967 $empl->quick_code,
$poste->id), 9);
1976 $sql=
"select nextval('s_jrn_pj".$this->id.
"')";
1977 $this->
db->exec_sql(
$sql);
1993 select jr_id,jr_pj_number,jr_date,to_char(jr_date,'DD.MM.YYYY') as jr_date_fmt,jr_montant, jr_comment,jr_internal,jrn_def_code
1995 join jrn_def on (jrn_def_id=jr_def_id)
1996 where $filter_ledger
1997 order by jr_date desc , substring(jr_pj_number,'[0-9]+$')::numeric desc limit $p_limit";
2014 return $this->
db->get_value(
'select jr_grpt_id from jrn where jr_internal=$1',
2027 $jrn=($this->
id==0)?
'and '.$g_user->get_ledger_sql():
' and jr_def_id = '.$this->id;
2028 $sql=
"select jr_id as id ,jr_internal as internal, ".
2029 "jr_pj_number as pj,jr_grpt_id,".
2030 " to_char(jr_date,'DDMMYY') as date_fmt, ".
2031 " jr_comment as comment, jr_montant as montant ,".
2032 " jr_grpt_id,jr_def_id,jrn.currency_id,currency_rate,currency_rate_ref,cr_code_iso ".
2033 " from jrn join jrn_def on (jr_def_id=jrn_def_id) ".
2034 " left join currency on (currency.id=jrn.currency_id) ".
2036 " jr_date >= (select p_start from parm_periode where p_id = $1)
2037 and jr_date <= (select p_end from parm_periode where p_id = $2)".
2038 ' '.$jrn.
' order by jr_date,substring(jr_pj_number,\'[0-9]+$\')::numeric asc';
2039 $ret=$this->
db->get_array(
$sql, array($p_from, $p_to));
2052 $array=$this->
db->get_array(
"select tva_id,tva_label,tva_poste
2054 where tva_rate != 0.0000
2055 and exists (select qp_vat_code from quant_purchase
2058 and exists (select j_id
2059 from jrnx where j_jrn_def = $1))
2065 $array=$this->
db->get_array(
"select tva_id,tva_label,tva_poste
2067 where tva_rate != 0.0000
2068 and exists (select qs_vat_code from quant_sold
2069 where qs_vat_code=tva_id
2071 exists (select j_id from jrnx where j_jrn_def = $1))
2098 $array=$this->
db->get_array(
'select sum(qp_price) as price,sum(qp_vat) as vat '.
2099 ',sum(coalesce(qp_nd_amount,0)+coalesce(qp_dep_priv,0)) as priv'.
2100 ',sum(coalesce(qp_nd_tva_recup,0)+coalesce(qp_nd_tva,0)) as tva_nd'.
2101 ',sum(qp_vat_sided) as tva_np'.
2102 ' from quant_purchase join jrnx using(j_id)
2103 where j_grpt=$1 ', array($p_jr_id));
2108 $array=$this->
db->get_array(
'select sum(qs_price) as price,sum(qs_vat) as vat '.
2111 ',sum(qs_vat_sided) as tva_np'.
2112 ' from quant_sold join jrnx using(j_id)
2113 where j_grpt=$1 ', array($p_jr_id));
2134 $array=$this->
db->get_array(
'select coalesce(sum(qp_vat),0) as sum_vat,tva_id
2135 from quant_purchase as p right join tva_rate on (qp_vat_code=tva_id) join jrnx using(j_id)
2136 where tva_rate !=0.0 and j_grpt=$1 group by tva_id',
2141 $array=$this->
db->get_array(
'select coalesce(sum(qs_vat),0) as sum_vat,tva_id
2142 from quant_sold as p right join tva_rate on (qs_vat_code=tva_id) join jrnx using(j_id)
2143 where tva_rate !=0.0 and j_grpt=$1 group by tva_id',
2182 $exercise=
$periode->get_exercice();
2185 $min_date=
$min->first_day();
2187 $periode_max=
new Periode($this->
db, $p_to);
2188 $max_date=$periode_max->first_day();
2194 $sql=
"select coalesce(sum(qp_price),0) as price".
2195 " ,coalesce(sum(qp_vat),0) as vat ".
2196 ',coalesce(sum(qp_dep_priv),0) as priv'.
2197 ',coalesce(sum(qp_vat_sided),0) as reversed'.
2198 ',coalesce(sum(qp_nd_tva_recup),0)+coalesce(sum(qp_nd_tva),0) as tva_nd'.
2199 ',coalesce(sum(qp_vat_sided),0) as tva_np'.
2200 ' from quant_purchase join jrnx using(j_id) '.
2201 " where j_date >= to_date($1,'DD.MM.YYYY') and j_date < to_date($2,'DD.MM.YYYY') ".
2202 ' and j_jrn_def = $3';
2204 array($min_date, $max_date, $this->
id));
2208 $array=$this->
db->get_array(
"select coalesce(sum(qp_vat),0) as sum_vat,tva_id
2209 from quant_purchase as p
2210 right join tva_rate on (qp_vat_code=tva_id) join jrnx using(j_id)
2213 and j_date >= to_date($1,'DD.MM.YYYY')
2214 and j_date < to_date($2,'DD.MM.YYYY')
2217 array($min_date, $max_date, $this->
id));
2223 $sql=
"select coalesce(sum(qs_price),0) as price".
2224 " ,coalesce(sum(qs_vat),0) as vat ".
2227 ',coalesce(sum(qs_vat_sided),0) as reversed'.
2229 ' from quant_sold join jrnx using(j_id) '.
2230 " where j_date >= to_date($1,'DD.MM.YYYY') and j_date < to_date($2,'DD.MM.YYYY') ".
2231 ' and j_jrn_def = $3';
2233 array($min_date, $max_date, $this->
id));
2236 $array=$this->
db->get_array(
"select coalesce(sum(qs_vat),0) as sum_vat,tva_id
2237 from quant_sold as p
2238 right join tva_rate on (qs_vat_code=tva_id)
2239 join jrnx using(j_id)
2242 j_date >= to_date($1,'DD.MM.YYYY')
2243 and j_date < to_date($2,'DD.MM.YYYY')
2246 array($min_date, $max_date, $this->
id));
2261 if ( $min_date <> $max_date)
2263 $cond=sprintf(
"j_date >= to_date('%s','DD.MM.YYYY') and j_date < to_date('%s','DD.MM.YYYY') ",
2264 $min_date,$max_date);
2266 $cond=sprintf(
"j_date = to_date('%s','DD.MM.YYYY') ",
2269 $saldo=$bank_card->get_bk_balance($cond);
2282 $exercise=
$periode->get_exercice();
2285 $min_date=
$min->first_day();
2287 $periode_max=
new Periode($this->
db, $p_to);
2288 $max_date=$periode_max->first_day();
2297 join jrnx using(j_id)
2298 join jrn_tax using (j_id)
2299 where j_date >= to_date($1,'DD.MM.YYYY') and j_date < to_date($2,'DD.MM.YYYY')
2300 and j_jrn_def = $3";
2302 array($min_date, $max_date, $this->
id));
2304 return array(
'other_tax_amount',
$amount);
2313 join jrnx using(j_id)
2314 join jrn_tax using (j_id)
2315 where j_date >= to_date($1,'DD.MM.YYYY') and j_date < to_date($2,'DD.MM.YYYY')
2316 and j_jrn_def = $3";
2318 array($min_date, $max_date, $this->
id));
2320 return array(
'other_tax_amount',
$amount);
2323 return array(
'other_tax_amount',0);
2335 echo Acc_Reconciliation::$javascript;
2339 $_SESSION[SESSION_KEY.
'g_pass']=
'phpcompta';
2343 $a->with_concerned=
true;
2345 echo
'<FORM method="post">';
2346 echo
$a->select_ledger()->input();
2352 echo
'<form method="post">';
2353 echo
$a->show_form();
2359 echo dossier::hidden();
2360 echo
'<input type="hidden" value="'.$id.
'" name="p_jrn">';
2364 if (
$op->count()!=0)
2367 'Utilisez une opération prédéfinie',
2369 echo
$op->show_button();
2375 if (isset(
$_POST[
'post_id']))
2378 echo
'<form method="post">';
2381 'onClick="quick_writing_add_row()"');
2386 if (isset(
$_POST[
'save_it']))
2395 catch (Exception
$e)
2398 echo
'<form method="post">';
2408 if (isset(
$_GET[
'use_opd']))
2410 $op=
new Pre_op_advanced(
$cn);
2416 echo
'<FORM method="post">';
2426 if ($pCase==
'search')
2432 $_SESSION[SESSION_KEY.
'g_pass']=
'phpcompta';
2433 echo
$ledger->search_form(
'ALL');
2439 if ($pCase==
'reverse')
2442 $jr_internal=
'OD-01-272';
2446 $jrn_def_id=
$cn->get_value(
'select jr_def_id from jrn where jr_internal=$1',
2447 array($jr_internal));
2449 $ledger->jr_id=
$cn->get_value(
'select jr_id from jrn where jr_internal=$1',
2450 array($jr_internal));
2452 echo
"Ouvrez le fichier ".__FILE__.
" à la ligne ".__LINE__.
" pour changer jr_internal et vérifier le résultat de l'extourne";
2454 $ledger->reverse(
'01.07.2010');
2456 catch (Exception
$e)
2472 array(
'cat'=>
'VEN',
'name'=>_(
"Journaux de vente")),
2473 array(
'cat'=>
'ACH',
'name'=>_(
"Journaux d'achat")),
2474 array(
'cat'=>
'FIN',
'name'=>_(
"Journaux Financier")),
2475 array(
'cat'=>
'ODS',
'name'=>_(
"Journaux d'Opérations diverses"))
2488 switch ($p_jrn_type)
2491 $tiers=$this->
db->get_value(
'select max(qs_client) from quant_sold join jrnx using (j_id) join jrn on (jr_grpt_id=j_grpt) where jrn.jr_id=$1',
2495 $tiers=$this->
db->get_value(
'select max(qp_supplier) from quant_purchase join jrnx using (j_id) join jrn on (jr_grpt_id=j_grpt) where jrn.jr_id=$1',
2500 $tiers=$this->
db->get_value(
'select qf_other from quant_fin where jr_id=$1',
2504 if ($this->
db->count()==0)
2516 if ($p_jrn_type==
'ODS')
2522 $name=$this->
db->get_value(
'select ad_value from fiche_detail where ad_id=1 and f_id=$1',
2524 $first_name=$this->
db->get_value(
'select ad_value from fiche_detail where ad_id=32 and f_id=$1',
2526 return $name.
' '.$first_name;
2536 $base_url=
"?".dossier::get().
"&ac=".
$_REQUEST[
'ac'];
2541 $r.=
'<TABLE id="cfgledger_table_id" class="vert_mtitle">';
2542 $r.=
'<TR><TD class="first"><A HREF="'.$base_url.
'&sa=add">'._(
'Ajout journal').
' </A></TD></TR>';
2543 $ret=$this->
db->exec_sql(
"select distinct jrn_def_id,jrn_def_name,
2544 jrn_def_class_deb,jrn_def_class_cred,jrn_def_type
2545 from jrn_def order by jrn_def_name");
2552 $url=$base_url.
"&sa=detail&p_jrn=".$l_line[
'jrn_def_id'];
2553 $r.=sprintf(
'<TR ledger_type="%s"><TD><A HREF="%s">%s</A></TD></TR>', $l_line[
'jrn_def_type'],
$url,
2554 h($l_line[
'jrn_def_name']).
' ('.$l_line[
'jrn_def_type'].
')');
2566 if ($this->load()==
false)
2568 throw new Exception(_(
"Journal n'existe pas"), -1);
2570 $type=$this->jrn_def_type;
2572 $code=$this->jrn_def_code;
2576 $wSearch->set_attribute(
'ipopup',
'ipop_account');
2577 $wSearch->set_attribute(
'account',
'p_jrn_class_deb');
2578 $wSearch->set_attribute(
'no_overwrite',
'1');
2579 $wSearch->set_attribute(
'noquery',
'1');
2581 $wSearch->name=
"p_jrn_class_deb";
2583 $wSearch->value=$this->jrn_def_class_deb;
2584 $search=$wSearch->input();
2586 $wPjPref=
new IText();
2587 $wPjPref->name=
'jrn_def_pj_pref';
2588 $wPjPref->value=$this->jrn_def_pj_pref;
2589 $pj_pref=$wPjPref->input();
2593 $wPjSeq->name=
'jrn_def_pj_seq';
2605 $min_row=
new INum(
"min_row", $this->jrn_deb_max_line);
2609 $description->style=
'class="itextarea" style="margin:0px;"';
2618 $num_op=
new ICheckBox(
'numb_operation');
2619 if ($this->jrn_def_num_op==1)
2620 $num_op->selected=
true;
2625 $f_id=$this->jrn_def_bank;
2629 $qcode_bank=$fBank->get_quick_code();
2635 $actif=
new ISelect(
"jrn_enable");
2637 [
"label"=>_(
"Activé"),
"value"=>1],
2638 [
"label"=>_(
"Désactivé"),
"value"=>0]
2640 $actif->selected=$this->jrn_enable;
2645 $negative=
new InputSwitch(
'negative_amount',$this->jrn_def_negative_amount);
2646 $negative_warning=
new IText(
"negative_warning",_($this->jrn_def_negative_warning));
2647 $negative_warning->size=55;
2650 $quantity=
new InputSwitch(
'p_jrn_quantity',$this->jrn_def_quantity);
2652 require_once NOALYSS_TEMPLATE.
'/param_jrn.php';
2663 $default_currency->value=$this->
db->make_array(
"select id,cr_code_iso from public.currency order by 1 ");
2665 $nb_operation=$this->
db->get_value(
"select count(*) from jrn where jr_def_id=$1",[$this->
id]);
2697 $p_jrn_deb_max_line=
$http->extract(
'p_jrn_deb_max_line');
2698 $p_jrn_name=
$http->extract(
'p_jrn_name');
2699 $p_jrn_type=
$http->extract(
'p_jrn_type');
2700 $p_jrn_quantity=
$http->extract(
'p_jrn_quantity',
'number',0);
2705 throw new Exception(
"Id invalide");
2706 if (
isNumber($p_jrn_deb_max_line)==0)
2707 throw new Exception(_(
"Nombre de ligne incorrect"));
2708 if (trim($p_jrn_name)==
"")
2709 throw new Exception(
"Nom de journal invalide");
2710 if ($this->
db->get_value(
"select count(*) from jrn_def where jrn_def_name=$1 and jrn_Def_id<>$2",
2711 array($p_jrn_name,
$p_jrn))>0)
2712 throw new Exception(_(
"Un journal avec ce nom existe déjà"));
2713 if ($p_jrn_type==
'FIN')
2715 $http=new \HttpInput();
2717 $bank=
$http->post(
"bank");
2718 $result=
$a->get_by_qcode(trim(strtoupper($bank)),
false);
2720 throw new Exception(_(
"Aucun compte en banque n'est donné"));
2722 if ($p_jrn_type==
"-1")
2724 throw new Exception(_(
'Choix du type de journal est obligatoire'));
2727 if ( isset(
$array[
'negative_warning']) &&
2728 isset(
$array[
'negative_amount']) &&
2729 $array[
'negative_amount'] == 1
2730 && trim(
$array[
'negative_warning'])==
"") {
2732 throw new Exception(_(
"Avertissement ne peut être vide"));
2734 if ( isset(
$array[
'negative_amount']) &&
2735 $array[
'negative_amount'] <> 0 &&
2736 $array[
'negative_amount'] <> 1 )
2738 throw new Exception(_(
"Valeur invalide {$array['negative_amount']}"));
2741 catch (Exception
$e)
2774 $this->jrn_def_quantity=(!isset($this->jrn_def_quantity)||$this->jrn_def_quantity===
null)?1:$this->jrn_def_quantity;
2784 $p_jrn_deb_max_line=
$http->extract(
"p_jrn_deb_max_line",
"number",-1);
2785 $min_row=
$http->extract(
"min_row");
2789 $this->jrn_def_ech_lib=
$http->extract(
'p_ech_lib');
2790 $this->jrn_def_max_line_deb=($p_jrn_deb_max_line<1)?1:$p_jrn_deb_max_line;
2791 $this->jrn_def_type=
$http->extract(
'p_jrn_type');
2792 $this->jrn_def_pj_pref=
$http->extract(
'jrn_def_pj_pref');
2793 $this->jrn_deb_max_line=($min_row<1)?1:$min_row;
2794 $this->jrn_def_description=
$http->extract(
'p_description');
2795 $this->jrn_enable=
$http->extract(
'jrn_enable');
2796 $this->currency_id=0;
2797 $this->jrn_def_negative_amount=
$http->extract(
'negative_amount',
'string',0);
2798 $this->jrn_def_negative_warning=
$http->extract(
"negative_warning",
'string',
2799 _(
"Attention, ce journal doit utiliser des montants négatifs"));
2800 $this->jrn_def_quantity=
$http->extract(
'p_jrn_quantity',
'string',1);
2801 $jrn_def_pj_seq=
$http->extract(
"jrn_def_pj_seq");
2802 switch ($this->jrn_def_type)
2805 $ACH_FICHECRED=
$http->extract(
'ACH_FICHECRED',
'array',array());
2806 $ACH_FICHEDEB=
$http->extract(
'ACH_FICHEDEB',
'array',array());
2807 $this->jrn_def_fiche_cred=(!empty($ACH_FICHECRED))?join(
',',$ACH_FICHECRED):
'';
2808 $this->jrn_def_fiche_deb=(!empty($ACH_FICHEDEB))?join(
',',$ACH_FICHEDEB):
"";
2811 $VEN_FICHECRED=
$http->extract(
'VEN_FICHECRED',
'array',array());
2812 $VEN_FICHEDEB=
$http->extract(
'VEN_FICHEDEB',
'array',array());
2813 $this->jrn_def_fiche_cred=(!empty($VEN_FICHECRED))?join(
',',$VEN_FICHECRED):
'';
2814 $this->jrn_def_fiche_deb=(!empty($VEN_FICHEDEB))?join(
',',$VEN_FICHEDEB):
"";
2818 $this->jrn_def_class_deb=
$http->extract(
'p_jrn_class_deb',
'string');
2819 $ODS_FICHEDEB=
$http->extract(
'ODS_FICHEDEB',
'array',array());
2820 $this->jrn_def_fiche_deb=(!empty($ODS_FICHEDEB))?join(
',',$ODS_FICHEDEB):
''; ;
2821 $this->jrn_def_fiche_cred=
null;
2826 $result=
$a->get_by_qcode(trim(strtoupper(
$http->extract(
'bank'))),
false);
2828 $this->jrn_def_bank=$bank;
2829 $FIN_FICHEDEB=
$http->extract(
'FIN_FICHEDEB',
'array',array());
2830 $this->jrn_def_fiche_deb=(!empty($FIN_FICHEDEB))?join(
',',$FIN_FICHEDEB):
"";
2832 throw new Exception(_(
"Aucun compte en banque n'est donné"));
2833 $this->jrn_def_num_op=
$http->extract(
'numb_operation',
'string',0);
2835 $nb_operation = $this->
db->get_value(
"select count(*) from jrn where jr_def_id=$1",
2841 $this->currency_id=
$http->extract(
"defaultCurrency");
2843 $this->currency_id=$this->
db->get_value(
"select currency_id from jrn_def where jrn_def_id=$1",
2851 if ($jrn_def_pj_seq!=0)
2867 $r.=
'<div id="payment"> ';
2868 $r.=
'<h2> '._(
'Paiement').
' </h2>';
2870 $mp->set_parameter(
'ledger_source', $this->
id);
2871 $r.=$mp->select($p_selected,$p_amount,
$p_date,$p_comm);
2883 $retry=
$http->post(
"sa",
"string",
"");
2885 $default_type=
$http->post(
"p_jrn_type",
"string", -1);
2886 $previous_jrn_def_pj_pref=
$http->post(
"jrn_def_pj_pref",
"string",
"");
2887 $previous_p_description=
$http->post(
"p_description",
"string",
"");
2888 $previous_p_jrn_name=
$http->post(
'p_jrn_name',
"string",
'');
2889 $previous_p_jrn_type=
$http->post(
"p_jrn_type",
"string",
"");
2892 $f_add_button->label=_(
'Créer une nouvelle fiche');
2893 $f_add_button->tabindex=-1;
2894 $f_add_button->set_attribute(
'jrn', -1);
2895 $f_add_button->javascript=
" select_card_type({type_cat:4,elementId:'bank',p_jrn:-1});";
2901 $str_add_button=$f_add_button->input();
2905 $wSearch->set_attribute(
'ipopup',
'ipop_account');
2906 $wSearch->set_attribute(
'account',
'p_jrn_class_deb');
2907 $wSearch->set_attribute(
'no_overwrite',
'1');
2908 $wSearch->set_attribute(
'noquery',
'1');
2910 $wSearch->name=
"p_jrn_class_deb";
2913 $search=$wSearch->input();
2937 $name=$previous_p_jrn_name;
2940 $a_jrn=$this->
db->make_array(
"select '-1',' -- "._(
"choix du type de journal").
" -- ' union select jrn_type_id,jrn_desc from jrn_type");
2941 $wType->selected=
'-1';
2942 $wType->value=$a_jrn;
2943 $wType->name=
"p_jrn_type";
2944 $wType->id=
"p_jrn_type_select_id";
2945 $wType->javascript=
' onchange="show_ledger_div()"';
2946 $wType->selected=$default_type;
2947 $type=$wType->input();
2948 $rcred=$rdeb=array();
2949 $wPjPref=
new IText();
2950 $wPjPref->name=
'jrn_def_pj_pref';
2951 $wPjPref->value=$previous_jrn_def_pj_pref;
2952 $pj_pref=$wPjPref->input();
2957 $description->style=
'class="itextarea" style="margin:0px;"';
2963 $num_op=
new ICheckBox(
'numb_operation');
2964 echo dossier::hidden();
2975 $negative_warning=
new IText(
'negative_warning',_(
"Attention, ce journal doit utiliser des montants négatifs"));
2976 $negative_warning->size=
"55";
2980 require_once NOALYSS_TEMPLATE.
'/param_jrn.php';
3024 extract(
$array, EXTR_SKIP);
3027 $this->jrn_def_ech_lib=$p_ech_lib;
3028 $this->jrn_def_max_line_deb=$p_jrn_deb_max_line;
3029 $this->jrn_def_type=$p_jrn_type;
3030 $this->jrn_def_pj_pref=$jrn_def_pj_pref;
3031 $this->jrn_deb_max_line=$min_row;
3032 $this->jrn_def_code=trim(substr($this->jrn_def_type, 0, 1));
3033 $this->jrn_def_code.=str_pad(
3036 $this->jrn_def_code=strtoupper($this->jrn_def_code);
3037 $this->jrn_def_description=$p_description;
3038 $this->currency_id=0;
3039 $this->jrn_def_negative_amount=$negative_amount;
3040 $this->jrn_def_negative_warning=$negative_warning;
3041 $this->jrn_enable=1;
3043 switch ($this->jrn_def_type)
3046 $this->jrn_def_fiche_cred=(isset($ACH_FICHECRED))?join(
',',$ACH_FICHECRED):
'';
3047 $this->jrn_def_fiche_deb=(isset($ACH_FICHEDEB))?join(
',',$ACH_FICHEDEB):
"";
3050 $this->jrn_def_fiche_cred=(isset($VEN_FICHECRED))?join(
',',$VEN_FICHECRED):
'';
3051 $this->jrn_def_fiche_deb=(isset($VEN_FICHEDEB))?join(
',',$VEN_FICHEDEB):
"";
3055 $this->jrn_def_class_deb=$p_jrn_class_deb;
3056 $this->jrn_def_fiche_deb=(isset($ODS_FICHEDEB))?join(
',',$ODS_FICHEDEB):
''; ;
3057 $this->jrn_def_fiche_cred=
null;
3061 $result=
$a->get_by_qcode(trim(strtoupper($bank)),
false);
3063 $this->jrn_def_bank=$bank_id;
3064 $this->jrn_def_fiche_deb=(isset($FIN_FICHEDEB))?join(
',',$FIN_FICHEDEB):
"";
3066 throw new Exception(_(
"Aucun compte en banque n'est donné"));
3067 $this->jrn_def_num_op=(isset($numb_operation))?1:0;
3068 $this->currency_id=$defaultCurrency;
3071 $this->jrn_def_quantity=(!isset($this->jrn_def_quantity)||$this->jrn_def_quantity==
null)?1:$this->jrn_def_quantity;
3073 $this->
id=$this->jrn_def_id;
3084 if ($this->
db->get_value(
"select count(jr_id) from jrn where jr_def_id=$1",
3086 throw new Exception(_(
"Impossible d'effacer un journal qui contient des opérations"));
3089 catch (Exception
$e)
3110 switch ($p_ledger_type)
3119 throw new Exception(
'Ledger_type invalid : '.$p_ledger_type);
3123 $sql=
"select jr_id, jr_internal, jr_date, jr_comment,jr_pj_number,jr_montant
3125 join jrn_def on (jrn_def_id=jr_def_id)
3128 and jr_ech $sql_op to_date($1,'DD.MM.YYYY')
3129 and coalesce (jr_rapt,'xx') <> 'paid'
3146 function get_rowSimple($p_from, $p_to, $pa_ledger=[],$trunc=0,$p_limit=-1,$p_offset=-1)
3148 if ( empty($pa_ledger) ) {
3152 if ( $pa_ledger == [0] ) {
3157 $alh_generic->get_rowSimple($trunc,$p_limit,$p_offset);
3158 $data=$alh_generic->get_data();
3202 if (!
$g_user->can_read_action($p_ag_id))
3203 die(_(
'Action non accessible'));
3207 $tiers_id=$this->
db->get_value(
'select f_id_dest from action_gestion where ag_id=$1',
3209 if ($this->
db->size()!=0)
3210 $qcode=$this->
db->get_value(
'select j_qcode from vw_poste_qcode where f_id=$1',
3215 $comment=$this->
db->get_value(
'select ag_title from action_gestion where ag_id=$1',
3218 $array[
'e_comm']=$comment;
3221 $a_item=$this->
db->get_array(
'select f_id,ad_text,ad_pu,ad_quant,ad_tva_id,ad_tva_amount,j_qcode
3224 left join vw_poste_qcode using(f_id)
3226 ag_id=$1', array($p_ag_id));
3228 $array[
'nb_item']=($this->
nb>count($a_item))?$this->
nb:count($a_item);
3229 for (
$i=0;
$i<count($a_item);
$i++)
3231 $array[
'e_march'.$i]=$a_item[
$i][
'j_qcode'];
3232 $array[
'e_march'.$i.
'_label']=$a_item[
$i][
'ad_text'];
3233 $array[
'e_march'.$i.
'_price']=$a_item[
$i][
'ad_pu'];
3234 $array[
'e_march'.$i.
'_tva_id']=$a_item[
$i][
'ad_tva_id'];
3235 $array[
'e_march'.$i.
'_tva_amount']=$a_item[
$i][
'ad_tva_amount'];
3236 $array[
'e_quant'.$i]=$a_item[
$i][
'ad_quant'];
3248 $lib=$this->
db->get_value(
'select pcm_lib from tmp_pcmn where pcm_val=$1',
3265 $r=(
$p_readonly==
false)?
'<div id="repo_div_id" style="height:185px;height:10rem;">':
'<div id="repo_div_id" >';
3272 $sel->selected=$p_repo;
3273 $r.=
"<p class=\"decale\">"._(
'Dans le dépôt').
" : ";
3278 $r.=
'<span class="notice">'.
'Stock non utilisé'.
'</span>';
3293 'do.php?'.
$url,
"",
"",
"smallbutton");
3294 return '<p>'.$button.
'</p>';
3303 echo
'<FORM METHOD="POST">';
3305 array(
"gDossier",
"ac",
"p_jrn",
"e_client",
"nb_item",
"desc",
"e_comm")
3310 $nb=
$http->post(
"nb_item",
"number", 0);
3318 "e_march".
$i.
"_price",
3319 "e_march".$i.
"_quant",
3320 "e_march".$i.
"_label",
3321 "e_march".$i.
"_tva_id",
3322 "e_march".$i.
"_tva_amount",
3343 $js_script=
"this.filter='{$p_filter}';this.elementId='{$p_id_update}';this.jrn=\$('p_jrn').value; select_card_type(this);";
3345 return $str_add_button;
3352 return $this->
db->get_value(
"select jrn_enable from jrn_def where jrn_def_id=$1",[$this->
id]);
3359 return $this->jrn_def_quantity;
3367 $this->jrn_def_quantity=$p_value;
3378 if ( $p_jrn_type ==
'ACH')
3380 $sql=
"select count(*) from jrnx join quant_purchase using (j_id) where j_grpt=$1";
3381 }
elseif ($p_jrn_type==
'VEN')
3383 $sql=
"select count(*) from jrnx join quant_sold using (j_id) where j_grpt=$1";
3384 }
elseif ($p_jrn_type==
'FIN')
3386 $sql=
"select count(*) from jrn join quant_fin using (jr_id) where jr_grpt_id=$1";
3388 }
elseif ($p_jrn_type==
'ODS')
return 0;
3391 throw new Exception(_(
'Journal incorrect'),1000);
3396 if (
$count > 0)
return TRUE;
3416 $select->javascript=sprintf(
'onchange="LedgerCurrencyUpdateMisc(\'%s\',\'%s\',\'%s\',\'%s\',\'%s\');'.
3417 '$(\'update_p_currency_rate\').innerHTML=$(\'p_currency_rate\').value;"',
3423 $select->javascript=sprintf(
'onchange="LedgerCurrencyUpdate(\'%s\',\'%s\',\'%s\',\'%s\',\'%s\');'.
3424 '$(\'update_p_currency_rate\').innerHTML=$(\'p_currency_rate\').value;"',
3429 throw new Exception(_(
"Journal type non déterminé"));
3440 if ( $cr->get_id() < 0 ) {
3441 throw new Exception(
"ACL.3214"._(
"Taux invalide"));
3453 if ($this->
id == 0) {
3454 throw new Exception(_(
"Journal invalide"), 1);
3457 if ( $p_amount > 0 &&
$ledger->getp(
"jrn_def_negative_amount")==1){
3458 return _(
$ledger->getp(
"jrn_def_negative_warning"));
3464 require NOALYSS_TEMPLATE.
"/acc_ledger-input_extra_info.php";
3474 if ($this->
jr_id == 0 || empty ($s_related_action)) {
return false; }
3478 $acc_operation->insert_related_action($s_related_action);
3494 $amount->value=
$http->request(
"other_tax_amount",
"number",0);
3496 $amount->javascript=
'onchange="format_number(this,2);refresh_ledger();"';
3498 $row=$this->
cn->get_row(
"select ac_id,ac_label,ac_rate from acc_other_tax where $1 = any (ajrn_def_id)",
3503onchange=
'if (! this.checked) { $("other_tax_amount").value=0;}compute_all_ledger();'
3514 $out.=
"<h4>"._(
"Total opération").
3515 "<span class=\"mx-4\" id='total_operation_other_tax'>".
3527 $row=$this->
cn->get_row(
"select ac_id,ac_label,ac_rate from acc_other_tax where ac_id=$1",
3528 [$p_additional_tax]);
3531 $p_amount=
h($p_amount);
3533<div
id=
"additional_tax">
3548 $cnt=$this->
db->get_value(
'select count(*)
3550 where array_position(ajrn_def_id,$1) is not null',[$this->
id]);
3551 if ($cnt == 0 )
return false;
3565 if (empty(
$p_array[
'e_pj']))
return true;
3566 if (empty(
$p_array[
'e_pj_suggest']))
return true;
3581 return span (_(
"Attention ! Numéro de Pièce non automatique mais forcée"),
'class="warning"');
noalyss_bcsub($p_first, $p_second, $p_decimal=4)
h2($p_string, $p_class="", $raw="")
sql_filter_per($p_cn, $p_from, $p_to, $p_form='p_id', $p_field='jr_tech_per')
Create the condition to filter on the j_tech_per thanks a from and to date.
noalyss_explode($separator, $string)
to avoid deprecated in PHP8.1 : explode cannot use a null
span($p_string, $p_extra='')
noalyss_strlentrim($p_string)
html_page_start($p_theme="", $p_script="", $p_script2="")
Default page header for each page.
noalyss_str_replace($search, $replace, $string)
tr($p_string, $p_extra='')
record_log($p_message)
Record an error message into the log file of the server.
nb($p_number)
format the number for the CSV export
td($p_string='', $p_extra='')
surround the string with td
nbm($p_number, $p_dec=2)
format the number with a sep.
alert($p_msg, $buffer=false)
alert in javascript
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
if(isset( $_REQUEST[ 'show'])) if(isset($_REQUEST['del'])) $ac
if(! empty( $error)) for($i=0;$i< count($error);$i++)( $last !=$error[$i]) $last
Manage the account from the table jrn, jrnx or tmp_pcmn.
Manage the account from the table tmp_pcmn.
display currency , convert to euro , and save them if used.
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger
manage the list of operation when we need several ledger with a different type or from Misceleaneous ...
$currency_id
!< default number of rows by default 10
use_quant_table($p_grpt_id, $p_jrn_type)
Check if the operation is used in the table quant*.
get_operation_date($p_date, $p_ledger_type, $sql_op)
Get operation from the ledger type before, after or with the given date .
search_group($p_what, $p_value)
retreive the jr_grpt_id from a ledger
listing()
listing of all ledgers
get_currency()
returns the code iso of the default currency for this ledger
get_propertie()
Get the properties of a journal.
get_operation($p_from, $p_to)
retrieve operation from jrn
get_class_def()
retrieve the jrn_def_class_deb and return it
previous_amount($p_to)
retrieve amount of previous periode
static next_number($p_cn, $p_type)
retrieve the next number for this type of ledger
select_depot($p_readonly, $p_repo)
Let you select the repository before confirming a sale or a purchase.
verify_autonumber($p_array)
compare given receipt number and suggested one, if different , it means that the user enters a receip...
CurrencyInput($p_currency_code, $p_currency_rate, $p_eur_amount)
Create a select from value for currency and add javascript to update $p_currency_rate and $p_eur_amou...
$nb
!< type of the ledger ACH ODS FIN VEN or GL
get_supplier_now()
get info from supplier to pay today
input_paid($p_selected, $p_amount=0, $p_date="", $p_comm="")
Create the section payment.
get_rowSimple($p_from, $p_to, $pa_ledger=[], $trunc=0, $p_limit=-1, $p_offset=-1)
Get simplified row from ledger Call Acc_Ledger_History_Generic:get_rowSimple.
get_customer_late()
get info from customer not yet paid
vat_operation($p_jr_id)
get the amount of vat for a given jr_grpt_id from the table quant_purchase
get_last($p_limit)
return the last p_limit operation into an array
warn_manual_receipt($p_array)
warn if the suggested receipt and receipt are different , it means that the user tried to number hims...
$is_loaded
!< is_loaded true the ledger definition is loaded or false, it is not
get_default_card($p_ledger_type, $p_side)
Return an array of default card for the ledger type given.
display_warning($pa_msg, $p_warning)
Display warning contained in an array.
is_enable()
Check if a ledger is enabled , 1 for yes and 0 if disabled.
inc_seq_pj()
increment the sequence for the pj
select_ledger($p_type="ALL", $p_access=3, $enable=TRUE)
Show a select list of the ledgers you can access in writing, reading or simply accessing.
static array_cat()
create an array of the existing cat, to be used in a checkbox form
get_other_amount($p_jr_id)
get the amount of vat for a given jr_grpt_id from the table quant_purchase
get_name()
Return the name of a ledger.
display_negative_warning($p_amount)
If the amount is positive and the ledger expects a negative amount, il will return the saved warning.
delete_ledger()
delete a ledger IF it doesn't contain anything
set_currency_id()
retrieve currency_id from database
set_ledger_id($p_id)
Set the jrn_def.jrn_def_id.
get_type()
Return the type of a ledger (ACH,VEN,ODS or FIN) or GL.
get_tiers_id($p_jrn_type, $jr_id)
Return the f_id of the tiers , called by get_tiers.
compute_internal_code($p_grpt)
compute the internal code of the saved operation and set the $this->jr_internal to the computed value
input_additional_tax()
form : display additional tax available for this ledger and value, set 2 values : checkbox if tax app...
verify_operation($p_array)
verify that the operation can be saved
save_new($array)
Insert a new ledger , member variable like jrn_def_id will changed.
$row
!< database connextion
find_label($p_value)
Retrieve the label of an accounting.
create_document($internal, $p_array)
create the invoice and saved it as attachment to the operation,
set_is_loaded($is_loaded)
button_copy_operation()
Show a button to create an operation identical to the recorded one.
get_fiche_def()
retrieve the jrn_def_fiche and return them into a array index deb, cred
verify_ledger($array)
Verify before update.
display_additional_tax($p_additional_tax, $p_amount)
in confirm screen , display the compute value for additional tax @parameter $p_additional_tax acc_oth...
has_quantity()
Check if a ledger is enabled , 1 for yes and 0 if disabled.
reverse($p_date, $p_label)
reverse the operation by creating the opposite one, the result is to avoid it it must be done in
$ledger_type
!< row of the ledger
get_solde($p_from, $p_to)
get the saldo of a ledger for a specific period
convert_from_follow($p_ag_id)
has_other_tax()
returns true if the ledger has an additional tax
update($array=null)
update a ledger
add_card($p_filter, $p_id_update)
Return a button to create new card, depending of the ledger.
input($p_array=null, $p_readonly=0)
Show the form to encode your operation.
confirm($p_array, $p_readonly=false)
show the result of the array to confirm before inserting
previous_other_tax($p_to)
retrieve the previous amount
save_followup($s_related_action)
attach action-followups to an operation,
check_payment($e_mp, $e_mp_qcode)
check if the payment method is valid
get_tiers($p_jrn_type, $jr_id)
Retrieve the third : supplier for purchase, customer for sale, bank for fin,.
__construct($p_cn, $p_id)
get_supplier_late()
get info from supplier not yet paid
check_periode()
Check if a Dossier is using the check on the periode, if true than the user has to enter the date and...
input_new()
display screen to enter a new ledger
button_new_operation()
Create a button to encode a new operation into the same ledger.
static test_me($pCase='')
this function is intended to test this class
get_customer_now()
get info from customer to pay today
guess_pj()
guess what the next pj should be
display_ledger()
display detail of a ledger
get_id($p_internal)
retrieve the jr_id thanks the internal code, do not change anything to the current object
select_default_currency()
create a select button to set the default currency for a ledger used only for empty financial ledger
existing_vat()
return the used VAT code with a rate > 0
set_quantity($p_value)
set quantity for the ledger to 1 or 0,
get_ledger_id()
Set the jrn_def.jrn_def_id.
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
Handle the table payment_method.
new class for managing the reconciliation it must be used instead of the function InsertRapt,...
this class is used to show the form for entering an operation only FOR analytic operation to save it,...
Concerns the Analytic plan (table plan_analytique)
static hidden($p_array)
return an HTML string containing hidden input type to hold the differant PA_ID
static fetch_all($ret)
wrapper for the function pg_fetch_all
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
Class Document corresponds to the table document.
static id()
return the 'gDossier' value after a check
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
This class handles only the numeric input, the input will call a javascript to change comma to period...
Generate the form for the periode Data Members.
show a button, for selecting a account and a input text for manually inserting an account the differe...
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Manage the TEXTAREA html element.
static icon_add($id, $p_javascript, $p_style="")
static longer($p_domid, $p_size)
Increase size of input_text (p_domid) with p_domid.
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
static show_note($p_domid)
Increase size of input_text (p_domid) with p_domid.
ORM abstract of the table public.jrn_def.
mother class for the lettering by account and by card use the tables jnt_letter, letter_deb and lette...
For the periode tables parm_periode and jrn_periode.
manage the predefined operation, link to the table op_def and op_def_detail
static available_ledger($get_from_periode)
find all the active ledger for the exerice of the periode and readable by the current user @global ty...
$def
show a form for quick_writing
if( $g_parameter->MY_PJ_SUGGEST=='Y') $e_date
for($e=0; $e< count($afiche); $e++) exit
if( $delta< 0) elseif( $delta==0)
for($i=0;$i< $nb_jrn;$i++) $deb