noalyss Version-10
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 124 of file acc_reconciliation.class.php.

124 {
125 $this->db = $cn;
126 $this->jr_id = 0;
127 $this->a_jrn = null;
128 }
$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 232 of file acc_reconciliation.class.php.

232 {
233 // Try to find same card from both operation
234 $sql = "select j1.f_id as fiche ,coalesce(j1.j_id,-1) as jrnx_id1,coalesce(j2.j_id,-1) as jrnx_id2,
235j1.j_poste as poste
236 from jrnx as j1
237 join jrn as jr1 on (j1.j_grpt=jr1.jr_grpt_id)
238 join jrnx as j2 on (coalesce(j1.f_id,-1)=coalesce(j2.f_id,-1) and j1.j_poste=j2.j_poste)
239 join jrn as jr2 on (j2.j_grpt=jr2.jr_grpt_id)
240 where
241 jr1.jr_id=$1
242 and
243 jr2.jr_id= $2";
244 $result = $this->db->get_array($sql, array($this->jr_id, $p_jrid));
245 if (count($result) == 0) {
246 return;
247 }
248 for ($i = 0; $i < count($result); $i++) {
249 if ($result[$i]['fiche'] != -1) {
250 $letter = new Lettering_Card($this->db);
251 $letter->insert_couple($result[$i]['jrnx_id1'], $result[$i]['jrnx_id2']);
252 } else {
253 $letter = new Lettering_Account($this->db);
254 $letter->insert_couple($result[$i]['jrnx_id1'], $result[$i]['jrnx_id2']);
255 }
256 }
257 }

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 448 of file acc_reconciliation.class.php.

448 {
449 static $done=false;
450 if ( $done ) {
451 return;
452 }
453 global $g_user;
454 $filter_date = str_replace("jr_date", "jr1.jr_date", $this->filter_date());
455
456 /* create ledger filters */
457 $sql_jrn = $this->ledger_filter();
458 $sql_jrn1 = str_replace("jr_def_id", "jr1.jr_def_id", $sql_jrn);
459
460 /* security on the ledger */
461 $sql = $g_user->get_ledger_sql('ALL', 3);
462 $sql_jrn2 = noalyss_str_replace('jrn_def_id', 'jr2.jr_def_id', $sql);
463
465 $sql_string = str_replace("FILTER_DATE", $filter_date, $sql_string);
466 $sql_string = str_replace("LEDGER_FILTER1", $sql_jrn1, $sql_string);
467 $sql_string = str_replace("LEDGER_FILTER2", $sql_jrn2, $sql_string);
468 try {
469
470 $this->db->exec_sql(" create temporary table temp_total_operation as $sql_string");
471 $done=true;
472 } catch (Exception $exc) {
473 echo $exc->getMessage();
474 return;
475 }
476 }
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 566 of file acc_reconciliation.class.php.

