noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Acc_Reconciliation Class Reference

new class for managing the reconciliation it must be used instead of the function InsertRapt, ... More...

+ Inheritance diagram for Acc_Reconciliation:
+ Collaboration diagram for Acc_Reconciliation:

Public Member Functions

 __construct ($cn)
 
 auto_letter ($p_jrid)
 try to letter same card between $p_jrid and $this->jr_id
 
 build_temp_total_operation ()
 build a temporary table with all operation + dependencies
 
 export_csv ($p_choice)
 Export to CSV.
 
 fill_info ()
 retrieve row from JRN
 
 filter_date ()
 create a string to filter thanks the date
 
 get ()
 Return an array of the concerned operation.
 
 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 return it.
 
 get_data ($p_choice)
 retrieve data
 
 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
 
 get_reconciled_amount ($p_equal=false)
 Prepare and put in memory the SQL detail_quant.
 
 insert ($jr_id2)
 Insert into jrn_rapt the concerned operations.
 
 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.
 
 prepare_query_detail_quant ()
 
 remove ($jr_id2)
 Insert into jrn_rapt the concerned operations.
 
 set_jr_id ($jr_id)
 
 show_detail ($p_ret)
 
 widget ()
 return a widget of type js_concerned
 

Static Public Member Functions

static test_me ()
 

Data Fields

 $a_jrn
 
 $db
 
 $end_day
 
 $jr_id
 
 $start_day
 
const SQL_ALL_OPERATION_RECONCILIED
 query for building the temporary table TEMP_TOTAL_OPERATION
 
const SQL_QUERY
 

Detailed Description

new class for managing the reconciliation it must be used instead of the function InsertRapt, ...

Definition at line 35 of file acc_reconciliation.class.php.

Constructor & Destructor Documentation

◆ __construct()

Acc_Reconciliation::__construct ( $cn)

Definition at line 109 of file acc_reconciliation.class.php.

109 {
110 $this->db = $cn;
111 $this->jr_id = 0;
112 $this->a_jrn = null;
113 }
$op jr_id
$acc_reconciliation a_jrn
$SecUser db

References $cn, a_jrn, db, and jr_id.

Member Function Documentation

◆ auto_letter()

Acc_Reconciliation::auto_letter ( $p_jrid)

try to letter same card between $p_jrid and $this->jr_id

Parameters
jrn.jr_id$p_jrid the operation to reconcile

Reimplemented in Acc_Reconciliation_Lettering.

Definition at line 217 of file acc_reconciliation.class.php.

217 {
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 }

References $i, $letter, $result, $sql, db, and jr_id.

Referenced by insert_rapt().

◆ build_temp_total_operation()

Acc_Reconciliation::build_temp_total_operation ( )

build a temporary table with all operation + dependencies

Returns
type

Definition at line 413 of file acc_reconciliation.class.php.

413 {
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 }
noalyss_str_replace($search, $replace, $string)
global $g_user
if no group available , then stop
const SQL_ALL_OPERATION_RECONCILIED
query for building the temporary table TEMP_TOTAL_OPERATION
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

References $g_user, $sql, db, filter_date(), ledger_filter(), noalyss_str_replace(), and SQL_ALL_OPERATION_RECONCILIED.

Referenced by get_not_reconciled(), get_reconciled(), and get_reconciled_amount().

+ Here is the call graph for this function:

◆ export_csv()

Acc_Reconciliation::export_csv ( $p_choice)

Export to CSV.

Parameters
type$p_choice
Note
must be set before calling
  • $this->a_jrn array of ledger
  • $this->start_day start date
  • $this->end_day end date
See also
Acc_Reconciliation\get_data

Definition at line 531 of file acc_reconciliation.class.php.

531 {
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 }
_("actif, passif,charge,...")
get_data($p_choice)
retrieve data

References $array, $delta, $depend, $e, $export, $i, $title, _, db, and get_data().

+ Here is the call graph for this function:

◆ fill_info()

Acc_Reconciliation::fill_info ( )

retrieve row from JRN

Deprecated
since version 9307
Returns
type

Definition at line 327 of file acc_reconciliation.class.php.

327 {
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 }

References $a, $sql, db, and jr_id.

◆ filter_date()

Acc_Reconciliation::filter_date ( )

create a string to filter thanks the date

Returns
a sql string like jr_date > ... and jr_date < ....
Note
use the data member start_day and end_day
See also
get_reconciled get_not_reconciled

