Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Update code for proper index.
James Colea83578d1ae81
diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilities.php b/app/Console/Commands/Upgrade/UpgradeLiabilities.phpindex 8cdf7169fc..528ecf7b09 100644--- a/app/Console/Commands/Upgrade/UpgradeLiabilities.php+++ b/app/Console/Commands/Upgrade/UpgradeLiabilities.php@@ -7,6 +7,7 @@ use FireflyIII\Models\Account;use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionJournal;use FireflyIII\Repositories\Account\AccountRepositoryInterface;+use FireflyIII\Services\Internal\Support\CreditRecalculateService;use FireflyIII\User;use Illuminate\Console\Command;use Log;@@ -145,6 +146,9 @@ class UpgradeLiabilities extends Command/** @var Account $account */foreach ($accounts as $account) {$this->upgradeLiability($account);+ $service = app(CreditRecalculateService::class);+ $service->setAccount($account);+ $service->recalculate();}}diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.phpindex 3aaacbf4cf..16e02e6403 100644--- a/app/Http/Controllers/Account/EditController.php+++ b/app/Http/Controllers/Account/EditController.php@@ -123,6 +123,9 @@ class EditController extends Controller$request->session()->forget('accounts.edit.fromUpdate');$openingBalanceAmount = app('steam')->positive((string)$repository->getOpeningBalanceAmount($account));+ if('0' === $openingBalanceAmount) {+ $openingBalanceAmount = '';+ }$openingBalanceDate = $repository->getOpeningBalanceDate($account);$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex a3f7e4c198..fe1a0284fa 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -789,5 +789,5 @@ class AccountRepository implements AccountRepositoryInterfacereturn $dbQuery->first(['accounts.*']);}-+}diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.phpindex 23c9627a51..da1522c070 100644--- a/app/Transformers/AccountTransformer.php+++ b/app/Transformers/AccountTransformer.php@@ -119,6 +119,7 @@ class AccountTransformer extends AbstractTransformer'liability_direction' => $liabilityDirection,'interest' => $interest,'interest_period' => $interestPeriod,+ 'current_debt' => $this->repository->getMetaValue($account,'current_debt'),'include_net_worth' => $includeNetWorth,'longitude' => $longitude,'latitude' => $latitude,diff --git a/frontend/src/components/accounts/Index.vue b/frontend/src/components/accounts/Index.vueindex b5ae2f03a6..6f3bda6978 100644--- a/frontend/src/components/accounts/Index.vue+++ b/frontend/src/components/accounts/Index.vue@@ -54,6 +54,31 @@<span v-if="null === data.item.iban && null !== data.item.account_number">{{ data.item.account_number }}</span><span v-if="null !== data.item.iban && null !== data.item.account_number">{{ data.item.iban }} ({{ data.item.account_number }})</span></template>+ <template #cell(last_activity)="data">+ <span v-if="'asset' === type && 'loading' === data.item.last_activity">+ <i class="fas fa-spinner fa-spin"></i>+ </span>+ <span v-if="'asset' === type && 'none' === data.item.last_activity" class="text-muted">+ {{ $t('firefly.never') }}+ </span>+ <span v-if="'asset' === type && 'loading' !== data.item.last_activity && 'none' !== data.item.last_activity">+ {{ data.item.last_activity }}+ </span>+ </template>+ <template #cell(amount_due)="data">+ <span class="text-success" v-if="parseFloat(data.item.amount_due) > 0">+ {{ Intl.NumberFormat('en-US', {style: 'currency', currency: data.item.currency_code}).format(data.item.amount_due) }}+ </span>++ <span class="text-danger" v-if="parseFloat(data.item.amount_due) < 0">+ {{ Intl.NumberFormat('en-US', {style: 'currency', currency: data.item.currency_code}).format(data.item.amount_due) }}+ </span>++ <span class="text-muted" v-if="parseFloat(data.item.amount_due) === 0.0">+ {{ Intl.NumberFormat('en-US', {style: 'currency', currency: data.item.currency_code}).format(data.item.amount_due) }}+ </span>++ </template><template #cell(current_balance)="data"><span class="text-success" v-if="parseFloat(data.item.current_balance) > 0">{{@@ -102,6 +127,9 @@}}</span>)</span></template>+ <template #cell(interest)="data">+ {{ parseFloat(data.item.interest) }}% ({{ data.item.interest_period }})+ </template><template #cell(menu)="data"><div class="btn-group btn-group-sm"><div class="dropdown">@@ -249,14 +277,24 @@ export default {updateFieldList: function () {this.fields = [];-this.fields = [{key: 'title', label: this.$t('list.name'), sortable: !this.orderMode}];if ('asset' === this.type) {this.fields.push({key: 'role', label: this.$t('list.role'), sortable: !this.orderMode});}+ if ('liabilities' === this.type) {+ this.fields.push({key: 'liability_type', label: this.$t('list.liability_type'), sortable: !this.orderMode});+ this.fields.push({key: 'liability_direction', label: this.$t('list.liability_direction'), sortable: !this.orderMode});+ this.fields.push({key: 'interest', label: this.$t('list.interest') + ' (' + this.$t('list.interest_period') + ')', sortable: !this.orderMode});+ }// add the restthis.fields.push({key: 'number', label: this.$t('list.iban'), sortable: !this.orderMode});this.fields.push({key: 'current_balance', label: this.$t('list.currentBalance'), sortable: !this.orderMode});+ if ('liabilities' === this.type) {+ this.fields.push({key: 'amount_due', label: this.$t('firefly.left_in_debt'), sortable: !this.orderMode});+ }+ if ('asset' === this.type || 'liabilities' === this.type) {+ this.fields.push({key: 'last_activity', label: this.$t('list.lastActivity'), sortable: !this.orderMode});+ }this.fields.push({key: 'menu', label: ' ', sortable: false});},getAccountList: function () {@@ -273,7 +311,6 @@ export default {// console.log('Index ready, not loading and not downloaded.');this.loading = true;this.filterAccountList();- // TODO filter accounts.}},downloadAccountList: function (page) {@@ -344,19 +381,45 @@ export default {acct.account_number = current.attributes.account_number;acct.current_balance = current.attributes.current_balance;acct.currency_code = current.attributes.currency_code;++ if ('liabilities' === this.type) {+ acct.liability_type = this.$t('firefly.account_type_' + current.attributes.liability_type);+ acct.liability_direction = this.$t('firefly.liability_direction_' + current.attributes.liability_direction + '_short');+ acct.interest = current.attributes.interest;+ acct.interest_period = this.$t('firefly.interest_calc_' + current.attributes.interest_period);+ acct.amount_due = current.attributes.current_debt;+ }acct.balance_diff = 'loading';+ acct.last_activity = 'loading';if (null !== current.attributes.iban) {acct.iban = current.attributes.iban.match(/.{1,4}/g).join(' ');}+ if (null === current.attributes.iban) {+ acct.iban = null;+ }this.allAccounts.push(acct);if ('asset' === this.type) {this.getAccountBalanceDifference(this.allAccounts.length - 1, current);+ this.getAccountLastActivity(this.allAccounts.length - 1, current);}}}},+ getAccountLastActivity: function (index, acct) {+ // console.log('getAccountLastActivity(' + index + ')');+ // get single transaction for account:+ // /api/v1/accounts/1/transactions?limit=1+ axios.get('./api/v1/accounts/' + acct.id + '/transactions?limit=1').then(response => {+ if (0 === response.data.data.length) {+ this.allAccounts[index].last_activity = 'none';+ return;+ }+ let date = new Date(response.data.data[0].attributes.transactions[0].date);+ this.allAccounts[index].last_activity = format(date, this.$t('config.month_and_day_fns'));+ });+ },getAccountBalanceDifference: function (index, acct) {// console.log('getAccountBalanceDifference(' + index + ')');// get account on day 0diff --git a/resources/lang/en_US/config.php b/resources/lang/en_US/config.phpindex 47ff08895a..c4bf677c5e 100644--- a/resources/lang/en_US/config.php+++ b/resources/lang/en_US/config.php@@ -28,6 +28,7 @@ return ['month' => '%B %Y','month_and_day' => '%B %e, %Y','month_and_day_moment_js' => 'MMM D, YYYY',+ 'month_and_day_fns' => 'MMMM d, y','month_and_date_day' => '%A %B %e, %Y','month_and_day_no_year' => '%B %e','date_time' => '%B %e, %Y, @ %T',diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex fd1c2886bf..ec0f24bf84 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -1325,6 +1325,9 @@ return ['account_type_Debt' => 'Debt','account_type_Loan' => 'Loan','account_type_Mortgage' => 'Mortgage',+ 'account_type_debt' => 'Debt',+ 'account_type_loan' => 'Loan',+ 'account_type_mortgage' => 'Mortgage','account_type_Credit card' => 'Credit card','liability_direction_credit' => 'I am owed this debt','liability_direction_debit' => 'I owe this debt to somebody else',diff --git a/resources/lang/en_US/list.php b/resources/lang/en_US/list.phpindex e3810b0f80..048e6c93aa 100644--- a/resources/lang/en_US/list.php+++ b/resources/lang/en_US/list.php@@ -130,6 +130,7 @@ return ['field' => 'Field','value' => 'Value','interest' => 'Interest',- 'interest_period' => 'interest period',+ 'interest_period' => 'Interest period','liability_type' => 'Type of liability',+ 'liability_direction' => 'Liability in/out',];