566 {
567 $export = new Noalyss_Csv(_('rapprochement'));
568 $export->send_header();
569
570 $array = $this->get_data($p_choice);
571 for ($i = 0; $i < count($array); $i++) {
572 if ( $i == 0)
573 {
574 $title[] = _('n°');
575 $title[] = _('Date');
576 $title[] = _('pièce');
577 $title[] = _('internal');
578 $title[] = _('Qcode');
579 $title[] = _('Nom');
580 $title[] = _('libellé');
581 $title[] = _('journal');
582 $title[] = _('type journal');
583 $title[] = _('montant');
584 $export->write_header($title);
585 }
586 $export->add($i, "number");
587 $export->add($array[$i]['str_jr1_jr_date']);
588 $export->add($array[$i]['jr1_jr_pj_number']);
589 $export->add($array[$i]['jr1_jr_internal']);
590 $export->add($array[$i]['tiers_qcode']);
591 $export->add($array[$i]['tiers_name']);
592 $export->add($array[$i]['jr1_jr_comment']);
593 $export->add($array[$i]['jrn1_jrn_def_name']);
594 $export->add($array[$i]['jrn1_jrn_def_type']);
595 $x=($array[$i]['to1_sum_amount']!=0)?$array[$i]['to1_sum_amount']:$array[$i]['jr1_jr_montant'];
596 $export->add($x, "number");
597 $export->write();
598
599 if ( $array[$i]['depend_count']>0) {
600 $depend=$this->db->get_array("select *
601 from temp_total_operation
602 where
603 jr1_jr_id=$1 and ra1_jra_concerned != jr1_jr_id"
604 ,[$array[$i]['jr1_jr_id']]);
605 $nb_depend = count($depend);
606 $totdepend=0;$delta=$x;
607 for ($e = 0; $e < $nb_depend ; $e++) {
608 $x=($depend[$e]['to2_sum_amount']!=0)?$depend[$e]['to2_sum_amount']:$depend[$e]['jr2_jr_montant'];
609 $totdepend=bcadd($totdepend,$x,2);
610 $delta=bcsub($delta,$x,2);
611 $export->add($i, "number");
612 $export->add($depend[$e]["str_jr2_jr_date"]);
613 $export->add($depend[$e]["jr2_jr_internal"]);
614 $export->add($array[$i]['tiers_name_2']);
615 $export->add($array[$i]['tiers_qcode_2']);
616 $export->add($depend[$e]["jr2_jr_pj_number"]);
617 $export->add($depend[$e]["jr2_jr_comment"]);
618 $export->add($depend[$e]['jrn2_jrn_def_name']);
619 $export->add($depend[$e]['jrn2_jrn_def_type']);
620 $export->add($x, "number");
621 $export->write();
622 }
623 $export->add("Total");
624 $export->add($totdepend,"number");
625 $export->add("Différence");
626 $export->add($delta,"number");
627 $export->write();
628
629 }
630
631
632 }
633 }
_("actif, passif,charge,...")
get_data($p_choice)
retrieve data

References $array, $delta, $depend, $e, $export, $i, $title, $x, _, 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 342 of file acc_reconciliation.class.php.

342 {
343 $sql = "select jr_id,jr_date,jr_comment,jr_internal,jr_montant,jr_pj_number,jr_def_id,jrn_def_name,jrn_def_type
344 from jrn join jrn_def on (jrn_def_id=jr_def_id)
345 where jr_id=$1";
346 $a = $this->db->get_array($sql, array($this->jr_id));
347 return $a[0];
348 }

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 527 of file acc_reconciliation.class.php.

527 {
528 global $g_user;
529 $g_user->db=$this->db;
530 list($start, $end) = $g_user->get_limit_current_exercice();
531
532 if (isDate($this->start_day) == null) {
533 $this->start_day = $start;
534 }
535 if (isDate($this->end_day) == null) {
536 $this->end_day = $end;
537 }
538 $sql = " (jr_date >= to_date('" . $this->start_day . "','DD.MM.YYYY')
539 and jr_date <= to_date('" . $this->end_day . "','DD.MM.YYYY'))";
540 return $sql;
541 }
isDate($p_date)
Verifie qu'une date est bien formaté en d.m.y et est valable.
$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 317 of file acc_reconciliation.class.php.

317 {
318 $sql = " select jr_id as cn from jrn_rapt where jra_concerned=$1
319 union
320 select jra_concerned as cn from jrn_rapt where jr_id=$2";
321 $Res = $this->db->exec_sql($sql, array($this->jr_id, $this->jr_id));
322
323 // If nothing is found return null
325
326 if ($n == 0)
327 return [];
328
329 // put everything in an array
330 for ($i = 0; $i < $n; $i++) {
332 $r[$i] = $l['cn'];
333 }
334 return $r;
335 }
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 684 of file acc_reconciliation.class.php.

