Beispiel #1
0
 /**
  * @test
  * @dataProvider float_copy
  */
 public function check_float_copy(FN $i, $scale)
 {
     $copy = $i->copy($scale);
     $this->assertSame($i->getValue(), $copy->getValue());
     $this->assertSame($i->getOrigin(), $copy->getOrigin());
     $this->assertEquals($scale, $copy->getScale());
 }
Beispiel #2
0
 /**
  * Calculate the TTC price from HT and TVA
  *
  * @param FloatNumber $ht
  * @param FloatNumber $tva between 0 and 1
  *
  * @return FloatNumber
  */
 public function ttc(FloatNumber $ht, FloatNumber $tva)
 {
     if ($tva->getValue() < 0 || $tva->getValue() > 100) {
         throw new \RuntimeException(sprintf('Tva %.2f should be between 0 and 1', $tva->getValue()));
     }
     if ($ht->getScale() < 4 && $tva->getScale() < 4) {
         $scale = 4;
         //default
     } else {
         $scale = FloatNumber::getScales($ht, $tva)[1];
         //max
     }
     $cht = $ht->copy($scale);
     $ctva = $tva->copy($scale);
     /** @var FloatNumber $res */
     $res = $this->add($cht, $this->mult($cht, $ctva));
     return $res->copy(FloatNumber::getScales($ht, $tva)[0]);
 }