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; namespace FireflyIII\Helpers\Csv\Converter;
use Auth; use Auth;
use Carbon\Carbon;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
/** /**
* Class AssetAccountIban * Class AssetAccountIban
@@ -27,20 +27,29 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
} }
if (strlen($this->value) > 0) { if (strlen($this->value) > 0) {
// find or create new account: // find or create new account:
$account = $this->findAccount(); $account = $this->findAccount();
$accountType = AccountType::where('type', 'Asset account')->first();
if (is_null($account)) { if (is_null($account)) {
// create it if doesn't exist. // create it if doesn't exist.
$account = Account::firstOrCreateEncrypted( // See issue #180
[ $repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
'name' => $this->value, $accountData = [
'iban' => $this->value, 'name' => $this->value,
'user_id' => Auth::user()->id, 'accountType' => 'asset',
'account_type_id' => $accountType->id, 'virtualBalance' => 0,
'active' => 1, '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; return $account;

View File

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

View File

@@ -20,15 +20,10 @@ class BudgetName extends BasicConverter implements ConverterInterface
{ {
// is mapped? Then it's easy! // is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) { 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 { } else {
$budget = Budget::firstOrCreateEncrypted( // See issue #180 $repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
[ $budget = $repository->store(['name' => $this->value, 'user' => Auth::user()->id]);
'name' => $this->value,
'user_id' => Auth::user()->id,
'active' => true,
]
);
} }
return $budget; 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> <a href="{{ route('accounts.show',income.id) }}" title="{{ income.name }}">{{ income.name }}</a>
{% if income.count > 1 %} {% if income.count > 1 %}
<br/> <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 %} {% endif %}
</td> </td>
<td>{{ income.amount|formatAmount }}</td> <td>{{ income.amount|formatAmount }}</td>