684 {
685 static $p = 0;
686 if ($p == 0) {
688 $p = 1;
689 }
690 bcscale(2);
691 $retdb = $this->db->execute("detail_quant", array($p_jrn_id));
692 $nb_record = Database::num_row($retdb);
693 if ($nb_record > 0) {
694 $total_price = $first_amount = 0;
695 for ($i = 0; $i < $nb_record; $i++) {
696 // then second_amount takes in account the vat_sided
697 $row = Database::fetch_array($retdb, $i);
698 $total_price = bcadd($row['price'], $row['vat_amount']);
699 $total_price = bcsub($total_price, $row['vat_sided']);
700 $total_price = bcadd($total_price, $row['nd_tva']);
701 $total_price = bcadd($total_price, $row['nd_tva_recup']);
702 $first_amount = bcadd($total_price, $first_amount);
703 }
704 } else {
705 // else take the amount from jrn
706 $first_amount = $p_default_amount;
707 }
708 return $first_amount;
709 }
$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 644 of file acc_reconciliation.class.php.

644 {
645 switch ($p_choice) {
646 case 0:
647 $array = $this->get_reconciled();
648 break;
649 case 1:
650 $array = $this->get_reconciled_amount(false);
651 break;
652 case 2:
653 $array = $this->get_reconciled_amount(true);
654 break;
655 case 3:
656 $array = $this->get_not_reconciled();
657 break;
658 default:
659 echo "Choix invalid";
660 throw new Exception("invalide");
661 }
662 return $array;
663 }
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 354 of file acc_reconciliation.class.php.

