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'
88 if ( array_key_exists($p_string,self::$variable) )
90 $idx=self::$variable[$p_string];
94 throw new Exception (__FILE__.
":".__LINE__._(
'Erreur attribut inexistant'));
98 if ( array_key_exists($p_string,self::$variable) )
100 $idx=self::$variable[$p_string];
101 $this->
$idx=$p_value;
104 throw new Exception (__FILE__.
":".__LINE__._(
'Erreur attribut inexistant'));
110 return var_export(self::$variable,
true);
115 if ( $this->check && $this->order != 0 )
throw new Exception (
'ORDER NOT RESPECTED');
116 $this->amount_vat=bcmul($this->amount,$this->amount_vat_rate);
117 $this->amount_vat=round($this->amount_vat,2);
125 if ( $this->check && $this->order > 2 )
throw new Exception (
'ORDER NOT RESPECTED');
127 $this->amount_nd=bcmul($this->amount,$this->amount_nd_rate);
128 $this->amount_nd=bcdiv($this->amount_nd,100);
129 $this->amount_nd=round($this->amount_nd,2);
131 $nd_vat=bcmul($this->amount_vat,$this->amount_nd_rate);
132 $nd_vat=bcdiv($nd_vat,100);
133 $nd_vat=round($nd_vat,2);
138 if ( $this->check && $this->order > 3 )
throw new Exception (
'ORDER NOT RESPECTED');
142 $this->nd_vat=bcmul($this->amount_vat,$this->nd_vat_rate);
143 $this->nd_vat=bcdiv($this->nd_vat,100);
144 $this->nd_vat=round($this->nd_vat,2);
149 if ( $this->check && $this->order > 4 )
throw new Exception (
'ORDER NOT RESPECTED');
153 $this->nd_ded_vat=bcmul($this->amount_vat,$this->nd_ded_vat_rate);
154 $this->nd_ded_vat=bcdiv($this->nd_ded_vat,100);
155 $this->nd_ded_vat=round($this->nd_ded_vat,2);
160 if ( $this->check && $this->order != 1 )
throw new Exception (
'ORDER NOT RESPECTED');
162 if ( $this->amount == 0 )
return;
163 $this->amount_perso=bcmul($this->amount,$this->amount_perso_rate);
164 $this->amount_perso=bcdiv($this->amount_perso,100);
165 $this->amount_perso=round($this->amount_perso,2);
172 $this->amount=bcsub($this->amount,$this->amount_perso);
174 $this->amount=bcsub($this->amount,$this->amount_nd);
175 $this->amount_vat=bcsub($this->amount_vat,$this->nd_ded_vat);
176 $this->amount_vat=round($this->amount_vat,2);
177 $this->amount_vat=bcsub($this->amount_vat,$this->nd_vat);
178 $this->amount_vat=round($this->amount_vat,2);
195 throw new Exception (_(
"Montant invalide"));
197 if ( $p_obj != null )
200 foreach ( array(
'amount',
'amount_vat',
'amount_nd',
'nd_vat',
'amount_perso',
'nd_ded_vat') as
$value)
201 $sum=bcadd($sum,$this->$value);
202 if ( $p_obj->amount_vat == 0 ) $p_obj->compute_vat();
203 $cmp=bcadd($p_obj->amount,$p_obj->amount_vat);
204 $diff=bcsub($sum,$cmp);
206 throw new Exception (_(
"ECHEC VERIFICATION : valeur totale = $sum valeur attendue = $cmp diff = $diff"));
213 echo
'key '.$key.
' Description '.
$value.
' value is '.$this->
$key.
'<br>';
226 $a->set_parameter(
'amount',1.23);
227 $a->set_parameter(
'amount_vat_rate',0.21);
229 echo
'<h1> Test VAT </h1>';
230 echo
'<h2> Data </h2>';
233 echo
'<h2> Result </h2>';
239 $a->set_parameter(
'amount',1.23);
240 $a->set_parameter(
'amount_vat_rate',0.21);
241 $a->set_parameter(
'amount_perso_rate',0.5);
242 echo
'<h1> Test VAT + Perso</h1>';
243 echo
'<h2> Data </h2>';
249 echo
'<h2> Result </h2>';
255 $a->set_parameter(
'amount',1.23);
256 $a->set_parameter(
'amount_vat_rate',0.21);
257 $a->set_parameter(
'nd_vat_rate',0.5);
259 echo
'<h1> Test VAT + ND VAT</h1>';
260 echo
'<h2> Data </h2>';
263 $a->compute_nd_vat();
265 echo
'<h2> Result </h2>';
271 $a->set_parameter(
'amount',1.23);
272 $a->set_parameter(
'amount_vat_rate',0.21);
273 $a->set_parameter(
'nd_vat_rate',0.5);
274 $a->set_parameter(
'amount_perso_rate',0.5);
277 echo
'<h1> Test VAT + ND VAT + perso</h1>';
278 echo
'<h2> Data </h2>';
282 $a->compute_nd_vat();
284 echo
'<h2> Result </h2>';
289 $a->set_parameter(
'amount',1.23);
290 $a->set_parameter(
'amount_vat_rate',0.21);
291 $a->set_parameter(
'amount_nd_rate',0.5);
294 echo
'<h1> Test VAT + ND </h1>';
295 echo
'<h2> Data </h2>';
301 $a->compute_nd_vat();
303 echo
'<h2> Result </h2>';
309 $a->set_parameter(
'amount',1.23);
310 $a->set_parameter(
'amount_vat_rate',0.21);
311 $a->set_parameter(
'amount_nd_rate',0.5);
312 $a->set_parameter(
'amount_perso_rate',0.2857);
314 echo
'<h1> Test VAT + ND + Perso</h1>';
315 echo
'<h2> Data </h2>';
321 $a->compute_nd_vat();
323 echo
'<h2> Result </h2>';
329 $a->set_parameter(
'amount',1.23);
330 $a->set_parameter(
'amount_vat_rate',0.21);
331 $a->set_parameter(
'nd_ded_vat_rate',0.5);
334 echo
'<h1> Test VAT + TVA ND DED</h1>';
335 echo
'<h2> Data </h2>';
341 $a->compute_nd_vat();
342 $a->compute_ndded_vat();
344 echo
'<h2> Result </h2>';
set_parameter($p_string, $p_value)
this class aims to compute different amount
compute_nd()
Compute the no deductible part of the amount, it reduce also the vat.