40 parent::__construct(
$cn, $pa_ledger, $p_from, $p_to, $p_mode);
41 $this->filter_operation=
'all';
42 $this->ledger_type=
'VEN';
54 include NOALYSS_TEMPLATE.
"/acc_ledger_history_sale_detail.php";
62 $this->ma_ledger, $this->m_from, $this->m_to, $this->m_mode);
63 $ledger_history->export_accounting_html();
75 include NOALYSS_TEMPLATE.
"/acc_ledger_history_sale_extended.php";
83 if ( $this->
db->is_prepare(
"detail_sale")== FALSE)
85 $this->
db->prepare(
"detail_sale",
"
87 (select f_id,ad_value as name
88 from fiche_detail where ad_id=1),
90 (select f_id,ad_value as qcode
91 from fiche_detail where ad_id=23)
92 select qs_price,qs_quantite,qs_vat,qs_vat_code,qs_unit,qs_vat_sided,name,qcode,tva_label,
93 qs_price+qs_vat-qs_vat_sided as tvac,
98 join jrnx using (j_id)
99 join card_name on (card_name.f_id=qs_fiche)
100 join card_qcode on (card_qcode.f_id=qs_fiche)
101 left join tva_rate on ( qs_vat_code=tva_id)
102 left join operation_currency using (j_id)
115 public function get_row($p_limit=-1, $p_offset=
"")
120 $cond_limite=($p_limit!=-1)?
" limit ".$p_limit.
" offset ".$p_offset:
"";
124 $ledger_list=join(
",", $this->ma_ledger);
128 qs_client,sum(qs_price) as novat,
130 sum(qs_vat_sided) as tva_sided
132 quant_sold group by qs_client,qs_internal),
134 select x.f_id as f_id,
135 (select ad_value from fiche_detail where ad_id=1 and f_id=x.f_id) as name,
136 (select ad_value from fiche_detail where ad_id=32 and f_id=x.f_id) as first_name,
137 (select ad_value from fiche_detail where ad_id=23 and f_id=x.f_id) as qcode
141 select sum(oc_amount) as sum_oc_amount,sum(oc_vat_amount) as sum_oc_vat_amount,jrnx.j_grpt
144 join jrnx using (j_id)
145 join quant_sold using (j_id)
148 other_tax as (select sum(case when j_debit is false
149 then j_montant else 0-j_montant end) as other_tax_amount,
152 join jrn_tax jt2 on (j1.j_id=jt2.j_id) group by j_grpt)
159 to_char(jr_date,'DD.MM.YYYY') as str_date,
160 to_char(jr_date_paid,'DD.MM.YYYY') as str_date_paid,
168 novat+vat-tva_sided as tvac,
169 to_char(jr_date,'DDMMYY') as str_date_short,
173 jrn.currency_rate_ref,
177 coalesce (other_tax_amount,0) other_tax_amount
180 join row_sale on (qs_internal=jr_internal)
181 join client_detail on (qs_client=f_id)
182 left join row_currency as rc on (rc.j_grpt = jrn.jr_grpt_id)
183 left join currency as c on (c.id=jrn.currency_id)
184 left join other_tax as ot on (ot.j_grpt=jrn.jr_grpt_id)
186 jr_def_id in ({$ledger_list})
190 order by jr_date, substring(jr_pj_number,'[0-9]+$')::numeric ";
191 $this->data=$this->
db->get_array(
$sql);
200 $prepare=$this->
db->is_prepare(
"vat_info");
201 if ( $prepare==FALSE) {
202 $this->
db->prepare(
"vat_info",
"
204 sum(qs_vat) vat_amount ,
210 group by qs_vat_code order by qs_vat_code");
217 $ret=$this->
db->execute(
"vat_info",array($this->data[
$i][
"jr_internal"]));
219 $this->data[
$i][
"detail_vat"]=
$array;
228 switch ($this->m_mode)
255 require_once NOALYSS_TEMPLATE.
'/acc_ledger_history_sale_oneline.php';
290 $title[]=_(
"Fournisseur");
295 $title[]=_(
"TVA annulée");
297 if (
$own->MY_TVA_USE==
'Y')
299 $a_Tva=$this->
db->get_array(
"select tva_id,tva_label from tva_rate order by tva_rate,tva_label,tva_id");
300 foreach($a_Tva as $line_tva)
302 $title[]=
"Tva ".$line_tva[
'tva_label'];
305 if ($nb_other_tax>0) {
310 $title[]=_(
"Devise HTVA");
313 $title[]=_(
"Taux utilisé");
314 $title[]=_(
"Date paiement");
315 $title[]=_(
"Code paiement");
316 $title[]=_(
"Montant paiement");
317 $title[]=_(
"n° opération");
321 foreach ($this->data as
$line)
328 $line[
"first_name"].
" ".
336 $a_tva_amount=array();
338 if (
$own->MY_TVA_USE ==
'Y' )
341 foreach ($a_Tva as
$l) {
343 $a_tva_amount[$t_id]=0;
345 foreach (
$line[
'detail_vat'] as $lineTVA)
347 $idx_tva=$lineTVA[
'qs_vat_code'];
348 $a_tva_amount[$idx_tva]=$lineTVA[
'vat_amount'];
350 foreach ($a_Tva as $line_tva)
352 $a=$line_tva[
'tva_id'];
353 $export->add($a_tva_amount[
$a],
"number");
356 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 ...
Acc_Ledger_History : Manage the list (history) of operations for display.
export_detail_html()
Display the operation of sales with detailled VAT.
export_extended_html()
display the operation with detailled vat per item
add_vat_info()
preprare the query for fetching the detailed VAT of an operation @staticvar int $prepare
get_row($p_limit=-1, $p_offset="")
Get the rows from jrnx and quant* tables.
export_csv()
export in csv with detail VAT
export_html()
display in HTML following the mode
prepare_detail()
Prepare the query for fetching detail of an operation.
$data
Contains rows from SQL.
export_oneline_html()
display in HTML one operation by line
export_accounting_html()
display the accounting
__construct(\Database $cn, $pa_ledger, $p_from, $p_to, $p_mode)
Display history of operation.
has_other_tax()
count the number of addition tax for the ledger
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...)