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

Display history of operation. More...

+ Inheritance diagram for Acc_Ledger_History:
+ Collaboration diagram for Acc_Ledger_History:

Public Member Functions

 __construct (Database $cn, $pa_ledger, $p_from, $p_to, $p_mode)
 
 export_accounting_html ()
 display accounting of operations m_mode=A
 
 export_detail_html ()
 display detail of operations m_mode=D
 
 export_extended_html ()
 display extended details of operation m_mode=E
 
 export_html ()
 call the right function , depending of m_mode
 
 export_oneline_html ()
 display operation on one line m_mode=L
 
 get_filter_operation ()
 Filter operation.
 
 get_from ()
 setter / getter
 
 get_ledger ()
 setter / getter
 
 get_ledger_type ()
 
 get_mode ()
 setter / getter
 
 get_row ($p_limit, $p_offset)
 
 get_tiers ($p_jrn_type, $jr_id)
 Retrieve the third : supplier for purchase, customer for sale, bank for fin,.
 
 get_tiers_id ($p_jrn_type, $jr_id)
 Return the f_id of the tiers , called by get_tiers.
 
 get_to ()
 setter / getter
 
 has_other_tax ()
 count the number of addition tax for the ledger
 
 set_a_ledger ($ma_ledger)
 setter ma_ledger (array of jrn_def_id)
 
 set_filter_operation ($filter_operation)
 Filter operation ,.
 
 set_from ($m_from)
 setter m_from (periode id)
 
 set_ledger_type ($ledger_type)
 
 set_m_mode ($m_mode)
 Setter.
 
 set_to ($m_to)
 setter m_to (periode id)
 

Static Public Member Functions

static factory (Database $cn, $pa_ledger, $p_from, $p_to, $p_mode, $p_paid)
 Build the right object.
 

Data Fields

 $db
 database connx
 

Protected Member Functions

 add_additional_tax_info ()
 add additional info about additional tax.
 
 build_filter_operation ()
 Build a SQL clause to filter operation depending if they are paid, unpaid or no filter.
 
 prepare_reconcile_date ()
 Prepare the query for fetching the linked operation @staticvar int $prepare.
 

Protected Attributes

 $filter_operation
 type of ledger VEN , ACH , ODS, FIN
 
 $ledger_type
 
 $m_from
 Starting Periode : periode.p_id.
 
 $m_mode
 mode of export L : one line, E accounting writing , D : Detail
 
 $m_to
 Ending Periode : periode.p_id.
 
 $ma_ledger
 Array of ledger id : jrn_def.jrn_def_id.
 

Detailed Description

Display history of operation.

See also
acc_ledger_historyTest.php

Definition at line 32 of file acc_ledger_history.class.php.

Constructor & Destructor Documentation

◆ __construct()

Acc_Ledger_History::__construct ( Database $cn,
$pa_ledger,
$p_from,
$p_to,
$p_mode )
Parameters
Database$cn
array$pa_ledgerarray of jrn_def.jrn_def_id
integer$p_fromperiode
integer$p_to
char$p_modeE D L or A , for Extended ,Detail , Listing , Accounting
Exceptions
Exceptionif $pa_ledger is not an array

Reimplemented in Acc_Ledger_History_Financial, and Acc_Ledger_History_Generic.

Definition at line 52 of file acc_ledger_history.class.php.

53 {
54 if (is_array($pa_ledger) == FALSE) {
55 throw new Exception (_('pa_ledger doit être un tableau'),EXC_PARAM_VALUE);
56 }
57 $this->db=$cn;
58 $this->ma_ledger=$pa_ledger;
59 $this->m_from=$p_from;
60 $this->m_to=$p_to;
61 $this->m_mode=$p_mode;
62 $this->filter_operation='all';
63 }
_("actif, passif,charge,...")
const EXC_PARAM_VALUE
Definition constant.php:343
$SecUser db

References $cn, _, db, and EXC_PARAM_VALUE.

Member Function Documentation

◆ add_additional_tax_info()

Acc_Ledger_History::add_additional_tax_info ( )
protected

add additional info about additional tax.

Add to $this->data an array containing the info about a additional tax. Concerns only purchase and sales ledgers

