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

this class extends PDF and let you export the detailled printing of any ledgers More...

+ Inheritance diagram for Print_Ledger_Simple:
+ Collaboration diagram for Print_Ledger_Simple:

Public Member Functions

 __construct ($p_cn, Acc_Ledger $p_jrn, $p_from, $p_to, $p_filter_operation)
 
 export ()
 export the ledger in PDF
 
 Footer ()
 write the Footer
 
 Header ()
 write the header of each page
 
 setDossierInfo ($dossier="n/a")
 
- Public Member Functions inherited from Print_Ledger
 __construct (\Database $p_cn, $orientation, $unit, $format, Acc_Ledger $p_ledger, $p_from, $p_to, $p_filter_operation)
 
 get_filter_operation ()
 
 get_from ()
 
 get_ledger ()
 
 get_to ()
 
 set_filter_operation ($filter_operation)
 Filter the operations ,.
 
 set_from ($from)
 
 set_ledger ($ledger)
 
 set_to ($to)
 
- Public Member Functions inherited from PDF
 __construct (Database $p_cn, $orientation='P', $unit='mm', $format='A4')
 
 get_tiers ($p_jr_id, $p_jrn_type)
 retrieve the client name and quick_code
 
- Public Member Functions inherited from PDF_Core
 __construct ( $orientation='P', $unit='mm', $format='A4')
 
 fill_row ($enable)
 set color for row ,
 
 get_margin_bottom ()
 
 get_margin_left ()
 
 get_margin_right ()
 
 get_margin_top ()
 
 get_orientation ()
 
 get_page_size ()
 
 get_unit ()
 
 is_fill ($p_step)
 If the step is even then return 1 and set the backgroup color to blue , otherwise returns 0, and set the background color to white It is use to compute alternated colored row , it the parameter fill in write_cell and cell.
 
 line_new ($p_step=null)
 Print all the cell stored and call Ln (new line)
 
 LongLine ($w, $h, $txt, $border=0, $align='', $fill=false)
 add a cell with automatic return to the line if the text is too long, deprecated , it calls only PDFCore::write_cell_
 
 write_cell ($width, $height=0, $txt='', $border=0, $interline=0, $align='', $fill=false, $link='')
 add a cell the text is not cut and don't return to this line if too large
 
 write_multi ($width, $interline, $txt, $border=0, $align='', $fill=false)
 add a cell with automatic return to the line if the text is too long
 

Additional Inherited Members

- Static Public Member Functions inherited from Print_Ledger
static available_ledger ($get_from_periode)
 find all the active ledger for the exerice of the periode and readable by the current user @global type $g_user
 
static factory (Database $cn, $p_type_export, Acc_Ledger $p_ledger, $p_from, $p_to, $p_filter_operation)
 Create an object Print_Ledger* depending on $p_type_export ( 0 => accounting 1-> one row per operation 2-> detail of item)
 
- Static Public Member Functions inherited from PDF
static test_me ()
 test the class
 
- Data Fields inherited from PDF
 $cn = null
 
 $date = ""
 
 $dossier = "n/a"
 
 $own = null
 
 $soc = ""
 
- Protected Member Functions inherited from Print_Ledger
 build_filter_operation ()
 Build a SQL clause to filter operation depending if they are paid, unpaid or no filter.
 
- Protected Member Functions inherited from PDF_Core
 add_cell (Cellule $Ce)
 
 check_page_add ()
 Check if a page must be added due a MultiCell.
 
 count_nb_row ($p_text, $p_colSize)
 Count the number of rows a p_text will take for a multicell.
 
 print_row ()
 print the current array of cell and reset it , if different colors are set on the same row you have to print it before changing
 
- Protected Attributes inherited from Print_Ledger
 $a_Tva
 $other_tax_previous (array)
 
 $filter_operation
 See Acc_Ledger_History::filter_operation.
 
 $flag_other_tax
 $flag_other_tax(bool) true if other tax exists
 
 $from
 
 $jrn_type
 
 $ledger
 concerned Ledger
 
 $other_tax_previous
 
 $previous
 internal variables for computing sum on PDF Listing
 
 $rap_htva
 $previous (array) see Acc_Ledger->previous_amount
 
 $rap_nd
 $rap_nd (float) $no-deductible tax
 
 $rap_other
 VAT when page starts.
 
 $rap_other_tax
 $rap_other_tav, amount to report for other tax than VAT
 
 $rap_priv
 $rap_priv (float) personal expense
 
 $rap_tva
 $rap_tva array(tva_id,amount)
 
 $rap_tva_np
 $rap_tva_np VAT not deductible
 
 $rap_tvac
 $rap_tvac (float) previous amount
 
 $show_col
 
 $to
 
 $tp_htva
 $tp_htva (float) total page price w/o VAT
 
 $tp_nd
 $tp_nd (float) total page price w/o VAT
 
 $tp_priv
 $tp_priv (float) total page personal expense
 
 $tp_tva
 $tp_tva (float) total page VAT
 
 $tp_tva_np
 $tp_tva_np (float) total page not deductible
 
 $tp_tvac
 $tp_tvac (float) total page full price All Tax Incl.
 
