71 if ( trim($jr_id2) ==
"" )
73 if ( strpos($jr_id2,
',') !== 0 )
75 $aRapt=explode(
',',$jr_id2);
76 foreach ($aRapt as $rRapt)
106 if ( $this->
jr_id==$jr_id2)
109 if ( $this->
db->count_sql(
"select jr_id from jrn where jr_id=".$this->jr_id)==0 )
111 if ( $this->
db->count_sql(
"select jr_id from jrn where jr_id=".$jr_id2)==0 )
115 if ( $this->
db->count_sql(
116 "select jra_id from jrn_rapt where jra_concerned=".$this->jr_id.
119 select jra_id from jrn_rapt where jr_id=".$this->jr_id.
120 " and jra_concerned=$jr_id2 ")
124 $Res=$this->
db->exec_sql(
"insert into jrn_rapt(jr_id,jra_concerned) values ".
125 "(".$this->
jr_id.
",$jr_id2)");
130 $source_type=$this->
db->get_value(
"select substr(jr_internal,1,1) from jrn where jr_id=$1",array($this->
jr_id));
131 $dest_type=$this->
db->get_value(
"select substr(jr_internal,1,1) from jrn where jr_id=$1",array($jr_id2));
132 if (($source_type ==
'A' || $source_type==
'V') && ($dest_type !=
'A' && $dest_type !=
'V'))
135 $date=$this->
db->get_value(
'select jr_date from jrn where jr_id=$1',array($jr_id2));
137 $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));
139 if (($source_type !=
'A' && $source_type !=
'V') && ($dest_type ==
'A' || $dest_type ==
'V'))
142 $date=$this->
db->get_value(
'select jr_date from jrn where jr_id=$1',array($this->
jr_id));
144 $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));
156 $sql=
"select j1.f_id as fiche ,coalesce(j1.j_id,-1) as jrnx_id1,coalesce(j2.j_id,-1) as jrnx_id2,
159 join jrn as jr1 on (j1.j_grpt=jr1.jr_grpt_id)
160 join jrnx as j2 on (coalesce(j1.f_id,-1)=coalesce(j2.f_id,-1) and j1.j_poste=j2.j_poste)
161 join jrn as jr2 on (j2.j_grpt=jr2.jr_grpt_id)
195 function remove($jr_id2)
203 if ( $this->
db->count_sql(
"select jra_id from jrn_rapt where ".
204 " jra_concerned=".$this->jr_id.
" and jr_id=$jr_id2
206 select jra_id from jrn_rapt where jra_concerned=$jr_id2 ".
207 " and jr_id=".$this->jr_id) !=0)
214 where jl_id in ( select jl_id from jnt_letter
215 join letter_cred as lc using(jl_id)
216 join letter_deb as ld using (jl_id)
218 lc.j_id in (select j_id
219 from jrnx join jrn on (j_grpt=jr_grpt_id)
220 where jr_id in ($1,$2))
222 ld.j_id in (select j_id
223 from jrnx join jrn on (j_grpt=jr_grpt_id)
224 where jr_id in ($1,$2))
229 $this->
db->exec_sql(
$sql, array($jr_id2, $this->
jr_id));
231 $Res=$this->
db->exec_sql(
"delete from jrn_rapt where ".
232 "(jra_concerned=$jr_id2 and jr_id=".$this->
jr_id.
") or
233 (jra_concerned=".$this->jr_id.
" and jr_id=$jr_id2) ");
246 $sql=
" select jr_id as cn from jrn_rapt where jra_concerned=$1
248 select jra_concerned as cn from jrn_rapt where jr_id=$2";
254 if ($n ==0 )
return [];
266 $sql=
"select jr_id,jr_date,jr_comment,jr_internal,jr_montant,jr_pj_number,jr_def_id,jrn_def_name,jrn_def_type
267 from jrn join jrn_def on (jrn_def_id=jr_def_id)
282 $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");
305 if ( ! empty ($this->
a_jrn ) && is_array($this->
a_jrn))
308 $r=
'and jr_def_id in (';
336 $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");
343 for (
$e=0;
$e<count($atmp);
$e++)
372 $retdb=$this->
db->execute(
"detail_quant",array(
$array[
$i][
'first'][
'jr_id']));
379 $total_price=bcadd($total_price,
$row[
'price']);
380 $total_price=bcadd($total_price,
$row[
'vat_amount']);
381 $total_price=bcsub($total_price,
$row[
'vat_sided']);
382 $total_price=bcadd($total_price,
$row[
'nd_amount']);
383 $total_price=bcadd($total_price,
$row[
'nd_tva_recup']);
386 $first_amount=$total_price;
390 $first_amount=
$array[
$i][
'first'][
'jr_montant'];
395 $retdb=$this->
db->execute(
"detail_quant",array(
$array[
$i][
'depend'][
$e][
'jr_id']));
403 $total_price=bcadd($total_price,
$row[
'price']);
404 $total_price=bcadd($total_price,
$row[
'vat_amount']);
405 $total_price=bcsub($total_price,
$row[
'vat_sided']);
406 $total_price=bcadd($total_price,
$row[
'nd_amount']);
407 $total_price=bcadd($total_price,
$row[
'nd_tva_recup']);
410 $second_amount=bcadd($second_amount,$total_price);
414 $second_amount=bcadd($second_amount,
$array[
$i][
'depend'][
$e][
'jr_montant']);
417 if ( $p_equal && $first_amount==$second_amount)
421 if ( ! $p_equal && $first_amount != $second_amount)
447 $sql=
" (jr_date >= to_date('".$this->start_day.
"','DD.MM.YYYY')
448 and jr_date <= to_date('".$this->
end_day.
"','DD.MM.YYYY'))";
456 echo
'<tr class="odd">';
458 echo
'<td colspan="5" style="border:1px solid black;width:auto">';
459 include NOALYSS_TEMPLATE.
'/impress_reconciliation_detail.php';
501 $title[]=_(
'type journal');
508 $title[]=_(
'nom journal');
509 $title[]=_(
'type journal');
525 $title[]=_(
'type journal');
540 $export->add($first[
'jr_date']);
541 $export->add($first[
'jr_internal']);
542 $export->add($first[
'jr_comment']);
543 $export->add($first[
'jr_pj_number']);
544 $export->add($first[
'jrn_def_name']);
545 $export->add($first[
'jrn_def_type']);
547 if (count($a_depend) > 0)
552 $depend = $a_depend[0];
555 $export->add($depend[
'jr_date']);
556 $export->add($depend[
'jr_internal']);
557 $export->add($depend[
'jr_comment']);
558 $export->add($depend[
'jr_pj_number']);
559 $export->add($depend[
'jrn_def_name']);
560 $export->add($depend[
'jrn_def_type']);
561 $export->add($amount_dep,
"number");
566 for (
$e = 1;
$e < count($a_depend);
$e++)
569 $depend = $a_depend[
$e];
579 $export->add($depend[
'jr_date']);
580 $export->add($depend[
'jr_internal']);
581 $export->add($depend[
'jr_comment']);
582 $export->add($depend[
'jr_pj_number']);
583 $export->add($depend[
'jrn_def_name']);
584 $export->add($depend[
'jrn_def_type']);
585 $export->add($amount_dep,
"number");
622 echo
"Choix invalid";
623 throw new Exception(
"invalide");
630 if ( $seen == 1)
return;
631 $this->
db->prepare(
'detail_quant',
'select * from v_quant_detail where jr_id=$1');
651 $retdb=$this->
db->execute(
"detail_quant",array($p_jrn_id));
656 $total_price=bcadd(
$row[
'price'],
$row[
'vat_amount']);
657 $total_price=bcsub($total_price,
$row[
'vat_sided']);
658 $first_amount=$total_price;
662 $first_amount=$p_default_amount;
664 return $first_amount;
671 var_dump(
$rap->get_reconciled_amount(
'',
false));
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
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...
prepare_query_detail_quant()
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
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
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_all($ret)
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
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.
$acc_reconciliation end_day
$acc_reconciliation start_day
$acc_reconciliation a_jrn