public function testGeneralUse() { $amount = new Currency(50, 'pt_BR'); $this->assertEquals('R$50,00', (string) $amount); $amount = new Currency(50, 'en_US'); $this->assertEquals('$50.00', (string) $amount); locale_set_default('pt_BR'); $amount = new Currency(-50); $this->assertEquals('(R$50,00)', (string) $amount); $amount = new Currency('(40,00)'); $this->assertEquals('(R$40,00)', (string) $amount); $amount->setFormat('{number} = {symbol}'); $this->assertEquals('(40,00 = R$)', (string) $amount); }
/** * {@inheritDoc} */ public function render() { $dataProvider = new DataProvider(); $budgetControlService = new BudgetControlService(new PurchaseService($dataProvider), new Goalr()); $monthlyGoal = MonthlyGoal::query()->mine()->currentMonth()->first(); if ($monthlyGoal) { $todayBudget = new Currency($budgetControlService->getDailyMonthlyBudget($monthlyGoal, \BackendAuth::getUser())); $todayBudget->setFormat('{number}'); $todaySpent = new Currency(Purchase::calcAmountByPeriod(new \DateTime(), new \DateTime(), \BackendAuth::getUser()->id)); $todaySpent->setFormat('{number}'); $this->vars['todaySpent'] = $todaySpent; $this->vars['todayBudget'] = $todayBudget; return $this->makePartial('dailybudget'); } else { return $this->makePartial('no_monthly_goal'); } }