354 {
356 $filter_date = $this->filter_date();
357 /* create ledger filter */
358 $sql_jrn = $this->ledger_filter();
359
360 $array = $this->db->get_array("
361 with total_operation as (
362 select
363 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
364 from
365 jrnx jx1
366 join jrn jn2 on (jn2.jr_grpt_id =jx1.j_grpt )
367 left join quant_sold qs on (jx1.j_id=qs.j_id)
368 left join quant_purchase qp on (qp.j_id =jx1.j_id)
369 group by jn2.jr_id)
370,tiers as (
371 select j_id,qf_other tiers_id from quant_fin
372 union
373 select j_id,qs_client from quant_sold qs
374 union
375 select j_id,qp_supplier from quant_purchase
376)
377 select distinct
378 jr1.jr_id jr1_jr_id
379 ,null ra1_jra_concerned
380 ,jr1.jr_date jr1_jr_date
381 ,to_char(jr1.jr_date,'DD.MM.YY') as str_jr1_jr_date
382 ,jr1.jr_comment jr1_jr_comment
383 ,jr1.jr_internal jr1_jr_internal
384 ,jr1.jr_montant jr1_jr_montant
385 ,case when to1.sum_amount=0 then jr1.jr_montant else to1.sum_amount end to1_sum_amount
386 ,jr1.jr_pj_number jr1_jr_pj_number
387 ,jr1.jr_def_id jr1_jr_def_id
388 ,jrn1.jrn_def_name jrn1_jrn_def_name
389 ,jrn1.jrn_def_type jrn1_jrn_def_type
390 ,null jr2_jr_date
391 ,null str_jr2_jr_date
392 ,null jr2_jr_comment
393 ,null jr2_jr_internal
394 ,null jr2_jr_montant
395 ,null to2_sum_amount
396 ,null jr2_jr_pj_number
397 ,null jr2_jr_def_id
398 ,null jrn2_jrn_def_name
399 ,null jrn2_jrn_def_type
400 ,0 depend_count
401 ,(select fd1.ad_value from fiche_detail fd1 where fd1.ad_id=1 and fd1.f_id=t3.tiers_id) as tiers_name
402 ,(select fd1.ad_value from fiche_detail fd1 where fd1.ad_id=23 and fd1.f_id=t3.tiers_id) as tiers_qcode
403from jrn jr1
404join total_operation to1 on (to1.jr_id=jr1.jr_id)
405join jrn_def jrn1 on (jrn1.jrn_def_id=jr1.jr_def_id)
406left join (select t2.tiers_id,j2.j_grpt from tiers t2 join jrnx j2 on (t2.j_id=j2.j_id) ) as t3 on (t3.j_grpt=jr1.jr_grpt_id )
407where
408 $filter_date
409 and $sql_jrn
410 and jr1.jr_id not in (select jr_id from jrn_rapt
411 union select jra_concerned from jrn_rapt)
412 order by jr_date
413");
414
415
416 return $array;
417 }
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 488 of file acc_reconciliation.class.php.

488 {
490 $sql_amount = Acc_Reconciliation::SQL_QUERY;
491
492 $a_row = $this->db->get_array("$sql_amount order by jr1_jr_date");
493 return $a_row;
494 }

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 507 of file acc_reconciliation.class.php.

507 {
508 // build temporary table temp_total_operation
510 // SQL with different amount
511 $sql_amount = Acc_Reconciliation::SQL_QUERY;
512 if ($p_equal) {
513 $sql_amount = $sql_amount . " where bs1.depend_sum_amount = to1_sum_amount ";
514 } else {
515 $sql_amount = $sql_amount . " where bs1.depend_sum_amount != to1_sum_amount";
516 }
517 $a_row = $this->db->get_array("$sql_amount order by jr1_jr_date");
518 return $a_row;
519 }

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 155 of file acc_reconciliation.class.php.

155 {
156 if (trim($jr_id2) == "")
157 return;
158 if (strpos($jr_id2, ',') !== 0) {
159 $aRapt = explode(',', $jr_id2);
160 foreach ($aRapt as $rRapt) {
161 if (isNumber($rRapt) == 1) {
162 $this->insert_rapt($rRapt);
163 }
164 }
165 } else
166 if (isNumber($jr_id2) == 1) {
167 $this->insert_rapt($jr_id2);
168 }
169 }
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 181 of file acc_reconciliation.class.php.

181 {
182 if (isNumber($this->jr_id) == 0 || isNumber($jr_id2) == 0) {
183 return false;
184 }
185 if ($this->jr_id == $jr_id2)
186 return true;
187
188 if ($this->db->count_sql("select jr_id from jrn where jr_id=$1" ,[ $this->jr_id]) == 0)
189 return false;
190 if ($this->db->count_sql("select jr_id from jrn where jr_id=$1",[$jr_id2]) == 0)
191 return false;
192
193 // verify if exists
194 if ($this->db->count_sql(
195 "select jra_id from jrn_rapt where jra_concerned=$1
196 and jr_id=$2
197 union
198 select jra_id from jrn_rapt where jr_id= $1
199 and jra_concerned=$2 " ,[$this->jr_id,$jr_id2]) == 0) {
200 // Ok we can insert
201 $Res = $this->db->exec_sql("insert into jrn_rapt(jr_id,jra_concerned) values ($1,$2)",
202 array($this->jr_id, $jr_id2)
203 );
204 // try to letter automatically same account from both operation
205 $this->auto_letter($jr_id2);
206
207 // update date of paiement -----------------------------------------------------------------------
208 $source_type = $this->db->get_value("select substr(jr_internal,1,1) from jrn where jr_id=$1", array($this->jr_id));
209 $dest_type = $this->db->get_value("select substr(jr_internal,1,1) from jrn where jr_id=$1", array($jr_id2));
210 if (($source_type == 'A' || $source_type == 'V') && ($dest_type != 'A' && $dest_type != 'V')) {
211 // set the date on source
212 $date = $this->db->get_value('select jr_date from jrn where jr_id=$1', array($jr_id2));
213 if (trim($date) == '')
214 $date = null;
215 $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));
216 }
217 if (($source_type != 'A' && $source_type != 'V') && ($dest_type == 'A' || $dest_type == 'V')) {
218 // set the date on dest
219 $date = $this->db->get_value('select jr_date from jrn where jr_id=$1', array($this->jr_id));
220 if (trim($date) == '')
221 $date = null;
222 $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));
223 }
224 }
225 return true;
226 }
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 425 of file acc_reconciliation.class.php.

