50 parent::__construct(
$cn, $pa_ledger, $p_from, $p_to, $p_mode);
51 $this->filter_operation=
'all';
52 $this->ledger_type=
'ACH';
66 $this->ma_ledger, $this->m_from, $this->m_to, $this->m_mode);
67 $ledger_history->export_accounting_html();
77 include NOALYSS_TEMPLATE.
"/acc_ledger_history_purchase_detail.php";
87 include NOALYSS_TEMPLATE.
"/acc_ledger_history_purchase_extended.php";
95 switch ($this->m_mode)
122 require_once NOALYSS_TEMPLATE.
'/acc_ledger_history_purchase_oneline.php';
130 public function get_row($p_limit=-1, $p_offset=
"")
135 $cond_limite=($p_limit!=-1)?
" limit ".$p_limit.
" offset ".$p_offset:
"";
137 $ledger_list=join(
",", $this->ma_ledger);
141 qp_supplier,sum(qp_price) as novat,
143 sum(qp_vat_sided) as tva_sided ,
144 sum(qp_nd_amount) as noded_amount,
145 sum(qp_nd_tva) as noded_vat,
146 sum(qp_dep_priv) as private_amount
148 quant_purchase group by qp_supplier,qp_internal),
150 select x.f_id as f_id,
151 (select ad_value from fiche_detail where ad_id=1 and f_id=x.f_id) as name,
152 (select ad_value from fiche_detail where ad_id=32 and f_id=x.f_id) as first_name,
153 (select ad_value from fiche_detail where ad_id=23 and f_id=x.f_id) as qcode
157 select sum(oc_amount) as sum_oc_amount,sum(oc_vat_amount) as sum_oc_vat_amount,jrnx.j_grpt
160 join jrnx using (j_id)
161 join quant_purchase qp using (j_id)
164 other_tax as (select sum(case when j_debit is true
165 then j_montant else 0-j_montant end) other_tax_amount
168 join jrn_tax jt2 on (j1.j_id=jt2.j_id) group by j_grpt)
175 to_char(jr_date,'DD.MM.YYYY') as str_date,
176 to_char(jr_date,'DDMMYY') as str_date_short,
177 to_char(jr_date_paid,'DD.MM.YYYY') as str_date_paid,
188 novat+vat-tva_sided as tvac,
193 jrn.currency_rate_ref,
197 coalesce (other_tax_amount,0) other_tax_amount
200 join row_purchase on (qp_internal=jr_internal)
201 join supplier_detail on (qp_supplier=f_id)
202 left join jrn_note using (jr_id)
203 left join row_currency as rc on (rc.j_grpt = jrn.jr_grpt_id)
204 left join currency as c on (c.id=jrn.currency_id)
205 left join other_tax as ot on (ot.j_grpt=jrn.jr_grpt_id)
207 jr_def_id in ({$ledger_list})
211 order by jrn.jr_date, substring(jr_pj_number,'[0-9]+$')::numeric ";
212 $this->data=$this->
db->get_array(
$sql);
220 $prepare=$this->
db->is_prepare(
"vat_infop");
223 $this->
db->prepare(
"vat_infop",
226 sum(qp_vat) vat_amount ,
232 group by qp_vat_code order by qp_vat_code");
238 $ret=$this->
db->execute(
"vat_infop",
239 array($this->data[
$i][
"jr_internal"]));
241 $this->data[
$i][
"detail_vat"]=
$array;
251 if ($this->
db->is_prepare(
"detail_purchase")==FALSE)
253 $this->
db->prepare(
"detail_purchase",
256 (select f_id,ad_value as name
257 from fiche_detail where ad_id=1),
259 (select f_id,ad_value as qcode
260 from fiche_detail where ad_id=23)
261 select qp_price,qp_quantite,qp_vat,qp_vat_code,qp_unit,qp_vat_sided,name,qcode,tva_label,
262 qp_price+qp_vat-qp_vat_sided as tvac
265 join jrnx using (j_id)
266 join card_name on (card_name.f_id=qp_fiche)
267 join card_qcode on (card_qcode.f_id=qp_fiche)
268 left join tva_rate on ( qp_vat_code=tva_id)
291 $prepared_query->prepare_reconcile_date();
307 $title[]=_(
"Fournisseur");
313 $title[]=_(
"tva non ded.");
318 if (
$own->MY_TVA_USE==
'Y')
320 $a_Tva=$this->
db->get_array(
"select tva_id,tva_label from tva_rate order by tva_rate,tva_label,tva_id");
321 foreach($a_Tva as $line_tva)
323 $title[]=
"Tva ".$line_tva[
'tva_label'];
326 if ($nb_other_tax>0) {
331 $title[]=_(
"Devise HTVA");
334 $title[]=_(
"Taux utilisé");
335 $title[]=_(
"Date paiement");
336 $title[]=_(
"Code paiement");
337 $title[]=_(
"Méthode paiement");
338 $title[]=_(
"Montant paiement");
339 $title[]=_(
"n° opération");
342 foreach ($this->data as
$line)
349 $line[
"first_name"].
" ".
359 $a_tva_amount=array();
360 if (
$own->MY_TVA_USE==
'Y')
363 foreach ($a_Tva as
$l)
366 $a_tva_amount[$t_id]=0;
368 foreach (
$line[
'detail_vat'] as $lineTVA)
370 $idx_tva=$lineTVA[
'qp_vat_code'];
371 $a_tva_amount[$idx_tva]=$lineTVA[
'vat_amount'];
374 foreach ($a_Tva as $line_tva)
376 $a=$line_tva[
'tva_id'];
377 $export->add($a_tva_amount[
$a],
"number");
380 if ( $nb_other_tax > 0)
sql_filter_per($p_cn, $p_from, $p_to, $p_form='p_id', $p_field='jr_tech_per')
Create the condition to filter on the j_tech_per thanks a from and to date.
manage the list of operation when we need several ledger with a different type or from Misceleaneous ...
Display the operations for Purchase.
export_oneline_html()
display in HTML one operation by line
export_detail_html()
display detail of operations m_mode=D
add_vat_info()
preprare the query for fetching the detailed VAT of an operation
get_row($p_limit=-1, $p_offset="")
Get the rows from jrnx and quant* tables.
get_filter_operation()
Filter operation.
export_accounting_html()
display the accounting
__construct(\Database $cn, $pa_ledger, $p_from, $p_to, $p_mode)
export_html()
display in HTML following the mode
export_extended_html()
display extended details of operation m_mode=E
$data
Contains rows from SQL.
export_csv()
export Purchase in CSV
prepare_detail()
Prepare the query for fetching detail of an operation.
Display history of operation.
has_other_tax()
count the number of addition tax for the ledger
$filter_operation
type of ledger VEN , ACH , ODS, FIN
prepare_reconcile_date()
Prepare the query for fetching the linked operation @staticvar int $prepare.
add_additional_tax_info()
add additional info about additional tax.
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
contains the class for connecting to Noalyss
Manage the CSV : manage files and write CSV record.
Class to manage the company parameter (address, name...)
contains prepared query used in different classes of the application