noalyss
Version-6.7.2
|
new class for managing the reconciliation it must be used instead of the function InsertRapt, ... More...
Public Member Functions | |
__construct ($cn) | |
auto_letter ($p_jrid) | |
try to letter same card between $p_jrid and $this->jr_id | |
export_csv ($p_choice) | |
Export to CSV. | |
fill_info () | |
filter_date () | |
create a string to filter thanks the date | |
get () | |
Return an array of the concerned operation. | |
get_data ($p_choice) | |
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. | |
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 | |
$db | |
$jr_id |
new class for managing the reconciliation it must be used instead of the function InsertRapt, ...
Definition at line 36 of file class_acc_reconciliation.php.
Acc_Reconciliation::__construct | ( | $ | cn | ) |
Acc_Reconciliation::auto_letter | ( | $ | p_jrid | ) |
try to letter same card between $p_jrid and $this->jr_id
jrn.jr_id | $p_jrid the operation to reconcile |
Definition at line 154 of file class_acc_reconciliation.php.
References $letter, $result, $sql, db, and jr_id.
Referenced by insert_rapt().
{ // Try to find same card from both operation $sql="select j1.f_id as fiche ,coalesce(j1.j_id,-1) as jrnx_id1,coalesce(j2.j_id,-1) as jrnx_id2, j1.j_poste as poste from jrnx as j1 join jrn as jr1 on (j1.j_grpt=jr1.jr_grpt_id) join jrnx as j2 on (coalesce(j1.f_id,-1)=coalesce(j2.f_id,-1) and j1.j_poste=j2.j_poste) join jrn as jr2 on (j2.j_grpt=jr2.jr_grpt_id) where jr1.jr_id=$1 and jr2.jr_id= $2"; $result=$this->db->get_array($sql,array($this->jr_id,$p_jrid)); if ( count($result) == 0) { return; } for ($i=0;$i<count($result);$i++) { if ( $result[$i]['fiche'] != -1) { $letter = new Lettering_Card($this->db); $letter->insert_couple($result[$i]['jrnx_id1'],$result[$i]['jrnx_id2']); } else { $letter = new Lettering_Account($this->db); $letter->insert_couple($result[$i]['jrnx_id1'],$result[$i]['jrnx_id2']); } } }
Acc_Reconciliation::export_csv | ( | $ | p_choice | ) |
Export to CSV.
type | $p_choice |
Definition at line 435 of file class_acc_reconciliation.php.
References $array, $e, get_data(), and printf.
{ $array = $this->get_data($p_choice); for ($i = 0; $i < count($array); $i++) { // --------------------------------------- // first index has 2 arrays : first & depend[] // --------------------------------------- $first = $array[$i]['first']; $a_depend = array(); if (isset($array[$i]['depend'])) { $a_depend = $array[$i]['depend']; //----- HEADER ---- if ($i == 0) { printf('"n°";"Date";"internal";"libellé";"n° pièce";"nom journal";"type journal";"montant"'); printf(';"<->";"Date";"internal";"libellé";"n° pièce";"nom journal";"type journal";"montant"' . "\n\r"); } } else { //----- HEADER ---- if ($i == 0) { printf('"n°";"Date";"internal";"libellé";"n° pièce";"nom journal";"type journal";"montant"' . "\n\r"); } } // -------------------------- // Print First // -------------------------- printf('%d;"%s";"%s";"%s";"%s";"%s";"%s";%f',$i, $first['jr_date'], $first['jr_internal'], $first['jr_comment'], $first['jr_pj_number'], $first['jrn_def_name'], $first['jrn_def_type'], $first['jr_montant']); if (count($a_depend) > 0) { // -------------------------------------- // Print first depending operation // -------------------------------------- $depend = $a_depend[0]; printf(';"<->";"%s";"%s";"%s";"%s";"%s";"%s";%f' . "\n\r", $depend['jr_date'], $depend['jr_internal'], $depend['jr_comment'], $depend['jr_pj_number'], $depend['jrn_def_name'], $depend['jrn_def_type'], $depend['jr_montant']); // -------------------------------------- // print other depending operation if any // -------------------------------------- for ($e = 1; $e < count($a_depend); $e++) { $depend = $a_depend[$e]; printf(';;;;;;;"<->";'); printf('"%s";"%s";"%s";"%s";"%s";"%s";%f' . "\n\r", $depend['jr_date'], $depend['jr_internal'], $depend['jr_comment'], $depend['jr_pj_number'], $depend['jrn_def_name'], $depend['jrn_def_type'], $depend['jr_montant']); } } else { printf("\n\r"); } } }
Definition at line 265 of file class_acc_reconciliation.php.
References $a, $sql, db, and jr_id.
Referenced by get_not_reconciled(), and get_reconciled().
create a string to filter thanks the date
Definition at line 395 of file class_acc_reconciliation.php.
References $end, $g_user, $sql, $start, end_day, isDate(), and start_day.
Referenced by get_not_reconciled(), and get_reconciled().
{ global $g_user; list($start,$end)=$g_user->get_limit_current_exercice(); if (isDate($this->start_day) ==null) { $this->start_day=$start; } if ( isDate($this->end_day) == null) { $this->end_day=$end; } $sql=" (jr_date >= to_date('".$this->start_day."','DD.MM.YYYY') and jr_date <= to_date('".$this->end_day."','DD.MM.YYYY'))"; return $sql; }
Return an array of the concerned operation.
database | connection |
Definition at line 245 of file class_acc_reconciliation.php.
References $l, $r, $Res, $sql, db, Database\fetch_array(), and Database\num_row().
{ $sql=" select jr_id as cn from jrn_rapt where jra_concerned=".$this->jr_id. " union ". " select jra_concerned as cn from jrn_rapt where jr_id=".$this->jr_id; $Res=$this->db->exec_sql($sql); // If nothing is found return null $n=Database::num_row($Res); if ($n ==0 ) return null; // put everything in an array for ($i=0;$i<$n;$i++) { $l=Database::fetch_array($Res,$i); $r[$i]=$l['cn']; } return $r; }
Acc_Reconciliation::get_data | ( | $ | p_choice | ) |
type | $p_choice |
|
Definition at line 502 of file class_acc_reconciliation.php.
References $array, echo, exit, get_not_reconciled(), get_reconciled(), and get_reconciled_amount().
Referenced by export_csv().
{ switch ($p_choice) { case 0: $array = $this->get_reconciled(); break; case 1: $array = $this->get_reconciled_amount(false); break; case 2: $array = $this->get_reconciled_amount(true); break; case 3: $array = $this->get_not_reconciled(); break; default: echo "Choix invalid"; exit(); } return $array; }
return array of not-reconciled operation Prepare and put in memory the SQL detail_quant
Definition at line 277 of file class_acc_reconciliation.php.
References $array, $ret, db, fill_info(), filter_date(), jr_id, and ledger_filter().
Referenced by get_data().
{ $filter_date=$this->filter_date(); /* create ledger filter */ $sql_jrn=$this->ledger_filter(); $array=$this->db->get_array("select distinct jr_id,jr_date from jrn where $filter_date and $sql_jrn and jr_id not in (select jr_id from jrn_rapt union select jra_concerned from jrn_rapt) order by jr_date"); $ret=array(); for ($i=0;$i<count($array);$i++) { $this->jr_id=$array[$i]['jr_id']; $ret[$i]['first']=$this->fill_info(); } $this->db->prepare('detail_quant','select * from v_quant_detail where jr_id=$1'); return $ret; }
return array of reconciled operation Prepare and put in memory the SQL detail_quant
Definition at line 330 of file class_acc_reconciliation.php.
References $array, $e, $ret, db, fill_info(), filter_date(), jr_id, and ledger_filter().
Referenced by get_data(), and get_reconciled_amount().
{ $filter_date=$this->filter_date(); /* create ledger filter */ $sql_jrn=$this->ledger_filter(); $array=$this->db->get_array("select distinct jr_id,jr_date from jrn where $filter_date and $sql_jrn and jr_id in (select jr_id from jrn_rapt union select jra_concerned from jrn_rapt) order by jr_date"); $ret=array(); for ($i=0;$i<count($array);$i++) { $this->jr_id=$array[$i]['jr_id']; $ret[$i]['first']=$this->fill_info(); $atmp=$this->get(); for ( $e=0;$e<count($atmp);$e++) { $this->jr_id=$atmp[$e]; $ret[$i]['depend'][$e]=$this->fill_info(); } } $this->db->prepare('detail_quant','select * from v_quant_detail where jr_id=$1'); return $ret; }
Acc_Reconciliation::get_reconciled_amount | ( | $ | p_equal = false | ) |
Prepare and put in memory the SQL detail_quant.
@return |
Definition at line 365 of file class_acc_reconciliation.php.
References $array, $e, $ret, and get_reconciled().
Referenced by get_data().
{ $array=$this->get_reconciled(); $ret=array(); bcscale(2); for ($i=0;$i<count($array);$i++) { $first_amount=$array[$i]['first']['jr_montant']; $second_amount=0; for ($e=0;$e<count($array[$i]['depend']);$e++) { $second_amount=bcadd($second_amount,$array[$i]['depend'][$e]['jr_montant']); } if ( $p_equal && $first_amount==$second_amount) { $ret[]=$array[$i]; } if ( ! $p_equal && $first_amount != $second_amount) { $ret[]=$array[$i]; } } return $ret; }
Acc_Reconciliation::insert | ( | $ | jr_id2 | ) |
Insert into jrn_rapt the concerned operations.
$jr_id2 | (jrn.jr_id) => jrn_rapt.jra_concerned or a string like "jr_id2,jr_id3,jr_id4..." |
Definition at line 70 of file class_acc_reconciliation.php.
References insert_rapt(), isNumber(), and trim().
{ if ( trim($jr_id2) == "" ) return; if ( strpos($jr_id2,',') !== 0 ) { $aRapt=explode(',',$jr_id2); foreach ($aRapt as $rRapt) { if ( isNumber($rRapt) == 1 ) { $this->insert_rapt($rRapt); } } } else if ( isNumber($jr_id2) == 1 ) { $this->insert_rapt($jr_id2); } }
Acc_Reconciliation::insert_rapt | ( | $ | jr_id2 | ) |
Insert into jrn_rapt the concerned operations should not be called directly, use insert instead.
$jr_id2 | (jrn.jr_id) => jrn_rapt.jra_concerned |
Definition at line 101 of file class_acc_reconciliation.php.
References $date, $Res, auto_letter(), db, isNumber(), jr_id, and trim().
Referenced by insert().
{ if ( isNumber($this->jr_id) == 0 || isNumber($jr_id2) == 0 ) { return false; } if ( $this->jr_id==$jr_id2) return true; if ( $this->db->count_sql("select jr_id from jrn where jr_id=".$this->jr_id)==0 ) return false; if ( $this->db->count_sql("select jr_id from jrn where jr_id=".$jr_id2)==0 ) return false; // verify if exists if ( $this->db->count_sql( "select jra_id from jrn_rapt where jra_concerned=".$this->jr_id. " and jr_id=$jr_id2 union select jra_id from jrn_rapt where jr_id=".$this->jr_id. " and jra_concerned=$jr_id2 ") ==0) { // Ok we can insert $Res=$this->db->exec_sql("insert into jrn_rapt(jr_id,jra_concerned) values ". "(".$this->jr_id.",$jr_id2)"); // try to letter automatically same account from both operation $this->auto_letter($jr_id2); // update date of paiement ----------------------------------------------------------------------- $source_type=$this->db->get_value("select substr(jr_internal,1,1) from jrn where jr_id=$1",array($this->jr_id)); $dest_type=$this->db->get_value("select substr(jr_internal,1,1) from jrn where jr_id=$1",array($jr_id2)); if (($source_type =='A' || $source_type=='V') && ($dest_type != 'A' && $dest_type != 'V')) { // set the date on source $date=$this->db->get_value('select jr_date from jrn where jr_id=$1',array($jr_id2)); if ( trim ($date) == '') $date=null; $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)); } if (($source_type !='A' && $source_type !='V') && ($dest_type == 'A' || $dest_type == 'V')) { // set the date on dest $date=$this->db->get_value('select jr_date from jrn where jr_id=$1',array($this->jr_id)); if (trim($date) == '') $date=null; $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)); } } return true; }
Create a sql condition to filter by security and by asked ledger based on $this->a_jrn.
Definition at line 299 of file class_acc_reconciliation.php.
References $g_user, $r, $sep, $sql, $value, and a_jrn.
Referenced by get_not_reconciled(), and get_reconciled().
{ global $g_user; /* get the available ledgers for current user */ $sql=$g_user->get_ledger_sql('ALL',3); $sql=str_replace('jrn_def_id','jr_def_id',$sql); $r=''; /* filter by this->r_jrn */ if ($this->a_jrn != null ) { $sep=''; $r='and jr_def_id in ('; foreach( $this->a_jrn as $key=>$value) { $r.=$sep.$value; $sep=','; } $r.=')'; } return $sql.' '.$r; }
Acc_Reconciliation::remove | ( | $ | jr_id2 | ) |
Insert into jrn_rapt the concerned operations.
$this->jr_id | (jrn.jr_id) => jrn_rapt.jr_id |
$jr_id2 | (jrn.jr_id) => jrn_rapt.jra_concerned |
remove also lettering between both operation
Definition at line 196 of file class_acc_reconciliation.php.
References $Res, $sql, db, isNumber(), and jr_id.
{ if ( isNumber($this->jr_id) == 0 or isNumber($jr_id2) == 0 ) { return; } // verify if exists if ( $this->db->count_sql("select jra_id from jrn_rapt where ". " jra_concerned=".$this->jr_id." and jr_id=$jr_id2 union select jra_id from jrn_rapt where jra_concerned=$jr_id2 ". " and jr_id=".$this->jr_id) !=0) { /** * remove also lettering between both operation */ $sql = " delete from jnt_letter where jl_id in ( select jl_id from jnt_letter join letter_cred as lc using(jl_id) join letter_deb as ld using (jl_id) where lc.j_id in (select j_id from jrnx join jrn on (j_grpt=jr_grpt_id) where jr_id in ($1,$2)) or ld.j_id in (select j_id from jrnx join jrn on (j_grpt=jr_grpt_id) where jr_id in ($1,$2)) )"; $this->db->exec_sql($sql, array($jr_id2, $this->jr_id)); // Ok we can delete $Res=$this->db->exec_sql("delete from jrn_rapt where ". "(jra_concerned=$jr_id2 and jr_id=".$this->jr_id.") or (jra_concerned=".$this->jr_id." and jr_id=$jr_id2) "); } }
Acc_Reconciliation::set_jr_id | ( | $ | jr_id | ) |
Acc_Reconciliation::show_detail | ( | $ | p_ret | ) |
Definition at line 413 of file class_acc_reconciliation.php.
References echo, and Database\num_row().
static Acc_Reconciliation::test_me | ( | ) | [static] |
Definition at line 525 of file class_acc_reconciliation.php.
{ $cn=new Database(dossier::id()); $rap=new Acc_Reconciliation($cn); var_dump($rap->get_reconciled_amount('',false)); }
return a widget of type js_concerned
Definition at line 53 of file class_acc_reconciliation.php.
{ $wConcerned=new IConcerned(); $wConcerned->extra=0; // with 0 javascript search from e_amount... field (see javascript) return $wConcerned; }
Acc_Reconciliation::$db |
database connection
Definition at line 38 of file class_acc_reconciliation.php.
Acc_Reconciliation::$jr_id |