/** * @param Preference $preference * * @return TransactionCurrency */ public function getCurrencyByPreference(Preference $preference) { $preferred = TransactionCurrency::whereCode($preference->data)->first(); if (is_null($preferred)) { $preferred = TransactionCurrency::first(); } return $preferred; }
/** * @return TransactionCurrency */ public function convert() { if (isset($this->mapped[$this->index][$this->value])) { $currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]); } else { $currency = TransactionCurrency::whereCode($this->value)->first(); } return $currency; }
/** * @return array */ public function process() { // fix currency if (is_null($this->data['currency'])) { $currencyPreference = Preferences::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR')); $this->data['currency'] = TransactionCurrency::whereCode($currencyPreference->data)->first(); } return $this->data; }
/** * */ protected function createPiggyBankEvent() { // piggy bank event // add money to this piggy bank // create a piggy bank event to match: $checking = $this->findAccount('Checking account'); $savings = $this->findAccount('Savings account'); $transfer = TransactionType::whereType('Transfer')->first(); $euro = TransactionCurrency::whereCode('EUR')->first(); $groceries = $this->findBudget('Groceries'); $house = $this->findCategory('House'); $piggyBank = $this->findPiggyBank('New camera'); $intoPiggy = $this->createJournal(['from' => $checking, 'to' => $savings, 'amount' => 100, 'transactionType' => $transfer, 'description' => 'Money for piggy', 'date' => $this->yaeom, 'transactionCurrency' => $euro, 'category' => $house, 'budget' => $groceries]); PiggyBankEvent::create(['piggy_bank_id' => $piggyBank->id, 'transaction_journal_id' => $intoPiggy->id, 'date' => $this->yaeom, 'amount' => 100]); }
/** * @return mixed|static */ public function getDefaultCurrency() { $cache = new CacheProperties(); $cache->addProperty('getDefaultCurrency'); if ($cache->has()) { return $cache->get(); } $currencyPreference = Prefs::get('currencyPreference', 'EUR'); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); $cache->store($currency); return $currency; }
/** * @covers FireflyIII\Support\Amount::getDefaultCurrency */ public function testGetDefaultCurrency() { // will the the euro: $eur = TransactionCurrency::whereCode('EUR')->first(); $result = $this->object->getDefaultCurrency(); $this->assertEquals($eur->id, $result->id); }
/** * @return mixed|static */ public function getDefaultCurrency() { $currencyPreference = Prefs::get('currencyPreference', 'EUR'); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); return $currency; }