예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function calculate($base, TaxRateInterface $rate)
 {
     if ($rate->isIncludedInPrice()) {
         return (int) round($base - $base / (1 + $rate->getAmount()));
     }
     return (int) round($base * $rate->getAmount());
 }
예제 #2
0
 function it_calculates_correct_tax_for_given_base_if_rate_is_included_in_price(TaxRateInterface $rate)
 {
     $rate->isIncludedInPrice()->willReturn(true);
     $rate->getAmount()->willReturn(0.23);
     $this->calculate(10000, $rate)->shouldReturn(1870);
     $rate->getAmount()->willReturn(0.2);
     $this->calculate(315, $rate)->shouldReturn(53);
 }