Definition at line 492 of file acc_reconciliation.class.php.

492 {
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 }
isDate($p_date)
$acc_reconciliation end_day
$acc_reconciliation start_day

References $db, $end, $g_user, $sql, $start, end_day, isDate(), and start_day.

Referenced by build_temp_total_operation(), and get_not_reconciled().

+ Here is the call graph for this function:

◆ get()

Acc_Reconciliation::get ( )

Return an array of the concerned operation.

Parameters
databaseconnection
Returns
array if something is found or null

Definition at line 302 of file acc_reconciliation.class.php.

302 {
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 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
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
$n
Definition compute.php:54

References $i, $l, $n, $r, $Res, $sql, db, DatabaseCore\fetch_array(), jr_id, and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ get_amount_noautovat()

Acc_Reconciliation::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 return it.

If the operation is not a sale or a purchase , it doesn't exist in the view then the function just returns the default amount

Parameters
type$p_jrn_idjrn.jr_id
type$p_default_amountamount to return if not found in the view v_quant_detail
Returns
number

Definition at line 643 of file acc_reconciliation.class.php.

643 {
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 }
$p
Definition calendar.php:9

References $i, $p, $row, db, DatabaseCore\fetch_array(), DatabaseCore\num_row(), and prepare_query_detail_quant().

+ Here is the call graph for this function:

◆ get_data()

Acc_Reconciliation::get_data ( $p_choice)

retrieve data

Parameters
type$p_choice
  • 0 : operation reconcilied
  • 1 : reconcilied with different amount
  • 2 : reconcilied with same amount
  • 3 : not reconcilied
Returns
$array

Definition at line 603 of file acc_reconciliation.class.php.

603 {
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 }
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
get_reconciled_amount($p_equal=false)
Prepare and put in memory the SQL detail_quant.

References $array, get_not_reconciled(), get_reconciled(), and get_reconciled_amount().

Referenced by export_csv().

+ Here is the call graph for this function:

◆ get_not_reconciled()

Acc_Reconciliation::get_not_reconciled ( )

return array of not-reconciled operation Prepare and put in memory the SQL detail_quant

Definition at line 339 of file acc_reconciliation.class.php.

339 {
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 }
build_temp_total_operation()
build a temporary table with all operation + dependencies

References $array, build_temp_total_operation(), db, filter_date(), and ledger_filter().

Referenced by get_data().

+ Here is the call graph for this function:

◆ get_reconciled()

Acc_Reconciliation::get_reconciled ( )

return array of reconciled operation Prepare and put in memory the SQL detail_quant

Returns
Note
See also

Definition at line 453 of file acc_reconciliation.class.php.

453 {
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 }

References $a_row, build_temp_total_operation(), db, and SQL_QUERY.

Referenced by get_data().

+ Here is the call graph for this function:

◆ get_reconciled_amount()

Acc_Reconciliation::get_reconciled_amount ( $p_equal = false)

Prepare and put in memory the SQL detail_quant.

Parameters

return

Note
See also

Definition at line 472 of file acc_reconciliation.class.php.

472 {
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 }

References $a_row, build_temp_total_operation(), db, and SQL_QUERY.

Referenced by get_data().

+ Here is the call graph for this function:

◆ insert()

Acc_Reconciliation::insert ( $jr_id2)

Insert into jrn_rapt the concerned operations.

Parameters
$jr_id2(jrn.jr_id) => jrn_rapt.jra_concerned or a string like "jr_id2,jr_id3,jr_id4..."
Returns
none

Definition at line 140 of file acc_reconciliation.class.php.

140 {
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 }
isNumber($p_int)
insert_rapt($jr_id2)
Insert into jrn_rapt the concerned operations should not be called directly, use insert instead.

References insert_rapt(), and isNumber().

+ Here is the call graph for this function:

◆ insert_rapt()

Acc_Reconciliation::insert_rapt ( $jr_id2)

Insert into jrn_rapt the concerned operations should not be called directly, use insert instead.

Parameters
$jr_id2(jrn.jr_id) => jrn_rapt.jra_concerned
Returns
none

Definition at line 166 of file acc_reconciliation.class.php.

166 {
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 }
auto_letter($p_jrid)
try to letter same card between $p_jrid and $this->jr_id

References $date, $Res, auto_letter(), db, isNumber(), and jr_id.

Referenced by insert(), and Acc_Reconciliation_Lettering\insert_reconcilied().

+ Here is the call graph for this function:

◆ ledger_filter()

Acc_Reconciliation::ledger_filter ( )

Create a sql condition to filter by security and by asked ledger based on $this->a_jrn.

Returns
a valid sql stmt to include
See also
get_not_reconciled get_reconciled

Definition at line 390 of file acc_reconciliation.class.php.

390 {
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 }

References $g_user, $r, $sep, $sql, $value, a_jrn, and noalyss_str_replace().

Referenced by build_temp_total_operation(), and get_not_reconciled().

+ Here is the call graph for this function:

◆ prepare_query_detail_quant()

Acc_Reconciliation::prepare_query_detail_quant ( )

Definition at line 624 of file acc_reconciliation.class.php.

624 {
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 }

References db.

Referenced by get_amount_noautovat().

◆ remove()

Acc_Reconciliation::remove ( $jr_id2)

Insert into jrn_rapt the concerned operations.

Parameters
$this->jr_id(jrn.jr_id) => jrn_rapt.jr_id
$jr_id2(jrn.jr_id) => jrn_rapt.jra_concerned
Returns
none

remove also lettering between both operation

Definition at line 253 of file acc_reconciliation.class.php.

253 {
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 }

References $Res, $sql, db, isNumber(), and jr_id.

+ Here is the call graph for this function:

◆ set_jr_id()

Acc_Reconciliation::set_jr_id ( $jr_id)

Definition at line 115 of file acc_reconciliation.class.php.

115 {
116 $this->jr_id = $jr_id;
117 }

References $jr_id, and jr_id.

Referenced by Acc_Reconciliation_Lettering\insert_reconcilied().

◆ show_detail()

Acc_Reconciliation::show_detail ( $p_ret)
Deprecated
since version 9307

Definition at line 510 of file acc_reconciliation.class.php.

510 {
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 }

References DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ test_me()

static Acc_Reconciliation::test_me ( )
static

Definition at line 670 of file acc_reconciliation.class.php.

670 {
672 $rap = new Acc_Reconciliation($cn);
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 }
static connect()

References $cn, and $rap.

◆ widget()

Acc_Reconciliation::widget ( )

return a widget of type js_concerned

Definition at line 123 of file acc_reconciliation.class.php.

123 {
124 $wConcerned = new IConcerned();
125 $wConcerned->extra = 0; // with 0 javascript search from e_amount... field (see javascript)
126
127 return $wConcerned;
128 }

Field Documentation

◆ $a_jrn

Acc_Reconciliation::$a_jrn

$a_jrn array of ledgers id (JRN_DEF.JRN_DEF_ID)

Definition at line 39 of file acc_reconciliation.class.php.

◆ $db

Acc_Reconciliation::$db

database connection

Definition at line 37 of file acc_reconciliation.class.php.

Referenced by filter_date().

◆ $end_day

Acc_Reconciliation::$end_day

$end_day (text DD.MM.YYYY) last day

Definition at line 41 of file acc_reconciliation.class.php.

◆ $jr_id

Acc_Reconciliation::$jr_id

jr_id

Definition at line 38 of file acc_reconciliation.class.php.

Referenced by set_jr_id().

◆ $start_day

Acc_Reconciliation::$start_day

$start_day (text DD.MM.YYYY) first day

Definition at line 40 of file acc_reconciliation.class.php.

◆ SQL_ALL_OPERATION_RECONCILIED

const Acc_Reconciliation::SQL_ALL_OPERATION_RECONCILIED

query for building the temporary table TEMP_TOTAL_OPERATION

Definition at line 46 of file acc_reconciliation.class.php.

Referenced by build_temp_total_operation().

◆ SQL_QUERY

const Acc_Reconciliation::SQL_QUERY
Initial value:
= "
with base_op as (select *
from temp_total_operation tm1
where tm1.jr1_jr_id = tm1.ra1_jra_concerned )
, depend_op as (select jr1_jr_id
, sum(case when to2_sum_amount != 0 then to2_sum_amount else jr2_jr_montant end) depend_sum_amount
,count(*) depend_count
from temp_total_operation tm1
where tm1.jr1_jr_id != tm1.ra1_jra_concerned
group by jr1_jr_id )
select *
from base_op bo1
join depend_op bs1 on (bo1.jr1_jr_id = bs1.jr1_jr_id)
"

Definition at line 94 of file acc_reconciliation.class.php.

Referenced by get_reconciled(), and get_reconciled_amount().


The documentation for this class was generated from the following file: