noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
acc_operation.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief this file match the tables jrn & jrnx the purpose is to
24 * remove or save accountant writing to these table.
25 */
26
27/*!
28 * @class Acc_Operation
29 * \brief this file match the tables jrn & jrnx the purpose is to
30 * remove or save accountant writing to these table.
31 *
32 */
34{
35 var $db; /*!< database connx */
36 var $jr_id; /*!< pk of jrn */
37 var $jrn_id; /*!< jrn_def_id */
38 var $debit; /*!< debit or credit */
39 var $user; /*!< current user */
40 var $jrn; /*!< the ledger to use */
41 var $poste; /*!< account */
42 var $date; /*!< the date */
43 var $periode; /*!< periode to use */
44 var $amount; /*!< amount of the operatoin */
45 var $grpt; /*!< the group id */
47 var $jr_optype; /*!< type of operation :NOR,CLO,EXT,OPE */
48 var $currency_rate; /*< currency rate used */
49 var $currency_id; /*< currency id */
50 var $currency_rate_ref; /*< currency rate in the table currency*/
51 //!< Qcode of item
52 var $qcode;
53 //!< internal code from jrn
56 var $desc;
57 var $type;
60 var $pj;
61 var $mt;
62 var $f_id;
63 /*!
64 * \brief constructor set automatically the attributes user and periode
65 * \param $p_cn the databse connection
66 */
67 function __construct($p_cn)
68 {
69 global $g_user;
70 $this->db=$p_cn;
71 $this->qcode="";
72 $this->user=$_SESSION[SESSION_KEY.'g_user'];
73 $this->periode=$g_user->get_periode();
74 $this->jr_id=0;
75 $this->jr_optype="NOR";
76 $this->amount=0;
77 $this->currency_rate=1;
78 $this->currency_rate_ref=1;
79 $this->currency_id=NULL;
80 }
81
82 function __toString(): string
83 {
84 $r=<<<EOF
85 Acc_Operation Object
86 [
87 db {$this->db}
88 qcode {$this->qcode}
89 user {$this->user}
90 periode {$this->periode}
91 jr_id {$this->jr_id}
92 jr_optype {$this->jr_optype}
93 amount {$this->amount}
94 currency_rate {$this->amount}
95 currency_rate_ref {$this->amount}
96 currency_id {$this->amount}
97 ]
98EOF;
99 return $r;
100
101 }
102
103 /**
104 *@brief retrieve the grpt_id from jrn for a jr_id
105 *@return jrn.jr_grpt_id or an empty string if not found
106 */
107 function seek_group()
108 {
109 $ret=$this->db->get_value('select jr_grpt_id from jrn where jr_id=$1',
110 array($this->jr_id));
111 return $ret;
112 }
113 /**
114 * \brief prepare the query for getting the qcode of the tiers, when
115 * executing this SQL , an array of (jrn.jr_id , jrnx.j_id) must be
116 * provided
117 */
118 private function prepare_sql_tiers()
119 {
120 // prepare for getting the tiers
121 $this->db->prepare('prep_tiers',"select fiche_detail.f_id,ad_value from
122 fiche_detail
123 join (select qf_other as f_id
124 from quant_fin
125 where
126 quant_fin.jr_id = $1
127 union all
128 select qp_supplier as f_id
129 from quant_purchase
130 where quant_purchase.j_id=$2
131 union all
132 select qs_client as f_id
133 from quant_sold
134 where quant_sold.j_id=$2 ) as v_fiche on (fiche_detail.f_id=v_fiche.f_id) where ad_id=23 ");
135 }
136 /**
137 * \brief prepare the query for getting the qcode of the tiers, when
138 * executing this SQL , an array of (jrn.jr_id , jrnx.j_id) must be
139 * provided
140 */
141 private function prepare_sql_counterpart()
142 {
143 // prepare for getting the tiers
144 $this->db->prepare('prep_counterpart',"select fiche_detail.f_id,ad_value from
145 fiche_detail
146 join (select qf_bank as f_id
147 from quant_fin
148 where
149 quant_fin.jr_id = $1
150 union all
151 select qp_fiche as f_id
152 from quant_purchase
153 where quant_purchase.j_id=$2
154 union all
155 select qs_fiche as f_id
156 from quant_sold
157 where quant_sold.j_id=$2 ) as v_fiche on (fiche_detail.f_id=v_fiche.f_id) where ad_id=23 ");
158 }
159 /**
160 * @brief Find the tiers of an operation , thanks the SQL prepared query
161 * prep_tiers and prep_counterpart. Return a string with the quick_code
162 * @param type $pn_jrn_id pk of the table jrn (jrn.jr_id)
163 * @param type $pn_jrnx_id pk of the table jrnx (jrnx.jr_id)
164 * @param type $p_code quickcode
165 * @return string
166 */
167 function find_tiers($pn_jrn_id,$pn_jrnx_id,$p_code)
168 {
169 static $p=0;
170 if ( $p == 0 ){
172 $this->prepare_sql_tiers();
173 $p=1;
174 }
175 $tiers="";
176 $res_tiers=$this->db->execute('prep_tiers',
177 array($pn_jrn_id,$pn_jrnx_id));
178 if ( Database::num_row($res_tiers) > 0) {
179 $atiers=Database::fetch_array($res_tiers);
180 $tiers=$atiers['ad_value'];
181 // If the found tiers has the same quickcode than the current
182 // card, it means it is a card of supplier or customer,
183 // so we must look for the countercard
184 if ($tiers == $p_code) {
185 $res_counterpart=$this->db->execute('prep_counterpart',
186 array($pn_jrn_id,$pn_jrnx_id));
187 $tiers="";
188 if ( Database::num_row($res_counterpart) > 0) {
189 $atiers=Database::fetch_array($res_counterpart);
190 $tiers=$atiers['ad_value'];
191 }
192 }
193 }
194 return $tiers;
195 }
196 /**
197 *@brief Insert into the table Jrn
198 *The needed data are :
199 * - this->date
200 * - this->amount
201 * - this->poste
202 * - this->grpt
203 * - this->jrn
204 * - this->type ( debit or credit)
205 * - this->user
206 * - this->periode
207 * - this->qcode
208 * - this->desc optional
209 *@note if the amount is less than 0 then side changes, for example debit becomes
210 *a credit and vice versa
211 *@return jrnx.j_id
212 */
213
214 function insert_jrnx()
215 {
216 if ( $this->poste == "") { throw new Exception (__FILE__.':'.__LINE__.' Poste comptable vide');return false; }
217 /* for negative amount the operation is reversed */
218 if ( $this->amount < 0 )
219 {
220 $this->type=($this->type=='d')?'c':'d';
221 }
222 if ( DEBUGNOALYSS > 1 ) {
223 echo "insert_jrnx = [{ $this->poste}] {$this->amount} rounded ".round($this->amount,2)." type {$this->type}<br>";
224 }
225 $this->amount=abs($this->amount);
226 $debit=($this->type=='c')?'false':'true';
227 $this->desc=(isset($this->desc))?$this->desc:'';
228 $this->amount=(trim($this->amount)==''||$this->amount==NULL)?0:$this->amount;
229 $Res=$this->db->exec_sql("select insert_jrnx
230 ($1::text,abs($2)::numeric,$3::account_type,$4::integer,$5::integer,$6::bool,$7::text,$8::integer,upper($9),$10::text)",
231 array(
232 $this->date, //$1
233 round($this->amount,2), //$2
234 $this->poste, //$3
235 $this->grpt, //$4
236 $this->jrn, //$5
237 $debit, //$6
238 $this->user, //$7
239 $this->periode, //$8
240 $this->qcode, // $9
241 $this->desc)); //$10
242 if ( $Res===FALSE) return FALSE;
243 $this->jrnx_id=$this->db->get_current_seq('s_jrn_op');
244 return $this->jrnx_id;
245
246 }
247
248 /**
249 * @brief get the sum of other tax linked to this operation
250 */
251 function get_sum_other_tax() {
252 if ( $this->jr_id == 0 ) {return 0;}
253 $sum=$this->db->get_value("select
254 sum(case when j_debit is false and jrn_def.jrn_def_type='ACH'
255 then 0-j_montant when j_debit is true and jrn_def.jrn_def_type='VEN'
256 then 0-j_montant
257 else j_montant end) sum_tax
258 from
259 jrn_tax join jrnx j1 using (j_id)
260 join jrn on (jr_grpt_id=j1.j_grpt)
261 join jrn_def on (jrn.jr_def_id=jrn_def.jrn_def_id)
262 where
263 jrn.jr_id=$1",[$this->jr_id]);
264 ;
265 if ( $this->db->count()==0) {return 0;}
266 return $sum;
267 }
268
269 /*!
270 *\brief set the pj of a operation in jrn. the jr_id must be set
271 *\note if the jr_id it fails
272 */
273 function update_receipt()
274 {
275 if ( noalyss_strlentrim($this->pj) == 0 )
276 {
277 // echo __LINE__."debug {$this->pj} est vide";
278 $sql="update jrn set jr_pj_number=$1 where jr_id=$2";
279 $this->db->exec_sql($sql,array(null,$this->jr_id));
280 return '';
281 }
282 /* is pj uniq ? */
283 if ( $this->db->count_sql("select jr_id from jrn
284 where jr_pj_number=$1 and jr_def_id=$2
285 and jr_id !=$3",
286 array($this->pj,$this->jrn,$this->jr_id)
287 ) == 0 )
288 {
289
290 $sql="update jrn set jr_pj_number=$1 where jr_id=$2";
291 $this->db->exec_sql($sql,array($this->pj,$this->jr_id));
292 }
293 else
294 {
295 /* get pref */
296 $pref=$this->db->get_value("select jrn_def_pj_pref from jrn_def where jrn_def_id=$1",
297 array($this->jrn));
298 /* try another seq */
299 $flag=0;
300 $limit=100;
301 while ( $flag == 0 )
302 {
303 /* limit the search to $limit */
304 if ( $limit < 1 )
305 {
306 $this->pj='';
307 $flag=2;
308 break;
309 }
310 /* get padding */
311 $padding=$this->db->get_value("select jrn_def_pj_padding from jrn_def where jrn_def_id=$1",
312 array($this->jrn));
313
314 $seq=$this->db->get_next_seq('s_jrn_pj'.$this->jrn);
315
316 // see Acc_Ledger::guess_pj
317 $this->pj=$pref.str_pad($seq,$padding??0,'0',STR_PAD_LEFT);
318
319 /* check if the new pj numb exist */
320 $c=$this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2
321 and jr_id !=$3",
322 array($this->pj,$this->jrn,$this->jr_id)
323 );
324 if ( $c == 0 )
325 {
326 $flag=1;
327 break;
328 }
329 $limit--;
330 }
331 /* a pj numb is found */
332 if ( $flag == 1 )
333 {
334 $sql="update jrn set jr_pj_number=$1 where jr_id=$2";
335 $this->db->exec_sql($sql,array($this->pj,$this->jr_id));
336 }
337 }
338 return $this->pj;
339 }
340
341 /*!
342 *\brief Insert into the table Jrn, the amount is computed from jrnx thanks the
343 * group id ($p_grpt)
344 *
345 * \return sequence of jr_id
346 *
347 */
348
349 function insert_jrn()
350 {
351 $p_comment=$this->desc;
352 if ( DEBUGNOALYSS > 1 ) {
353 echo "insert_jrn = {$this->amount} <br>";
354 }
355 $diff=$this->db->get_value("select check_balance ($1)",array($this->grpt));
356 if ( $diff != 0 )
357 {
358
359 printf (_("Erreur : balance incorrecte :diff = %s"),$diff);
360 return false;
361 }
362
363 $echeance=( isset( $this->echeance) && noalyss_strlentrim($this->echeance) != 0)?$this->echeance:null;
364 if ( ! isset($this->mt) )
365 {
366 $this->mt=microtime(true);
367 }
368
369 // if amount == -1then the triggers will throw an error
370 //
371 $this->amount=(trim($this->amount)==''||$this->amount==NULL)?0:$this->amount;
372 $Res=$this->db->exec_sql("insert into jrn (jr_def_id,jr_montant,jr_comment,".
373 "jr_date,jr_ech,jr_grpt_id,jr_tech_per,jr_mt,jr_optype,currency_id,currency_rate,currency_rate_ref) values (".
374 "$1,$2,$3,".
375 "to_date($4,'DD.MM.YYYY'),to_date($5,'DD.MM.YYYY'),$6,$7,$8,$9,$10,$11,$12)",
376 array ($this->jrn, $this->amount,$p_comment,
377 $this->date,$echeance,$this->grpt,$this->periode,$this->mt,$this->jr_optype,
378 $this->currency_id,$this->currency_rate,$this->currency_rate_ref)
379 );
380 if ($Res==FALSE)
381 {
382 return FALSE;
383 }
384 $this->jr_id=$this->db->get_current_seq('s_jrn');
385 return $this->jr_id;
386 }
387 /*!
388 * \brief Return the internal value, the property jr_id must be set before
389 *
390 * \return null si aucune valeur de trouv
391 *
392 */
393 function get_internal()
394 {
395 if ( ! isset($this->jr_id) )
396 throw new Exception('jr_id is not set',1);
397 $Res=$this->db->exec_sql("select jr_internal from jrn where jr_id=".$this->jr_id);
398 if ( Database::num_row($Res) == 0 ) return null;
400 $this->jr_internal= $l_line['jr_internal'];
401 return $this->jr_internal;
402 }
403 /*!
404 * \brief search an operation thankx it internal code
405 * \param internal code
406 * \return 0 ok -1 nok
407 */
408 function seek_internal($p_internal)
409 {
410 $res=$this->db->exec_sql('select jr_id from jrn where jr_internal=$1',
411 array($p_internal));
412 if ( Database::num_row($res) == 0 ) return -1;
414 return 0;
415 }
416 /*!
417 * \brief retrieve data from jrnx
418 *\note the data are filtered by the access of the current user
419 * \return an array or FALSE if nothing found
420 */
422 {
423 global $g_user;
424 $filter_sql=$g_user->get_ledger_sql('ALL',3);
425 $filter_sql=noalyss_str_replace('jrn_def_id','jr_def_id',$filter_sql);
426 if ( $this->jr_id==0 ) return;
427 $sql=" select jr_id,j_id,jr_date,j_qcode,j_poste,j_montant,jr_internal,case when j_debit = 'f' then 'C' else 'D' end as debit,jr_comment as description,
428 vw_name,pcm_lib,j_debit,coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter,jr_def_id ".
429 " from jrnx join jrn on (jr_grpt_id=j_grpt)
430 join tmp_pcmn on (j_poste=pcm_val)
431 left join vw_fiche_attr on (j_qcode=quick_code)
432 where
433 jr_id=$1 and $filter_sql order by j_debit desc";
434 $res=$this->db->exec_sql($sql,array($this->jr_id));
435 if ( Database::num_row ($res) == 0 ) return array();
437 return $all;
438 }
439 /*!\brief add a comment to the line (jrnx.j_text) */
440 function update_comment($p_text)
441 {
442 $sql="update jrnx set j_text=$1 where j_id=$2";
443 $this->db->exec_sql($sql,array($p_text,$this->jrnx_id));
444 }
445 /*!\brief add a comment to the operation (jrn.jr_text) */
446 function operation_update_comment($p_text)
447 {
448 $sql="update jrn set jr_comment=$1 where jr_id=$2";
449 $this->db->exec_sql($sql,array($p_text,$this->jr_id));
450 }
451 /*!\brief add a limit of payment to the operation (jrn.jr_ech) */
453 {
454 if ( isDate($p_text) == null )
455 {
456 $p_text=null;
457 }
458 $sql="update jrn set jr_ech=to_date($1,'DD.MM.YYYY') where jr_id=$2";
459 $this->db->exec_sql($sql,array($p_text,$this->jr_id));
460 }
461 /*!\brief return the jrn_def_id from jrn */
462 function get_ledger()
463 {
464 $sql="select jr_def_id from jrn where jr_id=$1";
465 $row=$this->db->get_value($sql,array($this->jr_id));
466 return $row;
467 }
468 /*!\brief display_jrnx_detail : get the data from get_jrnx_data and
469 return a string with HTML code
470 * \param table(=0 no code for table,1 code for table,2 code for CSV)
471
472 */
473 function display_jrnx_detail($p_table)
474 {
475 $show=$this->get_jrnx_detail();
476
477 $r='';
478 $r_notable='';
479 $csv="";
480 foreach ($show as $l)
481 {
482 $border="";
483 if ( $l['j_poste'] == $this->poste || ($l['j_qcode']==$this->qcode && trim($this->qcode) != ''))
484 $border=' class="highlight"';
485 $r.='<tr '.$border.'>';
486 $r.='<td>';
487 $a=$l['j_qcode'];
488
489 $r_notable.=$a;
490 $r.=$a;
491 $csv.='"'.$a.'";';
492 $r.='</td>';
493
494 $r.='<td '.$border.'>';
495 $a=$l['j_poste'];
496 $r_notable.=$a;
497 $r.=$a;
498 $csv.='"'.$a.'";';
499 $r.='</td>';
500
501 $r.='<td '.$border.'>';
502 // $a=($l['vw_name']=="")?$l['j_qcode']:$l['pcm_lib'];
503 $a=(noalyss_strlentrim($l['j_qcode'])==0)?$l['pcm_lib']:$l['vw_name'];
504 $r_notable.=$a;
505 $r.=h($a);
506 $csv.='"'.$a.'";';
507 $r.='</td>';
508
509 $r.='<td '.$border.'>';
510 $a=$l['j_montant'];
511 $r_notable.=$a;
512 $r.=$a;
513 $csv.=$a.';';
514 $r.='</td>';
515
516 $r.='<td '.$border.'>';
517 $a=$l['debit'];
518 $r_notable.=$a;
519 $r.=$a;
520 $csv.='"'.$a.'"';
521
522 $csv.="\r\n";
523 $r.='</td>';
524 $r.='<td '.$border.'>';
525 $a=($l['letter']!=-1)?$l['letter']:'';
526 $r_notable.=$a;
527 $r.=$a;
528 $csv.='"'.$a.'"';
529
530 $csv.="\r\n";
531 $r.='</td>';
532
533
534 $r.='</tr>';
535 }
536 switch ($p_table)
537 {
538 case 1:
539 return $r;
540 break;
541 case 0:
542 return $r_notable;
543 break;
544 case 2:
545 return $csv;
546 }
547 return "ERROR PARAMETRE";
548 }
549 /*!
550 * @brief Get data from jrnx where p_grpt=jrnx(j_grpt)
551 *
552 * @param connection
553 * @return array of 3 elements
554 * - First Element is an array
555 @verbatim
556 Array
557 (
558 [op_date] => 01.12.2009
559 [class_cred0] => 7000008
560 [mont_cred0] => 8880.0000
561 [op_cred0] => 754
562 [text_cred0] =>
563 [jr_internal] => 23VEN-01-302
564 [comment] =>
565 [ech] =>
566 [jr_id] => 302
567 [jr_def_id] => 2
568 [class_deb0] => 4000005
569 [mont_deb0] => 10744.8000
570 [text_deb0] =>
571 [op_deb0] => 755
572 [class_cred1] => 4511
573 [mont_cred1] => 1864.8000
574 [op_cred1] => 756
575 [text_cred1] =>
576 )
577 @endverbatim
578 * - Second : number of line with debit
579 * - Third : number of line with credit
580 */
581 function get_data ($p_grpt)
582 {
583 $Res=$this->db->exec_sql("select
584 to_char(j_date,'DD.MM.YYYY') as j_date,
585 j_text,
586 j_debit,
587 j_poste,
588 coalesce(j_qcode,'-') as qcode,
589 j_montant,
590 j_id,
591 jr_comment,
592 to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
593 to_char(jr_date,'DD.MM.YYYY') as jr_date,
594 jr_id,jr_internal,jr_def_id,jr_pj
595 from jrnx inner join jrn on j_grpt=jr_grpt_id where j_grpt=$1",array($p_grpt));
596 $MaxLine=Database::num_row($Res);
597 if ( $MaxLine == 0 ) return null;
598 $deb=0;
599 $cred=0;
600 for ( $i=0; $i < $MaxLine; $i++)
601 {
602
604 $l_array['op_date']=$l_line['j_date'];
605 if ( $l_line['j_debit'] == 't' )
606 {
607 $l_class=sprintf("class_deb%d",$deb);
608 $l_montant=sprintf("mont_deb%d",$deb);
609 $l_text=sprintf("text_deb%d",$deb);
610 $l_qcode=sprintf("qcode_deb%d",$deb);
611 $l_array[$l_class]=$l_line['j_poste'];
612 $l_array[$l_montant]=$l_line['j_montant'];
613 $l_array[$l_text]=$l_line['j_text'];
614 $l_array[$l_qcode]=$l_line['qcode'];
615 $l_id=sprintf("op_deb%d",$deb);
616 $l_array[$l_id]=$l_line['j_id'];
617 $deb++;
618 }
619 if ( $l_line['j_debit'] == 'f' )
620 {
621 $l_class=sprintf("class_cred%d",$cred);
622 $l_montant=sprintf("mont_cred%d",$cred);
623 $l_array[$l_class]=$l_line['j_poste'];
624 $l_array[$l_montant]=$l_line['j_montant'];
625 $l_id=sprintf("op_cred%d",$cred);
626 $l_array[$l_id]=$l_line['j_id'];
627 $l_text=sprintf("text_cred%d",$cred);
628 $l_array[$l_text]=$l_line['j_text'];
629 $l_qcode=sprintf("qcode_cred%d",$cred);
630 $l_array[$l_qcode]=$l_line['qcode'];
631 $cred++;
632 }
633 $l_array['jr_internal']=$l_line['jr_internal'];
634 $l_array['comment']=$l_line['jr_comment'];
635 $l_array['ech']=$l_line['jr_ech'];
636 $l_array['jr_id']=$l_line['jr_id'];
637 $l_array['jr_def_id']=$l_line['jr_def_id'];
638 }
639 return array($l_array,$deb,$cred);
640 }
641 /**
642 *@brief retrieve data from jrnx and jrn
643 *@return return an object
644 *@note
645 *@see
646 @code
647
648 @endcode
649 */
650 function get()
651 {
652 $ret=new Acc_Misc($this->db,$this->jr_id);
653 $ret->get();
654 return $ret;
655 }
656 /**
657 *@brief retrieve data from the table QUANT_*
658 *@return return an object or null if there is no
659 * data from the QUANT table
660 *@see Acc_Sold Acc_Purchase Acc_Fin Acc_Detail Acc_Misc
661 */
662 function get_quant()
663 {
664 $ledger_id=$this->get_ledger();
665 if ( $ledger_id=='') throw new Exception(_('Journal non trouvé'));
666 $oledger=new Acc_Ledger($this->db,$ledger_id);
667
668 // retrieve info from jrn_info
669
670
671 switch($oledger->get_type())
672 {
673 case 'VEN':
674 $ret=new Acc_Sold($this->db,$this->jr_id);
675 break;
676 case 'ACH':
677 $ret=new Acc_Purchase($this->db,$this->jr_id);
678 break;
679 case 'FIN':
680 $ret=new Acc_Fin($this->db,$this->jr_id);
681 break;
682 default:
683 $ret=new Acc_Misc($this->db,$this->jr_id);
684 break;
685 }
686 $ret->get();
687 if ( empty($ret->det->array))
688 {
689 $ret=new Acc_Misc($this->db,$this->jr_id);
690 $ret->get();
691 }
692 $ret->get_info();
693 return $ret;
694 }
695 /**
696 *@brief retrieve amount in currency for the operation
697 *@return amount in currency or 0 if this operation doesn't use currency
698 *@see Acc_Sold Acc_Purchase Acc_Fin Acc_Detail Acc_Misc
699 */
701 {
702 if ( $this->det->currency_id == 0 ) {
703 return 0;
704 }
705 $ledger_id=$this->get_ledger();
706 if ( $ledger_id=='') throw new Exception(_('Journal non trouvé'));
707 $oledger=new Acc_Ledger($this->db,$ledger_id);
708
709 // retrieve info from jrn_info
710
711
712 switch($oledger->get_type())
713 {
714 case 'VEN':
715 $sql_amount="
716 select
717 sum(oc_amount)+sum(oc_vat_amount )
718 from operation_currency oc
719 join quant_sold qs using(j_id)
720 where
721 oc.j_id in (select j_id
722 from jrnx join jrn on (jr_grpt_id=j_grpt)
723 where jr_id=$1);
724 ";
725 break;
726 case 'ACH':
727 $sql_amount="
728 select
729 sum(oc_amount)+sum(oc_vat_amount )
730 from operation_currency oc
731 join quant_purchase qs using(j_id)
732 where
733 oc.j_id in (select j_id
734 from jrnx join jrn on (jr_grpt_id=j_grpt)
735 where jr_id=$1);
736 ";
737 break;
738 case 'FIN':
739 $sql_amount="
740 select
741 sum(oc_amount)+sum(oc_vat_amount )
742 from operation_currency oc
743 join quant_fin qs using(j_id)
744 where
745 oc.j_id in (select j_id
746 from jrnx join jrn on (jr_grpt_id=j_grpt)
747 where jr_id=$1);
748 ";
749 break;
750 default:
751 $sql_amount="
752 select
753 sum(oc_amount)+sum(oc_vat_amount )
754 from operation_currency oc
755 join jrnx using(j_id)
756 join jrn on (jr_grpt_id=j_grpt)
757 where
758 jr_id=$1 and j_debit='t';
759 ";
760 break;
761 }
762 $amount=$this->db->get_value($sql_amount,[$this->jr_id]);
763 return $amount;
764 }
765 /**
766 * @brief retrieve info from the jrn_info, create 2 new arrays
767 * obj->info->command and obj->info->other
768 * the columns are the idx
769 */
770 function get_info()
771 {
772 $this->info=new stdClass();
773 // other info
774 $array=$this->db->get_value("select ji_value from jrn_info where
775 jr_id=$1 and id_type=$2",array($this->jr_id,'OTHER'));
776 $this->info->other= $array;
777
778 // Bon de commande
779 $array=$this->db->get_value("select ji_value from jrn_info where
780 jr_id=$1 and id_type=$2",array($this->jr_id,'BON_COMMANDE'));
781 $this->info->command= $array;
782
783 }
784 /**
785 * Save into jrn_info
786 * @param $p_info msg to save
787 * @param $p_type is OTHER or BON_COMMAND
788 */
789 function save_info($p_info,$p_type)
790 {
791 if ( ! in_array($p_type,array('OTHER','BON_COMMANDE'))) return;
792 if (trim($p_info)=="") {
793 $this->db->exec_sql('delete from jrn_info where jr_id=$1 and id_type=$2',array($this->jr_id,$p_type));
794 return;
795 }
796 $exist=$this->db->get_value('select count(ji_id) from jrn_info where jr_id=$1 and id_type=$2',array($this->jr_id,$p_type));
797 if ( $exist == "0" ) {
798 //insert into jrn_info
799 $this->db->exec_sql('insert into jrn_info(jr_id,id_type,ji_value) values ($1,$2,$3)',
800 array($this->jr_id,$p_type,$p_info));
801 } elseif ( $exist == 1) {
802 //update
803 $this->db->exec_sql('update jrn_info set ji_value=$3 where jr_id=$1 and id_type=$2',
804 array($this->jr_id,$p_type,$p_info));
805 }
806 }
807
808 function insert_related_action($p_string)
809 {
810 if ($p_string == "") return;
811 $a_action=explode(',',$p_string);
812 for ($i=0;$i<count($a_action);$i++)
813 {
814 $action = new Follow_Up($this->db,$a_action[$i]);
815 $action->operation=$this->jr_id;
816 $action->insert_operation();
817 }
818 }
819 /**
820 * @brief set the operation id (jrn.jr_id)
821 * @param type $p_id
822 */
823 function set_id($p_id)
824 {
825 if (isNumber($p_id)==0) {
826 throw new Exception(_('Acc_Operation::set_id , id invalide '));
827 }
828 $this->jr_id=$p_id;
829 }
830 /**
831 * \brief flag the operation as paid
832 */
833 function set_paid()
834 {
835 // Operation
836 if ( $this->jr_id == 0 )
837 throw new Exception(_('Object invalide, id incorrect'));
838 if (
839 $this->db->get_value('select count(*) from jrn where jr_id=$1',
840 array($this->jr_id)) == 0 )
841 throw new Exception(_('Object invalide, id incorrect'));
842
843 $this->db->exec_sql("update jrn set jr_rapt = 'paid' where jr_id = $1",
844 array($this->jr_id));
845 }
846 /**
847 * return amount of the jr_id
848 */
849 function get_amount()
850 {
851 if ( $this->jr_id == 0 )
852 throw new Exception(_('Object invalide, id incorrect'));
853 $amount=$this->db->get_value('select jr_montant from jrn where jr_id=$1',
854 array($this->jr_id));
855 return $amount;
856 }
857 static function test_me()
858 {
859 global $g_user;
860 $cn=Dossier::connect();
861 $g_user=new Noalyss_user($cn);
862 $a=new Acc_Operation($cn);
863 $a->jr_id=993;
864 $b=$a->get_quant();
865 echo h1('contain of get_quant() ');
866 var_dump($b);
867 echo h1('contain of get_jrnx_detail()');
868 var_dump($a->get_jrnx_detail());
869 }
870 /**
871 * Return a select object to choose the type of operation
872 * - NOR normal
873 * - EXT reverse operation
874 * - CLO closing periode
875 * - OPE opening periode
876 * @param string $p_status
877 * @return \ISelect
878 */
879 static function select_operation_type($p_status)
880 {
881 $type_operation=new ISelect("jr_optype");
882 $type_operation->value=array(
883 array(("label")=>_("Normal"), "value"=>"NOR"),
884 array(("label")=>_("Ouverture"), "value"=>"OPE"),
885 array(("label")=>_("Fermeture"), "value"=>"CLO"),
886 array(("label")=>_("Extourne"), "value"=>"EXT")
887 );
888
889 $type_operation->selected=$p_status;
890 return $type_operation;
891 }
892 /**
893 * @brief create a form to recreate the operation and returns it,
894 * it works the same as when you want to correct an operation instead of confirming
895 *
896 * @see compta_ach.inc.php
897 * @see compta_ven.inc.php
898 *
899 * @param $p_id string DOMID of the form
900 */
902 // retrieve all info about operation
903 $operation = $this->get_quant();
904 $array=$operation->compute_array();
905
906 global $g_user;
907 $a_code=$this->db->get_array("select code from v_menu_dependency vmd where me_code=$1 and p_id=$2",
908 array( $operation->signature,$g_user->get_profile()));
909 if ( empty ($a_code)) {
910 $r=_("Menu invalide");
911 return $r;
912 }
913
914 // Prepare the form
915 // select the menu where the operation will be duplicated
916 $r=sprintf('<form id="%s" method="POST" ACTION="%s">',$p_id,NOALYSS_URL."/do.php?".http_build_query([
917 "ac"=>$a_code[0]['code'],"gDossier"=>Dossier::id()
918 ]));
919 $r.=Dossier::hidden();
920 $default_currency=new Acc_Currency($this->db,0);
921 // select the menu where the operation will be duplicated
922
923 $r.="<p>";
924 $r.="<ul style=\"margin-left:2rem;padding-left:0;list-style:none;\">";
925 $r.=sprintf("<li>%s %s</li>",_("Date"),$operation->det->jr_pj_number);
926 $r.=sprintf("<li>%s %s</li>",_("Libellé"),$operation->det->jr_comment);
927 $r.=sprintf("<li>%s %s %s</li>",_("Montant "),nbm($operation->det->jr_montant),$default_currency->get_code());
928 // Add info if the operation using a currency
929 if ( $operation->det->currency_id != 0 ) {
930 $currency=$this->db->get_value("select cr_code_iso from currency where id=$1",[$operation->det->currency_id]);
931 $r.=sprintf("<li>%s %s</li>",_('Devise'),$currency);
932 $r.=sprintf("<li>%s %s</li>",_("Taux"),$operation->det->currency_rate);
933 $array['p_currency_code']=$operation->det->currency_id;
934 $array['p_currency_rate']=$operation->det->currency_rate;
935 }
936 $r.="</ul>";
937 $r.="</p>";
938 if (count($a_code) == 1 ) {
939 $r.=HtmlInput::hidden("ac",$a_code[0]['code']);
940 $r.=sprintf(_("Voulez-vous aller à %s pour dupliquer cette opération ?"),$a_code[0]['code']);
941
942 } else {
943 $select=new ISelect("ac");
944 $select->value=array();
945 $nb_code=count($a_code);
946
947 for ($i=0;$i<$nb_code;$i++) {
948 $select->value[]=array("label"=>$a_code[$i]['code'],"value"=>$a_code[$i]['code']);
949 }
950 $r.=sprintf(_("Voulez-vous aller à %s pour dupliquer cette opération ?"),$select->input());
951
952 }
953
954 $r.="</p>";
955
956 // For Misc Operation , if a card is given then there is no accounting
957 // modify amount with currency if not in default currency
958 if ( $operation->signature==="ODS") {
959 $nb_array = count($array);
960 for ($i = 0; $i < $nb_array; $i++) {
961 if (isset ($array["qc_" . $i]) && $array["qc_" . $i] != "") {
962 $array["poste" . $i] = "";
963 }
964
965 }
966 $idx=0;
967 foreach ($operation->det->array as $item) {
968 if ($operation->det->currency_id != 0) {
969 $array['amount'. $idx] = $item['oc_amount'];
970 $idx++;
971 }
972 }
973
974 }elseif ( $operation->signature==="ACH" || $operation->signature=="VEN") {
975 $idx=0;
976 foreach ($operation->det->array as $item) {
977
978 // currency replace amount
979 if ($operation->det->currency_id != 0 ) {
980 $array['e_march'.$idx.'_tva_amount']=$item['oc_vat_amount'];
981 $array['e_march'.$idx.'_tva_amount']=$item['oc_amount'];
982 $array['e_march'.$idx.'_price']=$item['oc_price_unit'];
983 }
984
985 if ( isset ($item['qs_vat_sided']) && $item['qs_vat_sided'] != 0 ) {
986 $array['e_march'.$idx.'_tva_amount']=0;
987 }elseif (isset ($item['qp_vat_sided']) && $item['qp_vat_sided'] != 0 ){
988 $array['e_march'.$idx.'_tva_amount']=0;
989 }
990
991 $idx++;
992 }
993 }elseif ($operation->signature=='FIN') {
994 $idx=0;
995 foreach ($operation->det->array as $item) {
996 if ($operation->det->currency_id != 0) {
997 $array['e_other' . $idx . '_amount'] = $item['oc_amount'];
998 $idx++;
999 }
1000 }
1001 }
1002
1003 if ( DEBUGNOALYSS>1) {
1004 echo \Noalyss\Dbg::hidden_info("operation->det_array", $operation->det->array);
1005 echo \Noalyss\Dbg::hidden_info("operation->det", $operation->det);
1006 echo \Noalyss\Dbg::hidden_info("array", $array);
1007 }
1008 // transform the operation into hidden element
1009 $r.=HtmlInput::simple_array_to_hidden($array);
1010 $r.=HtmlInput::hidden("e_comm",$operation->det->jr_comment);
1011 $r.=HtmlInput::submit(uniqid(), _("Dupliquer"));
1012 $r.=HtmlInput::button_close("duplicate_operation_div");
1013 $r.='</form>';
1014
1015
1016 // return the form as a string
1017 return $r;
1018 }
1019
1020}
1021/////////////////////////////////////////////////////////////////////////////
1022
1023/**
1024 * @class Acc_Detail
1025 * @brief Contains the detail of an operation Acc_Operation
1026 */
1028{
1029 public $det;
1030 public $jr_id;
1031 public $info;
1032
1033 function __construct($p_cn,$p_jrid=0)
1034 {
1035 parent::__construct($p_cn);
1036 $this->jr_id=$p_jrid;
1037 $this->det=new stdClass();
1038 }
1039 /**
1040 *@brief retrieve some common data from jrn as
1041 * the datum, the comment,payment limit...
1042 */
1043 function get()
1044 {
1045 $sql="SELECT jr_id, jr_def_id, jr_montant, jr_comment, jr_date, jr_grpt_id,
1046 jr_internal, jr_tech_date, jr_tech_per, jrn_ech, jr_ech, jr_rapt,jr_ech,
1047 jr_valid, jr_opid, jr_c_opid, jr_pj, jr_pj_name, jr_pj_type,
1048 jr_pj_number, jr_mt,jr_rapt,jr_date_paid,jr_optype,currency_id,currency_rate,currency_rate_ref
1049 FROM jrn where jr_id=$1";
1050 $array=$this->db->get_array($sql,array($this->jr_id));
1051 if ( count($array) == 0 ) throw new Exception('Aucune ligne trouvée');
1052 foreach ($array[0] as $key=>$val)
1053 {
1054 $this->det->$key=$val;
1055 }
1056 $sql="select n_text from jrn_note where jr_id=$1";
1057 $this->det->note=$this->db->get_value($sql,array($this->jr_id));
1058 $this->det->note=strip_tags($this->det->note);
1059 }
1060 /**
1061 *
1062 */
1063 function compute_array()
1064 {
1065 $array=array();
1066 $array['desc']=$this->det->jr_comment;
1067 $array['e_date']="";
1068 $array['e_ech']="";
1069 $array['p_jrn']=$this->det->jr_def_id;
1070 return $array;
1071
1072 }
1073}
1074/////////////////////////////////////////////////////////////////////////////
1075/**
1076 * @class Acc_Misc
1077 *@brief this class manage data from the JRNX and JRN
1078 * table
1079 *@note Data member are the column of the table
1080 */
1082{
1083 var $signature; /*!< signature of the obj ODS */
1084 var $array; /*!< an array containing the data from JRNX */
1085 function __construct($p_cn,$p_jrid=0)
1086 {
1087 parent::__construct($p_cn,$p_jrid);
1088 $this->signature='ODS';
1089 $this->det=new stdClass();
1090 }
1091 function get()
1092 {
1093 parent::get();
1094 $sql="
1095SELECT jx1.j_id
1096 ,jx1.j_date
1097 ,jx1.j_montant
1098 ,jx1.j_poste
1099 ,jx1.j_grpt
1100 ,jx1.j_rapt
1101 ,jx1.j_jrn_def
1102 ,jx1.j_debit
1103 ,jx1.j_text
1104 ,jx1.j_centralized
1105 ,jx1.j_internal
1106 ,jx1.j_tech_user
1107 ,jx1.j_tech_date
1108 ,jx1.j_tech_per
1109 ,jx1.j_qcode
1110 ,jx1.f_id
1111 ,oc1.oc_amount
1112 FROM jrnx jx1
1113 left join operation_currency oc1 using(j_id)
1114 where
1115 jx1.j_grpt = $1
1116 order by jx1.j_debit desc,jx1.j_poste
1117";
1118 $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
1119 }
1120 /***
1121 * Compute an array for using with Acc_Ledger::insert
1122 *
1123 */
1124 function compute_array()
1125 {
1126 $this->get();
1127 $array=parent::compute_array();
1128 $nb_array=count($this->det->array);
1129 $array['nb_item']=$nb_array;
1130
1131 for ($i=0;$i<$nb_array;$i++) {
1132 $array["qc_".$i]=$this->det->array[$i]['j_qcode'];
1133 $array["poste".$i]=$this->det->array[$i]['j_poste'];
1134 $array["amount".$i]=$this->det->array[$i]['j_montant'];
1135 if ( $this->det->array[$i]['j_debit'] == 't') {
1136 $array["ck".$i]=1;
1137 }
1138 $array["ld".$i]=$this->det->array[$i]['j_text'];
1139 }
1140
1141 return $array;
1142
1143 }
1144}
1145/////////////////////////////////////////////////////////////////////////////
1146/**
1147 * @class Acc_Sold
1148 *@brief this class manage data from the QUANT_SOLD
1149 * table
1150 *@note Data member are the column of the table
1151 */
1153{
1154 function __construct($p_cn,$p_jrid=0)
1155 {
1156 parent::__construct($p_cn,$p_jrid);
1157 $this->signature='VEN';
1158 $this->det=new stdClass();
1159 }
1160 function get()
1161 {
1162 parent::get();
1163 $sql="
1164 select qs_id, qs_internal
1165, jx1.j_id
1166, qs1.qs_fiche
1167, qs1.qs_quantite
1168, qs1.qs_price
1169, qs1.qs_vat
1170, qs1.qs_vat_code
1171, qs1.qs_client
1172, qs1.qs_valid
1173, jx1.j_text
1174, qs_vat_sided
1175, qs_unit
1176, jx1.j_debit
1177,oc1.oc_amount
1178,oc1.oc_vat_amount
1179,oc1.oc_price_unit
1180from quant_sold qs1
1181join jrnx jx1 using(j_id)
1182left join operation_currency oc1 using(j_id)
1183where jx1.j_grpt = $1
1184order by jx1.j_id;
1185 ";
1186 $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
1187 }
1188 /***
1189 * @brief Compute an array for using with Acc_Ledger::insert
1190 *
1191 */
1192 function compute_array()
1193 {
1194 $this->get();
1195 $array=parent::compute_array();
1196 $nb_array=count($this->det->array);
1197 $array['nb_item']=$nb_array;
1198
1199
1200 $array["e_client"]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23",
1201 array($this->det->array[0]['qs_client']));
1202
1203 for ($i=0;$i<$nb_array;$i++) {
1204 $array["e_march".$i]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23",
1205 array($this->det->array[$i]['qs_fiche']));
1206
1207 $array["e_march".$i."_price"]=$this->det->array[$i]['qs_unit'];
1208 $array["e_march".$i."_label"]=$this->det->array[$i]['j_text'];
1209 $array["e_march".$i."_tva_id"]=$this->det->array[$i]['qs_vat_code'];
1210 $array["e_march".$i."_tva_amount"]=$this->det->array[$i]['qs_vat'];
1211 $array["e_quant".$i]=$this->det->array[$i]['qs_quantite'];
1212 }
1213 $array['correct']=1;
1214 return $array;
1215
1216 }
1217
1218}
1219/////////////////////////////////////////////////////////////////////////////
1220/**
1221 * @class Acc_Purchase
1222 *@brief this class manage data from the QUANT_PURCHASE
1223 * table
1224 *@note Data member are the column of the table
1225
1226 */
1228{
1229 function __construct($p_cn,$p_jrid=0)
1230 {
1231 parent::__construct($p_cn,$p_jrid);
1232 $this->signature='ACH';
1233 }
1234
1235 function get()
1236 {
1237 parent::get();
1238 $sql="
1239 select qp_id, qp_internal
1240, jx1.j_id
1241, qp1.qp_fiche
1242, qp1.qp_quantite
1243, qp1.qp_price
1244, qp1.qp_vat
1245, qp1.qp_vat_code
1246, qp1.qp_nd_amount
1247, qp1.qp_nd_tva
1248, qp1.qp_nd_tva_recup
1249, qp1.qp_supplier
1250, qp1.qp_valid
1251, qp1.qp_dep_priv
1252, jx1.j_text
1253, qp1.qp_vat_sided
1254, qp1.qp_unit
1255, jx1.j_debit
1256,oc1.oc_amount
1257,oc1.oc_vat_amount
1258,oc1.oc_price_unit
1259from quant_purchase qp1
1260join jrnx jx1 using(j_id)
1261left join operation_currency oc1 using(j_id)
1262where jx1.j_grpt = $1
1263order by jx1.j_id
1264 ";
1265 $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
1266 }
1267
1268
1269 /***
1270 * @brief Compute an array for using with Acc_Ledger::insert
1271 *
1272 */
1273 function compute_array()
1274 {
1275 $this->get();
1276 $array=parent::compute_array();
1277 $nb_array=count($this->det->array);
1278 $array['nb_item']=$nb_array;
1279
1280
1281 $array["e_client"]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23",
1282 array($this->det->array[0]['qp_supplier']));
1283
1284 for ($i=0;$i<$nb_array;$i++) {
1285 $array["e_march".$i]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23",
1286 array($this->det->array[$i]['qp_fiche']));
1287
1288 $array["e_march".$i."_price"]=$this->det->array[$i]['qp_unit'];
1289 $array["e_march".$i."_label"]=$this->det->array[$i]['j_text'];
1290 $array["e_march".$i."_tva_id"]=$this->det->array[$i]['qp_vat_code'];
1291 $array["e_march".$i."_tva_amount"]=$this->det->array[$i]['qp_vat'];
1292 $array["e_quant".$i]=$this->det->array[$i]['qp_quantite'];
1293
1294 }
1295 $array['correct']=1;
1296
1297 return $array;
1298
1299 }
1300
1301
1302}
1303/////////////////////////////////////////////////////////////////////////////
1304/**
1305 * @class Acc_Fin
1306 *@brief this class manage data from the QUANT_FIN
1307 * table
1308 *@note Data member are the column of the table
1309 */
1310class Acc_Fin extends Acc_Detail
1311{
1312 function __construct($p_cn,$p_jrid=0)
1313 {
1314 parent::__construct($p_cn,$p_jrid);
1315 $this->signature='FIN';
1316 }
1317
1318 function get()
1319 {
1320 parent::get();
1321 $sql="SELECT qf_id
1322 ,qf_bank
1323 ,jr_id
1324 ,qf_other
1325 ,qf_amount,j_id
1326 ,oc1.oc_amount
1327 ,oc1.oc_vat_amount
1328 ,oc1.oc_price_unit
1329 FROM quant_fin
1330 left join operation_currency oc1 using(j_id)
1331 where
1332 jr_id = $1";
1333 $this->det->array=$this->db->get_array($sql,array($this->jr_id));
1334 }
1335 /***
1336 * Compute an array for using with Acc_Ledger::insert
1337 *
1338 */
1339 function compute_array()
1340 {
1341 $this->get();
1342 $array=parent::compute_array();
1343 $nb_array=count($this->det->array);
1344 $array['nb_item']=$nb_array;
1345
1346
1347 for ($i=0;$i<$nb_array;$i++) {
1348 $array["e_other".$i]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23",
1349 array($this->det->array[$i]['qf_other']));
1350
1351 $array["e_other".$i."_amount"]=$this->det->array[$i]['qf_amount'];
1352 $array["e_other".$i."_comment"]=$this->det->jr_comment;
1353 }
1354 $array['correct']=1;
1355 return $array;
1356
1357 }
1358}
isNumber($p_int)
isDate($p_date)
noalyss_strlentrim($p_string)
h1($p_string, $p_class="")
Definition ac_common.php:72
noalyss_str_replace($search, $replace, $string)
nbm($p_number, $p_dec=2)
format the number with a sep.
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'])
$op jr_id
if(isNumber($jr_id)==0) $ledger_id
$input_from user
_("actif, passif,charge,...")
$input_from type
for($j=0;$j< $nb_row;$j++)($j%2==0)? 'even' $show
$p
Definition calendar.php:9
display currency , convert to euro , and save them if used.
Contains the detail of an operation Acc_Operation.
__construct($p_cn, $p_jrid=0)
this class manage data from the QUANT_FIN table
__construct($p_cn, $p_jrid=0)
Class for jrn, class acc_ledger for manipulating the ledger AND some acc.
this class manage data from the JRNX and JRN table
__construct($p_cn, $p_jrid=0)
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
prepare_sql_tiers()
prepare the query for getting the qcode of the tiers, when executing this SQL , an array of (jrn....
get_sum_other_tax()
get the sum of other tax linked to this operation
operation_update_comment($p_text)
add a comment to the operation (jrn.jr_text)
get_quant()
retrieve data from the table QUANT_*
form_clone_operation($p_id)
create a form to recreate the operation and returns it, it works the same as when you want to correct...
insert_jrnx()
Insert into the table Jrn The needed data are :
static select_operation_type($p_status)
Return a select object to choose the type of operation.
get_internal()
Return the internal value, the property jr_id must be set before.
get_data($p_grpt)
Get data from jrnx where p_grpt=jrnx(j_grpt)
get_amount()
return amount of the jr_id
__construct($p_cn)
constructor set automatically the attributes user and periode
set_paid()
flag the operation as paid
update_receipt()
set the pj of a operation in jrn. the jr_id must be set
get_ledger()
return the jrn_def_id from jrn
insert_jrn()
Insert into the table Jrn, the amount is computed from jrnx thanks the group id ($p_grpt)
operation_update_date_limit($p_text)
add a limit of payment to the operation (jrn.jr_ech)
update_comment($p_text)
add a comment to the line (jrnx.j_text)
save_info($p_info, $p_type)
Save into jrn_info.
$qcode
< Qcode of item
get_jrnx_detail()
retrieve data from jrnx
prepare_sql_counterpart()
prepare the query for getting the qcode of the tiers, when executing this SQL , an array of (jrn....
get_currency_amount()
retrieve amount in currency for the operation
get_info()
retrieve info from the jrn_info, create 2 new arrays obj->info->command and obj->info->other the colu...
display_jrnx_detail($p_table)
display_jrnx_detail : get the data from get_jrnx_data and return a string with HTML code
find_tiers($pn_jrn_id, $pn_jrnx_id, $p_code)
Find the tiers of an operation , thanks the SQL prepared query prep_tiers and prep_counterpart.
set_id($p_id)
set the operation id (jrn.jr_id)
seek_internal($p_internal)
search an operation thankx it internal code
insert_related_action($p_string)
seek_group()
retrieve the grpt_id from jrn for a jr_id
this class manage data from the QUANT_PURCHASE table
__construct($p_cn, $p_jrid=0)
this class manage data from the QUANT_SOLD table
__construct($p_cn, $p_jrid=0)
static fetch_all($ret)
wrapper for the function pg_fetch_all
static fetch_result($ret, $p_row=0, $p_col=0)
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_action for manipulating actions action can be :
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
$c
Definition compute.php:48
$bal jrn
$SecUser db
$flag
Definition install.php:536
if( $delta< 0) elseif( $delta==0)
for($i=0;$i< $nb_jrn;$i++) $deb