Various fixes.

This commit is contained in:
James Cole 2016-02-13 13:13:22 +01:00
parent 706b095f95
commit 693ff3cc66
6 changed files with 49 additions and 31 deletions

0
.codeclimate.yml Executable file → Normal file
View File

View File

@ -3,8 +3,8 @@ declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
/**
* Class AssetAccountIban
@ -27,20 +27,29 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
}
if (strlen($this->value) > 0) {
// find or create new account:
$account = $this->findAccount();
$accountType = AccountType::where('type', 'Asset account')->first();
$account = $this->findAccount();
if (is_null($account)) {
// create it if doesn't exist.
$account = Account::firstOrCreateEncrypted( // See issue #180
[
'name' => $this->value,
'iban' => $this->value,
'user_id' => Auth::user()->id,
'account_type_id' => $accountType->id,
'active' => 1,
]
);
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$accountData = [
'name' => $this->value,
'accountType' => 'asset',
'virtualBalance' => 0,
'virtualBalanceCurrency' => 1, // hard coded.
'active' => true,
'user' => Auth::user()->id,
'iban' => null,
'accountNumber' => $this->value,
'accountRole' => null,
'openingBalance' => 0,
'openingBalanceDate' => new Carbon,
'openingBalanceCurrency' => 1, // hard coded.
];
$account = $repository->store($accountData);
}
return $account;

View File

@ -3,6 +3,7 @@ declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
@ -26,7 +27,6 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
return $account;
}
// find or create new account:
$accountType = AccountType::where('type', 'Asset account')->first();
$set = Auth::user()->accounts()->accountTypeIn(['Asset account', 'Default account'])->get();
/** @var Account $entry */
foreach ($set as $entry) {
@ -36,15 +36,25 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
}
// create it if doesnt exist.
$account = Account::firstOrCreateEncrypted( // See issue #180
[
'name' => $this->value,
'iban' => '',
'user_id' => Auth::user()->id,
'account_type_id' => $accountType->id,
'active' => 1,
]
);
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$accountData = [
'name' => $this->value,
'accountType' => 'asset',
'virtualBalance' => 0,
'virtualBalanceCurrency' => 1, // hard coded.
'active' => true,
'user' => Auth::user()->id,
'iban' => null,
'accountNumber' => $this->value,
'accountRole' => null,
'openingBalance' => 0,
'openingBalanceDate' => new Carbon,
'openingBalanceCurrency' => 1, // hard coded.
];
$account = $repository->store($accountData);
return $account;
}

View File

@ -20,15 +20,10 @@ class BudgetName extends BasicConverter implements ConverterInterface
{
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$budget = Auth::user()->budgets()->find($this->mapped[$this->index][$this->value]);
$budget = Auth::user()->budgets()->find($this->mapped[$this->index][$this->value]); // see issue #180
} else {
$budget = Budget::firstOrCreateEncrypted( // See issue #180
[
'name' => $this->value,
'user_id' => Auth::user()->id,
'active' => true,
]
);
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$budget = $repository->store(['name' => $this->value, 'user' => Auth::user()->id]);
}
return $budget;

0
gulpfile.js Executable file → Normal file
View File

View File

@ -15,7 +15,11 @@
<a href="{{ route('accounts.show',income.id) }}" title="{{ income.name }}">{{ income.name }}</a>
{% if income.count > 1 %}
<br/>
<small>{{ income.count }} {{ 'transactions'|_|lower }}</small>
<small>
{{ income.count }} {{ 'transactions'|_|lower }}
<i class="fa fa-fw text-muted fa-info-circle"></i>
</small>
{% endif %}
</td>
<td>{{ income.amount|formatAmount }}</td>