Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Add new stuff
Sander Dorigo3ab98c4c7626
diff --git a/config/translations.php b/config/translations.phpindex b4bc0be5f1..a2618854d4 100644--- a/config/translations.php+++ b/config/translations.php@@ -64,6 +64,7 @@ return ['you_create_transfer','you_create_withdrawal','you_create_deposit',+ 'inactive','liability_direction_debit_short','liability_direction_credit_short','liability_direction_null_short',diff --git a/package-lock.json b/package-lock.jsonindex 096d0fd2eb..af95e2872c 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,5 +1,5 @@{- "name": "firefly-iii",+ "name": "release","lockfileVersion": 3,"requires": true,"packages": {diff --git a/resources/assets/v1/src/components/transactions/AccountSelect.vue b/resources/assets/v1/src/components/transactions/AccountSelect.vuedeleted file mode 100644index 4e3f3b1b1b..0000000000--- a/resources/assets/v1/src/components/transactions/AccountSelect.vue+++ /dev/null@@ -1,244 +0,0 @@-<!--- - AccountSelect.vue- - Copyright (c) 2019 [email protected]- -- - This file is part of Firefly III (https://github.com/firefly-iii).- -- - This program is free software: you can redistribute it and/or modify- - it under the terms of the GNU Affero General Public License as- - published by the Free Software Foundation, either version 3 of the- - License, or (at your option) any later version.- -- - This program is distributed in the hope that it will be useful,- - but WITHOUT ANY WARRANTY; without even the implied warranty of- - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- - GNU Affero General Public License for more details.- -- - You should have received a copy of the GNU Affero General Public License- - along with this program. If not, see <https://www.gnu.org/licenses/>.- -->-<template>- <div class="form-group" v-bind:class="{ 'has-error': hasError()}">- <div class="col-sm-12 text-sm">- {{ inputDescription }}- </div>- <div class="col-sm-12">- <div class="input-group">- <input- spellcheck="false"- ref="input"- :data-index="index"- :disabled="inputDisabled"- :name="inputName"- :placeholder="inputDescription"- :title="inputDescription"- autocomplete="off"- class="form-control"- data-role="input"- type="text"- v-on:submit.prevent>- <span class="input-group-btn">- <button- class="btn btn-default"- tabIndex="-1"- type="button"- v-on:click="clearSource"><i class="fa fa-trash-o"></i></button>- </span>- </div>- <typeahead- v-model="name"- :async-function="aSyncFunction"- :open-on-empty=true- :open-on-focus=true- :target="target"- item-key="name_with_balance"- v-on:input="selectedItem"- >- <template slot="item" slot-scope="props">- <li v-for="(item, index) in props.items" :class="{active:props.activeIndex===index}">- <a role="button" @click="props.select(item)">- <span v-html="betterHighlight(item)"></span>- </a>- </li>- </template>- </typeahead>- <ul v-for="error in this.error" class="list-unstyled">- <li class="text-danger">{{ error }}</li>- </ul>- </div>- </div>--</template>-<script>-export default {- props: {- inputName: String,- inputDescription: String,- index: Number,- transactionType: String,- error: Array,- accountName: {- type: String,- default: ''- },- accountTypeFilters: {- type: Array,- default: function () {- return [];- }- },- defaultAccountTypeFilters: {- type: Array,- default: function () {- return [];- }- }- },-- data() {- return {- accountAutoCompleteURI: null,- name: null,- trType: this.transactionType,- target: null,- inputDisabled: false,- allowedTypes: this.accountTypeFilters,- defaultAllowedTypes: this.defaultAccountTypeFilters- }- },- ready() {- // console.log('ready(): this.name = this.accountName (' + this.accountName + ')');- this.name = this.accountName;- },- mounted() {- this.target = this.$refs.input;- this.updateACURI(this.allowedTypes.join(','));- // console.log('mounted(): this.name = this.accountName (' + this.accountName + ')');- this.name = this.accountName;- this.triggerTransactionType();- },-- watch: {- transactionType() {- this.triggerTransactionType();- },- accountName() {- // console.log('AccountSelect watch accountName!');- this.name = this.accountName;- },- accountTypeFilters() {- let types = this.accountTypeFilters.join(',');- if (0 === this.accountTypeFilters.length) {- types = this.defaultAccountTypeFilters.join(',');- }- this.updateACURI(types);- }- },- methods:- {- aSyncFunction: function (query, done) {- axios.get(this.accountAutoCompleteURI + query)- .then(res => {- done(res.data);- })- .catch(err => {- // any error handler- })- },- betterHighlight: function (item) {- var inputValue = this.$refs.input.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');- var escapedName = this.escapeHtml(item.name_with_balance);- return escapedName.replace(new RegExp(("" + inputValue), 'i'), '<b>$&</b>');- },- escapeHtml: function (string) {-- let entityMap = {- '&': '&',- '<': '<',- '>': '>',- '"': '"',- "'": ''',- '/': '/',- '`': '`',- '=': '='- };-- return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) {- return entityMap[s];- });-- },-- updateACURI: function (types) {- this.accountAutoCompleteURI =- document.getElementsByTagName('base')[0].href +- 'api/v1/autocomplete/accounts' +- '?types=' +- types +- '&query=';- // console.log('Auto complete URI is now ' + this.accountAutoCompleteURI);- },- hasError: function () {- return this.error.length > 0;- },- triggerTransactionType: function () {- // console.log('On triggerTransactionType(' + this.inputName + ')');- if (null === this.name) {- // console.log('this.name is NULL.');- }- if (null === this.transactionType) {- // console.log('Transaction type is NULL.');- return;- }- if ('' === this.transactionType) {- // console.log('Transaction type is "".');- return;- }- this.inputDisabled = false;- if (this.transactionType.toString() !== '' && this.index > 0) {- if (this.transactionType.toString().toLowerCase() === 'transfer') {- this.inputDisabled = true;- // TODO needs to copy value from very first input.-- return;- }-- if (this.transactionType.toString().toLowerCase() === 'withdrawal' && this.inputName.substr(0, 6).toLowerCase() === 'source') {- // TODO also clear value?- this.inputDisabled = true;- return;- }-- if (this.transactionType.toString().toLowerCase() === 'deposit' && this.inputName.substr(0, 11).toLowerCase() === 'destination') {- // TODO also clear value?- this.inputDisabled = true;- }- }- },- selectedItem: function (e) {- // console.log('In SelectedItem()');- if (typeof this.name === 'undefined') {- // console.log('Is undefined');- return;- }- if (typeof this.name === 'string') {- // console.log('Is a string.');- //this.trType = null;- this.$emit('clear:value');- }- // emit the fact that the user selected a type of account- // (influencing the destination)- // console.log('Is some object maybe:');- // console.log(this.name);- this.$emit('select:account', this.name);- },- clearSource: function (e) {- // console.log('clearSource()');- //props.value = '';- this.name = '';- // some event?- this.$emit('clear:value')- }- }-}-</script>diff --git a/resources/assets/v1/src/components/transactions/Bill.vue b/resources/assets/v1/src/components/transactions/Bill.vuedeleted file mode 100644index fd2daa8645..0000000000--- a/resources/assets/v1/src/components/transactions/Bill.vue+++ /dev/null@@ -1,116 +0,0 @@-<!--- - Bill.vue- - Copyright (c) 2019 [email protected]- -- - This file is part of Firefly III (https://github.com/firefly-iii).- -- - This program is free software: you can redistribute it and/or modify- - it under the terms of the GNU Affero General Public License as- - published by the Free Software Foundation, either version 3 of the- - License, or (at your option) any later version.- -- - This program is distributed in the hope that it will be useful,- - but WITHOUT ANY WARRANTY; without even the implied warranty of- - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- - GNU Affero General Public License for more details.- -- - You should have received a copy of the GNU Affero General Public License- - along with this program. If not, see <https://www.gnu.org/licenses/>.- -->--<template>- <div v-if="typeof this.transactionType === 'undefined' || this.transactionType === 'withdrawal' || this.transactionType === 'Withdrawal' || this.transactionType === '' || null === this.transactionType"- class="form-group"- v-bind:class="{ 'has-error': hasError()}">- <div class="col-sm-12 text-sm">- {{ $t('firefly.bill') }}- </div>- <div class="col-sm-12">- <select- v-if="this.bills.length > 0"- ref="bill"- v-model="selected"- :title="$t('firefly.bill')"- class="form-control"- name="bill[]"- @input="handleInput"- v-on:change="signalChange">- <option v-for="cBill in this.bills"- :label="cBill.name"- :value="cBill.id">{{ cBill.name }}- </option>- </select>- <p v-if="this.bills.length === 1" class="help-block" v-html="$t('firefly.no_bill_pointer')"></p>- <ul v-for="error in this.error" class="list-unstyled">- <li class="text-danger">{{ error }}</li>- </ul>- </div>- </div>-</template>--<script>-export default {- name: "Bill",- props: {- transactionType: String,- value: {- type: [String, Number],- default: 0- },- error: Array,- no_bill: String,- },- mounted() {- // console.log('bill: mounted');- this.loadBills();- },- data() {- return {- selected: this.value ?? 0,- bills: [],- }- },- watch: {- value: function () {- // console.log('bill: value changed to ' + this.value);- this.selected = this.value;- }- },- methods: {- // Fixes edit change bill not updating on every browser- signalChange: function (e) {- this.$emit('input', this.$refs.bill.value);- },- handleInput(e) {- this.$emit('input', this.$refs.bill.value);- },- hasError: function () {- return this.error.length > 0;- },- loadBills: function () {- let URI = document.getElementsByTagName('base')[0].href + 'api/v1/autocomplete/bills?limit=1337';- axios.get(URI, {}).then((res) => {- this.bills = [- {- name: this.no_bill,- id: 0,- }- ];- for (const key in res.data) {- if (res.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {- let current = res.data[key];- if(current.active) {- this.bills.push(res.data[key]);- }- }- }- this.bills.sort(function(a, b) {- if (a.name < b.name) return -1;- if (a.name > b.name) return 1;- return 0;- });- });- }- }-}-</script>diff --git a/resources/assets/v3/js/pages/transactions/create.js b/resources/assets/v3/js/pages/transactions/create.jsindex 5167ad7f00..7cd716a6f9 100644--- a/resources/assets/v3/js/pages/transactions/create.js+++ b/resources/assets/v3/js/pages/transactions/create.js@@ -46,6 +46,9 @@ import i18next from "i18next";import {processUploadError} from "./shared/process-upload-error.js";import {showMessageOrRedirectUser} from "./shared/show-message-or-redirect.js";import {addSplit} from "./shared/add-split.js";+import {clearSourceAccount, clearDestinationAccount} from './shared/clear-fields.js';+import {detectTransactionType} from './shared/detect-transaction-type.js';+import {determineAmountCurrency} from './shared/determine-amount-currency.js';// TODO fix tags// TODO upload attachments to other file// TODO fix two maps, perhaps disconnect from entries entirely.@@ -120,11 +123,7 @@ let create = function () {},- // part of the account selection auto-complete- filters: {- source: [],- destination: [],- },+// events in the formchangedDateTime(event) {@@ -152,86 +151,11 @@ let create = function () {showMessageOrRedirectUser: showMessageOrRedirectUser,parseErrors: parseErrors,addSplit:addSplit,-- detectTransactionType() {- const sourceType = this.entries[0].source_account.type ?? 'unknown';- const destType = this.entries[0].destination_account.type ?? 'unknown';- if ('unknown' === sourceType && 'unknown' === destType) {- this.groupProperties.transactionType = 'unknown';- console.warn('Cannot infer transaction type from two unknown accounts.');- this.disableSplitAccounts();- return;- }-- // transfer: both are the same and in strict set of account types- if (sourceType === destType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(sourceType)) {- this.groupProperties.transactionType = 'transfer';- console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');-- // this also locks the amount into the amount of the source account- // and the foreign amount (if different) in that of the destination account.- console.log('filter down currencies for transfer.');- this.determineAmountCurrency(this.entries[0].source_account.currency_code);- this.filterForeignCurrencies(this.entries[0].destination_account.currency_code);- this.disableSplitAccounts();- return;- }- // withdrawals:- if ('Asset account' === sourceType && ['Expense account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {- this.groupProperties.transactionType = 'withdrawal';- console.log('[a] Transaction type is detected to be "' + this.groupProperties.transactionType + '".');- this.determineAmountCurrency(this.entries[0].source_account.currency_code);- this.disableSplitAccounts();- return;- }- if ('Asset account' === sourceType && 'unknown' === destType) {- this.groupProperties.transactionType = 'withdrawal';- console.log('[b] Transaction type is detected to be "' + this.groupProperties.transactionType + '".');- this.determineAmountCurrency(this.entries[0].source_account.currency_code);- this.disableSplitAccounts();- return;- }- if (['Debt', 'Loan', 'Mortgage'].includes(sourceType) && 'Expense account' === destType) {- this.groupProperties.transactionType = 'withdrawal';- console.log('[c] Transaction type is detected to be "' + this.groupProperties.transactionType + '".');- this.determineAmountCurrency(this.entries[0].source_account.currency_code);- this.disableSplitAccounts();- return;- }-- // deposits:- if ('Revenue account' === sourceType && ['Asset account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {- this.groupProperties.transactionType = 'deposit';- console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');- this.disableSplitAccounts();- this.determineAmountCurrency(this.entries[0].destination_account.currency_code);- return;- }- if ('unknown' === sourceType && ['Asset account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {- this.groupProperties.transactionType = 'deposit';- console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');- this.determineAmountCurrency(this.entries[0].destination_account.currency_code);- this.disableSplitAccounts();- return;- }- if ('Expense account' === sourceType && ['Asset account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {- this.groupProperties.transactionType = 'deposit';- console.warn('FORCE transaction type to be "' + this.groupProperties.transactionType + '".');- this.entries[0].source_account.id = '';- this.determineAmountCurrency(this.entries[0].destination_account.currency_code);- this.disableSplitAccounts();- return;- }- if (['Debt', 'Loan', 'Mortgage'].includes(sourceType) && 'Asset account' === destType) {- this.groupProperties.transactionType = 'deposit';- console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');- this.determineAmountCurrency(this.entries[0].destination_account.currency_code);- this.disableSplitAccounts();- return;- }- console.warn('Unknown account combination between "' + sourceType + '" and "' + destType + '".');- this.disableSplitAccounts();- },+ clearSourceAccount: clearSourceAccount,+ clearDestinationAccount: clearDestinationAccount,+ detectTransactionType: detectTransactionType,+ determineAmountCurrency: determineAmountCurrency,+ addAllAutocompleteToForm: addAllAutocompleteToForm,filterForeignCurrencies(code) {@@ -265,32 +189,11 @@ let create = function () {}},- determineAmountCurrency(code) {- let list = [];- let currency;- for (let i in this.formData.enabledCurrencies) {- if (this.formData.enabledCurrencies.hasOwnProperty(i)) {- let current = this.formData.enabledCurrencies[i];- if (current.code === code) {- currency = current;- }- }- }- list.push(currency);- if(1 === list.length) {- this.formData.amountCurrency = list[0];- // this also forces the currency_code on ALL entries.- for (let i in this.entries) {- if (this.entries.hasOwnProperty(i)) {- this.entries[i].currency_code = code;- }- }- }- },+addedSplit() {- addAllAutocompleteToForm(this.filters);+ this.addAllAutocompleteToForm();},processUpload(event) {@@ -303,14 +206,7 @@ let create = function () {clearCategory(index) {this.entries[index].category_name = '';},- clearSourceAccount(index) {- this.entries[index].source_account = getAccount();- this.detectTransactionType();- },- clearDestinationAccount(index) {- this.entries[index].destination_account = getAccount();- this.detectTransactionType();- },+init() {console.log('init()');@@ -371,10 +267,6 @@ let create = function () {// });////- // source can never be expense account- this.filters.source = ['Asset account', 'Loan', 'Debt', 'Mortgage', 'Revenue account'];- // destination can never be revenue account- this.filters.destination = ['Expense account', 'Loan', 'Debt', 'Mortgage', 'Asset account'];},save() {this.notifications.error.show = false;diff --git a/resources/assets/v3/js/pages/transactions/edit.js b/resources/assets/v3/js/pages/transactions/edit.jsindex 7df87168bd..003c32c693 100644--- a/resources/assets/v3/js/pages/transactions/edit.js+++ b/resources/assets/v3/js/pages/transactions/edit.js@@ -44,6 +44,9 @@ import {changedAmount} from "./shared/changed-amount.js";import {changedForeignAmount} from "./shared/changed-foreign-amount.js";import {parseErrors} from "./shared/parse-errors.js";import {addSplit} from "./shared/add-split.js";+import {clearDestinationAccount, clearSourceAccount} from "./shared/clear-fields.js";+import {detectTransactionType} from "./shared/detect-transaction-type.js";+import {determineAmountCurrency} from "./shared/determine-amount-currency.js";// TODO upload attachments to other file// TODO fix two maps, perhaps disconnect from entries entirely.@@ -127,11 +130,13 @@ let transactions = function () {showMessageOrRedirectUser: showMessageOrRedirectUser,parseErrors: parseErrors,addSplit:addSplit,+ clearSourceAccount: clearSourceAccount,+ clearDestinationAccount: clearDestinationAccount,+ detectTransactionType: detectTransactionType,+ determineAmountCurrency: determineAmountCurrency,+ addAllAutocompleteToForm: addAllAutocompleteToForm,// part of the account selection auto-complete- filters: {- source: [], destination: [],- },changedDateTime(event) {console.warn('changedDateTime, event is not used');@@ -193,9 +198,6 @@ let transactions = function () {for (let i in this.entries) {if (this.entries.hasOwnProperty(i)) {this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);- // TODO this does not include all possible types.- this.filters.source.push(this.entries[i].source_account.type);- this.filters.destination.push(this.entries[i].destination_account.type);}}setTimeout(() => {@@ -222,6 +224,7 @@ let transactions = function () {},init() {+ console.log('Init()');this.i18next = i18next;// download translations and get the transaction group.this.notifications.wait.show = true;@@ -347,7 +350,7 @@ let transactions = function () {addedSplit() {console.log('addedSplit()');this.disableSplitAccounts();- addAllAutocompleteToForm(this.filters);+ this.addAllAutocompleteToForm();},}diff --git a/resources/assets/v3/js/pages/transactions/shared/add-autocomplete.js b/resources/assets/v3/js/pages/transactions/shared/add-autocomplete.jsindex 90dfb3e2c4..77a2882ed5 100644--- a/resources/assets/v3/js/pages/transactions/shared/add-autocomplete.js+++ b/resources/assets/v3/js/pages/transactions/shared/add-autocomplete.js@@ -38,7 +38,33 @@ export function getUrls() {}}-export function addAllAutocompleteToForm(filters) {+export function addAllAutocompleteToForm() {+ console.log('Now in addAllAutocompleteToForm()');+ // filters are hard coded.+ // part of the account selection auto-complete+ let filters = {+ // source can never be expense account+ source: ['Asset account', 'Loan', 'Debt', 'Mortgage', 'Revenue account'],+ // destination can never be revenue account+ destination: ['Expense account', 'Loan', 'Debt', 'Mortgage', 'Asset account'],+ };+ // depending on the type of the transaction,+ // the filters are changed. For edit form, this means+ // the available account types may be limited.+ if('edit' === this.formBehaviour.formType) {++ if('withdrawal' === this.groupProperties.transactionType) {+ filters.destination = ['Expense account'];+ }+ if('deposit' === this.groupProperties.transactionType) {+ filters.source = ['Revenue account'];+ }+ if('transfer' === this.groupProperties.transactionType) {+ filters.source = [this.entries[0].source_account.type];+ filters.destination = [this.entries[0].source_account.type];+ }+ }+const urls = getUrls();setTimeout(() => {// addedSplit, is called from the HTMLdiff --git a/resources/assets/v3/js/pages/transactions/shared/add-split.js b/resources/assets/v3/js/pages/transactions/shared/add-split.jsindex 0b6a780694..5fd12e3e7d 100644--- a/resources/assets/v3/js/pages/transactions/shared/add-split.js+++ b/resources/assets/v3/js/pages/transactions/shared/add-split.js@@ -25,5 +25,5 @@ export function addSplit() {console.log('addSplit()');this.entries.push(createEmptySplit());this.disableSplitAccounts();- addAllAutocompleteToForm(this.filters);+ this.addAllAutocompleteToForm();}diff --git a/resources/assets/v3/js/pages/transactions/shared/clear-fields.js b/resources/assets/v3/js/pages/transactions/shared/clear-fields.jsnew file mode 100644index 0000000000..2d2d637494--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/clear-fields.js@@ -0,0 +1,11 @@+import {getAccount} from "./create-empty-split.js";++export function clearSourceAccount(index) {+ this.entries[index].source_account = getAccount();+ this.detectTransactionType();+}++export function clearDestinationAccount(index) {+ this.entries[index].destination_account = getAccount();+ this.detectTransactionType();+};diff --git a/resources/assets/v3/js/pages/transactions/shared/detect-transaction-type.js b/resources/assets/v3/js/pages/transactions/shared/detect-transaction-type.jsnew file mode 100644index 0000000000..b233a01ac5--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/detect-transaction-type.js@@ -0,0 +1,79 @@+export function detectTransactionType() {+ const sourceType = this.entries[0].source_account.type ?? 'unknown';+ const destType = this.entries[0].destination_account.type ?? 'unknown';+ if ('unknown' === sourceType && 'unknown' === destType) {+ this.groupProperties.transactionType = 'unknown';+ console.warn('Cannot infer transaction type from two unknown accounts.');+ this.disableSplitAccounts();+ return;+ }++ // transfer: both are the same and in strict set of account types+ if (sourceType === destType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(sourceType)) {+ this.groupProperties.transactionType = 'transfer';+ console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');++ // this also locks the amount into the amount of the source account+ // and the foreign amount (if different) in that of the destination account.+ console.log('filter down currencies for transfer.');+ this.determineAmountCurrency(this.entries[0].source_account.currency_code);+ this.filterForeignCurrencies(this.entries[0].destination_account.currency_code);+ this.disableSplitAccounts();+ return;+ }+ // withdrawals:+ if ('Asset account' === sourceType && ['Expense account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {+ this.groupProperties.transactionType = 'withdrawal';+ console.log('[a] Transaction type is detected to be "' + this.groupProperties.transactionType + '".');+ this.determineAmountCurrency(this.entries[0].source_account.currency_code);+ this.disableSplitAccounts();+ return;+ }+ if ('Asset account' === sourceType && 'unknown' === destType) {+ this.groupProperties.transactionType = 'withdrawal';+ console.log('[b] Transaction type is detected to be "' + this.groupProperties.transactionType + '".');+ this.determineAmountCurrency(this.entries[0].source_account.currency_code);+ this.disableSplitAccounts();+ return;+ }+ if (['Debt', 'Loan', 'Mortgage'].includes(sourceType) && 'Expense account' === destType) {+ this.groupProperties.transactionType = 'withdrawal';+ console.log('[c] Transaction type is detected to be "' + this.groupProperties.transactionType + '".');+ this.determineAmountCurrency(this.entries[0].source_account.currency_code);+ this.disableSplitAccounts();+ return;+ }++ // deposits:+ if ('Revenue account' === sourceType && ['Asset account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {+ this.groupProperties.transactionType = 'deposit';+ console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');+ this.disableSplitAccounts();+ this.determineAmountCurrency(this.entries[0].destination_account.currency_code);+ return;+ }+ if ('unknown' === sourceType && ['Asset account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {+ this.groupProperties.transactionType = 'deposit';+ console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');+ this.determineAmountCurrency(this.entries[0].destination_account.currency_code);+ this.disableSplitAccounts();+ return;+ }+ if ('Expense account' === sourceType && ['Asset account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {+ this.groupProperties.transactionType = 'deposit';+ console.warn('FORCE transaction type to be "' + this.groupProperties.transactionType + '".');+ this.entries[0].source_account.id = '';+ this.determineAmountCurrency(this.entries[0].destination_account.currency_code);+ this.disableSplitAccounts();+ return;+ }+ if (['Debt', 'Loan', 'Mortgage'].includes(sourceType) && 'Asset account' === destType) {+ this.groupProperties.transactionType = 'deposit';+ console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');+ this.determineAmountCurrency(this.entries[0].destination_account.currency_code);+ this.disableSplitAccounts();+ return;+ }+ console.warn('Unknown account combination between "' + sourceType + '" and "' + destType + '".');+ this.disableSplitAccounts();+};diff --git a/resources/assets/v3/js/pages/transactions/shared/determine-amount-currency.js b/resources/assets/v3/js/pages/transactions/shared/determine-amount-currency.jsnew file mode 100644index 0000000000..5521046844--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/determine-amount-currency.js@@ -0,0 +1,22 @@+export function determineAmountCurrency(code) {+ let list = [];+ let currency;+ for (let i in this.formData.enabledCurrencies) {+ if (this.formData.enabledCurrencies.hasOwnProperty(i)) {+ let current = this.formData.enabledCurrencies[i];+ if (current.code === code) {+ currency = current;+ }+ }+ }+ list.push(currency);+ if(1 === list.length) {+ this.formData.amountCurrency = list[0];+ // this also forces the currency_code on ALL entries.+ for (let i in this.entries) {+ if (this.entries.hasOwnProperty(i)) {+ this.entries[i].currency_code = code;+ }+ }+ }+};diff --git a/resources/assets/v3/js/pages/transactions/shared/load-budgets.js b/resources/assets/v3/js/pages/transactions/shared/load-budgets.jsindex 3279e65ce6..f774c6715b 100644--- a/resources/assets/v3/js/pages/transactions/shared/load-budgets.js+++ b/resources/assets/v3/js/pages/transactions/shared/load-budgets.js@@ -20,6 +20,7 @@import Get from "../../../api/model/budget/get.js";+import i18next from "i18next";export function loadBudgets(includeInactive) {let params = {@@ -36,14 +37,16 @@ export function loadBudgets(includeInactive) {let current = response.data.data[i];if(true === current.attributes.active) {let obj = {- id: current.id, name: current.attributes.name,+ id: current.id,+ name: current.attributes.name,};returnData.push(obj);continue;}if(includeInactive && false === current.attributes.active) {let obj = {- id: current.id, name: current.attributes.name,+ id: current.id,+ name: current.attributes.name + ' ('+i18next.t('firefly.inactive').toLowerCase()+')',};returnData.push(obj);}