- Protected Attributes inherited from PDF_Core
 $bigger
 
 $cells =array()
 

Detailed Description

this class extends PDF and let you export the detailled printing of any ledgers

Definition at line 33 of file print_ledger_simple.class.php.

Constructor & Destructor Documentation

◆ __construct()

Print_Ledger_Simple::__construct ( $p_cn,
Acc_Ledger $p_jrn,
$p_from,
$p_to,
$p_filter_operation )

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

38 {
39
40 parent::__construct($p_cn,'L', 'mm', 'A4',$p_jrn,$p_from,$p_to,$p_filter_operation);
41
42 $this->a_Tva=$this->get_ledger()->existing_vat();
43 foreach($this->a_Tva as $line_tva)
44 {
45 //initialize Amount TVA
46 $tmp1=$line_tva['tva_id'];
47 $this->rap_tva[$tmp1]=0;
48 }
49 $this->rap_other_tax=0;
50 $this->jrn_type=$p_jrn->get_type();
51 //----------------------------------------------------------------------
52 /* report
53 *
54 * get rappel to initialize amount rap_xx
55 *the easiest way is to compute sum from quant_
56 */
57 $from_periode=$this->get_from();
58 $this->previous=$this->get_ledger()->previous_amount($from_periode);
59 $this->other_tax_previous=$this->get_ledger()->previous_other_tax($from_periode);
60
61 /* initialize the amount to report */
62 foreach($this->previous['tva'] as $line_tva)
63 {
64 //initialize Amount TVA
65 $tmp1=$line_tva['tva_id'];
66 $this->rap_tva[$tmp1]=$line_tva['sum_vat'];
67 }
68
69 $this->rap_htva=$this->previous['price'];
70 $this->rap_tvac=bcadd($this->previous['price'],$this->previous['vat']);
71 $this->rap_tvac=bcadd($this->rap_tvac,$this->previous['tva_nd']);
72 $this->rap_tvac=bcsub($this->rap_tvac,$this->previous['tva_np']);
73 $this->rap_tvac=bcsub($this->rap_tvac,$this->previous['reversed']);
74 $this->rap_priv=$this->previous['priv'];
75 $this->rap_nd=$this->previous['tva_nd'];
76 $this->rap_tva_np=$this->previous['tva_np'];
77 $this->flag_other_tax=false;
78
79 if ($this->jrn_type == 'ACH' || $this->jrn_type=='VEN') {
80 $periode=new Periode($p_cn,$p_from);
81 $first_date=$periode->first_day();
82 $periode=new Periode($p_cn,$p_to);
83 $last_date=$periode->last_day();
84
85 $count=$this->cn->get_value("
86 select count(*)
87 from jrn_tax join jrnx using (j_id)
88 join jrn on (j_grpt=jr_grpt_id) where
89 j_date >= to_date($1,'DD.MM.YYYY')
90 and j_date <= to_date($2,'DD.MM.YYYY')
91 and j_jrn_def=$3",
92 array($first_date,$last_date,$p_jrn->id));
93 if ($count>0) { $this->flag_other_tax=true;}
94 }
95 }
$input_from cn
$count

References $count, $from_periode, $p_jrn, $periode, cn, Print_Ledger\get_from(), and Print_Ledger\get_ledger().

+ Here is the call graph for this function:

Member Function Documentation

◆ export()

Print_Ledger_Simple::export ( )

export the ledger in PDF

Definition at line 255 of file print_ledger_simple.class.php.

