コード例 #1
0
 public function testDontDecreaseTodays_ButForecast_Purchases()
 {
     $purchase_service = new \shina\controlmybudget\PurchaseService($this->data_provider, new Date('2014-08-01'));
     $purchase = new \shina\controlmybudget\Purchase\Purchase();
     $purchase->date = new Date('2014-08-02');
     $purchase->place = 'foo';
     $purchase->amount = 10;
     $purchase_service->save($purchase, $this->user);
     $monthly_goal = new \shina\controlmybudget\MonthlyGoal\MonthlyGoal();
     $monthly_goal->month = 8;
     $monthly_goal->year = 2014;
     $monthly_goal->amount_goal = 1510;
     $monthly_goal->events = [];
     $goalr = new Goalr(new Date('2014-08-02'));
     $budget_control_service = new \shina\controlmybudget\BudgetControlService($this->purchase_service, $goalr);
     $this->assertEquals(50, $budget_control_service->getDailyMonthlyBudget($monthly_goal, $this->user));
 }
コード例 #2
0
 public function testGetForecastAmountByPeriod()
 {
     $purchase_service = new \shina\controlmybudget\PurchaseService($this->data_provider, new Date('2014-08-15'));
     $purchase = new \shina\controlmybudget\Purchase\Purchase();
     $purchase->date = new DateTime('2014-08-10');
     $purchase->place = 'Zona Sul';
     $purchase->amount = 2.1;
     $purchase_service->save($purchase, $this->user);
     $purchase = new \shina\controlmybudget\Purchase\Purchase();
     $purchase->date = new DateTime('2014-08-15');
     $purchase->place = 'Natalandia';
     $purchase->amount = 300;
     $purchase_service->save($purchase, $this->user);
     $purchase = new \shina\controlmybudget\Purchase\Purchase();
     $purchase->date = new DateTime('2014-08-18');
     $purchase->place = 'Casa do carnaval';
     $purchase->amount = 54.7;
     $purchase_service->save($purchase, $this->user);
     $amount = $purchase_service->getForecastAmountByPeriod(new DateTime('2014-08-01'), new DateTime('2014-08-31'), $this->user);
     $this->assertEquals(54.7, $amount);
 }