@@ -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 4b47faaad5..b78768235e 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -1130,6 +1130,7 @@ return [
'already_cleared_transactions' => 'Already cleared transactions (:count)',
'submitted_end_balance' => 'Submitted end balance',
'initial_balance_description' => 'Initial balance for ":account"',
+ 'liability_credit_description' => 'Liability credit for ":account"',
'interest_calc_' => 'unknown',
'interest_calc_daily' => 'Per day',
'interest_calc_monthly' => 'Per month',
@@ -1317,9 +1318,16 @@ 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',
+ 'liability_direction_credit_short' => 'Owed this debt',
+ 'liability_direction_debit_short' => 'Owe this debt',
+ 'liability_direction__short' => 'Unknown',
+ 'Liability credit' => 'Liability credit',
'budgets' => 'Budgets',
'tags' => 'Tags',
'reports' => 'Reports',
@@ -1390,6 +1398,7 @@ return [
'splitByAccount' => 'Split by account',
'coveredWithTags' => 'Covered with tags',
'leftInBudget' => 'Left in budget',
+ 'left_in_debt' => 'Amount due',
'sumOfSums' => 'Sum of sums',
'noCategory' => '(no category)',
'notCharged' => 'Not charged (yet)',
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',
];
diff --git a/resources/lang/en_US/validation.php b/resources/lang/en_US/validation.php
index 48540ee6fe..b7e6143ff5 100644
--- a/resources/lang/en_US/validation.php
+++ b/resources/lang/en_US/validation.php
@@ -200,6 +200,7 @@ return [
'need_id_in_edit' => 'Each split must have transaction_journal_id (either valid ID or 0).',
'ob_source_need_data' => 'Need to get a valid source account ID and/or valid source account name to continue.',
+ 'lc_source_need_data' => 'Need to get a valid source account ID to continue.',
'ob_dest_need_data' => 'Need to get a valid destination account ID and/or valid destination account name to continue.',
'ob_dest_bad_data' => 'Could not find a valid destination account when searching for ID ":id" or name ":name".',
diff --git a/resources/views/v1/accounts/create.twig b/resources/views/v1/accounts/create.twig
index a74107c270..f5e4aeceb8 100644
--- a/resources/views/v1/accounts/create.twig
+++ b/resources/views/v1/accounts/create.twig
@@ -27,7 +27,8 @@
{% endif %}
{% if objectType == 'liabilities' %}
{{ ExpandedForm.select('liability_type_id', liabilityTypes) }}
- {{ ExpandedForm.amountNoCurrency('opening_balance', null, {label:'debt_start_amount'|_, helpText: 'debt_start_amount_help'|_}) }}
+ {{ ExpandedForm.amountNoCurrency('opening_balance', null, {label:'debt_start_amount'|_}) }}
+ {{ ExpandedForm.select('liability_direction', liabilityDirections) }}
{{ ExpandedForm.date('opening_balance_date', null, {label:'debt_start_date'|_}) }}
{{ ExpandedForm.percentage('interest') }}
{{ ExpandedForm.select('interest_period', interestPeriods, null, {helpText: 'interest_period_help'|_}) }}
diff --git a/resources/views/v1/accounts/edit.twig b/resources/views/v1/accounts/edit.twig
index 01013d7d72..a52a1e5f56 100644
--- a/resources/views/v1/accounts/edit.twig
+++ b/resources/views/v1/accounts/edit.twig
@@ -36,6 +36,7 @@
{% if objectType == 'liabilities' %}
{{ ExpandedForm.select('liability_type_id', liabilityTypes) }}
{{ ExpandedForm.amountNoCurrency('opening_balance', null, {label:'debt_start_amount'|_, helpText: 'debt_start_amount_help'|_}) }}
+ {{ ExpandedForm.select('liability_direction', liabilityDirections) }}
{{ ExpandedForm.date('opening_balance_date', null, {label:'debt_start_date'|_}) }}
{{ ExpandedForm.percentage('interest') }}
{{ ExpandedForm.select('interest_period', interestPeriods) }}
diff --git a/resources/views/v1/list/accounts.twig b/resources/views/v1/list/accounts.twig
index 9e679d9e5f..5923f81a6f 100644
--- a/resources/views/v1/list/accounts.twig
+++ b/resources/views/v1/list/accounts.twig
@@ -11,10 +11,16 @@
{% endif %}
{% if objectType == 'liabilities' %}
{{ trans('list.liability_type') }} |
+
{{ trans('form.liability_direction') }} |
{{ trans('list.interest') }} ({{ trans('list.interest_period') }}) |
{% endif %}
{{ trans('form.account_number') }} |
-
{{ trans('list.currentBalance') }} |
+
{{ trans('list.currentBalance') }} |
+ {% if objectType == 'liabilities' %}
+
+ {{ trans('firefly.left_in_debt') }}
+ |
+ {% endif %}
{{ trans('list.active') }} |
{# hide last activity to make room for other stuff #}
{% if objectType != 'liabilities' %}
@@ -50,10 +56,9 @@
{% endif %}
{% if objectType == 'liabilities' %}
-
{{ account.accountTypeString }} |
-
- {{ account.interest }}% ({{ account.interestPeriod|lower }})
- |
+
{{ account.accountTypeString }} |
+
{{ trans('firefly.liability_direction_'~account.liability_direction~'_short') }} |
+
{{ account.interest }}% ({{ account.interestPeriod|lower }}) |
{% endif %}
{{ account.iban }}{% if account.iban == '' %}{{ accountGetMetaField(account, 'account_number') }}{% endif %} |
@@ -61,6 +66,13 @@
{{ formatAmountByAccount(account, account.endBalance) }}
|
+ {% if objectType == 'liabilities' %}
+
+ {% if '-' != account.current_debt %}
+ {{ formatAmountByAccount(account, account.current_debt, false) }}
+ {% endif %}
+ |
+ {% endif %}
{% if account.active %}
diff --git a/resources/views/v1/list/groups.twig b/resources/views/v1/list/groups.twig
index 3b71fdb60d..e8ccf53311 100644
--- a/resources/views/v1/list/groups.twig
+++ b/resources/views/v1/list/groups.twig
@@ -118,6 +118,9 @@
{% if transaction.transaction_type_type == 'Opening balance' %}
{% endif %}
+ {% if transaction.transaction_type_type == 'Liability credit' %}
+
+ {% endif %}
|
@@ -136,11 +139,13 @@
{% endif %}
|
+ {# deposit #}
{% if transaction.transaction_type_type == 'Deposit' %}
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
{% if null != transaction.foreign_amount %}
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
{% endif %}
+ {# transfer #}
{% elseif transaction.transaction_type_type == 'Transfer' %}
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}
@@ -148,6 +153,7 @@
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
{% endif %}
+ {# opening balance #}
{% elseif transaction.transaction_type_type == 'Opening balance' %}
{% if transaction.source_account_type == 'Initial balance account' %}
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
@@ -160,6 +166,7 @@
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
{% endif %}
{% endif %}
+ {# reconciliation #}
{% elseif transaction.transaction_type_type == 'Reconciliation' %}
{% if transaction.source_account_type == 'Reconciliation account' %}
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
@@ -172,6 +179,22 @@
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
{% endif %}
{% endif %}
+ {# liability credit #}
+ {% elseif transaction.transaction_type_type == 'Liability credit' %}
+ {% if transaction.source_account_type == 'Liability credit' %}
+ {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
+ {% if null != transaction.foreign_amount %}
+ ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
+ {% endif %}
+ {% else %}
+ {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
+ {% if null != transaction.foreign_amount %}
+ ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
+ {% endif %}
+ {% endif %}
+
+
+ {# THE REST #}
{% else %}
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
{% if null != transaction.foreign_amount %}
diff --git a/resources/views/v1/transactions/show.twig b/resources/views/v1/transactions/show.twig
index 47450983e0..e73ae146dc 100644
--- a/resources/views/v1/transactions/show.twig
+++ b/resources/views/v1/transactions/show.twig
@@ -39,6 +39,7 @@
{{ 'clone'|_ }}
{% endif %}
+
@@ -231,12 +232,17 @@
{{ journal.source_name }} →
{% endif %}
+
{% if first.transactiontype.type == 'Withdrawal' or first.transactiontype.type == 'Deposit' %}
{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
{% elseif first.transactiontype.type == 'Transfer' or first.transactiontype.type == 'Opening balance' %}
{{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places, false) }}
+ {% elseif first.transactiontype.type == 'Liability credit' %}
+
+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places, false) }}
+
{% endif %}
|