58 'amount_vat'=>
'amount_vat',
59 'amount_vat_rate'=>
'amount_vat_rate',
61 'nd_vat_rate'=>
'nd_vat_rate',
62 'nd_ded_vat'=>
'nd_ded_vat',
63 'nd_ded_vat_rate'=>
'nd_ded_vat_rate',
64 'amount_nd'=>
'amount_nd',
65 'amount_nd_rate'=>
'amount_nd_rate',
66 'nd_vat_rate'=>
'nd_vat_rate',
67 'amount_perso'=>
'amount_perso',
68 'amount_perso_rate'=>
'amount_perso_rate',
69 'amount_currency'=>
'amount_currency',
70 'amount_vat_currency'=>
'amount_vat_currency',
71 'currency_rate'=>
'currency_rate'
92 $this->amount=bcdiv($this->amount,$this->currency_rate,6);
93 $this->amount_currency=$local_amount;
97 $local_amount=$this->amount_vat;
98 $this->amount_vat=bcdiv($this->amount_vat,$this->currency_rate,6);
99 $this->amount_vat_currency=$local_amount;
109 throw new Exception (__FILE__.
":".__LINE__._(
'Erreur attribut inexistant'));
116 $this->
$idx=$p_value;
119 throw new Exception (__FILE__.
":".__LINE__._(
'Erreur attribut inexistant'));
129 if ( $this->check && $this->order != 0 )
throw new Exception (
'ORDER NOT RESPECTED');
130 $this->amount_vat=bcmul($this->amount,$this->amount_vat_rate);
131 $this->amount_vat=round($this->amount_vat,2);
132 $this->amount_vat_currency=bcmul($this->amount_vat,$this->currency_rate);
140 if ( $this->check && $this->order > 2 )
throw new Exception (
'ORDER NOT RESPECTED');
142 $this->amount_nd=bcmul($this->amount,$this->amount_nd_rate);
143 $this->amount_nd=bcdiv($this->amount_nd,100);
144 $this->amount_nd=round($this->amount_nd,2);
146 $nd_vat=bcmul($this->amount_vat,$this->amount_nd_rate);
147 $nd_vat=bcdiv($nd_vat,100);
148 $nd_vat=round($nd_vat,2);
153 if ( $this->check && $this->order > 3 )
throw new Exception (
'ORDER NOT RESPECTED');
157 $this->nd_vat=bcmul($this->amount_vat,$this->nd_vat_rate);
158 $this->nd_vat=bcdiv($this->nd_vat,100);
159 $this->nd_vat=round($this->nd_vat,2);
164 if ( $this->check && $this->order > 4 )
throw new Exception (
'ORDER NOT RESPECTED');
168 $this->nd_ded_vat=bcmul($this->amount_vat,$this->nd_ded_vat_rate);
169 $this->nd_ded_vat=bcdiv($this->nd_ded_vat,100);
170 $this->nd_ded_vat=round($this->nd_ded_vat,2);
175 if ( $this->check && $this->order != 1 )
throw new Exception (
'ORDER NOT RESPECTED');
177 if ( $this->amount == 0 )
return;
178 $this->amount_perso=bcmul($this->amount,$this->amount_perso_rate);
179 $this->amount_perso=bcdiv($this->amount_perso,100);
180 $this->amount_perso=round($this->amount_perso,2);
187 $this->amount=bcsub($this->amount,$this->amount_perso);
189 $this->amount=bcsub($this->amount,$this->amount_nd);
190 $this->amount_vat=bcsub($this->amount_vat,$this->nd_ded_vat);
191 $this->amount_vat=round($this->amount_vat,2);
192 $this->amount_vat=bcsub($this->amount_vat,$this->nd_vat);
193 $this->amount_vat=round($this->amount_vat,2);
210 throw new Exception (_(
"Montant invalide"));
212 if ( $p_obj !=
null )
215 foreach ( array(
'amount',
'amount_vat',
'amount_nd',
'nd_vat',
'amount_perso',
'nd_ded_vat') as
$value)
216 $sum=bcadd($sum,$this->$value);
217 if ( $p_obj->amount_vat == 0 ) $p_obj->compute_vat();
218 $cmp=bcadd($p_obj->amount,$p_obj->amount_vat);
219 $diff=bcsub($sum,$cmp);
221 throw new Exception (_(
"ECHEC VERIFICATION : valeur totale = $sum valeur attendue = $cmp diff = $diff"));
228 echo
'key '.$key.
' Description '.
$value.
' value is '.$this->$key.
'<br>';
241 $a->set_parameter(
'amount',1.23);
242 $a->set_parameter(
'amount_vat_rate',0.21);
244 echo
'<h1> Test VAT </h1>';
245 echo
'<h2> Data </h2>';
248 echo
'<h2> Result </h2>';
254 $a->set_parameter(
'amount',1.23);
255 $a->set_parameter(
'amount_vat_rate',0.21);
256 $a->set_parameter(
'amount_perso_rate',0.5);
257 echo
'<h1> Test VAT + Perso</h1>';
258 echo
'<h2> Data </h2>';
264 echo
'<h2> Result </h2>';
270 $a->set_parameter(
'amount',1.23);
271 $a->set_parameter(
'amount_vat_rate',0.21);
272 $a->set_parameter(
'nd_vat_rate',0.5);
274 echo
'<h1> Test VAT + ND VAT</h1>';
275 echo
'<h2> Data </h2>';
278 $a->compute_nd_vat();
280 echo
'<h2> Result </h2>';
286 $a->set_parameter(
'amount',1.23);
287 $a->set_parameter(
'amount_vat_rate',0.21);
288 $a->set_parameter(
'nd_vat_rate',0.5);
289 $a->set_parameter(
'amount_perso_rate',0.5);
292 echo
'<h1> Test VAT + ND VAT + perso</h1>';
293 echo
'<h2> Data </h2>';
297 $a->compute_nd_vat();
299 echo
'<h2> Result </h2>';
304 $a->set_parameter(
'amount',1.23);
305 $a->set_parameter(
'amount_vat_rate',0.21);
306 $a->set_parameter(
'amount_nd_rate',0.5);
309 echo
'<h1> Test VAT + ND </h1>';
310 echo
'<h2> Data </h2>';
316 $a->compute_nd_vat();
318 echo
'<h2> Result </h2>';
324 $a->set_parameter(
'amount',1.23);
325 $a->set_parameter(
'amount_vat_rate',0.21);
326 $a->set_parameter(
'amount_nd_rate',0.5);
327 $a->set_parameter(
'amount_perso_rate',0.2857);
329 echo
'<h1> Test VAT + ND + Perso</h1>';
330 echo
'<h2> Data </h2>';
336 $a->compute_nd_vat();
338 echo
'<h2> Result </h2>';
344 $a->set_parameter(
'amount',1.23);
345 $a->set_parameter(
'amount_vat_rate',0.21);
346 $a->set_parameter(
'nd_ded_vat_rate',0.5);
349 echo
'<h1> Test VAT + TVA ND DED</h1>';
350 echo
'<h2> Data </h2>';
356 $a->compute_nd_vat();
357 $a->compute_ndded_vat();
359 echo
'<h2> Result </h2>';
this class aims to compute different amount
set_parameter($p_string, $p_value)
compute_nd()
Compute the no deductible part of the amount, it reduce also the vat.