27 require_once(
'class_listing.php');
28 require_once(NOALYSS_INCLUDE.
'/class/class_fiche.php');
29 require_once(
'class_tva_parameter.php');
33 "date_decl"=>
"date_decl",
34 "start_periode"=>
"start_periode",
35 "end_periode"=>
"end_periode",
36 "xml_file"=>
"xml_file",
41 "flag_periode"=>
"flag_periode",
42 "exercice"=>
"exercice",
43 "periode_dec"=>
"periode_dec"
49 $year =
new IText(
'year');
54 $str_submit=HtmlInput::submit(
'decl',_(
'Afficher'));
55 $str_hidden=HtmlInput::extension().dossier::hidden();
58 $r=
'<form class="print" method="get">';
59 $r.=
"Année :".$str_year;
62 $r.=HtmlInput::request_to_hidden(array(
'ac'));
68 if ( isset($p_array[
'name_child'])) {
69 $name=$p_array[
'name_child'];
70 $qcode=$p_array[
'qcode'];
71 $code=$p_array[
'plugin_code'];
72 $tva_num=$p_array[
'tva_num_child'];
74 $amount_vat=$p_array[
'amount_vat'];
77 for ($i=0;$i<count(
$name);$i++){
79 $child->set_parameter(
'amount',
$amount[$i]);
80 $child->set_parameter(
'amount_vat',$amount_vat[$i]);
81 $child->set_parameter(
'qcode',$qcode[$i]);
82 $child->set_parameter(
'name_child',
$name[$i]);
83 $child->set_parameter(
'tva_num',$tva_num[$i]);
89 $this->aChild=array();
91 $this->start_periode=$p_array[
'start_periode'];
92 $this->end_periode=$p_array[
'end_periode'];
93 $this->flag_periode=$p_array[
'flag_periode'];
94 $this->tva_name=$p_array[
'name'];
95 $this->num_tva=$p_array[
'num_tva'];
96 $this->adress=$p_array[
'adress'];
97 $this->country=$p_array[
'country'];
98 $this->periode_dec=$p_array[
'periode_dec'];
99 $this->exercice=$p_array[
'exercice'];
102 $r=
'<form class="print" id="readonly">';
103 $r.=HtmlInput::request_to_hidden(array(
'ac'));
107 $js_remove=sprintf(
"onclick=\"if ( confirm('%s')){remove_form('%s',%d,%d,'lc');}\"",
108 "Vous confirmez vouloir effacer ?",
112 $r.=HtmlInput::button(
'Effacer',
'Effacer',$js_remove);
114 $r.= create_script(
"$('readonly').disable();");
118 $sql=
"select * from tva_belge.assujetti where a_id=$1";
120 $res=$this->db->get_array(
124 if ( $this->db->count() == 0 )
return 0;
125 foreach (
$res[0] as $idx=>$value) { $this->$idx=$value; }
127 $sql=
"select * from tva_belge.assujetti_chld where a_id=$1";
128 $res=$this->db->get_array(
132 $nb=$this->db->count();
135 for ($i=0;$i<$nb;$i++){
137 foreach (
$res[$i] as $idx=>$value){
154 INSERT INTO tva_belge.assujetti(
155 start_date, end_date, periodicity, tva_name,
156 num_tva, adress, country, periode_dec,exercice)
157 VALUES (to_date($1,
'DD.MM.YYYY'),to_date($2,
'DD.MM.YYYY'),$3,$4,$5,$6,$7,$8,$9) returning
a_id;
159 $this->a_id=$this->db->get_value(
$sql,
161 $this->start_periode,
173 for ($e=0;$e<count($this->aChild);$e++){
174 $this->aChild[$e]->set_parameter(
'depend',$this->a_id);
175 $this->aChild[$e]->insert();
185 $code_customer=
new Acc_Parm_Code($this->db);
186 $code_customer->p_code=
'CUSTOMER';
187 $code_customer->load();
189 if (trim(
$a)==
'')
$a=-1;
191 select sum(j_montant) as amount,j_qcode
193 where j_grpt in (select distinct j_grpt from quant_sold join jrnx
using (j_id) where qs_vat_code in (
$a) )
194 and j_poste::text like $1||
'%'
195 and (j_date >= to_date($2,
'DD.MM.YYYY') and j_date <= to_date($3,
'DD.MM.YYYY'))
199 $all=$this->db->get_array(
$sql,array($code_customer->p_value,
200 $this->start_periode,
207 for ($i=0;$i<count($all);$i++){
211 $child->set_parameter(
'qcode',$all[$i][
'j_qcode']);
212 $fiche=
new Fiche($this->db);
213 $fiche->get_by_qcode($all[$i][
'j_qcode'],
false);
214 $num_tva=
$fiche->strAttribut(ATTR_DEF_NUMTVA);
215 $child->set_parameter(
'tva_num',$num_tva);
216 $sq=
"select sum(qs_vat) from quant_sold
217 where qs_client = $1 and j_id in (select distinct j_id from jrnx where j_date >= to_date($2,'DD.MM.YYYY')
218 and j_date <= to_date($3,'DD.MM.YYYY')
220 and qs_vat_code in ($a)
224 $exclude=
"select coalesce(sum(qs_price),0) from quant_sold
225 where qs_client = $1 and j_id in (select distinct j_id from jrnx where j_date >= to_date($2,'DD.MM.YYYY')
226 and j_date <= to_date($3,'DD.MM.YYYY')
228 and qs_vat_code not in ($a)
230 $excl=$this->db->get_value($exclude,array(
$fiche->id,
231 $this->start_periode,
232 $this->end_periode));
233 $amount_vat=$this->db->get_value($sq,array(
$fiche->id,
234 $this->start_periode,
235 $this->end_periode));
236 $amount=$all[$i][
'amount']-$amount_vat-$excl;
237 $child->set_parameter(
'amount',
$amount);
238 $child->set_parameter(
'amount_vat',$amount_vat);
240 $child->set_parameter(
'name_child',
$fiche->strAttribut(ATTR_DEF_NAME));
250 $res=
'<fieldset><legend>Listing</legend>';
251 $res.=
'<table id="tb_dsp" class="result" style="width:80%;">';
252 $clean=
new IButton(
'rm_b');
253 $clean->label=
'Efface ligne';
254 $clean->javascript=
"deleteRow('tb_dsp',this);";
259 $r.=th(
'Code Pays et numéro de TVA');
260 $r.=th(
'montant CA');
261 $r.=th(
'montant TVA');
265 for ($i=0;$i<count($this->aChild);$i++) {
267 $b=
new IText(
'name_child[]',$this->aChild[$i]->
get_parameter(
'name_child'));
268 $c=
new IText(
'tva_num_child[]',$this->aChild[$i]->
get_parameter(
'tva_num'));
269 $e=
new INum(
'amount[]',$this->aChild[$i]->
get_parameter(
'amount'));
270 $d=
new INum(
'amount_vat[]',$this->aChild[$i]->
get_parameter(
'amount_vat'));
273 $amount_vat+=round($this->aChild[$i]->
get_parameter(
'amount_vat'),2);
279 if (! $readonly)
$r.=td($clean->input());
289 $r.=td(hb(sprintf(
'%.02f',$amount_vat)));
302 "tva_num"=>
"ac_tvanum",
303 "amount"=>
"ac_amount",
304 "amount_vat"=>
"ac_vat",
307 "name_child"=>
'ac_name'
312 INSERT INTO tva_belge.assujetti_chld(
313 a_id, ac_tvanum, ac_amount, ac_vat, ac_qcode,
315 VALUES ($1, $2, $3, $4, $5, $6) returning ac_id;
317 $this->ic_id=$this->db->get_value(
$sql,array(
static choose_periode($by_year=false)
display_info()
display the information about the company
if(isset($_POST['remove'])) $array
display_declaration_amount($readonly=false)
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_amount from amortissement amortissement_histo where a_id