256 {
257 bcscale(4);
258 $ledger=$this->get_ledger();
259 $ledger_history=Acc_Ledger_History::factory($this->cn,
260 array($ledger->id),
261 $this->get_from(),
262 $this->get_to(),
263 'D',
264 $this->get_filter_operation());
265 $ledger_history->get_row();
266 $a_jrn=$ledger_history->get_data();
267
268 if ( $a_jrn == null ) return;
269
270 // Count the number of VAT cols
271 $flag_tva=(count($this->a_Tva) > 4)?true:false;
272
273 // Prepare the query for reconcile date
274 $prepared_query=new Prepared_Query($ledger->db);
275 $prepared_query->prepare_reconcile_date();
276
277 for ( $i=0;$i<count($a_jrn);$i++)
278 {
279 /* initialize tva */
280 for ($f=0;$f<count($this->a_Tva);$f++)
281 {
282 $l=$this->a_Tva[$f]['tva_id'];
283 $atva_amount[$l]=0;
284 }
285
286 // retrieve info from ledger
287 $aAmountVat=$ledger->vat_operation($a_jrn[$i]['jr_grpt_id']);
288
289 // put vat into array
290 for ($f=0;$f<count($aAmountVat);$f++)
291 {
292 $l=$aAmountVat[$f]['tva_id'];
293 $atva_amount[$l]=bcadd($atva_amount[$l],$aAmountVat[$f]['sum_vat']);
294 $this->tp_tva[$l]=bcadd($this->tp_tva[$l],$aAmountVat[$f]['sum_vat']);
295 $this->rap_tva[$l]=bcadd($this->rap_tva[$l],$aAmountVat[$f]['sum_vat']);
296
297 }
298 $row=$a_jrn[$i];
299 $ret_reconcile=$ledger->db->execute('reconcile_date',array($row['jr_id']));
300 $this->write_multi(15,5,($row['jr_pj_number']),0);
301 $this->write_multi(11,5,$row['str_date_short'],0,0);
302 $this->write_cell(13,5,$row['jr_internal'],0,0);
303 list($qc,$name)=$this->get_tiers($row['jr_id'],$this->jrn_type);
304 $this->write_multi(40,5,"[".$qc."]".$name,0,'L');
305
306 if ( !$flag_tva ) {
307 $this->write_multi(65,5,mb_substr($row['jr_comment'],0,150),0,'L');
308 }
309
310 /* get other amount (without vat, total vat included, private, ND */
311 $other=$ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
312
313 $this->write_cell(15,5,nbm($other['price']),0,0,'R');
314
315 if ( $ledger_history->get_ledger_type() !='VEN')
316 {
317 $this->write_cell(15,5,nbm($other['priv']),0,0,'R');
318 $this->write_cell(15,5,nbm($other['tva_nd']),0,0,'R');
319 }
320
321 $this->write_cell(15,5,nbm($other['tva_np']),0,0,'R');
322
323 foreach ($atva_amount as $row_atva_amount)
324 {
325 $this->write_cell(15, 5, nbm($row_atva_amount), 0, 0, 'R');
326 }
327
328 $l_tvac=bcadd($other['price'], bcsub($other['vat'],$other['tva_np']));
329 $l_tvac=bcadd($l_tvac,$other['tva_nd']);
330 $l_tvac=bcadd($l_tvac,$a_jrn[$i]['other_tax_amount']);
331 if ($this->flag_other_tax) {
332 $this->write_cell(15, 5, nbm($a_jrn[$i]['other_tax_amount']), 0, 0, 'R');
333 }
334 $this->write_cell(15,5,nbm($l_tvac),0,0,'R');
335 $this->line_new(2);
336 // Add the payment information on another row
338 $str_payment="";
339 if ($max > 0) {
340 $this->write_cell(15,5, _("Payé par"));
341 $sep="";
342 for ($e=0;$e<$max;$e++) {
344 $msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]".$row['qcode_name']:$row['jr_internal'];
345 $str_payment=$row['jr_date'].$msg.$sep;
346 $sep=' , ';
347 }
348 $this->write_cell (120,5,$str_payment);
349 }
350
351
352 $this->line_new(3);
353 // Total page
354 $this->tp_htva=bcadd($this->tp_htva,$other['price']);
355 $this->tp_tvac=bcadd($this->tp_tvac,$other['price']);
356 $this->tp_tvac=bcadd($this->tp_tvac,$other['vat']);
357 $this->tp_tvac=bcadd($this->tp_tvac,$other['tva_nd']);
358 $this->tp_tvac=bcsub($this->tp_tvac,$other['tva_np']);
359 $this->tp_tva_np=bcadd($this->tp_tva_np,$other['tva_np']);
360 $this->tp_priv=bcadd($this->tp_priv,$other['priv']);
361 $this->tp_nd=bcadd($this->tp_nd,$other['tva_nd']);
362
363
364 // Total report
365 $this->rap_htva=bcadd($this->rap_htva,$other['price']);
366 $this->rap_tvac=bcadd($this->rap_tvac,$other['price']);
367 $this->rap_tvac=bcadd($this->rap_tvac,$other['vat']);
368 $this->rap_tvac=bcsub($this->rap_tvac,$other['tva_np']);
369 $this->rap_tvac=bcadd($this->rap_tvac,$other['tva_nd']);
370 $this->rap_priv=bcadd($this->rap_priv,$other['priv']);
371 $this->rap_nd=bcadd($this->rap_nd,$other['tva_nd']);
372 $this->rap_tva_np=bcadd($this->rap_tva_np,$other['tva_np']);
373
374 if ($this->flag_other_tax) {
375 $this->tp_other_tax = bcadd($this->tp_other_tax, $a_jrn[$i]['other_tax_amount']);
376 $this->rap_other_tax = bcadd($this->rap_other_tax, $a_jrn[$i]['other_tax_amount']);
377 }
378
379 }
380 }
nbm($p_number, $p_dec=2)
format the number with a sep.
_("actif, passif,charge,...")
static factory(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode, $p_paid)
Build the right object.
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
line_new($p_step=null)
Print all the cell stored and call Ln (new line)
write_cell($width, $height=0, $txt='', $border=0, $interline=0, $align='', $fill=false, $link='')
add a cell the text is not cut and don't return to this line if too large
write_multi($width, $interline, $txt, $border=0, $align='', $fill=false)
add a cell with automatic return to the line if the text is too long
get_tiers($p_jr_id, $p_jrn_type)
retrieve the client name and quick_code
Definition pdf.class.php:84
$ledger
concerned Ledger