$this->data[$i]['supp_tax']['ac_id'] id in Acc_Other_Tax
$this->data[$i]['supp_tax']['j_montant']  Amount of this tax
$this->data[$i]['supp_tax']['ac_label']   Label of this tax
$this->data[$i]['supp_tax']['ac_rate']    Rate of this tax
$this->data[$i]['supp_tax']['j_poste']    Accounting
 * 

Definition at line 386 of file acc_ledger_history.class.php.

387 {
388 $prepare=$this->db->is_prepare("supp_tax_info");
389 if ( $prepare == false ){
390 $this->db->prepare("supp_tax_info","
391 select
392 case when j.j_debit is false and jd.jrn_def_type='ACH' then 0-j_montant
393 when j.j_debit is true and jd.jrn_def_type='VEN' then 0-j_montant
394 else j.j_montant end j_montant,
395 jt1.ac_id,
396 ac_label,
397 ac_rate,j_poste
398 from
399 jrn_tax jt1
400 join acc_other_tax using (ac_id)
401 join jrnx j using (j_id)
402 join jrn_def jd on (j.j_jrn_def=jd.jrn_def_id)
403 where j_grpt=$1
404 ");
405
406 }
407 $data=$this->get_data();
408 $nb_row=count($data);
409
410 for ($i=0;$i<$nb_row;$i++)
411 {
412 $ret=$this->db->execute("supp_tax_info",array($data[$i]["jr_grpt_id"]));
414 $array=($array==false)?array():$array;
415 $data[$i]["supp_tax"]=$array;
416 }
417 $this->set_data($data);
418 }
static fetch_all($ret)
wrapper for the function pg_fetch_all

References $array, $data, $i, $nb_row, $ret, db, and DatabaseCore\fetch_all().

Referenced by Acc_Ledger_History_Purchase\export_extended_html(), and Acc_Ledger_History_Sale\export_extended_html().

+ Here is the call graph for this function:

◆ build_filter_operation()

Acc_Ledger_History::build_filter_operation ( )
protected

Build a SQL clause to filter operation depending if they are paid, unpaid or no filter.

Returns
string SQL Clause

Definition at line 319 of file acc_ledger_history.class.php.

320 {
321 switch ( $this->get_filter_operation() )
322 {
323 case 'all':
324 $sql_filter="";
325 break;
326 case 'paid':
327 $sql_filter=" and (jr_date_paid is not null or jr_rapt ='paid' ) ";
328 break;
329 case 'unpaid':
330 $sql_filter=" and (jr_date_paid is null and coalesce(jr_rapt,'x') <> 'paid' ) ";
331 break;
332 default:
333 throw new Exception(_("Filtre invalide",5));
334
335 }
336 return $sql_filter;
337 }
get_filter_operation()
Filter operation.
$sql_filter
Definition preod.inc.php:43

References $sql_filter, _, and get_filter_operation().

Referenced by Acc_Ledger_History_Purchase\get_row(), and Acc_Ledger_History_Sale\get_row().

+ Here is the call graph for this function:

◆ export_accounting_html()

Acc_Ledger_History::export_accounting_html ( )
abstract

display accounting of operations m_mode=A

Reimplemented in Acc_Ledger_History_Financial, Acc_Ledger_History_Generic, Acc_Ledger_History_Purchase, and Acc_Ledger_History_Sale.

◆ export_detail_html()

Acc_Ledger_History::export_detail_html ( )
abstract

◆ export_extended_html()

Acc_Ledger_History::export_extended_html ( )
abstract

display extended details of operation m_mode=E

Reimplemented in Acc_Ledger_History_Financial, Acc_Ledger_History_Generic, Acc_Ledger_History_Purchase, and Acc_Ledger_History_Sale.

◆ export_html()

Acc_Ledger_History::export_html ( )
abstract

call the right function , depending of m_mode

Reimplemented in Acc_Ledger_History_Financial, Acc_Ledger_History_Generic, Acc_Ledger_History_Purchase, and Acc_Ledger_History_Sale.

◆ export_oneline_html()

Acc_Ledger_History::export_oneline_html ( )
abstract

◆ factory()

static Acc_Ledger_History::factory ( Database $cn,
$pa_ledger,
$p_from,
$p_to,
$p_mode,
$p_paid )
static

Build the right object.

Parameters
Database$cndatabase conx
array$pa_ledgerledger of array
integer$p_fromperiode id
integer$p_toperiode id
char$p_modeL (list operation) E (extended detail) A (accouting writing) D (Detailled VAT)
$p_paidvalues are all means all operations, paid only paid operation, unpaid for only unpaid
Returns
Acc_Ledger_History_Generic Acc_Ledger_History_Sale Acc_Ledger_History_Financial Acc_Ledger_History_Purchase
Examples
acc_ledger_historyTest.php.

Definition at line 162 of file acc_ledger_history.class.php.

163 {
164 // For Accounting writing , we use Acc_Ledger_History
165 if ($p_mode=="A")
166 {
167 $ret=new Acc_Ledger_History_Generic($cn, $pa_ledger, $p_from, $p_to,
168 $p_mode);
169 return $ret;
170 }
171 $nb_ledger=count($pa_ledger);
172 $ledger=new Acc_Ledger($cn, $pa_ledger[0]);
173 $type=$ledger->get_type();
174
175 // If first one is ODS so Acc_Ledger_History
176 if ($type=="ODS")
177 {
178 $ret=new Acc_Ledger_History_Generic($cn, $pa_ledger, $p_from, $p_to,
179 $p_mode);
180 return $ret;
181 }
182 // If all of the same type then use the corresponding class
183
184 for ($i=0; $i<$nb_ledger; $i++)
185 {
186 $ledger=new Acc_Ledger($cn, $pa_ledger[$i]);
187 $type_next=$ledger->get_type();
188
189 // If type different then we go back to the generic
190 if ($type_next!=$type)
191 {
192 $ret=new Acc_Ledger_History_Generic($cn, $pa_ledger, $p_from,
193 $p_to, $p_mode);
194 return $ret;
195 }
196 }
197 switch ($type)
198 {
199 case "ACH":
200 $ret=new Acc_Ledger_History_Purchase($cn, $pa_ledger, $p_from,
201 $p_to, $p_mode);
202 $ret->set_filter_operation($p_paid);
203 return $ret;
204 break;
205 case "FIN":
206 $ret=new Acc_Ledger_History_Financial($cn, $pa_ledger, $p_from,
207 $p_to, $p_mode);
208 return $ret;
209 break;
210 case "VEN":
211 $ret=new Acc_Ledger_History_Sale($cn, $pa_ledger, $p_from,
212 $p_to, $p_mode);
213 $ret->set_filter_operation($p_paid);
214 return $ret;
215 break;
216
217 default:
218 break;
219 }
220 }

References $cn, $i, $ledger, $ret, and $type.

Referenced by Print_Ledger_Simple\export(), and Print_Ledger_Simple_Without_Vat\export().

◆ get_filter_operation()

Acc_Ledger_History::get_filter_operation ( )

Filter operation.

Reimplemented in Acc_Ledger_History_Purchase.

Definition at line 341 of file acc_ledger_history.class.php.

342 {
344 }
$filter_operation
type of ledger VEN , ACH , ODS, FIN

References $filter_operation.

Referenced by build_filter_operation().

◆ get_from()

Acc_Ledger_History::get_from ( )

setter / getter

Returns
m_from (periode id)

Definition at line 68 of file acc_ledger_history.class.php.

69 {
70 return $this->m_from;
71 }
$m_from
Starting Periode : periode.p_id.

References $m_from.

◆ get_ledger()

Acc_Ledger_History::get_ledger ( )

setter / getter

Returns
ma_ledger (array)

Definition at line 100 of file acc_ledger_history.class.php.

101 {
102 return $this->ma_ledger;
103 }
$ma_ledger
Array of ledger id : jrn_def.jrn_def_id.

References $ma_ledger.

◆ get_ledger_type()

Acc_Ledger_History::get_ledger_type ( )

Definition at line 72 of file acc_ledger_history.class.php.

References $ledger_type.

◆ get_mode()

Acc_Ledger_History::get_mode ( )

setter / getter

Returns
m_mode (A,L,E,D)

Definition at line 108 of file acc_ledger_history.class.php.

109 {
110 return $this->m_mode;
111 }
$m_mode
mode of export L : one line, E accounting writing , D : Detail

References $m_mode.

◆ get_row()

Acc_Ledger_History::get_row ( $p_limit,
$p_offset )
abstract

◆ get_tiers()

Acc_Ledger_History::get_tiers ( $p_jrn_type,
$jr_id )

Retrieve the third : supplier for purchase, customer for sale, bank for fin,.

Parameters
$p_jrn_typetype of the ledger FIN, VEN ACH or ODS
$jr_idjrn.jr_id
Todo
duplicate function , also in Acc_Ledger\get_tiers, remove one

Definition at line 228 of file acc_ledger_history.class.php.

229 {
230 if ($p_jrn_type=='ODS')
231 return ' ';
232 $tiers=$this->get_tiers_id($p_jrn_type, $jr_id);
233 if ($tiers==0)
234 return "";
235
236 $name=$this->db->get_value('select ad_value from fiche_detail where ad_id=1 and f_id=$1',
237 array($tiers));
238 $first_name=$this->db->get_value('select ad_value from fiche_detail where ad_id=32 and f_id=$1',
239 array($tiers));
240 return $name.' '.$first_name;
241 }
$jr_id
get_tiers_id($p_jrn_type, $jr_id)
Return the f_id of the tiers , called by get_tiers.

References $jr_id, $name, $tiers, db, and get_tiers_id().

Referenced by Acc_Ledger_History_Generic\export_oneline_html().

+ Here is the call graph for this function:

◆ get_tiers_id()

Acc_Ledger_History::get_tiers_id ( $p_jrn_type,
$jr_id )

Return the f_id of the tiers , called by get_tiers.

Parameters
$p_jrn_typetype of the ledger FIN, VEN ACH or ODS
$jr_idjrn.jr_id

Definition at line 248 of file acc_ledger_history.class.php.

249 {
250 $tiers=0;
251 switch ($p_jrn_type)
252 {
253 case 'VEN':
254 $tiers=$this->db->get_value('select max(qs_client) '
255 . 'from quant_sold join jrnx using (j_id) '
256 . 'join jrn on (jr_grpt_id=j_grpt) where jrn.jr_id=$1',
257 array($jr_id));
258 break;
259 case 'ACH':
260 $tiers=$this->db->get_value('select max(qp_supplier) '
261 . ' from quant_purchase '
262 . ' join jrnx using (j_id) '
263 . ' join jrn on (jr_grpt_id=j_grpt) '
264 . ' where jrn.jr_id=$1',
265 array($jr_id));
266
267 break;
268 case 'FIN':
269 $tiers=$this->db->get_value('select qf_other from quant_fin where jr_id=$1',
270 array($jr_id));
271 break;
272 }
273 if ($this->db->count()==0)
274 return 0;
275 return $tiers;
276 }

References $jr_id, $tiers, and db.

Referenced by get_tiers().

◆ get_to()

Acc_Ledger_History::get_to ( )

setter / getter

Returns
m_to (periode id)

Definition at line 92 of file acc_ledger_history.class.php.

93 {
94 return $this->m_to;
95 }
$m_to
Ending Periode : periode.p_id.

References $m_to.

◆ has_other_tax()

Acc_Ledger_History::has_other_tax ( )

count the number of addition tax for the ledger

Returns
integer

Definition at line 364 of file acc_ledger_history.class.php.

365 {
366 $str_ledger=join(',',$this->ma_ledger);
367 $count=$this->db->get_value("select count(*)
368 from jrn_tax
369 join jrnx using (j_id)
370 join jrn on (jr_grpt_id=j_grpt)
371 where jr_tech_per>=$1 and jr_tech_per <=$2
372 and jr_def_id in ($str_ledger) ",[$this->m_from,$this->m_to]);
373 return $count;
374 }
$count

References $count, and db.

Referenced by Acc_Ledger_History_Purchase\export_csv(), Acc_Ledger_History_Sale\export_csv(), Acc_Ledger_History_Purchase\export_oneline_html(), and Acc_Ledger_History_Sale\export_oneline_html().

◆ prepare_reconcile_date()

Acc_Ledger_History::prepare_reconcile_date ( )
protected

Prepare the query for fetching the linked operation @staticvar int $prepare.

Definition at line 283 of file acc_ledger_history.class.php.

284 {
285 static $not_done=TRUE;
286 if ($not_done ) {
287 $prepare_query = new Prepared_Query($this->db);
288 $prepare_query->prepare_reconcile_date();
289 }
290 $not_done=FALSE;
291 }

References db.

Referenced by Acc_Ledger_History_Purchase\export_csv(), Acc_Ledger_History_Sale\export_csv(), Acc_Ledger_History_Purchase\export_detail_html(), Acc_Ledger_History_Sale\export_detail_html(), Acc_Ledger_History_Purchase\export_extended_html(), Acc_Ledger_History_Sale\export_extended_html(), Acc_Ledger_History_Financial\export_oneline_html(), Acc_Ledger_History_Purchase\export_oneline_html(), and Acc_Ledger_History_Sale\export_oneline_html().

◆ set_a_ledger()

Acc_Ledger_History::set_a_ledger ( $ma_ledger)

setter ma_ledger (array of jrn_def_id)

Definition at line 131 of file acc_ledger_history.class.php.

132 {
133 if (is_array($ma_ledger)==FALSE)
134 throw new Exception(_("invalid parameter"), EXC_PARAM_VALUE);
135 $this->ma_ledger=$ma_ledger;
136 return $this;
137 }

References $ma_ledger, _, and EXC_PARAM_VALUE.

◆ set_filter_operation()

Acc_Ledger_History::set_filter_operation ( $filter_operation)

Filter operation ,.

Parameters
string$filter_operation,valid: all, paid, unpaid

Definition at line 350 of file acc_ledger_history.class.php.

351 {
352 if (in_array($filter_operation,['all','paid','unpaid']))
353 {
354 $this->filter_operation=$filter_operation;
355 return $this;
356 }
357 throw new Exception(_("Filter invalide ".$filter_operation),5);
358 }

References $filter_operation, and _.

◆ set_from()

Acc_Ledger_History::set_from ( $m_from)

setter m_from (periode id)

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

116 {
117 $this->m_from=$m_from;
118 return $this;
119 }

References $m_from.

◆ set_ledger_type()

Acc_Ledger_History::set_ledger_type ( $ledger_type)

Definition at line 77 of file acc_ledger_history.class.php.

78 {
79 if (! in_array($ledger_type,['ACH','ODS','VEN','FIN'])) {
80 record_log('Acc_Ledger_History:set_ledger_type '.var_export($ledger_type,TRUE));
81 throw new Exception (_("Donnée invalide",EXC_PARAM_VALUE));
82 }
83
84 $this->ledger_type=$ledger_type;
85 return $this;
86 }
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...

References $ledger_type, _, EXC_PARAM_VALUE, and record_log().

+ Here is the call graph for this function:

◆ set_m_mode()

Acc_Ledger_History::set_m_mode ( $m_mode)

Setter.

Parameters
$m_modeD,A,L,E
Returns
$this
Exceptions
Exception

Definition at line 144 of file acc_ledger_history.class.php.

145 {
146 if ($m_mode!='E'&&$m_mode!='D'&&$m_mode!='L'&&$m_mode!='A')
147 throw new Exception(_("invalid parameter"), EXC_PARAM_VALUE);
148 $this->m_mode=$m_mode;
149 return $this;
150 }

References $m_mode, _, and EXC_PARAM_VALUE.

◆ set_to()

Acc_Ledger_History::set_to ( $m_to)

setter m_to (periode id)

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

124 {
125 $this->m_to=$m_to;
126 return $this;
127 }

References $m_to.

Field Documentation

◆ $db

Acc_Ledger_History::$db

database connx

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

◆ $filter_operation

Acc_Ledger_History::$filter_operation
protected

type of ledger VEN , ACH , ODS, FIN

to filter paid, unpaid or all operation

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

Referenced by get_filter_operation(), Acc_Ledger_History_Purchase\get_filter_operation(), and set_filter_operation().

◆ $ledger_type

Acc_Ledger_History::$ledger_type
protected

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

Referenced by get_ledger_type(), and set_ledger_type().

◆ $m_from

Acc_Ledger_History::$m_from
protected

Starting Periode : periode.p_id.

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

Referenced by get_from(), and set_from().

◆ $m_mode

Acc_Ledger_History::$m_mode
protected

mode of export L : one line, E accounting writing , D : Detail

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

Referenced by get_mode(), and set_m_mode().

◆ $m_to

Acc_Ledger_History::$m_to
protected

Ending Periode : periode.p_id.

Definition at line 36 of file acc_ledger_history.class.php.

Referenced by get_to(), and set_to().

◆ $ma_ledger

Acc_Ledger_History::$ma_ledger
protected

Array of ledger id : jrn_def.jrn_def_id.

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

Referenced by get_ledger(), and set_a_ledger().


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