@@ -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 rest
this.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 0
diff --git a/resources/lang/en_US/config.php b/resources/lang/en_US/config.php
index 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.php
index 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.php
index 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',
];