/**
  * @param TransactionCurrency $currency
  * @param array               $data
  *
  * @return TransactionCurrency
  */
 public function update(TransactionCurrency $currency, array $data)
 {
     $currency->code = $data['code'];
     $currency->symbol = $data['symbol'];
     $currency->name = $data['name'];
     $currency->save();
     return $currency;
 }
 public function run()
 {
     DB::table('transaction_currencies')->delete();
     TransactionCurrency::create(['code' => 'EUR', 'name' => 'Euro', 'symbol' => '€']);
     TransactionCurrency::create(['code' => 'USD', 'name' => 'US Dollar', 'symbol' => '$']);
     TransactionCurrency::create(['code' => 'HUF', 'name' => 'Hungarian forint', 'symbol' => 'Ft']);
 }
Esempio n. 3
0
 /**
  * @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;
 }
 public function run()
 {
     DB::table('transaction_currencies')->delete();
     TransactionCurrency::create(['code' => 'EUR', 'name' => 'Euro', 'symbol' => '€']);
     TransactionCurrency::create(['code' => 'USD', 'name' => 'US Dollar', 'symbol' => '$']);
     TransactionCurrency::create(['code' => 'HUF', 'name' => 'Hungarian forint', 'symbol' => 'Ft']);
     TransactionCurrency::create(['code' => 'BRL', 'name' => 'Real', 'symbol' => 'R$']);
     TransactionCurrency::create(['code' => 'GBP', 'name' => 'British Pound', 'symbol' => '£']);
 }
Esempio n. 5
0
 /**
  * @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;
 }
 /**
  * @return array
  */
 public function getMap() : array
 {
     $currencies = TC::get();
     $list = [];
     foreach ($currencies as $currency) {
         $list[$currency->id] = $currency->name . ' (' . $currency->code . ')';
     }
     asort($list);
     $list = [0 => trans('csv.do_not_map')] + $list;
     return $list;
 }
Esempio n. 7
0
 /**
  *
  */
 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]);
 }
Esempio n. 8
0
 /**
  * @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;
 }
Esempio n. 9
0
 /**
  * @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);
 }
Esempio n. 10
0
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('attachment', function ($value) {
    if (Auth::check()) {
        $object = Attachment::where('id', $value)->where('user_id', Auth::user()->id)->first();
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('currency', function ($value) {
    if (Auth::check()) {
        $object = TransactionCurrency::find($value);
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('bill', function ($value) {
    if (Auth::check()) {
        $object = Bill::where('id', $value)->where('user_id', Auth::user()->id)->first();
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Esempio n. 11
0
 /**
  * @return mixed|static
  */
 public function getDefaultCurrency()
 {
     $currencyPreference = Prefs::get('currencyPreference', 'EUR');
     $currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
     return $currency;
 }