425 {
426 global $g_user;
427 /* get the available ledgers for current user */
428 $sql = $g_user->get_ledger_sql('ALL', 3);
429 $sql = noalyss_str_replace('jrn_def_id', 'jr_def_id', $sql);
430 $r = '';
431 /* filter by this->r_jrn */
432 if (!empty($this->a_jrn) && is_array($this->a_jrn)) {
433 $sep = '';
434 $r = 'and jr_def_id in (';
435 foreach ($this->a_jrn as $key => $value) {
436 $r .= $sep . $value;
437 $sep = ',';
438 }
439 $r .= ')';
440 }
441 return $sql . ' ' . $r;
442 }

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 665 of file acc_reconciliation.class.php.

665 {
666 static $seen = 0;
667 if ($seen == 1)
668 return;
669 $this->db->prepare('detail_quant', 'select * from v_quant_detail where jr_id=$1');
670 // $this->db->prepare('detail_depend',' ');
671 $seen = 1;
672 }

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 268 of file acc_reconciliation.class.php.

268 {
269 if (isNumber($this->jr_id) == 0 or
270 isNumber($jr_id2) == 0) {
271 return;
272 }
273 // verify if exists
274 if ($this->db->count_sql("select jra_id from jrn_rapt where " .
275 " jra_concerned=" . $this->jr_id . " and jr_id=$jr_id2
276 union
277 select jra_id from jrn_rapt where jra_concerned=$jr_id2 " .
278 " and jr_id=" . $this->jr_id) != 0) {
279 /**
280 * remove also lettering between both operation
281 */
282 $sql = "
283delete from
284 jnt_letter
285where jl_id in ( select jl_id from jnt_letter
286 join letter_cred as lc using(jl_id)
287 join letter_deb as ld using (jl_id)
288where
289 lc.j_id in (select j_id
290 from jrnx join jrn on (j_grpt=jr_grpt_id)
291 where jr_id in ($1,$2))
292 or
293 ld.j_id in (select j_id
294 from jrnx join jrn on (j_grpt=jr_grpt_id)
295 where jr_id in ($1,$2))
296
297
298
299 )";
300 $this->db->exec_sql($sql, array($jr_id2, $this->jr_id));
301 // Ok we can delete
302 $Res = $this->db->exec_sql("delete from jrn_rapt where
303 (jra_concerned=$1 and jr_id= $2) or
304 (jra_concerned=$2 and jr_id=$1) ",
305 [$jr_id2,$this->jr_id]);
306 }
307 }

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 130 of file acc_reconciliation.class.php.

130 {
131 $this->jr_id = $jr_id;
132 }

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 545 of file acc_reconciliation.class.php.

545 {
546 if (Database::num_row($p_ret) > 0) {
547 echo '<tr >';
548 echo '<td></td>';
549 echo '<td colspan="5" style="border:1px solid black;width:auto">';
550 include NOALYSS_TEMPLATE . '/impress_reconciliation_detail.php';
551 echo '</td>';
552 echo '</tr>';
553 }
554 }

References DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ test_me()

static Acc_Reconciliation::test_me ( )
static

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

711 {
713 $rap = new Acc_Reconciliation($cn);
714 var_dump($rap->get_reconciled_amount(false));
715 $rap->build_temp_total_operation();
716 $rap->build_temp_total_operation();
717 $rap->build_temp_total_operation();
718 }
static connect()

References $cn, and $rap.

◆ widget()

Acc_Reconciliation::widget ( )

return a widget of type js_concerned

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

138 {
139 $wConcerned = new IConcerned();
140 $wConcerned->extra = 0; // with 0 javascript search from e_amount... field (see javascript)
141
142 return $wConcerned;
143 }

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 109 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: