Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Clean up code, move logic from v1 to v3.
James Cole0435f206969d
diff --git a/config/translations.php b/config/translations.phpindex b8b7e3dd4e..b4bc0be5f1 100644--- a/config/translations.php+++ b/config/translations.php@@ -61,6 +61,9 @@ return ['bad_type_destination',],'firefly' => [+ 'you_create_transfer',+ 'you_create_withdrawal',+ 'you_create_deposit','liability_direction_debit_short','liability_direction_credit_short','liability_direction_null_short',diff --git a/package.json b/package.jsonindex ac5d01231f..6d3925ab36 100644--- a/package.json+++ b/package.json@@ -3,7 +3,6 @@"postinstall": "patch-package --error-on-fail"},"workspaces": [- "resources/assets/v1","resources/assets/v3"],"dependencies": {diff --git a/resources/assets/v1/src/components/form/Checkbox.vue b/resources/assets/v1/src/components/form/Checkbox.vuedeleted file mode 100644index 3d05fa8acb..0000000000--- a/resources/assets/v1/src/components/form/Checkbox.vue+++ /dev/null@@ -1,73 +0,0 @@-<!--- - Active.vue- - Copyright (c) 2022 [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">- <label class="col-sm-4 control-label">- {{ title }}- </label>-- <div class="col-sm-8">- <div class="checkbox">- <label>- <input v-model=active :name="name" @change="handleInput" type="checkbox" value="1">- </label>- </div>- <p class="help-block" v-text="$t('firefly.webhook_active_form_help')"></p>- </div>- </div>-</template>--<script>-export default {- name: "Checkbox",- props: {- name: {- type: String,- },- title: {- type: String,- },- value: {- type: Boolean,- }- },- data() {- return {- active: true,- };- },- mounted() {- this.active = this.value;- },- methods: {- handleInput() {- // console.log(this.active);- this.$emit('input', this.active);- },- },- watch: {- value: function (val) {- this.active = val;-- }- }-}-</script>diff --git a/resources/assets/v1/src/components/transactions/CreateTransaction.vue b/resources/assets/v1/src/components/transactions/CreateTransaction.vueindex 3a0e693d0d..9bc68d91a2 100644--- a/resources/assets/v1/src/components/transactions/CreateTransaction.vue+++ b/resources/assets/v1/src/components/transactions/CreateTransaction.vue@@ -20,109 +20,12 @@<template><form accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data">- <input name="_token" type="hidden" value="xxx">- <div v-if="error_message !== ''" class="row">- <div class="col-lg-12">- <div class="alert alert-danger alert-dismissible" role="alert">- <button class="close" data-dismiss="alert" type="button"- v-bind:aria-label="$t('firefly.close')"><span- aria-hidden="true">×</span></button>- <strong>{{ $t("firefly.flash_error") }}</strong> {{ error_message }}- </div>- </div>- </div>-- <div v-if="success_message !== ''" class="row">- <div class="col-lg-12">- <div class="alert alert-success alert-dismissible" role="alert">- <button class="close" data-dismiss="alert" type="button"- v-bind:aria-label="$t('firefly.close')"><span- aria-hidden="true">×</span></button>- <strong>{{ $t("firefly.flash_success") }}</strong> <span v-html="success_message"></span>- </div>- </div>- </div><div><div v-for="(transaction, index) in transactions" class="row"><div class="col-lg-12"><div class="box">- <div class="box-header with-border">- <h3 class="box-title splitTitle">- <span v-if="transactions.length > 1">{{ $t('firefly.single_split') }} {{ index + 1 }} / {{- transactions.length- }}</span>- <span v-if="transactions.length === 1">{{- $t('firefly.transaction_journal_information')- }}</span>- </h3>- <div v-if="transactions.length > 1" class="box-tools pull-right">- <button class="btn btn-xs btn-danger" type="button"- v-on:click="deleteTransaction(index, $event)"><i- class="fa fa-trash"></i></button>- </div>- </div><div class="box-body"><div class="row">- <div id="transaction-info" class="col-lg-4">- <transaction-description- v-model="transaction.description"- :error="transaction.errors.description"- :index="index"- >- </transaction-description>- <account-select- :accountName="transaction.source_account.name"- :accountTypeFilters="transaction.source_account.allowed_types"- :defaultAccountTypeFilters="transaction.source_account.default_allowed_types"- :error="transaction.errors.source_account"- :index="index"- :transactionType="transactionType"- inputName="source[]"- v-bind:inputDescription="$t('firefly.source_account')"- v-on:clear:value="clearSource(index)"- v-on:select:account="selectedSourceAccount(index, $event)"- ></account-select>- <account-select- :accountName="transaction.destination_account.name"- :accountTypeFilters="transaction.destination_account.allowed_types"- :defaultAccountTypeFilters="transaction.destination_account.default_allowed_types"- :error="transaction.errors.destination_account"- :index="index"- :transactionType="transactionType"- inputName="destination[]"- v-bind:inputDescription="$t('firefly.destination_account')"- v-on:clear:value="clearDestination(index)"- v-on:select:account="selectedDestinationAccount(index, $event)"- ></account-select>- <p v-if="0!== index && (null === transactionType || 'invalid' === transactionType || '' === transactionType)"- class="text-warning">- {{ $t('firefly.multi_account_warning_unknown') }}- </p>- <p v-if="0!== index && 'Withdrawal' === transactionType" class="text-warning">- {{ $t('firefly.multi_account_warning_withdrawal') }}- </p>- <p v-if="0!== index && 'Deposit' === transactionType" class="text-warning">- {{ $t('firefly.multi_account_warning_deposit') }}- </p>- <p v-if="0!== index && 'Transfer' === transactionType" class="text-warning">- {{ $t('firefly.multi_account_warning_transfer') }}- </p>- <standard-date v-if="0===index"- v-model="transaction.date"- :error="transaction.errors.date"- :index="index"- >- </standard-date>- <div v-if="index===0">- <transaction-type- :destination="transaction.destination_account.type"- :source="transaction.source_account.type"- v-on:set:transactionType="setTransactionType($event)"- v-on:act:limitSourceType="limitSourceType($event)"- v-on:act:limitDestinationType="limitDestinationType($event)"- ></transaction-type>- </div>- </div><div id="amount-info" class="col-lg-4"><amountv-model="transaction.amount"diff --git a/resources/assets/v1/src/components/transactions/TransactionType.vue b/resources/assets/v1/src/components/transactions/TransactionType.vuedeleted file mode 100644index f49bdea9e5..0000000000--- a/resources/assets/v1/src/components/transactions/TransactionType.vue+++ /dev/null@@ -1,86 +0,0 @@-<!--- - TransactionType.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">- <div class="col-sm-12">- <label v-if="sentence !== ''" class="control-label text-info">- {{ sentence }}- </label>- </div>- </div>---</template>--<script>-export default {- props: {- source: String,- destination: String,- type: String- },- methods: {- changeValue: function () {- if (this.source && this.destination) {- let transactionType = '';- if (window.accountToTypes[this.source]) {- if (window.accountToTypes[this.source][this.destination]) {- transactionType = window.accountToTypes[this.source][this.destination];- } else {- console.warn('User selected an impossible destination.');- }- } else {- console.warn('User selected an impossible source.');- }- if ('' !== transactionType) {- this.transactionType = transactionType;- this.sentence = this.$t('firefly.you_create_' + transactionType.toLowerCase());-- // Must also emit a change to set ALL sources and destinations to this particular type.- this.$emit('act:limitSourceType', this.source);- this.$emit('act:limitDestinationType', this.destination);- }- } else {- this.sentence = '';- this.transactionType = '';- }- // emit event how cool is that.- this.$emit('set:transactionType', this.transactionType);- }- },- data() {- return {- transactionType: this.type,- sentence: ''-- }- },- watch: {- source() {- this.changeValue();- },- destination() {- this.changeValue();- }- },- name: "TransactionType"-}-</script>diff --git a/resources/assets/v3/js/pages/transactions/create.js b/resources/assets/v3/js/pages/transactions/create.jsindex 51dde6b74b..36c6db541e 100644--- a/resources/assets/v3/js/pages/transactions/create.js+++ b/resources/assets/v3/js/pages/transactions/create.js@@ -50,6 +50,7 @@ let create = function () {return {// transactions are stored in "entries":entries: [],+ i18next: null,// state of the form is stored in formState:formStates: {@@ -335,6 +336,7 @@ let create = function () {init() {console.log('init()');+ this.i18next = i18next;this.addSplit();// load currencies and save in form data.diff --git a/resources/views/components/transaction/split.blade.php b/resources/views/components/transaction/split.blade.phpindex 7b22cf1d35..9a53b01e24 100644--- a/resources/views/components/transaction/split.blade.php+++ b/resources/views/components/transaction/split.blade.php@@ -18,6 +18,9 @@<!-- DESTINATION ACCOUNT -->@include('partials.form.transaction.destination-account')+ <!-- DETECTED TRANSACTION TYPE -->+ @include('partials.form.transaction.transaction-type')+<!-- DATE AND TIME -->@include('partials.form.transaction.date-time')</div>diff --git a/resources/views/components/transaction/tab-list.blade.php b/resources/views/components/transaction/tab-list.blade.phpindex bfc5ebf965..59ff93c860 100644--- a/resources/views/components/transaction/tab-list.blade.php+++ b/resources/views/components/transaction/tab-list.blade.php@@ -21,9 +21,7 @@</li></template><li class="nav-item" role="presentation">- <button class="nav-link" type="button" role="tab" @click="addSplit()"- ><em class="bi bi-plus-circle"></em>- </button>+ <button class="nav-link" type="button" role="tab" @click="addSplit()"><em class="bi bi-plus-circle"></em></button></li><li class="nav-item"><a class="nav-link disabled" aria-disabled="true">diff --git a/resources/views/partials/form/transaction/transaction-type.blade.php b/resources/views/partials/form/transaction/transaction-type.blade.phpnew file mode 100644index 0000000000..d49bc68534--- /dev/null+++ b/resources/views/partials/form/transaction/transaction-type.blade.php@@ -0,0 +1,10 @@+<template x-if="'unknown' !== groupProperties.transactionType">+ <div class="row mb-0">+ <label class="col-sm-1 col-form-label d-none d-sm-block">+ + </label>+ <div class="col-sm-10">+ <em x-text="i18next.t('firefly.you_create_' + groupProperties.transactionType)"></em>+ </div>+ </div>+</template>