noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Tax_Detail Class Reference
+ Collaboration diagram for Tax_Detail:

Public Member Functions

 __construct ($tva_code, $from, $to, $ledger_id)
 
 button_export_csv ()
 
 csv ()
 export the result in a CSV file
 
 get_data ()
 get data
 
 html ()
 display the result in HTML
 

Static Public Member Functions

static display_form ()
 display a form for giving tva_code and dates
 

Protected Attributes

 $from
 Start date.
 
 $ledger_id
 ledger_id (jrn_def.jrn_def_id) -1, means all ledger Sale + Purchase
 
 $to
 end date
 
 $tva_code
 tva_code
 

Detailed Description

Definition at line 25 of file tax_detail.class.php.

Constructor & Destructor Documentation

◆ __construct()

Tax_Detail::__construct ( $tva_code,
$from,
$to,
$ledger_id )

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

32 {
33
34 $this->tva_code=$tva_code;
35 $this->from=$from;
36 $this->to=$to;
37 $this->ledger_id=$ledger_id;
38
39 }
$anc_grandlivre to
$anc_grandlivre from
$ledger_id
ledger_id (jrn_def.jrn_def_id) -1, means all ledger Sale + Purchase
$from
Start date.

References $from, $ledger_id, $to, $tva_code, from, and to.

Member Function Documentation

◆ button_export_csv()

Tax_Detail::button_export_csv ( )

Definition at line 152 of file tax_detail.class.php.

153 {
154 require NOALYSS_TEMPLATE."/tax_detail-button_export_csv.php";
155 }

◆ csv()

Tax_Detail::csv ( )

export the result in a CSV file

Definition at line 160 of file tax_detail.class.php.

160 {
161 $noalyss_csv=new Noalyss_Csv(sprintf("tax_detail-{$this->tva_code}-{$this->from}-{$this->to}"));
162 $data=$this->get_data();
163
164 $header=[_("date"),_('piece'),_("n° interne"),_("fiche"),_("poste"),_("base"),_("privé"),_("code tva"),_("taux"),_("montant tva"),_("non deductible"),_("recup")];
165 $noalyss_csv->send_header();
166 $noalyss_csv->write_header($header );
167 foreach ($data as $item) {
168
169 $noalyss_csv->add($item['str_date']);
170 $noalyss_csv->add($item['jr_pj_number']);
171 $noalyss_csv->add($item['jr_internal']);
172 $noalyss_csv->add($item['j_qcode']);
173 $noalyss_csv->add($item['j_poste']);
174 $noalyss_csv->add(nb($item['j_montant'],2),"number");
175 $noalyss_csv->add(nb($item['qp_dep_priv'],2),"number");
176 $noalyss_csv->add($item['tva_code']);
177 $noalyss_csv->add(nb($item['tva_rate'],2),"number");
178 $noalyss_csv->add(nb($item['vat_amount'],2),"number");
179 $noalyss_csv->add(nb($item['qp_nd_tva'],2),"number");
180 $noalyss_csv->add(nb($item['qp_nd_tva_recup'],2),"number");
181 $noalyss_csv->write();
182
183 }
184 }
nb($p_number)
format the number for the CSV export
_("actif, passif,charge,...")
get_data()
get data
if(count($a_accounting)==0) $header

References $data, $header, _, get_data(), and nb().

+ Here is the call graph for this function:

◆ display_form()

static Tax_Detail::display_form ( )
static

display a form for giving tva_code and dates

Returns
void

Definition at line 45 of file tax_detail.class.php.

46 {
47 require_once NOALYSS_TEMPLATE."/tax_detail-display_form.php";
48 }

◆ get_data()

Tax_Detail::get_data ( )

get data

Definition at line 53 of file tax_detail.class.php.

