noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
acc_reconciliation.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22
23/**
24 * \file
25 * \brief class acc_reconciliation, this class is new and the code
26 * must use it
27 *
28 */
29
30/**
31 * \brief new class for managing the reconciliation it must be used
32 * instead of the function InsertRapt, ...
33 *
34 */
36
37 var $db; /*!< database connection */
38 var $jr_id; /*!< jr_id */
39 var $a_jrn; /*!< $a_jrn array of ledgers id (JRN_DEF.JRN_DEF_ID) */
40 var $start_day; /*!< $start_day (text DD.MM.YYYY) first day */
41 var $end_day;/*!< $end_day (text DD.MM.YYYY) last day */
42
43 /**
44 * query for building the temporary table TEMP_TOTAL_OPERATION
45 */
47 with total_operation as (
48 select
49 jn2.jr_id,coalesce(sum(qs_price+qs_vat-qs_vat_sided),0)+coalesce(sum(qp_price+qp_vat-qp_vat_sided+qp.qp_nd_tva + qp.qp_nd_tva_recup),0) sum_amount
50 from
51 jrnx jx1
52 join jrn jn2 on (jn2.jr_grpt_id =jx1.j_grpt )
53 left join quant_sold qs on (jx1.j_id=qs.j_id)
54 left join quant_purchase qp on (qp.j_id =jx1.j_id)
55 group by jn2.jr_id
56), all_operation as (select jr_id,jra_concerned from jrn_rapt union select jra_concerned,jr_id from jrn_rapt)
57select distinct
58 jr1.jr_id jr1_jr_id
59 ,ra1.jra_concerned ra1_jra_concerned
60 ,jr1.jr_date jr1_jr_date
61 ,to_char(jr1.jr_date,'DD.MM.YY') as str_jr1_jr_date
62 ,jr1.jr_comment jr1_jr_comment
63 ,jr1.jr_internal jr1_jr_internal
64 ,jr1.jr_montant jr1_jr_montant
65 ,case when to1.sum_amount=0 then jr1.jr_montant else to1.sum_amount end to1_sum_amount
66 ,jr1.jr_pj_number jr1_jr_pj_number
67 ,jr1.jr_def_id jr1_jr_def_id
68 ,jrn1.jrn_def_name jrn1_jrn_def_name
69 ,jrn1.jrn_def_type jrn1_jrn_def_type
70 ,jr2.jr_date jr2_jr_date
71 ,to_char(jr2.jr_date,'DD.MM.YY') as str_jr2_jr_date
72 ,jr2.jr_comment jr2_jr_comment
73 ,jr2.jr_internal jr2_jr_internal
74 ,jr2.jr_montant jr2_jr_montant
75 ,to2.sum_amount to2_sum_amount
76 ,jr2.jr_pj_number jr2_jr_pj_number
77 ,jr2.jr_def_id jr2_jr_def_id
78 ,jrn2.jrn_def_name jrn2_jrn_def_name
79 ,jrn2.jrn_def_type jrn2_jrn_def_type
80from jrn jr1
81join total_operation to1 on (to1.jr_id=jr1.jr_id)
82join jrn_def jrn1 on (jrn1.jrn_def_id=jr1.jr_def_id)
83join all_operation ra1 on (ra1.jra_concerned=jr1.jr_id or ra1.jr_id=jr1.jr_id)
84join jrn jr2 on (ra1.jra_concerned =jr2.jr_id)
85join total_operation to2 on (to2.jr_id=jr2.jr_id)
86join jrn_def jrn2 on (jrn2.jrn_def_id=jr2.jr_def_id)
87where
88FILTER_DATE
89and LEDGER_FILTER1
90and LEDGER_FILTER2
91order by jr1.jr_date,jr1.jr_id
92 ";
93 // Get the data to display
94 const SQL_QUERY = "
95with base_op as (select *
96 from temp_total_operation tm1
97 where tm1.jr1_jr_id = tm1.ra1_jra_concerned )
98, depend_op as (select jr1_jr_id
99 , sum(case when to2_sum_amount != 0 then to2_sum_amount else jr2_jr_montant end) depend_sum_amount
100 ,count(*) depend_count
101 from temp_total_operation tm1
102 where tm1.jr1_jr_id != tm1.ra1_jra_concerned
103 group by jr1_jr_id )
104select *
105from base_op bo1
106join depend_op bs1 on (bo1.jr1_jr_id = bs1.jr1_jr_id)
107";
108
109 function __construct($cn) {
110 $this->db = $cn;
111 $this->jr_id = 0;
112 $this->a_jrn = null;
113 }
114
115 function set_jr_id($jr_id) {
116 $this->jr_id = $jr_id;
117 }
118
119 /**
120 * \brief return a widget of type js_concerned
121 */
122
123 function widget() {
124 $wConcerned = new IConcerned();
125 $wConcerned->extra = 0; // with 0 javascript search from e_amount... field (see javascript)
126
127 return $wConcerned;
128 }
129
130 /**
131 * \brief Insert into jrn_rapt the concerned operations
132 *
133 * \param $jr_id2 (jrn.jr_id) => jrn_rapt.jra_concerned or a string
134 * like "jr_id2,jr_id3,jr_id4..."
135 *
136 * \return none
137 *
138 */
139
140 function insert($jr_id2) {
141 if (trim($jr_id2) == "")
142 return;
143 if (strpos($jr_id2, ',') !== 0) {
144 $aRapt = explode(',', $jr_id2);
145 foreach ($aRapt as $rRapt) {
146 if (isNumber($rRapt) == 1) {
147 $this->insert_rapt($rRapt);
148 }
149 }
150 } else
151 if (isNumber($jr_id2) == 1) {
152 $this->insert_rapt($jr_id2);
153 }
154 }
155
156 /**
157 * \brief Insert into jrn_rapt the concerned operations
158 * should not be called directly, use insert instead
159 *
160 * \param $jr_id2 (jrn.jr_id) => jrn_rapt.jra_concerned
161 *
162 * \return none
163 *
164 */
165
166 function insert_rapt($jr_id2) {
167 if (isNumber($this->jr_id) == 0 || isNumber($jr_id2) == 0) {
168 return false;
169 }
170 if ($this->jr_id == $jr_id2)
171 return true;
172
173 if ($this->db->count_sql("select jr_id from jrn where jr_id=$1" ,[ $this->jr_id]) == 0)
174 return false;
175 if ($this->db->count_sql("select jr_id from jrn where jr_id=$1",[$jr_id2]) == 0)
176 return false;
177
178 // verify if exists
179 if ($this->db->count_sql(
180 "select jra_id from jrn_rapt where jra_concerned=$1
181 and jr_id=$2
182 union
183 select jra_id from jrn_rapt where jr_id= $1
184 and jra_concerned=$2 " ,[$this->jr_id,$jr_id2]) == 0) {
185 // Ok we can insert
186 $Res = $this->db->exec_sql("insert into jrn_rapt(jr_id,jra_concerned) values ($1,$2)",
187 array($this->jr_id, $jr_id2)
188 );
189 // try to letter automatically same account from both operation
190 $this->auto_letter($jr_id2);
191
192 // update date of paiement -----------------------------------------------------------------------
193 $source_type = $this->db->get_value("select substr(jr_internal,1,1) from jrn where jr_id=$1", array($this->jr_id));
194 $dest_type = $this->db->get_value("select substr(jr_internal,1,1) from jrn where jr_id=$1", array($jr_id2));
195 if (($source_type == 'A' || $source_type == 'V') && ($dest_type != 'A' && $dest_type != 'V')) {
196 // set the date on source
197 $date = $this->db->get_value('select jr_date from jrn where jr_id=$1', array($jr_id2));
198 if (trim($date) == '')
199 $date = null;
200 $this->db->exec_sql('update jrn set jr_date_paid=$1 where jr_id=$2 and jr_date_paid is null ', array($date, $this->jr_id));
201 }
202 if (($source_type != 'A' && $source_type != 'V') && ($dest_type == 'A' || $dest_type == 'V')) {
203 // set the date on dest
204 $date = $this->db->get_value('select jr_date from jrn where jr_id=$1', array($this->jr_id));
205 if (trim($date) == '')
206 $date = null;
207 $this->db->exec_sql('update jrn set jr_date_paid=$1 where jr_id=$2 and jr_date_paid is null ', array($date, $jr_id2));
208 }
209 }
210 return true;
211 }
212
213 /**
214 * @brief try to letter same card between $p_jrid and $this->jr_id
215 * @param jrn.jr_id $p_jrid the operation to reconcile
216 */
217 function auto_letter($p_jrid) {
218 // Try to find same card from both operation
219 $sql = "select j1.f_id as fiche ,coalesce(j1.j_id,-1) as jrnx_id1,coalesce(j2.j_id,-1) as jrnx_id2,
220j1.j_poste as poste
221 from jrnx as j1
222 join jrn as jr1 on (j1.j_grpt=jr1.jr_grpt_id)
223 join jrnx as j2 on (coalesce(j1.f_id,-1)=coalesce(j2.f_id,-1) and j1.j_poste=j2.j_poste)
224 join jrn as jr2 on (j2.j_grpt=jr2.jr_grpt_id)
225 where
226 jr1.jr_id=$1
227 and
228 jr2.jr_id= $2";
229 $result = $this->db->get_array($sql, array($this->jr_id, $p_jrid));
230 if (count($result) == 0) {
231 return;
232 }
233 for ($i = 0; $i < count($result); $i++) {
234 if ($result[$i]['fiche'] != -1) {
235 $letter = new Lettering_Card($this->db);
236 $letter->insert_couple($result[$i]['jrnx_id1'], $result[$i]['jrnx_id2']);
237 } else {
238 $letter = new Lettering_Account($this->db);
239 $letter->insert_couple($result[$i]['jrnx_id1'], $result[$i]['jrnx_id2']);
240 }
241 }
242 }
243
244 /**
245 * \brief Insert into jrn_rapt the concerned operations
246 *
247 * \param $this->jr_id (jrn.jr_id) => jrn_rapt.jr_id
248 * \param $jr_id2 (jrn.jr_id) => jrn_rapt.jra_concerned
249 *
250 * \return none
251 */
252
253 function remove($jr_id2) {
254 if (isNumber($this->jr_id) == 0 or
255 isNumber($jr_id2) == 0) {
256 return;
257 }
258 // verify if exists
259 if ($this->db->count_sql("select jra_id from jrn_rapt where " .
260 " jra_concerned=" . $this->jr_id . " and jr_id=$jr_id2
261 union
262 select jra_id from jrn_rapt where jra_concerned=$jr_id2 " .
263 " and jr_id=" . $this->jr_id) != 0) {
264 /**
265 * remove also lettering between both operation
266 */
267 $sql = "
268delete from
269 jnt_letter
270where jl_id in ( select jl_id from jnt_letter
271 join letter_cred as lc using(jl_id)
272 join letter_deb as ld using (jl_id)
273where
274 lc.j_id in (select j_id
275 from jrnx join jrn on (j_grpt=jr_grpt_id)
276 where jr_id in ($1,$2))
277 or
278 ld.j_id in (select j_id
279 from jrnx join jrn on (j_grpt=jr_grpt_id)
280 where jr_id in ($1,$2))
281
282
283
284 )";
285 $this->db->exec_sql($sql, array($jr_id2, $this->jr_id));
286 // Ok we can delete
287 $Res = $this->db->exec_sql("delete from jrn_rapt where
288 (jra_concerned=$1 and jr_id= $2) or
289 (jra_concerned=$2 and jr_id=$1) ",
290 [$jr_id2,$this->jr_id]);
291 }
292 }
293
294 /**
295 * \brief Return an array of the concerned operation
296 *
297 *
298 * \param database connection
299 * \return array if something is found or null
300 */
301
302 function get() {
303 $sql = " select jr_id as cn from jrn_rapt where jra_concerned=$1
304 union
305 select jra_concerned as cn from jrn_rapt where jr_id=$2";
306 $Res = $this->db->exec_sql($sql, array($this->jr_id, $this->jr_id));
307
308 // If nothing is found return null
310
311 if ($n == 0)
312 return [];
313
314 // put everything in an array
315 for ($i = 0; $i < $n; $i++) {
317 $r[$i] = $l['cn'];
318 }
319 return $r;
320 }
321
322 /**
323 * @deprecated since version 9307
324 * @brief retrieve row from JRN
325 * @return type
326 */
327 function fill_info() {
328 $sql = "select jr_id,jr_date,jr_comment,jr_internal,jr_montant,jr_pj_number,jr_def_id,jrn_def_name,jrn_def_type
329 from jrn join jrn_def on (jrn_def_id=jr_def_id)
330 where jr_id=$1";
331 $a = $this->db->get_array($sql, array($this->jr_id));
332 return $a[0];
333 }
334
335 /**
336 * @brief return array of not-reconciled operation
337 * Prepare and put in memory the SQL detail_quant
338 */
341 $filter_date = $this->filter_date();
342 /* create ledger filter */
343 $sql_jrn = $this->ledger_filter();
344
345 $array = $this->db->get_array("
346 select distinct
347 jr1.jr_id jr1_jr_id
348 ,null ra1_jra_concerned
349 ,jr1.jr_date jr1_jr_date
350 ,to_char(jr1.jr_date,'DD.MM.YY') as str_jr1_jr_date
351 ,jr1.jr_comment jr1_jr_comment
352 ,jr1.jr_internal jr1_jr_internal
353 ,jr1.jr_montant jr1_jr_montant
354 ,jr1.jr_montant to1_sum_amount
355 ,jr1.jr_pj_number jr1_jr_pj_number
356 ,jr1.jr_def_id jr1_jr_def_id
357 ,jrn1.jrn_def_name jrn1_jrn_def_name
358 ,jrn1.jrn_def_type jrn1_jrn_def_type
359 ,null jr2_jr_date
360 ,null str_jr2_jr_date
361 ,null jr2_jr_comment
362 ,null jr2_jr_internal
363 ,null jr2_jr_montant
364 ,null to2_sum_amount
365 ,null jr2_jr_pj_number
366 ,null jr2_jr_def_id
367 ,null jrn2_jrn_def_name
368 ,null jrn2_jrn_def_type
369 ,0 depend_count
370from jrn jr1
371join jrn_def jrn1 on (jrn1.jrn_def_id=jr1.jr_def_id)
372where
373 $filter_date
374 and $sql_jrn
375 and jr1.jr_id not in (select jr_id from jrn_rapt
376 union select jra_concerned from jrn_rapt)
377 order by jr_date
378");
379
380
381 return $array;
382 }
383
384 /**
385 * @brief Create a sql condition to filter by security and by asked ledger
386 * based on $this->a_jrn
387 * @return a valid sql stmt to include
388 * @see get_not_reconciled get_reconciled
389 */
390 function ledger_filter() {
391 global $g_user;
392 /* get the available ledgers for current user */
393 $sql = $g_user->get_ledger_sql('ALL', 3);
394 $sql = noalyss_str_replace('jrn_def_id', 'jr_def_id', $sql);
395 $r = '';
396 /* filter by this->r_jrn */
397 if (!empty($this->a_jrn) && is_array($this->a_jrn)) {
398 $sep = '';
399 $r = 'and jr_def_id in (';
400 foreach ($this->a_jrn as $key => $value) {
401 $r .= $sep . $value;
402 $sep = ',';
403 }
404 $r .= ')';
405 }
406 return $sql . ' ' . $r;
407 }
408
409 /**
410 * @brief build a temporary table with all operation + dependencies
411 * @return type
412 */
414 static $done=false;
415 if ( $done ) {
416 return;
417 }
418 global $g_user;
419 $filter_date = str_replace("jr_date", "jr1.jr_date", $this->filter_date());
420
421 /* create ledger filters */
422 $sql_jrn = $this->ledger_filter();
423 $sql_jrn1 = str_replace("jr_def_id", "jr1.jr_def_id", $sql_jrn);
424
425 /* security on the ledger */
426 $sql = $g_user->get_ledger_sql('ALL', 3);
427 $sql_jrn2 = noalyss_str_replace('jrn_def_id', 'jr2.jr_def_id', $sql);
428
430 $sql_string = str_replace("FILTER_DATE", $filter_date, $sql_string);
431 $sql_string = str_replace("LEDGER_FILTER1", $sql_jrn1, $sql_string);
432 $sql_string = str_replace("LEDGER_FILTER2", $sql_jrn2, $sql_string);
433 try {
434
435 $this->db->exec_sql(" create temporary table temp_total_operation as $sql_string");
436 $done=true;
437 } catch (Exception $exc) {
438 echo $exc->getMessage();
439 return;
440 }
441 }
442
443 /**
444 * @brief return array of reconciled operation
445 * Prepare and put in memory the SQL detail_quant
446 * @return
447 * @note
448 * @see
449 @code
450
451 @endcode
452 */
453 function get_reconciled() {
455 $sql_amount = Acc_Reconciliation::SQL_QUERY;
456
457 $a_row = $this->db->get_array("$sql_amount order by jr1_jr_date");
458 return $a_row;
459 }
460
461 /**
462 * @brief
463 * Prepare and put in memory the SQL detail_quant
464 * @param
465 * @return
466 * @note
467 * @see
468 @code
469
470 @endcode
471 */
472 function get_reconciled_amount($p_equal = false) {
473 // build temporary table temp_total_operation
475 // SQL with different amount
476 $sql_amount = Acc_Reconciliation::SQL_QUERY;
477 if ($p_equal) {
478 $sql_amount = $sql_amount . " where bs1.depend_sum_amount = to1_sum_amount ";
479 } else {
480 $sql_amount = $sql_amount . " where bs1.depend_sum_amount != to1_sum_amount";
481 }
482 $a_row = $this->db->get_array("$sql_amount order by jr1_jr_date");
483 return $a_row;
484 }
485
486 /**
487 * @brief create a string to filter thanks the date
488 * @return a sql string like jr_date > ... and jr_date < ....
489 * @note use the data member start_day and end_day
490 * @see get_reconciled get_not_reconciled
491 */
492 function filter_date() {
493 global $g_user;
494 $g_user->db=$this->db;
495 list($start, $end) = $g_user->get_limit_current_exercice();
496
497 if (isDate($this->start_day) == null) {
498 $this->start_day = $start;
499 }
500 if (isDate($this->end_day) == null) {
501 $this->end_day = $end;
502 }
503 $sql = " (jr_date >= to_date('" . $this->start_day . "','DD.MM.YYYY')
504 and jr_date <= to_date('" . $this->end_day . "','DD.MM.YYYY'))";
505 return $sql;
506 }
507 /**
508 * @deprecated since version 9307
509 */
510 function show_detail($p_ret) {
511 if (Database::num_row($p_ret) > 0) {
512 echo '<tr >';
513 echo '<td></td>';
514 echo '<td colspan="5" style="border:1px solid black;width:auto">';
515 include NOALYSS_TEMPLATE . '/impress_reconciliation_detail.php';
516 echo '</td>';
517 echo '</tr>';
518 }
519 }
520
521 /**
522 * @brief Export to CSV
523 * @param type $p_choice
524 *
525 * @note must be set before calling
526 * - $this->a_jrn array of ledger
527 * - $this->start_day start date
528 * - $this->end_day end date
529 * @see Acc_Reconciliation::get_data
530 */
531 function export_csv($p_choice) {
532 $export = new Noalyss_Csv(_('rapprochement'));
533 $export->send_header();
534
535 $array = $this->get_data($p_choice);
536 for ($i = 0; $i < count($array); $i++) {
537 if ( $i == 0)
538 {
539 $title[] = _('n°');
540 $title[] = _('Date');
541 $title[] = _('internal');
542 $title[] = _('libellé');
543 $title[] = _('pièce');
544 $title[] = _('journal');
545 $title[] = _('type journal');
546 $title[] = _('montant');
547 $export->write_header($title);
548 }
549 $export->add($i, "number");
550 $export->add($array[$i]['str_jr1_jr_date']);
551 $export->add($array[$i]['jr1_jr_internal']);
552 $export->add($array[$i]['jr1_jr_pj_number']);
553 $export->add($array[$i]['jr1_jr_comment']);
554 $export->add($array[$i]['jrn1_jrn_def_name']);
555 $export->add($array[$i]['jrn1_jrn_def_type']);
556 $x=($array[$i]['to1_sum_amount']!=0)?$array[$i]['to1_sum_amount']:$array[$i]['jr1_jr_montant'];
557 $export->add($x, "number");
558 $export->write();
559
560 if ( $array[$i]['depend_count']>0) {
561 $depend=$this->db->get_array("select *
562 from temp_total_operation
563 where
564 jr1_jr_id=$1 and ra1_jra_concerned != jr1_jr_id"
565 ,[$array[$i]['jr1_jr_id']]);
566 $nb_depend = count($depend);
567 $totdepend=0;$delta=$x;
568 for ($e = 0; $e < $nb_depend ; $e++) {
569 $x=($depend[$e]['to2_sum_amount']!=0)?$depend[$e]['to2_sum_amount']:$depend[$e]['jr2_jr_montant'];
570 $totdepend=bcadd($totdepend,$x,2);
571 $delta=bcsub($delta,$x,2);
572 $export->add($i, "number");
573 $export->add($depend[$e]["str_jr2_jr_date"]);
574 $export->add($depend[$e]["jr2_jr_internal"]);
575 $export->add($depend[$e]["jr2_jr_pj_number"]);
576 $export->add($depend[$e]["jr2_jr_comment"]);
577 $export->add($depend[$e]['jrn2_jrn_def_name']);
578 $export->add($depend[$e]['jrn2_jrn_def_type']);
579 $export->add($x, "number");
580 $export->write();
581 }
582 $export->add("Total");
583 $export->add($totdepend,"number");
584 $export->add("Différence");
585 $export->add($delta,"number");
586 $export->write();
587
588 }
589
590
591 }
592 }
593
594 /**
595 * @brief retrieve data
596 * @param type $p_choice
597 * - 0 : operation reconcilied
598 * - 1 : reconcilied with different amount
599 * - 2 : reconcilied with same amount
600 * - 3 : not reconcilied
601 * @return $array
602 */
603 function get_data($p_choice) {
604 switch ($p_choice) {
605 case 0:
606 $array = $this->get_reconciled();
607 break;
608 case 1:
609 $array = $this->get_reconciled_amount(false);
610 break;
611 case 2:
612 $array = $this->get_reconciled_amount(true);
613 break;
614 case 3:
615 $array = $this->get_not_reconciled();
616 break;
617 default:
618 echo "Choix invalid";
619 throw new Exception("invalide");
620 }
621 return $array;
622 }
623
625 static $seen = 0;
626 if ($seen == 1)
627 return;
628 $this->db->prepare('detail_quant', 'select * from v_quant_detail where jr_id=$1');
629 // $this->db->prepare('detail_depend',' ');
630 $seen = 1;
631 }
632
633 /**
634 * @brief Retrieve the amount VAT included and autoreversed VAT excluded thanks
635 * the view v_quant_detail and return it.
636 * If the operation is not a sale or a purchase , it doesn't exist in the
637 * view then the function just returns the default amount
638 * @param type $p_jrn_id jrn.jr_id
639 * @param type $p_default_amount amount to return if not found in the view
640 * v_quant_detail
641 * @return number
642 */
643 function get_amount_noautovat($p_jrn_id, $p_default_amount) {
644 static $p = 0;
645 if ($p == 0) {
647 $p = 1;
648 }
649 bcscale(2);
650 $retdb = $this->db->execute("detail_quant", array($p_jrn_id));
651 $nb_record = Database::num_row($retdb);
652 if ($nb_record > 0) {
653 $total_price = $first_amount = 0;
654 for ($i = 0; $i < $nb_record; $i++) {
655 // then second_amount takes in account the vat_sided
656 $row = Database::fetch_array($retdb, $i);
657 $total_price = bcadd($row['price'], $row['vat_amount']);
658 $total_price = bcsub($total_price, $row['vat_sided']);
659 $total_price = bcadd($total_price, $row['nd_tva']);
660 $total_price = bcadd($total_price, $row['nd_tva_recup']);
661 $first_amount = bcadd($total_price, $first_amount);
662 }
663 } else {
664 // else take the amount from jrn
665 $first_amount = $p_default_amount;
666 }
667 return $first_amount;
668 }
669
670 static function test_me() {
671 $cn = Dossier::connect();
673 var_dump($rap->get_reconciled_amount(false));
674 $rap->build_temp_total_operation();
675 $rap->build_temp_total_operation();
676 $rap->build_temp_total_operation();
677 }
678}
isNumber($p_int)
isDate($p_date)
noalyss_str_replace($search, $replace, $string)
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$op jr_id
_("actif, passif,charge,...")
$p
Definition calendar.php:9
new class for managing the reconciliation it must be used instead of the function InsertRapt,...
get_amount_noautovat($p_jrn_id, $p_default_amount)
Retrieve the amount VAT included and autoreversed VAT excluded thanks the view v_quant_detail and ret...
get_data($p_choice)
retrieve data
const SQL_ALL_OPERATION_RECONCILIED
query for building the temporary table TEMP_TOTAL_OPERATION
export_csv($p_choice)
Export to CSV.
get_not_reconciled()
return array of not-reconciled operation Prepare and put in memory the SQL detail_quant
get_reconciled()
return array of reconciled operation Prepare and put in memory the SQL detail_quant
widget()
return a widget of type js_concerned
build_temp_total_operation()
build a temporary table with all operation + dependencies
get_reconciled_amount($p_equal=false)
Prepare and put in memory the SQL detail_quant.
auto_letter($p_jrid)
try to letter same card between $p_jrid and $this->jr_id
fill_info()
retrieve row from JRN
insert_rapt($jr_id2)
Insert into jrn_rapt the concerned operations should not be called directly, use insert instead.
ledger_filter()
Create a sql condition to filter by security and by asked ledger based on $this->a_jrn.
filter_date()
create a string to filter thanks the date
insert($jr_id2)
Insert into jrn_rapt the concerned operations.
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
Html Input.
only for operation retrieved thanks a account (jrnx.j_poste) manage the accounting entries for a give...
only for operation retrieved thanks a quick_code manage the accounting entries for a given card
Manage the CSV : manage files and write CSV record.
$n
Definition compute.php:54
$acc_reconciliation end_day
$acc_reconciliation start_day
$acc_reconciliation a_jrn
$SecUser db