References $e, $f, $i, $l, Print_Ledger\$ledger, $max, $msg, $name, $other, $ret_reconcile, $row, $sep, _, cn, Acc_Ledger_History\factory(), DatabaseCore\fetch_array(), Print_Ledger\get_ledger(), PDF\get_tiers(), PDF_Core\line_new(), nbm(), DatabaseCore\num_row(), PDF_Core\write_cell(), and PDF_Core\write_multi().

+ Here is the call graph for this function:

◆ Footer()

Print_Ledger_Simple::Footer ( )

write the Footer

Reimplemented from PDF.

Definition at line 189 of file print_ledger_simple.class.php.

190 {
191 //Position at 3 cm from bottom
192 $this->SetY(-20);
193 /* write reporting */
194 $flag_tva=(count($this->a_Tva) > 4)?true:false;
195 if ( ! $flag_tva)
196 $this->Cell(143,6,'Total page ','T',0,'R'); /* HTVA */
197 else
198 $this->Cell(78,6,'Total page ','T',0,'R'); /* HTVA */
199
200 $this->Cell(15,6,nbm($this->tp_htva),'T',0,'R'); /* HTVA */
201 if ( $this->jrn_type !='VEN')
202 {
203 $this->Cell(15,6,nbm($this->tp_priv),'T',0,'R'); /* prive */
204 $this->Cell(15,6,nbm($this->tp_nd),'T',0,'R'); /* Tva ND */
205 }
206 $this->Cell(15,6,nbm($this->tp_tva_np),'T',0,'R'); /* Tva Unpaid */
207 foreach($this->a_Tva as $line_tva)
208 {
209 $l=$line_tva['tva_id'];
210 $this->Cell(15,6,nbm($this->tp_tva[$l]),'T',0,'R');
211 }
212 if ($this->flag_other_tax) {
213 $this->Cell(15, 6, nbm($this->tp_other_tax), 'T', 0, 'R'); /* Tvac */
214 }
215 $this->Cell(15,6,nbm($this->tp_tvac),'T',0,'R'); /* Tvac */
216 $this->Ln(2);
217 $flag_tva=(count($this->a_Tva) > 4)?true:false;
218
219 if ( ! $flag_tva)
220 $this->Cell(143,6,'report',0,0,'R');
221 else
222 $this->Cell(78,6,'report',0,0,'R');
223
224 $this->Cell(15,6,nbm($this->rap_htva),0,0,'R'); /* HTVA */
225 if ( $this->jrn_type !='VEN')
226 {
227 $this->Cell(15,6,nbm($this->rap_priv),0,0,'R'); /* prive */
228 $this->Cell(15,6,nbm($this->rap_nd),0,0,'R'); /* Tva ND */
229 }
230 $this->Cell(15,6,nbm($this->rap_tva_np),0,0,'R'); /* Tva ND */
231
232 foreach($this->a_Tva as $line_tva)
233 {
234 $l=$line_tva['tva_id'];
235 $this->Cell(15,6,nbm($this->rap_tva[$l]),0,0,'R');
236 }
237 if ($this->flag_other_tax) {
238 $this->Cell(15, 6, nbm($this->rap_other_tax), 0, 0, 'R'); /* Other tax */
239 }
240 $this->Cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
241 $this->Ln(2);
242
243 //Arial italic 8
244 $this->SetFont('Arial', 'I', 8);
245 //Page number
246 $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
247 // Created by NOALYSS
248 $this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
249 }