54 {
55 global $g_user,$cn;
56 $filter_ledger=" where ";
57
58
59 // Security
60 if ($g_user->get_status_security_ledger()==1 && $g_user->isAdmin()==0) {
61 $sSecurity=$g_user->get_ledger_sql('ALL')." and ";
62 $sSecurity=str_replace('jrn_def_id','v1.jr_def_id',$sSecurity);
63 $filter_ledger.=$sSecurity;
64 }
65
66 // filter on the date
67 $filter_ledger.=" jr_date >= to_date ($1,'DD.MM.YYYY') and jr_date <= to_date($2,'DD.MM.YYYY')";
68
69 // SQL index of array for array used in DatabaseCore::get_array
70 $param_idx=3;
71 $aParameter=array($this->from,$this->to);
72
73 // filter on vat_code
74 if ( !empty($this->tva_code ) )
75 {
76 $acc_tva=Acc_Tva::build($cn, $this->tva_code);
77 $filter_ledger.=" and tva_opid = \$$param_idx ";
78 $aParameter[]=$acc_tva->tva_id;
79 $param_idx++;
80 }
81 // filter on the ledger
82 if ( $this->ledger_id <> -1 ) {
83 $filter_ledger.= " and jr_def_id = \$$param_idx";
84 $param_idx++;
85 $aParameter[]=$this->ledger_id;
86
87 }
88 $sql="
89with v_amount_tva as (select
90 f_id
91 ,j_qcode
92 ,case when j_debit is true then 0-j_montant else j_montant end j_montant
93 , qp_vat_code tva_opid
94 , 0-qp_nd_tva qp_nd_tva
95 , 0-qp_nd_tva_recup qp_nd_tva_recup
96 , 0-qp_dep_priv qp_dep_priv
97 , qp_vat_sided
98 , j_poste
99 , j_debit
100 , j_text
101 , jr2.jr_id
102 , jr2.jr_pj_number
103 , jr2.jr_internal
104 ,jr2.jr_date
105 ,to_char(jr2.jr_date,'DD.MM.YY') str_date
106 ,jr_def_id
107 ,0-qp_vat vat_amount
108 from jrnx jr1
109 join jrn jr2 on (jr1.j_grpt = jr2.jr_grpt_id)
110 join quant_purchase q1 using (j_id)
111 union all
112 select f_id
113 ,j_qcode
114 ,case when j_debit is true then 0-j_montant else j_montant end
115 , qs_vat_code
116 , 0
117 , 0
118 , 0
119 , 0
120 , j_poste
121 , j_debit
122 , j_text
123 , jr4.jr_id
124 , jr4.jr_pj_number
125 , jr4.jr_internal
126 ,jr4.jr_date
127 ,to_char(jr4.jr_date,'DD.MM.YY')
128 ,jr_def_id
129 ,qs_vat
130 from jrnx jr3
131 join jrn jr4 on (jr3.j_grpt = jr4.jr_grpt_id)
132 join quant_sold qs using (j_id)
133 )
134select *, tva_label,format ('%s (%s)',t1.tva_code ,t1.tva_label) tva_code,tva_rate
135from v_amount_tva v1
136join tva_rate t1 on (v1.tva_opid=t1.tva_id)
137$filter_ledger
138order by jr_date,j_debit
139 ";
140 $data=$cn->get_array($sql,$aParameter);
141 return $data;
142 }
global $g_user
if no group available , then stop
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.
$filter_ledger
Definition preod.inc.php:39

References $cn, $data, $filter_ledger, $g_user, $ledger_id, $sql, Acc_Tva\build(), from, and to.

Referenced by csv(), and html().

+ Here is the call graph for this function:

◆ html()

Tax_Detail::html ( )

display the result in HTML

Returns
void

Definition at line 147 of file tax_detail.class.php.

147 {
148 global $data;
149 $data=$this->get_data();
150 require NOALYSS_TEMPLATE."/tax_detail-html.php";
151 }

References $data, and get_data().

+ Here is the call graph for this function:

Field Documentation

◆ $from

Tax_Detail::$from
protected

Start date.

Definition at line 27 of file tax_detail.class.php.

Referenced by __construct().

◆ $ledger_id

Tax_Detail::$ledger_id
protected

ledger_id (jrn_def.jrn_def_id) -1, means all ledger Sale + Purchase

Definition at line 30 of file tax_detail.class.php.

Referenced by __construct(), and get_data().

◆ $to

Tax_Detail::$to
protected

end date

Definition at line 28 of file tax_detail.class.php.

Referenced by __construct().

◆ $tva_code

Tax_Detail::$tva_code
protected

tva_code

Definition at line 29 of file tax_detail.class.php.

Referenced by __construct().


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