Beispiel #1
0
 public function it_returns_VAT_if_revenue_set_as_repeatable_and_months_are_the_same(Revenue $revenue, DateTime $date)
 {
     $date->format('n')->shouldBeCalled()->willReturn(7);
     $revenue->getVATCalculationMonth()->shouldBeCalled()->willReturn(7);
     $revenue->getDate()->willReturn(new DateTime('2014-07-23'));
     $revenue->isRepeating()->willReturn(true);
     $revenue->getVAT()->shouldBeCalled()->willReturn(231);
     $this->getVAT($revenue, $date)->shouldReturn(231);
 }
Beispiel #2
0
 /**
  * Get VAT from revenue/expense based on a date of interest and revenue/expense repeat status
  *
  * @param  Expense|Revenue $moneyType
  * @param  DateTime        $date
  * @return double
  */
 public function getVAT($moneyType, DateTime $date)
 {
     if ($moneyType->getVATCalculationMonth() != $date->format('n')) {
         return 0;
     }
     $moneyTypeDate = $moneyType->getDate() ?: $moneyType->getDate(true);
     if (!$moneyType->isRepeating() && $moneyTypeDate->format('Y') != $date->format('Y')) {
         return 0;
     }
     return $moneyType->getVAT();
 }