/**
  * @covers Acc_Compute::compute_nd
  * @todo   Implement testCompute_nd().
  */
 public function testCompute_nd()
 {
     $this->object->set_parameter('amount', 1.23);
     $this->object->set_parameter('amount_vat_rate', 0.21);
     $this->object->set_parameter('amount_nd_rate', 50);
     $this->object->check = false;
     $this->object->compute_nd();
     $this->assertEquals($this->object->amount_nd, 0.62);
 }
 public static function test_me()
 {
     $a = new Acc_Compute();
     echo $a->get_info();
     echo '<hr>';
     // Compute some operation to see if the computed amount are
     // correct
     //Test VAT
     $a->set_parameter('amount', 1.23);
     $a->set_parameter('amount_vat_rate', 0.21);
     echo '<h1> Test VAT </h1>';
     echo '<h2> Data </h2>';
     $a->display();
     echo '<h2> Result </h2>';
     $a->compute_vat();
     $a->display();
     $a->verify();
     // Test VAT + perso
     $a = new Acc_Compute();
     $a->set_parameter('amount', 1.23);
     $a->set_parameter('amount_vat_rate', 0.21);
     $a->set_parameter('amount_perso_rate', 0.5);
     echo '<h1> Test VAT + Perso</h1>';
     echo '<h2> Data </h2>';
     $a->display();
     $b = clone $a;
     $a->compute_vat();
     $a->compute_perso();
     $a->correct();
     echo '<h2> Result </h2>';
     $a->display();
     $a->verify($b);
     // TEST VAT + ND
     // Test VAT + perso
     $a = new Acc_Compute();
     $a->set_parameter('amount', 1.23);
     $a->set_parameter('amount_vat_rate', 0.21);
     $a->set_parameter('nd_vat_rate', 0.5);
     $b = clone $a;
     echo '<h1> Test VAT + ND VAT</h1>';
     echo '<h2> Data </h2>';
     $a->display();
     $a->compute_vat();
     $a->compute_nd_vat();
     $a->correct();
     echo '<h2> Result </h2>';
     $a->display();
     $a->verify($b);
     // TEST VAT + ND
     // Test VAT + perso
     $a = new Acc_Compute();
     $a->set_parameter('amount', 1.23);
     $a->set_parameter('amount_vat_rate', 0.21);
     $a->set_parameter('nd_vat_rate', 0.5);
     $a->set_parameter('amount_perso_rate', 0.5);
     $b = clone $a;
     echo '<h1> Test VAT + ND VAT + perso</h1>';
     echo '<h2> Data </h2>';
     $a->display();
     $a->compute_vat();
     $a->compute_perso();
     $a->compute_nd_vat();
     $a->correct();
     echo '<h2> Result </h2>';
     $a->display();
     $a->verify($b);
     // TEST VAT + ND
     $a = new Acc_Compute();
     $a->set_parameter('amount', 1.23);
     $a->set_parameter('amount_vat_rate', 0.21);
     $a->set_parameter('amount_nd_rate', 0.5);
     $b = clone $a;
     echo '<h1> Test VAT + ND </h1>';
     echo '<h2> Data </h2>';
     $a->display();
     $a->compute_vat();
     $a->compute_nd();
     $a->compute_perso();
     $a->compute_nd_vat();
     $a->correct();
     echo '<h2> Result </h2>';
     $a->display();
     $a->verify($b);
     // TEST VAT + ND
     // + Perso
     $a = new Acc_Compute();
     $a->set_parameter('amount', 1.23);
     $a->set_parameter('amount_vat_rate', 0.21);
     $a->set_parameter('amount_nd_rate', 0.5);
     $a->set_parameter('amount_perso_rate', 0.2857);
     $b = clone $a;
     echo '<h1> Test VAT + ND  + Perso</h1>';
     echo '<h2> Data </h2>';
     $a->display();
     $a->compute_vat();
     $a->compute_nd();
     $a->compute_perso();
     $a->compute_nd_vat();
     $a->correct();
     echo '<h2> Result </h2>';
     $a->display();
     $a->verify($b);
     // TEST VAT + ND
     // + Perso
     $a = new Acc_Compute();
     $a->set_parameter('amount', 1.23);
     $a->set_parameter('amount_vat_rate', 0.21);
     $a->set_parameter('nd_ded_vat_rate', 0.5);
     $b = clone $a;
     echo '<h1> Test VAT   +  TVA ND DED</h1>';
     echo '<h2> Data </h2>';
     $a->display();
     $a->compute_vat();
     $a->compute_nd();
     $a->compute_perso();
     $a->compute_nd_vat();
     $a->compute_ndded_vat();
     $a->correct();
     echo '<h2> Result </h2>';
     $a->display();
     $a->verify($b);
 }
 /**
  * Compute the ND amount thanks the attribute of the concerned card. The object 
  * $p_nd_amount will changed
  * 
  * @param Acc_Compute $p_nd_amount object with ND amount
  * @param Fiche $p_fiche Concerned Card (purchase items)
  * @param type $p_tva_bot 0 TVA on one side, 1 TVA on both side
  */
 private function compute_no_deductible(Acc_Compute $p_nd_amount, Fiche $p_fiche)
 {
     if (!$p_fiche->empty_attribute(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE)) {
         $p_nd_amount->amount_nd_rate = $p_fiche->strAttribut(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE);
         $p_nd_amount->compute_nd();
     }
     if (!$p_fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE)) {
         $p_nd_amount->nd_vat_rate = $p_fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE);
         $p_nd_amount->compute_nd_vat();
     }
     if (!$p_fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP)) {
         $p_nd_amount->nd_ded_vat_rate = $p_fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
         $p_nd_amount->compute_ndded_vat();
     }
     if (!$p_fiche->empty_attribute(ATTR_DEF_DEP_PRIV)) {
         $p_nd_amount->amount_perso_rate = $p_fiche->strAttribut(ATTR_DEF_DEP_PRIV);
         $p_nd_amount->compute_perso();
     }
 }