References $l, and nbm().

+ Here is the call graph for this function:

◆ Header()

Print_Ledger_Simple::Header ( )

write the header of each page

Reimplemented from PDF.

Definition at line 104 of file print_ledger_simple.class.php.

105 {
106 //Arial bold 12
107 $this->SetFont('DejaVu', 'B', 12);
108 //Title
109 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
110 //Line break
111 $this->Ln(20);
112 $this->SetFont('DejaVu', 'B', 8);
113 /* column header */
114 //----------------------------------------------------------------------
115 // Show column header, if $flag_tva is false then display vat as column
116 foreach($this->a_Tva as $line_tva)
117 {
118 //initialize Amount TVA
119 $tmp1=$line_tva['tva_id'];
120 $this->rap_tva[$tmp1]=(isset($this->rap_tva[$tmp1]))?$this->rap_tva[$tmp1]:0;
121 }
122 $this->Cell(15,6,_('Pièce'));
123 $this->Cell(10,6,_('Date'));
124 $this->Cell(13,6,_('ref'));
125 if ( $this->jrn_type=='ACH')
126 $this->Cell(40,6,_('Client'));
127 else
128 $this->Cell(40,6,_('Fournisseur'));
129
130 $flag_tva=(count($this->a_Tva) > 4)?true:false;
131 if ( !$flag_tva ) $this->Cell(65,6,_('Description'));
132
133 $this->Cell(15,6,_('HTVA'),0,0,'R');
134 if ( $this->jrn_type=='ACH')
135 {
136 $this->Cell(15,6,_('Priv/DNA'),0,0,'R');
137 $this->Cell(15,6,_('TVA ND'),0,0,'R');
138 }
139 $this->Cell(15,6,_('TVA NP'),0,0,'R'); // Unpaid TVA --> autoliquidation, NPR
140 foreach($this->a_Tva as $line_tva)
141 {
142 $this->Cell(15,6,$line_tva['tva_label'],0,0,'R');
143 }
144 if ($this->flag_other_tax) {
145 $this->Cell(15,6,'Autre Tx',0,0,'R');
146
147 }
148 $this->Cell(15,6,'TVAC',0,0,'R');
149 $this->Ln(5);
150
151 $this->SetFont('DejaVu','',6);
152 // page Header
153 if ( ! $flag_tva)
154 $this->Cell(143,6,'report',0,0,'R');
155 else
156 $this->Cell(78,6,'report',0,0,'R');
157 $this->Cell(15,6,nbm($this->rap_htva),0,0,'R'); /* HTVA */
158 if ( $this->jrn_type != 'VEN')
159 {
160 $this->Cell(15,6,nbm($this->rap_priv),0,0,'R'); /* prive */
161 $this->Cell(15,6,nbm($this->rap_nd),0,0,'R'); /* Tva ND */
162 }
163 $this->Cell(15,6,nbm($this->rap_tva_np),0,0,'R'); /* Tva ND */
164 foreach($this->rap_tva as $line_tva)
165 $this->Cell(15,6,nbm($line_tva),0,0,'R');
166 if ($this->flag_other_tax) {
167 $this->Cell(15, 6, nbm($this->rap_other_tax), 0, 0, 'R'); /* Other tax */
168 }
169 $this->Cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
170
171 $this->Ln(6);
172 //total page
173 $this->tp_htva=0.0;
174 $this->tp_tvac=0.0;
175 $this->tp_priv=0;
176 $this->tp_nd=0;
177 $this->tp_tva_np=0;
178 $this->tp_other_tax=0;
179 foreach($this->a_Tva as $line_tva)
180 {
181 //initialize Amount TVA
182 $tmp1=$line_tva['tva_id'];
183 $this->tp_tva[$tmp1]=0.0;
184 }
185 }

References _, and nbm().

+ Here is the call graph for this function:

◆ setDossierInfo()

Print_Ledger_Simple::setDossierInfo ( $dossier = "n/a")

Reimplemented from PDF.

Definition at line 97 of file print_ledger_simple.class.php.

98 {
99 $this->dossier = dossier::name()." ".$dossier;
100 }
$dossier
Definition pdf.class.php:38

References PDF\$dossier.


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