It is now possible to select a different currency if desired (issue #37).

This commit is contained in:
James Cole
2015-01-30 18:09:13 +01:00
parent 7752329b94
commit 5a890c5c3a
8 changed files with 51 additions and 14 deletions

View File

@@ -94,14 +94,12 @@ class TransactionCurrency implements TransactionCurrencyInterface, CommonDatabas
* Returns an object with id $id.
*
* @param int $objectId
* @throws NotImplementedException
* @codeCoverageIgnore
*
* @return \Eloquent
*/
public function find($objectId)
{
throw new NotImplementedException;
return \TransactionCurrency::find($objectId);
}
/**

View File

@@ -102,7 +102,7 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
public function update(Eloquent $model, array $data)
{
$journalType = $this->getJournalType($data['what']);
$currency = $this->getJournalCurrency($data['currency']);
$currency = $this->getJournalCurrencyById($data['transaction_currency_id']);
$model->description = $data['description'];
$model->date = $data['date'];
@@ -304,6 +304,19 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
return $currencyRepository->findByCode($currency);
}
/**
* @param int $currencyId
*
* @return null|\TransactionCurrency
*/
public function getJournalCurrencyById($currencyId)
{
/** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencyRepository */
$currencyRepository = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
return $currencyRepository->find($currencyId);
}
/**
* @SuppressWarnings("CamelCase") // I'm fine with this.
*

View File

@@ -30,8 +30,8 @@ class Form
$value = self::fillFieldValue($name, $value);
$options['step'] = 'any';
$options['min'] = '0.01';
$defaultCurrency = \Amount::getDefaultCurrency();
$currencies = \TransactionCurrency::where('name', '!=', $defaultCurrency->name)->get();
$defaultCurrency = isset($options['currency']) ? $options['currency'] : \Amount::getDefaultCurrency();
$currencies = \TransactionCurrency::orderBy('code','ASC')->get();
$html = \View::make('form.amount', compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
return $html;
@@ -141,7 +141,7 @@ class Form
$value = self::fillFieldValue($name, $value);
$options['step'] = 'any';
$defaultCurrency = \Amount::getDefaultCurrency();
$currencies = \TransactionCurrency::where('name', '!=', $defaultCurrency->name)->get();
$currencies = \TransactionCurrency::orderBy('code','ASC')->get();
$html = \View::make('form.balance', compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
return $html;
}