Skip to content

Firefly III: a personal finances manager

Some improvements, also edit screen.

James Cole2a2f29533d75
diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.php
new file mode 100644
index 0000000000..b0a8646d6a
--- /dev/null
+++ b/app/Http/Controllers/Transaction/EditController.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * EditController.php
+ * Copyright (c) 2019 [email protected]
+ *
+ * This file is part of Firefly III.
+ *
+ * Firefly III is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Firefly III 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace FireflyIII\Http\Controllers\Transaction;
+
+
+use FireflyIII\Http\Controllers\Controller;
+use FireflyIII\Models\TransactionGroup;
+use FireflyIII\Repositories\Account\AccountRepositoryInterface;
+
+/**
+ * Class EditController
+ */
+class EditController extends Controller
+{
+
+ /**
+ * SingleController constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+
+ $maxFileSize = app('steam')->phpBytes(ini_get('upload_max_filesize'));
+ $maxPostSize = app('steam')->phpBytes(ini_get('post_max_size'));
+ $uploadSize = min($maxFileSize, $maxPostSize);
+
+
+ app('view')->share('uploadSize', $uploadSize);
+
+ // some useful repositories:
+ $this->middleware(
+ function ($request, $next) {
+
+ app('view')->share('title', (string)trans('firefly.transactions'));
+ app('view')->share('mainTitleIcon', 'fa-repeat');
+
+ return $next($request);
+ }
+ );
+ }
+
+
+ /**
+ * @param TransactionGroup $transactionGroup
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ */
+ public function edit(TransactionGroup $transactionGroup)
+ {
+ /** @var AccountRepositoryInterface $repository */
+ $repository = app(AccountRepositoryInterface::class);
+ $allowedOpposingTypes = config('firefly.allowed_opposing_types');
+ $accountToTypes = config('firefly.account_to_transaction');
+ $defaultCurrency = app('amount')->getDefaultCurrency();
+ $cash = $repository->getCashAccount();
+
+ return view('transactions.edit', compact('cash', 'transactionGroup', 'allowedOpposingTypes', 'accountToTypes', 'defaultCurrency'
+
+ ));
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.php
index ae54bbe4fd..87b4c8c00a 100644
--- a/app/Services/Internal/Update/GroupUpdateService.php
+++ b/app/Services/Internal/Update/GroupUpdateService.php
@@ -56,10 +56,10 @@ class GroupUpdateService
Log::debug(sprintf('Will now update journal #%d (only journal in group #%d)', $first->id, $transactionGroup->id));
$this->updateTransactionJournal($transactionGroup, $first, reset($transactions));
$transactionGroup->refresh();
-
+ app('preferences')->mark();
return $transactionGroup;
}
- die('cannot update split');
+ die('cannot update split yet.');
app('preferences')->mark();
}
diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php
index c5e71e7a29..4ac0447a1e 100644
--- a/app/Transformers/TransactionGroupTransformer.php
+++ b/app/Transformers/TransactionGroupTransformer.php
@@ -295,6 +295,7 @@ class TransactionGroupTransformer extends AbstractTransformer
'currency_id' => $row['currency_id'],
'currency_code' => $row['currency_code'],
+ 'currency_name' => $row['currency_name'],
'currency_symbol' => $row['currency_symbol'],
'currency_decimal_places' => $row['currency_decimal_places'],
diff --git a/public/v1/js/app.js b/public/v1/js/app.js
index fc8910caa6..6ee10da05a 100644
--- a/public/v1/js/app.js
+++ b/public/v1/js/app.js
@@ -12551,7 +12551,9 @@ Vue.component('account-select', __webpack_require__(119));
Vue.component('passport-clients', __webpack_require__(124));
Vue.component('passport-authorized-clients', __webpack_require__(129));
Vue.component('passport-personal-access-tokens', __webpack_require__(134));
+
Vue.component('create-transaction', __webpack_require__(139));
+Vue.component('edit-transaction', __webpack_require__(144));
var app = new Vue({
el: '#app'
@@ -51533,7 +51535,7 @@ exports = module.exports = __webpack_require__(0)(false);
// module
-exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
+exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
// exports
@@ -51600,30 +51602,44 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
return this.error.length > 0;
},
changeData: function changeData() {
+ var transactionType = this.transactionType;
// reset of all are empty:
- //console.log('Type "' + this.transactionType + '"');
+ //console.log('Type "' + transactionType + '"');
//console.log('Source "' + this.source.name + '"');
//console.log('Dest "' + this.destination.name + '"');
- if (!this.transactionType && !this.source.name && !this.destination.name) {
+ if (!transactionType && !this.source.name && !this.destination.name) {
$(this.$refs.cur).text('');
+ console.log('A');
return;
}
- if ('' === this.transactionType && '' !== this.source.currency_name) {
+ if (null === transactionType) {
+ transactionType = '';
+ }
+
+ if ('' === transactionType && '' !== this.source.currency_name) {
$(this.$refs.cur).text(this.source.currency_name);
+ console.log('B');
return;
}
- if ('' === this.transactionType && '' !== this.destination.currency_name) {
+ if ('' === transactionType && '' !== this.destination.currency_name) {
$(this.$refs.cur).text(this.destination.currency_name);
+ console.log('C');
return;
}
- if (this.transactionType === 'Withdrawal' || this.transactionType === 'Transfer') {
+ if (transactionType === 'Withdrawal' || transactionType === 'Transfer') {
$(this.$refs.cur).text(this.source.currency_name);
+ console.log('D');
return;
}
- if (this.transactionType === 'Deposit') {
+ if (transactionType === 'Deposit') {
$(this.$refs.cur).text(this.destination.currency_name);
+ console.log('E');
return;
}
+ console.log('transactionType: ' + transactionType);
+ console.log('this.source.name: ' + this.source.name);
+ console.log('this.destination.name: ' + this.destination.name);
+ console.log('F');
}
},
watch: {
@@ -54882,7 +54898,7 @@ exports = module.exports = __webpack_require__(0)(false);
// module
-exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
+exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
// exports
@@ -55263,114 +55279,1607 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
return data;
},
submit: function submit(e) {
- var _this = this;
+ var _this = this;
+
+ var uri = './api/v1/transactions?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
+ var data = this.convertData();
+ if (this.resetFormAfter) {
+ this.resetTransactions();
+ }
+
+ var button = $(e.currentTarget);
+ button.prop("disabled", true);
+
+ axios.post(uri, data).then(function (response) {
+ if (_this.createAnother) {
+ // do message:
+ _this.success_message = '<a href="transactions/show/' + response.data.data.id + '">The transaction</a> has been stored.';
+ _this.error_message = '';
+ if (_this.resetFormAfter) {
+ _this.addTransaction();
+ }
+ button.prop("disabled", false);
+ } else {
+ window.location.href = 'transactions/show/' + response.data.data.id + '?message=created';
+ }
+ }).catch(function (error) {
+ // give user errors things back.
+ // something something render errors.
+ _this.parseErrors(error.response.data);
+ // something.
+ button.prop("disabled", false);
+ });
+ if (e) {
+ e.preventDefault();
+ }
+ },
+
+ setDefaultErrors: function setDefaultErrors() {
+ for (var key in this.transactions) {
+ if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+ this.transactions[key].errors = {
+ source_account: [],
+ destination_account: [],
+ description: [],
+ amount: [],
+ date: [],
+ budget_id: [],
+ foreign_amount: [],
+ category: [],
+ piggy_bank: [],
+ tags: [],
+ // custom fields:
+ custom_errors: {
+ interest_date: [],
+ book_date: [],
+ process_date: [],
+ due_date: [],
+ payment_date: [],
+ invoice_date: [],
+ internal_reference: [],
+ notes: [],
+ attachments: []
+ }
+ };
+ }
+ }
+ },
+ parseErrors: function parseErrors(errors) {
+ this.setDefaultErrors();
+ this.error_message = "";
+ if (errors.message.length > 0) {
+ this.error_message = "There was something wrong with your submission. Please check out the errors below.";
+ } else {
+ this.error_message = '';
+ }
+ var transactionIndex = void 0;
+ var fieldName = void 0;
+
+ for (var key in errors.errors) {
+ if (errors.errors.hasOwnProperty(key)) {
+ if (key === 'group_title') {
+ this.group_title_errors = errors.errors[key];
+ }
+ if (key !== 'group_title') {
+ // lol dumbest way to explode "transactions.0.something" ever.
+ transactionIndex = parseInt(key.split('.')[1]);
+ fieldName = key.split('.')[2];
+ // set error in this object thing.
+ switch (fieldName) {
+ case 'amount':
+ case 'date':
+ case 'budget_id':
+ case 'description':
+ case 'tags':
+ this.transactions[transactionIndex].errors[fieldName] = errors.errors[key];
+ break;
+ case 'source_name':
+ case 'source_id':
+ this.transactions[transactionIndex].errors.source_account = this.transactions[transactionIndex].errors.source_account.concat(errors.errors[key]);
+ break;
+ case 'destination_name':
+ case 'destination_id':
+ this.transactions[transactionIndex].errors.destination_account = this.transactions[transactionIndex].errors.destination_account.concat(errors.errors[key]);
+ break;
+ case 'foreign_amount':
+ case 'foreign_currency_id':
+ this.transactions[transactionIndex].errors.foreign_amount = this.transactions[transactionIndex].errors.foreign_amount.concat(errors.errors[key]);
+ break;
+ }
+ }
+ }
+ }
+ },
+ resetTransactions: function resetTransactions() {
+ this.transactions = [];
+ },
+ addTransaction: function addTransaction(e) {
+ this.transactions.push({
+ description: "",
+ date: "",
+ amount: "",
+ category: "",
+ piggy_bank: 0,
+ errors: {
+ source_account: [],
+ destination_account: [],
+ description: [],
+ amount: [],
+ date: [],
+ budget_id: [],
+ foreign_amount: [],
+ category: [],
+ piggy_bank: [],
+ tags: [],
+ // custom fields:
+ custom_errors: {
+ interest_date: [],
+ book_date: [],
+ process_date: [],
+ due_date: [],
+ payment_date: [],
+ invoice_date: [],
+ internal_reference: [],
+ notes: [],
+ attachments: []
+ }
+ },
+ budget: 0,
+ tags: [],
+ custom_fields: {
+ "interest_date": "",
+ "book_date": "",
+ "process_date": "",
+ "due_date": "",
+ "payment_date": "",
+ "invoice_date": "",
+ "internal_reference": "",
+ "notes": "",
+ "attachments": []
+ },
+ foreign_amount: {
+ amount: "",
+ currency_id: 0
+ },
+ source_account: {
+ id: 0,
+ name: "",
+ type: "",
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: []
+ },
+ destination_account: {
+ id: 0,
+ name: "",
+ type: "",
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: []
+ }
+ });
+ if (this.transactions.length === 1) {
+ // set first date.
+ var today = new Date();
+ this.transactions[0].date = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
+ }
+ if (e) {
+ e.preventDefault();
+ }
+ },
+ setTransactionType: function setTransactionType(type) {
+ this.transactionType = type;
+ },
+ deleteTransaction: function deleteTransaction(index, event) {
+ event.preventDefault();
+ for (var key in this.transactions) {
+ if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {}
+ }
+
+ this.transactions.splice(index, 1);
+
+ for (var _key in this.transactions) {
+ if (this.transactions.hasOwnProperty(_key) && /^0$|^[1-9]\d*$/.test(_key) && _key <= 4294967294) {}
+ }
+ },
+ limitSourceType: function limitSourceType(type) {
+ var i = void 0;
+ for (i = 0; i < this.transactions.length; i++) {
+ this.transactions[i].source_account.allowed_types = [type];
+ }
+ },
+ limitDestinationType: function limitDestinationType(type) {
+ var i = void 0;
+ for (i = 0; i < this.transactions.length; i++) {
+ this.transactions[i].destination_account.allowed_types = [type];
+ }
+ },
+
+ selectedSourceAccount: function selectedSourceAccount(index, model) {
+ if (typeof model === 'string') {
+ // cant change types, only name.
+ this.transactions[index].source_account.name = model;
+ } else {
+ this.transactions[index].source_account = {
+ id: model.id,
+ name: model.name,
+ type: model.type,
+ currency_id: model.currency_id,
+ currency_name: model.currency_name,
+ currency_code: model.currency_code,
+ currency_decimal_places: model.currency_decimal_places,
+ allowed_types: this.transactions[index].source_account.allowed_types
+ };
+
+ // force types on destination selector.
+ this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
+ }
+ },
+ selectedDestinationAccount: function selectedDestinationAccount(index, model) {
+ if (typeof model === 'string') {
+ // cant change types, only name.
+ this.transactions[index].destination_account.name = model;
+ } else {
+ this.transactions[index].destination_account = {
+ id: model.id,
+ name: model.name,
+ type: model.type,
+ currency_id: model.currency_id,
+ currency_name: model.currency_name,
+ currency_code: model.currency_code,
+ currency_decimal_places: model.currency_decimal_places,
+ allowed_types: this.transactions[index].destination_account.allowed_types
+ };
+
+ // force types on destination selector.
+ this.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type];
+ }
+ },
+ clearSource: function clearSource(index) {
+ console.log('clearSource(' + index + ')');
+ // reset source account:
+ this.transactions[index].source_account = {
+ id: 0,
+ name: '',
+ type: '',
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: this.transactions[index].source_account.allowed_types
+ };
+ // reset destination allowed account types.
+ this.transactions[index].destination_account.allowed_types = [];
+
+ // if there is a destination model, reset the types of the source
+ // by pretending we selected it again.
+ if (this.transactions[index].destination_account) {
+ this.selectedDestinationAccount(index, this.transactions[index].destination_account);
+ }
+ },
+ clearDestination: function clearDestination(index) {
+ console.log('clearDestination(' + index + ')');
+ // reset destination account:
+ this.transactions[index].destination_account = {
+ id: 0,
+ name: '',
+ type: '',
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: this.transactions[index].destination_account.allowed_types
+ };
+ // reset destination allowed account types.
+ this.transactions[index].source_account.allowed_types = [];
+
+ // if there is a source model, reset the types of the destination
+ // by pretending we selected it again.
+ if (this.transactions[index].source_account) {
+ this.selectedSourceAccount(index, this.transactions[index].source_account);
+ }
+ }
+ },
+
+ /*
+ * The component's data.
+ */
+ data: function data() {
+ return {
+ transactionType: null,
+ group_title: "",
+ transactions: [],
+ group_title_errors: [],
+ error_message: "",
+ success_message: "",
+ cash_account_id: 0,
+ createAnother: false,
+ resetFormAfter: false,
+ resetButtonDisabled: true
+ };
+ }
+});
+
+/***/ }),
+/* 143 */
+/***/ (function(module, exports, __webpack_require__) {
+
+var render = function() {
+ var _vm = this
+ var _h = _vm.$createElement
+ var _c = _vm._self._c || _h
+ return _c(
+ "form",
+ {
+ staticClass: "form-horizontal",
+ attrs: {
+ method: "POST",
+ action: "transactions/store",
+ "accept-charset": "UTF-8",
+ id: "store",
+ enctype: "multipart/form-data"
+ }
+ },
+ [
+ _c("input", { attrs: { name: "_token", type: "hidden", value: "xxx" } }),
+ _vm._v(" "),
+ _vm.error_message !== ""
+ ? _c("div", { staticClass: "row" }, [
+ _c("div", { staticClass: "col-lg-12" }, [
+ _c(
+ "div",
+ {
+ staticClass: "alert alert-danger alert-dismissible",
+ attrs: { role: "alert" }
+ },
+ [
+ _vm._m(0),
+ _vm._v(" "),
+ _c("strong", [_vm._v("Error!")]),
+ _vm._v(" " + _vm._s(_vm.error_message) + "\n ")
+ ]
+ )
+ ])
+ ])
+ : _vm._e(),
+ _vm._v(" "),
+ _vm.success_message !== ""
+ ? _c("div", { staticClass: "row" }, [
+ _c("div", { staticClass: "col-lg-12" }, [
+ _c(
+ "div",
+ {
+ staticClass: "alert alert-success alert-dismissible",
+ attrs: { role: "alert" }
+ },
+ [
+ _vm._m(1),
+ _vm._v(" "),
+ _c("strong", [_vm._v("Success!")]),
+ _vm._v(" "),
+ _c("span", {
+ domProps: { innerHTML: _vm._s(_vm.success_message) }
+ })
+ ]
+ )
+ ])
+ ])
+ : _vm._e(),
+ _vm._v(" "),
+ _vm.transactions.length > 1
+ ? _c("div", { staticClass: "row" }, [
+ _c("div", { staticClass: "col-lg-6" }, [
+ _c("div", { staticClass: "box" }, [
+ _vm._m(2),
+ _vm._v(" "),
+ _c(
+ "div",
+ { staticClass: "box-body" },
+ [
+ _c("group-description", {
+ attrs: { error: _vm.group_title_errors },
+ model: {
+ value: _vm.group_title,
+ callback: function($$v) {
+ _vm.group_title = $$v
+ },
+ expression: "group_title"
+ }
+ })
+ ],
+ 1
+ )
+ ])
+ ])
+ ])
+ : _vm._e(),
+ _vm._v(" "),
+ _c(
+ "div",
+ _vm._l(_vm.transactions, function(transaction, index) {
+ return _c("div", { staticClass: "row" }, [
+ _c("div", { staticClass: "col-lg-12" }, [
+ _c("div", { staticClass: "box" }, [
+ _c("div", { staticClass: "box-header with-border" }, [
+ _c("h3", { staticClass: "box-title splitTitle" }, [
+ _vm.transactions.length > 1
+ ? _c("span", [
+ _vm._v(
+ "Split " +
+ _vm._s(index + 1) +
+ " / " +
+ _vm._s(_vm.transactions.length)
+ )
+ ])
+ : _vm._e(),
+ _vm._v(" "),
+ _vm.transactions.length === 1
+ ? _c("span", [_vm._v("Transaction information")])
+ : _vm._e()
+ ]),
+ _vm._v(" "),
+ _vm.transactions.length > 1
+ ? _c(
+ "div",
+ {
+ staticClass: "box-tools pull-right",
+ attrs: { x: "" }
+ },
+ [
+ _c(
+ "button",
+ {
+ staticClass: "btn btn-xs btn-danger",
+ on: {
+ click: function($event) {
+ _vm.deleteTransaction(index, $event)
+ }
+ }
+ },
+ [_c("i", { staticClass: "fa fa-trash" })]
+ )
+ ]
+ )
+ : _vm._e()
+ ]),
+ _vm._v(" "),
+ _c("div", { staticClass: "box-body" }, [
+ _c("div", { staticClass: "row" }, [
+ _c(
+ "div",
+ { staticClass: "col-lg-4" },
+ [
+ _c("account-select", {
+ attrs: {
+ inputName: "source[]",
+ title: "Source account",
+ accountName: transaction.source_account.name,
+ accountTypeFilters:
+ transaction.source_account.allowed_types,
+ transactionType: _vm.transactionType,
+ index: index,
+ error: transaction.errors.source_account
+ },
+ on: {
+ "clear:value": function($event) {
+ _vm.clearSource(index)
+ },
+ "select:account": function($event) {
+ _vm.selectedSourceAccount(index, $event)
+ }
+ }
+ }),
+ _vm._v(" "),
+ _c("account-select", {
+ attrs: {
+ inputName: "destination[]",
+ title: "Destination account",
+ accountName: transaction.destination_account.name,
+ accountTypeFilters:
+ transaction.destination_account.allowed_types,
+ transactionType: _vm.transactionType,
+ index: index,
+ error: transaction.errors.destination_account
+ },
+ on: {
+ "clear:value": function($event) {
+ _vm.clearDestination(index)
+ },
+ "select:account": function($event) {
+ _vm.selectedDestinationAccount(index, $event)
+ }
+ }
+ }),
+ _vm._v(" "),
+ _c("transaction-description", {
+ attrs: {
+ index: index,
+ error: transaction.errors.description
+ },
+ model: {
+ value: transaction.description,
+ callback: function($$v) {
+ _vm.$set(transaction, "description", $$v)
+ },
+ expression: "transaction.description"
+ }
+ }),
+ _vm._v(" "),
+ _c("standard-date", {
+ attrs: {
+ index: index,
+ error: transaction.errors.date
+ },
+ model: {
+ value: transaction.date,
+ callback: function($$v) {
+ _vm.$set(transaction, "date", $$v)
+ },
+ expression: "transaction.date"
+ }
+ }),
+ _vm._v(" "),
+ index === 0
+ ? _c(
+ "div",
+ [
+ _c("transaction-type", {
+ attrs: {
+ source: transaction.source_account.type,
+ destination:
+ transaction.destination_account.type
+ },
+ on: {
+ "set:transactionType": function($event) {
+ _vm.setTransactionType($event)
+ },
+ "act:limitSourceType": function($event) {
+ _vm.limitSourceType($event)
+ },
+ "act:limitDestinationType": function(
+ $event
+ ) {
+ _vm.limitDestinationType($event)
+ }
+ }
+ })
+ ],
+ 1
+ )
+ : _vm._e()
+ ],
+ 1
+ ),
+ _vm._v(" "),
+ _c(
+ "div",
+ { staticClass: "col-lg-4" },
+ [
+ _c("amount", {
+ attrs: {
+ source: transaction.source_account,
+ destination: transaction.destination_account,
+ error: transaction.errors.amount,
+ transactionType: _vm.transactionType
+ },
+ model: {
+ value: transaction.amount,
+ callback: function($$v) {
+ _vm.$set(transaction, "amount", $$v)
+ },
+ expression: "transaction.amount"
+ }
+ }),
+ _vm._v(" "),
+ _c("foreign-amount", {
+ attrs: {
+ source: transaction.source_account,
+ destination: transaction.destination_account,
+ transactionType: _vm.transactionType,
+ error: transaction.errors.foreign_amount
+ },
+ model: {
+ value: transaction.foreign_amount,
+ callback: function($$v) {
+ _vm.$set(transaction, "foreign_amount", $$v)
+ },
+ expression: "transaction.foreign_amount"
+ }
+ })
+ ],
+ 1
+ ),
+ _vm._v(" "),
+ _c(
+ "div",
+ { staticClass: "col-lg-4" },
+ [
+ _c("budget", {
+ attrs: {
+ transactionType: _vm.transactionType,
+ error: transaction.errors.budget_id
+ },
+ model: {
+ value: transaction.budget,
+ callback: function($$v) {
+ _vm.$set(transaction, "budget", $$v)
+ },
+ expression: "transaction.budget"
+ }
+ }),
+ _vm._v(" "),
+ _c("category", {
+ attrs: {
+ transactionType: _vm.transactionType,
+ error: transaction.errors.category
+ },
+ model: {
+ value: transaction.category,
+ callback: function($$v) {
+ _vm.$set(transaction, "category", $$v)
+ },
+ expression: "transaction.category"
+ }
+ }),
+ _vm._v(" "),
+ _c("piggy-bank", {
+ attrs: {
+ transactionType: _vm.transactionType,
+ error: transaction.errors.piggy_bank
+ },
+ model: {
+ value: transaction.piggy_bank,
+ callback: function($$v) {
+ _vm.$set(transaction, "piggy_bank", $$v)
+ },
+ expression: "transaction.piggy_bank"
+ }
+ }),
+ _vm._v(" "),
+ _c("tags", {
+ attrs: { error: transaction.errors.tags },
+ model: {
+ value: transaction.tags,
+ callback: function($$v) {
+ _vm.$set(transaction, "tags", $$v)
+ },
+ expression: "transaction.tags"
+ }
+ }),
+ _vm._v(" "),
+ _c("custom-transaction-fields", {
+ attrs: { error: transaction.errors.custom_errors },
+ model: {
+ value: transaction.custom_fields,
+ callback: function($$v) {
+ _vm.$set(transaction, "custom_fields", $$v)
+ },
+ expression: "transaction.custom_fields"
+ }
+ })
+ ],
+ 1
+ )
+ ])
+ ]),
+ _vm._v(" "),
+ _vm.transactions.length - 1 === index
+ ? _c("div", { staticClass: "box-footer" }, [
+ _c(
+ "button",
+ {
+ staticClass: "btn btn-primary",
+ on: { click: _vm.addTransaction }
+ },
+ [_vm._v("Add another split")]
+ )
+ ])
+ : _vm._e()
+ ])
+ ])
+ ])
+ }),
+ 0
+ ),
+ _vm._v(" "),
+ _c("div", { staticClass: "row" }, [
+ _c("div", { staticClass: "col-lg-3 col-md-4 col-sm-6 col-xs-12" }, [
+ _c("div", { staticClass: "box" }, [
+ _vm._m(3),
+ _vm._v(" "),
+ _c("div", { staticClass: "box-body" }, [
+ _c("div", { staticClass: "checkbox" }, [
+ _c("label", [
+ _c("input", {
+ directives: [
+ {
+ name: "model",
+ rawName: "v-model",
+ value: _vm.createAnother,
+ expression: "createAnother"
+ }
+ ],
+ attrs: { name: "create_another", type: "checkbox" },
+ domProps: {
+ checked: Array.isArray(_vm.createAnother)
+ ? _vm._i(_vm.createAnother, null) > -1
+ : _vm.createAnother
+ },
+ on: {
+ change: function($event) {
+ var $$a = _vm.createAnother,
+ $$el = $event.target,
+ $$c = $$el.checked ? true : false
+ if (Array.isArray($$a)) {
+ var $$v = null,
+ $$i = _vm._i($$a, $$v)
+ if ($$el.checked) {
+ $$i < 0 && (_vm.createAnother = $$a.concat([$$v]))
+ } else {
+ $$i > -1 &&
+ (_vm.createAnother = $$a
+ .slice(0, $$i)
+ .concat($$a.slice($$i + 1)))
+ }
+ } else {
+ _vm.createAnother = $$c
+ }
+ }
+ }
+ }),
+ _vm._v(
+ "\n After storing, return here to create another one.\n "
+ )
+ ]),
+ _vm._v(" "),
+ _c(
+ "label",
+ { class: { "text-muted": this.createAnother === false } },
+ [
+ _c("input", {
+ directives: [
+ {
+ name: "model",
+ rawName: "v-model",
+ value: _vm.resetFormAfter,
+ expression: "resetFormAfter"
+ }
+ ],
+ attrs: {
+ disabled: this.createAnother === false,
+ name: "reset_form",
+ type: "checkbox"
+ },
+ domProps: {
+ checked: Array.isArray(_vm.resetFormAfter)
+ ? _vm._i(_vm.resetFormAfter, null) > -1
+ : _vm.resetFormAfter
+ },
+ on: {
+ change: function($event) {
+ var $$a = _vm.resetFormAfter,
+ $$el = $event.target,
+ $$c = $$el.checked ? true : false
+ if (Array.isArray($$a)) {
+ var $$v = null,
+ $$i = _vm._i($$a, $$v)
+ if ($$el.checked) {
+ $$i < 0 &&
+ (_vm.resetFormAfter = $$a.concat([$$v]))
+ } else {
+ $$i > -1 &&
+ (_vm.resetFormAfter = $$a
+ .slice(0, $$i)
+ .concat($$a.slice($$i + 1)))
+ }
+ } else {
+ _vm.resetFormAfter = $$c
+ }
+ }
+ }
+ }),
+ _vm._v(
+ "\n Reset form after submission\n\n "
+ )
+ ]
+ )
+ ])
+ ]),
+ _vm._v(" "),
+ _c("div", { staticClass: "box-footer" }, [
+ _c("div", { staticClass: "btn-group" }, [
+ _c(
+ "button",
+ {
+ staticClass: "btn btn-success",
+ attrs: { id: "submitButton" },
+ on: { click: _vm.submit }
+ },
+ [_vm._v("Submit")]
+ )
+ ])
+ ])
+ ])
+ ])
+ ])
+ ]
+ )
+}
+var staticRenderFns = [
+ function() {
+ var _vm = this
+ var _h = _vm.$createElement
+ var _c = _vm._self._c || _h
+ return _c(
+ "button",
+ {
+ staticClass: "close",
+ attrs: {
+ type: "button",
+ "data-dismiss": "alert",
+ "aria-label": "Close"
+ }
+ },
+ [_c("span", { attrs: { "aria-hidden": "true" } }, [_vm._v("×")])]
+ )
+ },
+ function() {
+ var _vm = this
+ var _h = _vm.$createElement
+ var _c = _vm._self._c || _h
+ return _c(
+ "button",
+ {
+ staticClass: "close",
+ attrs: {
+ type: "button",
+ "data-dismiss": "alert",
+ "aria-label": "Close"
+ }
+ },
+ [_c("span", { attrs: { "aria-hidden": "true" } }, [_vm._v("×")])]
+ )
+ },
+ function() {
+ var _vm = this
+ var _h = _vm.$createElement
+ var _c = _vm._self._c || _h
+ return _c("div", { staticClass: "box-header with-border" }, [
+ _c("h3", { staticClass: "box-title" }, [
+ _vm._v(
+ "\n Description of the split transaction\n "
+ )
+ ])
+ ])
+ },
+ function() {
+ var _vm = this
+ var _h = _vm.$createElement
+ var _c = _vm._self._c || _h
+ return _c("div", { staticClass: "box-header with-border" }, [
+ _c("h3", { staticClass: "box-title" }, [
+ _vm._v("\n Submission\n ")
+ ])
+ ])
+ }
+]
+render._withStripped = true
+module.exports = { render: render, staticRenderFns: staticRenderFns }
+if (false) {
+ module.hot.accept()
+ if (module.hot.data) {
+ require("vue-hot-reload-api") .rerender("data-v-3c64c482", module.exports)
+ }
+}
+
+/***/ }),
+/* 144 */
+/***/ (function(module, exports, __webpack_require__) {
+
+var disposed = false
+function injectStyle (ssrContext) {
+ if (disposed) return
+ __webpack_require__(145)
+}
+var normalizeComponent = __webpack_require__(2)
+/* script */
+var __vue_script__ = __webpack_require__(147)
+/* template */
+var __vue_template__ = __webpack_require__(148)
+/* template functional */
+var __vue_template_functional__ = false
+/* styles */
+var __vue_styles__ = injectStyle
+/* scopeId */
+var __vue_scopeId__ = "data-v-16510831"
+/* moduleIdentifier (server only) */
+var __vue_module_identifier__ = null
+var Component = normalizeComponent(
+ __vue_script__,
+ __vue_template__,
+ __vue_template_functional__,
+ __vue_styles__,
+ __vue_scopeId__,
+ __vue_module_identifier__
+)
+Component.options.__file = "resources/assets/js/components/transactions/EditTransaction.vue"
+
+/* hot reload */
+if (false) {(function () {
+ var hotAPI = require("vue-hot-reload-api")
+ hotAPI.install(require("vue"), false)
+ if (!hotAPI.compatible) return
+ module.hot.accept()
+ if (!module.hot.data) {
+ hotAPI.createRecord("data-v-16510831", Component.options)
+ } else {
+ hotAPI.reload("data-v-16510831", Component.options)
+ }
+ module.hot.dispose(function (data) {
+ disposed = true
+ })
+})()}
+
+module.exports = Component.exports
+
+
+/***/ }),
+/* 145 */
+/***/ (function(module, exports, __webpack_require__) {
+
+// style-loader: Adds some css to the DOM by adding a <style> tag
+
+// load the styles
+var content = __webpack_require__(146);
+if(typeof content === 'string') content = [[module.i, content, '']];
+if(content.locals) module.exports = content.locals;
+// add the styles to the DOM
+var update = __webpack_require__(1)("b5880834", content, false, {});
+// Hot Module Replacement
+if(false) {
+ // When the styles change, update the <style> tags
+ if(!content.locals) {
+ module.hot.accept("!!../../../../../node_modules/css-loader/index.js!../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-16510831\",\"scoped\":true,\"hasInlineConfig\":true}!../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./EditTransaction.vue", function() {
+ var newContent = require("!!../../../../../node_modules/css-loader/index.js!../../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-16510831\",\"scoped\":true,\"hasInlineConfig\":true}!../../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./EditTransaction.vue");
+ if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
+ update(newContent);
+ });
+ }
+ // When the module is disposed, remove the <style> tags
+ module.hot.dispose(function() { update(); });
+}
+
+/***/ }),
+/* 146 */
+/***/ (function(module, exports, __webpack_require__) {
+
+exports = module.exports = __webpack_require__(0)(false);
+// imports
+
+
+// module
+exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
+
+// exports
+
+
+/***/ }),
+/* 147 */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+
+/* harmony default export */ __webpack_exports__["default"] = ({
+ name: "EditTransaction",
+ props: {
+ groupId: Number
+ },
+ mounted: function mounted() {
+ this.getGroup();
+ },
+ ready: function ready() {
+ console.log('Ready Group ID: ' + this.groupId);
+ },
+
+ methods: {
+ positiveAmount: function positiveAmount(amount) {
+ if (amount < 0) {
+ return amount * -1;
+ }
+ return amount;
+ },
+
+ selectedSourceAccount: function selectedSourceAccount(index, model) {
+ if (typeof model === 'string') {
+ // cant change types, only name.
+ this.transactions[index].source_account.name = model;
+ } else {
+ this.transactions[index].source_account = {
+ id: model.id,
+ name: model.name,
+ type: model.type,
+ currency_id: model.currency_id,
+ currency_name: model.currency_name,
+ currency_code: model.currency_code,
+ currency_decimal_places: model.currency_decimal_places,
+ allowed_types: this.transactions[index].source_account.allowed_types
+ };
+
+ // force types on destination selector.
+ //this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
+ }
+ },
+ selectedDestinationAccount: function selectedDestinationAccount(index, model) {
+ if (typeof model === 'string') {
+ // cant change types, only name.
+ this.transactions[index].destination_account.name = model;
+ } else {
+ this.transactions[index].destination_account = {
+ id: model.id,
+ name: model.name,
+ type: model.type,
+ currency_id: model.currency_id,
+ currency_name: model.currency_name,
+ currency_code: model.currency_code,
+ currency_decimal_places: model.currency_decimal_places,
+ allowed_types: this.transactions[index].destination_account.allowed_types
+ };
+
+ // force types on destination selector.
+ //this.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type];
+ }
+ },
+ clearSource: function clearSource(index) {
+ console.log('clearSource(' + index + ')');
+ // reset source account:
+ this.transactions[index].source_account = {
+ id: 0,
+ name: '',
+ type: '',
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: this.transactions[index].source_account.allowed_types
+ };
+ // reset destination allowed account types.
+ // this.transactions[index].destination_account.allowed_types = [];
+
+ // if there is a destination model, reset the types of the source
+ // by pretending we selected it again.
+ if (this.transactions[index].destination_account) {
+ this.selectedDestinationAccount(index, this.transactions[index].destination_account);
+ }
+ },
+ setTransactionType: function setTransactionType(type) {
+ this.transactionType = type;
+ },
+ deleteTransaction: function deleteTransaction(index, event) {
+ event.preventDefault();
+ for (var key in this.transactions) {
+ if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {}
+ }
+
+ this.transactions.splice(index, 1);
+
+ for (var _key in this.transactions) {
+ if (this.transactions.hasOwnProperty(_key) && /^0$|^[1-9]\d*$/.test(_key) && _key <= 4294967294) {}
+ }
+ },
+ clearDestination: function clearDestination(index) {
+ console.log('clearDestination(' + index + ')');
+ // reset destination account:
+ console.log('Destination allowed types first:');
+ console.log(this.transactions[index].destination_account.allowed_types);
+ this.transactions[index].destination_account = {
+ id: 0,
+ name: '',
+ type: '',
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: this.transactions[index].destination_account.allowed_types
+ };
+ // reset destination allowed account types.
+ //this.transactions[index].source_account.allowed_types = [];
+
+ // if there is a source model, reset the types of the destination
+ // by pretending we selected it again.
+ if (this.transactions[index].source_account) {
+ this.selectedSourceAccount(index, this.transactions[index].source_account);
+ }
+
+ console.log('Destination allowed types after:');
+ console.log(this.transactions[index].destination_account.allowed_types);
+ },
+ getGroup: function getGroup() {
+ var _this = this;
+
+ var page = window.location.href.split('/');
+ var groupId = page[page.length - 1];
+
+ var uri = './api/v1/transactions/' + groupId + '?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
+ console.log(uri);
+
+ // fill in transactions array.
+ axios.get(uri).then(function (response) {
+ console.log(response.data.data);
+ _this.group_title = response.data.data.attributes.group_title;
+ var transactions = response.data.data.attributes.transactions.reverse();
+ for (var key in transactions) {
+ if (transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+ var transaction = transactions[key];
+ console.log(transactions[key]);
+ _this.transactions.push({
+ description: transaction.description,
+ date: transaction.date.substr(0, 10),
+ amount: _this.positiveAmount(transaction.amount),
+ category: transaction.category_name,
+ errors: {
+ source_account: [],
+ destination_account: [],
+ description: [],
+ amount: [],
+ date: [],
+ budget_id: [],
+ foreign_amount: [],
+ category: [],
+ piggy_bank: [],
+ tags: [],
+ // custom fields:
+ custom_errors: {
+ interest_date: [],
+ book_date: [],
+ process_date: [],
+ due_date: [],
+ payment_date: [],
+ invoice_date: [],
+ internal_reference: [],
+ notes: [],
+ attachments: []
+ }
+ },
+ budget: transaction.budget_id,
+ tags: transaction.tags,
+ custom_fields: {
+ interest_date: transaction.interest_date,
+ book_date: transaction.book_date,
+ process_date: transaction.process_date,
+ due_date: transaction.due_date,
+ payment_date: transaction.payment_date,
+ invoice_date: transaction.invoice_date,
+ internal_reference: transaction.internal_reference,
+ notes: transaction.notes
+ },
+ foreign_amount: {
+ amount: _this.positiveAmount(transaction.foreign_amount),
+ currency_id: transaction.foreign_currency_id
+ },
+ source_account: {
+ id: transaction.source_id,
+ name: transaction.source_name,
+ type: transaction.source_type,
+ // i dont know these
+ currency_id: transaction.currency_id,
+ currency_name: transaction.currency_name,
+ currency_code: transaction.currency_code,
+ currency_decimal_places: transaction.currency_decimal_places,
+ allowed_types: [transaction.source_type]
+ },
+ destination_account: {
+ id: transaction.destination_id,
+ name: transaction.destination_name,
+ type: transaction.destination_type,
+ currency_id: transaction.currency_id,
+ currency_name: transaction.currency_name,
+ currency_code: transaction.currency_code,
+ currency_decimal_places: transaction.currency_decimal_places,
+ allowed_types: [transaction.destination_type]
+ }
+ });
+ }
+ }
+ }).catch(function (error) {
+ console.error('Some error.');
+ });
+ },
+ convertData: function convertData() {
+ var data = {
+ 'transactions': []
+ };
+ var tagList = [];
+ var transactionType = void 0;
+ var firstSource = void 0;
+ var firstDestination = void 0;
+ var foreignAmount = null;
+ var foreignCurrency = null;
+ var currentArray = void 0;
+ var sourceId = void 0;
+ var sourceName = void 0;
+ var destId = void 0;
+ var destName = void 0;
+ var date = void 0;
+
+ if (this.transactions.length > 1) {
+ data.group_title = this.group_title;
+ }
+
+ // get transaction type from first transaction
+ transactionType = this.transactionType ? this.transactionType.toLowerCase() : 'invalid';
+
+ // if the transaction type is invalid, might just be that we can deduce it from
+ // the presence of a source or destination account
+ firstSource = this.transactions[0].source_account.type;
+ firstDestination = this.transactions[0].destination_account.type;
+
+ if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstSource)) {
+ //console.log('Assumed this is a withdrawal.');
+ transactionType = 'withdrawal';
+ }
+
+ if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstDestination)) {
+ //console.log('Assumed this is a deposit.');
+ transactionType = 'deposit';
+ }
+
+ for (var key in this.transactions) {
+ if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+
+ sourceId = this.transactions[key].source_account.id;
+ sourceName = this.transactions[key].source_account.name;
+ destId = this.transactions[key].destination_account.id;
+ destName = this.transactions[key].destination_account.name;
+
+ date = this.transactions[key].date;
+ if (key > 0) {
+ date = this.transactions[0].date;
+ }
+
+ // if type is 'withdrawal' and destination is empty, cash withdrawal.
+ if (transactionType === 'withdrawal' && '' === destName) {
+ destId = window.cashAccountId;
+ }
+
+ // if type is 'deposit' and source is empty, cash deposit.
+ if (transactionType === 'deposit' && '' === sourceName) {
+ sourceId = window.cashAccountId;
+ }
+
+ // if key is over 0 and type is withdrawal or transfer, take source from key 0.
+ if (key > 0 && (transactionType.toLowerCase() === 'withdrawal' || transactionType.toLowerCase() === 'transfer')) {
+ sourceId = this.transactions[0].source_account.id;
+ sourceName = this.transactions[0].source_account.name;
+ }
+
+ // if key is over 0 and type is deposit or transfer, take destination from key 0.
+ if (key > 0 && (transactionType.toLowerCase() === 'deposit' || transactionType.toLowerCase() === 'transfer')) {
+ destId = this.transactions[0].destination_account.id;
+ destName = this.transactions[0].destination_account.name;
+ }
+
+ tagList = [];
+ foreignAmount = null;
+ foreignCurrency = null;
+ // loop tags
+ for (var tagKey in this.transactions[key].tags) {
+ if (this.transactions[key].tags.hasOwnProperty(tagKey) && /^0$|^[1-9]\d*$/.test(tagKey) && key <= 4294967294) {
+ tagList.push(this.transactions[key].tags[tagKey].text);
+ }
+ }
+
+ // set foreign currency info:
+ if (this.transactions[key].foreign_amount.amount !== '' && parseFloat(this.transactions[key].foreign_amount.amount) !== .00) {
+ foreignAmount = this.transactions[key].foreign_amount.amount;
+ foreignCurrency = this.transactions[key].foreign_amount.currency_id;
+ }
+ if (foreignCurrency === this.transactions[key].currency_id) {
+ foreignAmount = null;
+ foreignCurrency = null;
+ }
+
+ // correct some id's
+ if (0 === destId) {
+ destId = null;
+ }
+ if (0 === sourceId) {
+ sourceId = null;
+ }
+
+ currentArray = {
+ type: transactionType,
+ date: date,
+
+ amount: this.transactions[key].amount,
+ currency_id: this.transactions[key].currency_id,
+
+ description: this.transactions[key].description,
+
+ source_id: sourceId,
+ source_name: sourceName,
+
+ destination_id: destId,
+ destination_name: destName,
+
+ category_name: this.transactions[key].category,
+ //budget_id: this.transactions[key].budget,
+ //piggy_bank_id: this.transactions[key].piggy_bank,
+
+
+ interest_date: this.transactions[key].custom_fields.interest_date,
+ book_date: this.transactions[key].custom_fields.book_date,
+ process_date: this.transactions[key].custom_fields.process_date,
+ due_date: this.transactions[key].custom_fields.due_date,
+ payment_date: this.transactions[key].custom_fields.payment_date,
+ invoice_date: this.transactions[key].custom_fields.invoice_date,
+ internal_reference: this.transactions[key].custom_fields.internal_reference,
+ notes: this.transactions[key].custom_fields.notes
+ };
+
+ if (tagList.length > 0) {
+ currentArray.tags = tagList;
+ }
+ if (null !== foreignAmount) {
+ currentArray.foreign_amount = foreignAmount;
+ currentArray.foreign_currency_id = foreignCurrency;
+ }
+ // set budget id and piggy ID.
+ if (parseInt(this.transactions[key].budget) > 0) {
+ currentArray.budget_id = parseInt(this.transactions[key].budget);
+ }
+ if (parseInt(this.transactions[key].piggy_bank) > 0) {
+ currentArray.piggy_bank_id = parseInt(this.transactions[key].piggy_bank);
+ }
+
+ data.transactions.push(currentArray);
+ }
+ }
+ //console.log(data);
+
+ return data;
+ },
+ submit: function submit(e) {
+ var _this2 = this;
- var uri = './api/v1/transactions?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
+ console.log('I am submit');
+ var page = window.location.href.split('/');
+ var groupId = page[page.length - 1];
+ var uri = './api/v1/transactions/' + groupId + '?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
var data = this.convertData();
- if (this.resetFormAfter) {
- this.resetTransactions();
- }
- axios.post(uri, data).then(function (response) {
- if (_this.createAnother) {
+
+ var button = $(e.currentTarget);
+ button.prop("disabled", true);
+
+ axios.put(uri, data).then(function (response) {
+ if (_this2.returnAfter) {
// do message:
- _this.success_message = '<a href="transactions/show/' + response.data.data.id + '">The transaction</a> has been stored.';
- _this.error_message = '';
- if (_this.resetFormAfter) {
- _this.addTransaction();
+ _this2.success_message = '<a href="transactions/show/' + response.data.data.id + '">The transaction</a> has been updated.';
+ _this2.error_message = '';
+ button.prop("disabled", false);
+ // TODO better
+ if (_this2.resetFormAfter) {
+ _this2.getGroup();
}
} else {
- window.location.href = 'transactions/show/' + response.data.data.id + '?message=created';
+ window.location.href = 'transactions/show/' + response.data.data.id + '?message=updated';
}
}).catch(function (error) {
// give user errors things back.
// something something render errors.
- _this.parseErrors(error.response.data);
+ _this2.parseErrors(error.response.data);
// something.
+ button.prop("disabled", false);
});
if (e) {
e.preventDefault();
}
},
-
- setDefaultErrors: function setDefaultErrors() {
- for (var key in this.transactions) {
- if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
- this.transactions[key].errors = {
- source_account: [],
- destination_account: [],
- description: [],
- amount: [],
- date: [],
- budget_id: [],
- foreign_amount: [],
- category: [],
- piggy_bank: [],
- tags: [],
- // custom fields:
- custom_errors: {
- interest_date: [],
- book_date: [],
- process_date: [],
- due_date: [],
- payment_date: [],
- invoice_date: [],
- internal_reference: [],
- notes: [],
- attachments: []
- }
- };
- }
- }
- },
- parseErrors: function parseErrors(errors) {
- this.setDefaultErrors();
- this.error_message = "";
- if (errors.message.length > 0) {
- this.error_message = "There was something wrong with your submission. Please check out the errors below.";
- } else {
- this.error_message = '';
- }
- var transactionIndex = void 0;
- var fieldName = void 0;
-
- for (var key in errors.errors) {
- if (errors.errors.hasOwnProperty(key)) {
- if (key === 'group_title') {
- this.group_title_errors = errors.errors[key];
- }
- if (key !== 'group_title') {
- // lol dumbest way to explode "transactions.0.something" ever.
- transactionIndex = parseInt(key.split('.')[1]);
- fieldName = key.split('.')[2];
- // set error in this object thing.
- switch (fieldName) {
- case 'amount':
- case 'date':
- case 'budget_id':
- case 'description':
- case 'tags':
- this.transactions[transactionIndex].errors[fieldName] = errors.errors[key];
- break;
- case 'source_name':
- case 'source_id':
- this.transactions[transactionIndex].errors.source_account = this.transactions[transactionIndex].errors.source_account.concat(errors.errors[key]);
- break;
- case 'destination_name':
- case 'destination_id':
- this.transactions[transactionIndex].errors.destination_account = this.transactions[transactionIndex].errors.destination_account.concat(errors.errors[key]);
- break;
- case 'foreign_amount':
- case 'foreign_currency_id':
- this.transactions[transactionIndex].errors.foreign_amount = this.transactions[transactionIndex].errors.foreign_amount.concat(errors.errors[key]);
- break;
- }
- }
- }
- }
- },
- resetTransactions: function resetTransactions() {
- this.transactions = [];
- },
addTransaction: function addTransaction(e) {
this.transactions.push({
description: "",
@@ -55440,150 +56949,29 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
allowed_types: []
}
});
- if (this.transactions.length === 1) {
- // set first date.
- var today = new Date();
- this.transactions[0].date = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
- }
if (e) {
e.preventDefault();
}
- },
- setTransactionType: function setTransactionType(type) {
- this.transactionType = type;
- },
- deleteTransaction: function deleteTransaction(index, event) {
- event.preventDefault();
- for (var key in this.transactions) {
- if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {}
- }
-
- this.transactions.splice(index, 1);
-
- for (var _key in this.transactions) {
- if (this.transactions.hasOwnProperty(_key) && /^0$|^[1-9]\d*$/.test(_key) && _key <= 4294967294) {}
- }
- },
- limitSourceType: function limitSourceType(type) {
- var i = void 0;
- for (i = 0; i < this.transactions.length; i++) {
- this.transactions[i].source_account.allowed_types = [type];
- }
- },
- limitDestinationType: function limitDestinationType(type) {
- var i = void 0;
- for (i = 0; i < this.transactions.length; i++) {
- this.transactions[i].destination_account.allowed_types = [type];
- }
- },
-
- selectedSourceAccount: function selectedSourceAccount(index, model) {
- if (typeof model === 'string') {
- // cant change types, only name.
- this.transactions[index].source_account.name = model;
- } else {
- this.transactions[index].source_account = {
- id: model.id,
- name: model.name,
- type: model.type,
- currency_id: model.currency_id,
- currency_name: model.currency_name,
- currency_code: model.currency_code,
- currency_decimal_places: model.currency_decimal_places,
- allowed_types: this.transactions[index].source_account.allowed_types
- };
-
- // force types on destination selector.
- this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
- }
- },
- selectedDestinationAccount: function selectedDestinationAccount(index, model) {
- if (typeof model === 'string') {
- // cant change types, only name.
- this.transactions[index].destination_account.name = model;
- } else {
- this.transactions[index].destination_account = {
- id: model.id,
- name: model.name,
- type: model.type,
- currency_id: model.currency_id,
- currency_name: model.currency_name,
- currency_code: model.currency_code,
- currency_decimal_places: model.currency_decimal_places,
- allowed_types: this.transactions[index].destination_account.allowed_types
- };
-
- // force types on destination selector.
- this.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type];
- }
- },
- clearSource: function clearSource(index) {
- console.log('clearSource(' + index + ')');
- // reset source account:
- this.transactions[index].source_account = {
- id: 0,
- name: '',
- type: '',
- currency_id: 0,
- currency_name: '',
- currency_code: '',
- currency_decimal_places: 2,
- allowed_types: this.transactions[index].source_account.allowed_types
- };
- // reset destination allowed account types.
- this.transactions[index].destination_account.allowed_types = [];
-
- // if there is a destination model, reset the types of the source
- // by pretending we selected it again.
- if (this.transactions[index].destination_account) {
- this.selectedDestinationAccount(index, this.transactions[index].destination_account);
- }
- },
- clearDestination: function clearDestination(index) {
- console.log('clearDestination(' + index + ')');
- // reset destination account:
- this.transactions[index].destination_account = {
- id: 0,
- name: '',
- type: '',
- currency_id: 0,
- currency_name: '',
- currency_code: '',
- currency_decimal_places: 2,
- allowed_types: this.transactions[index].destination_account.allowed_types
- };
- // reset destination allowed account types.
- this.transactions[index].source_account.allowed_types = [];
-
- // if there is a source model, reset the types of the destination
- // by pretending we selected it again.
- if (this.transactions[index].source_account) {
- this.selectedSourceAccount(index, this.transactions[index].source_account);
- }
}
},
- /*
- * The component's data.
- */
data: function data() {
return {
- transactionType: null,
- group_title: "",
- transactions: [],
- group_title_errors: [],
+ group: this.groupId,
error_message: "",
success_message: "",
- cash_account_id: 0,
- createAnother: false,
- resetFormAfter: false,
+ transactions: [],
+ group_title: "",
+ returnAfter: false,
+ transactionType: null,
+ group_title_errors: [],
resetButtonDisabled: true
};
}
});
/***/ }),
-/* 143 */
+/* 148 */
/***/ (function(module, exports, __webpack_require__) {
var render = function() {
@@ -55596,7 +56984,7 @@ var render = function() {
staticClass: "form-horizontal",
attrs: {
method: "POST",
- action: "transactions/store",
+ action: "transactions/update",
"accept-charset": "UTF-8",
id: "store",
enctype: "multipart/form-data"
@@ -55904,20 +57292,6 @@ var render = function() {
}
}),
_vm._v(" "),
- _c("piggy-bank", {
- attrs: {
- transactionType: _vm.transactionType,
- error: transaction.errors.piggy_bank
- },
- model: {
- value: transaction.piggy_bank,
- callback: function($$v) {
- _vm.$set(transaction, "piggy_bank", $$v)
- },
- expression: "transaction.piggy_bank"
- }
- }),
- _vm._v(" "),
_c("tags", {
attrs: { error: transaction.errors.tags },
model: {
@@ -55977,94 +57351,42 @@ var render = function() {
{
name: "model",
rawName: "v-model",
- value: _vm.createAnother,
- expression: "createAnother"
+ value: _vm.returnAfter,
+ expression: "returnAfter"
}
],
- attrs: { name: "create_another", type: "checkbox" },
+ attrs: { name: "return_after", type: "checkbox" },
domProps: {
- checked: Array.isArray(_vm.createAnother)
- ? _vm._i(_vm.createAnother, null) > -1
- : _vm.createAnother
+ checked: Array.isArray(_vm.returnAfter)
+ ? _vm._i(_vm.returnAfter, null) > -1
+ : _vm.returnAfter
},
on: {
change: function($event) {
- var $$a = _vm.createAnother,
+ var $$a = _vm.returnAfter,
$$el = $event.target,
$$c = $$el.checked ? true : false
if (Array.isArray($$a)) {
var $$v = null,
$$i = _vm._i($$a, $$v)
if ($$el.checked) {
- $$i < 0 && (_vm.createAnother = $$a.concat([$$v]))
+ $$i < 0 && (_vm.returnAfter = $$a.concat([$$v]))
} else {
$$i > -1 &&
- (_vm.createAnother = $$a
+ (_vm.returnAfter = $$a
.slice(0, $$i)
.concat($$a.slice($$i + 1)))
}
} else {
- _vm.createAnother = $$c
+ _vm.returnAfter = $$c
}
}
}
}),
_vm._v(
- "\n After storing, return here to create another one.\n "
+ "\n After updating, return here to create another one.\n "
)
- ]),
- _vm._v(" "),
- _c(
- "label",
- { class: { "text-muted": this.createAnother === false } },
- [
- _c("input", {
- directives: [
- {
- name: "model",
- rawName: "v-model",
- value: _vm.resetFormAfter,
- expression: "resetFormAfter"
- }
- ],
- attrs: {
- disabled: this.createAnother === false,
- name: "reset_form",
- type: "checkbox"
- },
- domProps: {
- checked: Array.isArray(_vm.resetFormAfter)
- ? _vm._i(_vm.resetFormAfter, null) > -1
- : _vm.resetFormAfter
- },
- on: {
- change: function($event) {
- var $$a = _vm.resetFormAfter,
- $$el = $event.target,
- $$c = $$el.checked ? true : false
- if (Array.isArray($$a)) {
- var $$v = null,
- $$i = _vm._i($$a, $$v)
- if ($$el.checked) {
- $$i < 0 &&
- (_vm.resetFormAfter = $$a.concat([$$v]))
- } else {
- $$i > -1 &&
- (_vm.resetFormAfter = $$a
- .slice(0, $$i)
- .concat($$a.slice($$i + 1)))
- }
- } else {
- _vm.resetFormAfter = $$c
- }
- }
- }
- }),
- _vm._v(
- "\n Reset form after submission\n\n "
- )
- ]
- )
+ ])
])
]),
_vm._v(" "),
@@ -56073,7 +57395,7 @@ var render = function() {
_c(
"button",
{ staticClass: "btn btn-success", on: { click: _vm.submit } },
- [_vm._v("Submit")]
+ [_vm._v("Update")]
)
])
])
@@ -56146,7 +57468,7 @@ module.exports = { render: render, staticRenderFns: staticRenderFns }
if (false) {
module.hot.accept()
if (module.hot.data) {
- require("vue-hot-reload-api") .rerender("data-v-3c64c482", module.exports)
+ require("vue-hot-reload-api") .rerender("data-v-16510831", module.exports)
}
}
diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js
index 22387421e0..273c0f07e0 100644
--- a/resources/assets/js/app.js
+++ b/resources/assets/js/app.js
@@ -59,7 +59,9 @@ Vue.component('account-select', require('./components/transactions/AccountSelect
Vue.component('passport-clients', require('./components/passport/Clients.vue'));
Vue.component('passport-authorized-clients', require('./components/passport/AuthorizedClients.vue'));
Vue.component('passport-personal-access-tokens', require('./components/passport/PersonalAccessTokens.vue'));
+
Vue.component('create-transaction', require('./components/transactions/CreateTransaction'));
+Vue.component('edit-transaction', require('./components/transactions/EditTransaction'));
const app = new Vue({
diff --git a/resources/assets/js/components/transactions/Amount.vue b/resources/assets/js/components/transactions/Amount.vue
index 66bd5ce481..9a2da847eb 100644
--- a/resources/assets/js/components/transactions/Amount.vue
+++ b/resources/assets/js/components/transactions/Amount.vue
@@ -52,30 +52,44 @@
return this.error.length > 0;
},
changeData: function () {
+ let transactionType = this.transactionType;
// reset of all are empty:
- //console.log('Type "' + this.transactionType + '"');
+ //console.log('Type "' + transactionType + '"');
//console.log('Source "' + this.source.name + '"');
//console.log('Dest "' + this.destination.name + '"');
- if (!this.transactionType && !this.source.name && !this.destination.name) {
+ if (!transactionType && !this.source.name && !this.destination.name) {
$(this.$refs.cur).text('');
+ console.log('A');
return;
}
- if ('' === this.transactionType && '' !== this.source.currency_name) {
+ if(null === transactionType) {
+ transactionType = '';
+ }
+
+ if ('' === transactionType && '' !== this.source.currency_name) {
$(this.$refs.cur).text(this.source.currency_name);
+ console.log('B');
return;
}
- if ('' === this.transactionType && '' !== this.destination.currency_name) {
+ if ('' === transactionType && '' !== this.destination.currency_name) {
$(this.$refs.cur).text(this.destination.currency_name);
+ console.log('C');
return;
}
- if (this.transactionType === 'Withdrawal' || this.transactionType === 'Transfer') {
+ if (transactionType === 'Withdrawal' || transactionType === 'Transfer') {
$(this.$refs.cur).text(this.source.currency_name);
+ console.log('D');
return;
}
- if (this.transactionType === 'Deposit') {
+ if (transactionType === 'Deposit') {
$(this.$refs.cur).text(this.destination.currency_name);
+ console.log('E');
return;
}
+ console.log('transactionType: ' + transactionType);
+ console.log('this.source.name: ' + this.source.name);
+ console.log('this.destination.name: ' + this.destination.name);
+ console.log('F');
}
},
watch: {
diff --git a/resources/assets/js/components/transactions/CreateTransaction.vue b/resources/assets/js/components/transactions/CreateTransaction.vue
index 3d369b5b56..ade06b13d6 100644
--- a/resources/assets/js/components/transactions/CreateTransaction.vue
+++ b/resources/assets/js/components/transactions/CreateTransaction.vue
@@ -194,7 +194,7 @@
</div>
<div class="box-footer">
<div class="btn-group">
- <button class="btn btn-success" @click="submit">Submit</button>
+ <button class="btn btn-success" id="submitButton" @click="submit">Submit</button>
</div>
</div>
</div>
@@ -310,10 +310,10 @@
}
// correct some id's
- if(0 === destId) {
+ if (0 === destId) {
destId = null;
}
- if(0 === sourceId) {
+ if (0 === sourceId) {
sourceId = null;
}
@@ -377,6 +377,10 @@
if (this.resetFormAfter) {
this.resetTransactions();
}
+
+ let button = $(e.currentTarget);
+ button.prop("disabled", true);
+
axios.post(uri, data)
.then(response => {
if (this.createAnother) {
@@ -386,6 +390,7 @@
if (this.resetFormAfter) {
this.addTransaction();
}
+ button.prop("disabled", false);
} else {
window.location.href = 'transactions/show/' + response.data.data.id + '?message=created';
}
@@ -394,6 +399,7 @@
// something something render errors.
this.parseErrors(error.response.data);
// something.
+ button.prop("disabled", false);
});
if (e) {
e.preventDefault();
diff --git a/resources/assets/js/components/transactions/EditTransaction.vue b/resources/assets/js/components/transactions/EditTransaction.vue
new file mode 100644
index 0000000000..2453aa2e73
--- /dev/null
+++ b/resources/assets/js/components/transactions/EditTransaction.vue
@@ -0,0 +1,711 @@
+<!--
+ - EditTransaction.vue
+ - Copyright (c) 2019 [email protected]
+ -
+ - This file is part of Firefly III.
+ -
+ - Firefly III is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU General Public License as published by
+ - the Free Software Foundation, either version 3 of the License, or
+ - (at your option) any later version.
+ -
+ - Firefly III 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 General Public License for more details.
+ -
+ - You should have received a copy of the GNU General Public License
+ - along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
+ -->
+
+<template>
+ <form method="POST" action="transactions/update" accept-charset="UTF-8" class="form-horizontal" id="store"
+ enctype="multipart/form-data">
+ <input name="_token" type="hidden" value="xxx">
+ <div class="row" v-if="error_message !== ''">
+ <div class="col-lg-12">
+ <div class="alert alert-danger alert-dismissible" role="alert">
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
+ aria-hidden="true">&times;</span></button>
+ <strong>Error!</strong> {{ error_message }}
+ </div>
+ </div>
+ </div>
+
+ <div class="row" v-if="success_message !== ''">
+ <div class="col-lg-12">
+ <div class="alert alert-success alert-dismissible" role="alert">
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
+ aria-hidden="true">&times;</span></button>
+ <strong>Success!</strong> <span v-html="success_message"></span>
+ </div>
+ </div>
+ </div>
+ <div class="row" v-if="transactions.length > 1">
+ <div class="col-lg-6">
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">
+ Description of the split transaction
+ </h3>
+ </div>
+ <div class="box-body">
+ <group-description
+ :error="group_title_errors"
+ v-model="group_title"
+ ></group-description>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div>
+ <div class="row" v-for="(transaction, index) in transactions">
+ <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">Split {{ index+1 }} / {{ transactions.length }}</span>
+ <span v-if="transactions.length === 1">Transaction information</span>
+ </h3>
+ <div class="box-tools pull-right" v-if="transactions.length > 1" x>
+ <button v-on:click="deleteTransaction(index, $event)" class="btn btn-xs btn-danger"><i
+ class="fa fa-trash"></i></button>
+ </div>
+ </div>
+ <div class="box-body">
+ <div class="row">
+ <div class="col-lg-4">
+ <account-select
+ inputName="source[]"
+ title="Source account"
+ :accountName="transaction.source_account.name"
+ :accountTypeFilters="transaction.source_account.allowed_types"
+ :transactionType="transactionType"
+ :index="index"
+ v-on:clear:value="clearSource(index)"
+ v-on:select:account="selectedSourceAccount(index, $event)"
+ :error="transaction.errors.source_account"
+ ></account-select>
+ <account-select
+ inputName="destination[]"
+ title="Destination account"
+ :accountName="transaction.destination_account.name"
+ :accountTypeFilters="transaction.destination_account.allowed_types"
+ :transactionType="transactionType"
+ :index="index"
+ v-on:clear:value="clearDestination(index)"
+ v-on:select:account="selectedDestinationAccount(index, $event)"
+ :error="transaction.errors.destination_account"
+ ></account-select>
+ <transaction-description
+ v-model="transaction.description"
+ :index="index"
+ :error="transaction.errors.description"
+ >
+ </transaction-description>
+ <standard-date
+ v-model="transaction.date"
+ :index="index"
+ :error="transaction.errors.date"
+ >
+ </standard-date>
+ <div v-if="index===0">
+ <transaction-type
+ :source="transaction.source_account.type"
+ :destination="transaction.destination_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 class="col-lg-4">
+ <amount
+ :source="transaction.source_account"
+ :destination="transaction.destination_account"
+ v-model="transaction.amount"
+ :error="transaction.errors.amount"
+ :transactionType="transactionType"
+ ></amount>
+ <foreign-amount
+ :source="transaction.source_account"
+ :destination="transaction.destination_account"
+ v-model="transaction.foreign_amount"
+ :transactionType="transactionType"
+ :error="transaction.errors.foreign_amount"
+ ></foreign-amount>
+ </div>
+ <div class="col-lg-4">
+ <budget
+ :transactionType="transactionType"
+ v-model="transaction.budget"
+ :error="transaction.errors.budget_id"
+ ></budget>
+ <category
+ :transactionType="transactionType"
+ v-model="transaction.category"
+ :error="transaction.errors.category"
+ ></category>
+ <!--
+ <piggy-bank
+ :transactionType="transactionType"
+ v-model="transaction.piggy_bank"
+ :error="transaction.errors.piggy_bank"
+ ></piggy-bank>
+ -->
+ <tags
+ v-model="transaction.tags"
+ :error="transaction.errors.tags"
+ ></tags>
+ <custom-transaction-fields
+ v-model="transaction.custom_fields"
+ :error="transaction.errors.custom_errors"
+ ></custom-transaction-fields>
+ </div>
+ </div>
+ </div>
+ <div class="box-footer" v-if="transactions.length-1 === index">
+ <button class="btn btn-primary" @click="addTransaction">Add another split</button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">
+ Submission
+ </h3>
+ </div>
+ <div class="box-body">
+ <div class="checkbox">
+ <label>
+ <input v-model="returnAfter" name="return_after" type="checkbox">
+ After updating, return here to create another one.
+ </label>
+ </div>
+ </div>
+ <div class="box-footer">
+ <div class="btn-group">
+ <button class="btn btn-success" @click="submit">Update</button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </form>
+</template>
+
+<script>
+ export default {
+ name: "EditTransaction",
+ props: {
+ groupId: Number
+ },
+ mounted() {
+ this.getGroup();
+ },
+ ready() {
+ console.log('Ready Group ID: ' + this.groupId);
+ },
+ methods: {
+ positiveAmount: function (amount) {
+ if (amount < 0) {
+ return amount * -1;
+ }
+ return amount;
+ },
+
+ selectedSourceAccount: function (index, model) {
+ if (typeof model === 'string') {
+ // cant change types, only name.
+ this.transactions[index].source_account.name = model;
+ } else {
+ this.transactions[index].source_account = {
+ id: model.id,
+ name: model.name,
+ type: model.type,
+ currency_id: model.currency_id,
+ currency_name: model.currency_name,
+ currency_code: model.currency_code,
+ currency_decimal_places: model.currency_decimal_places,
+ allowed_types: this.transactions[index].source_account.allowed_types
+ };
+
+ // force types on destination selector.
+ //this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
+ }
+ },
+ selectedDestinationAccount: function (index, model) {
+ if (typeof model === 'string') {
+ // cant change types, only name.
+ this.transactions[index].destination_account.name = model;
+ } else {
+ this.transactions[index].destination_account = {
+ id: model.id,
+ name: model.name,
+ type: model.type,
+ currency_id: model.currency_id,
+ currency_name: model.currency_name,
+ currency_code: model.currency_code,
+ currency_decimal_places: model.currency_decimal_places,
+ allowed_types: this.transactions[index].destination_account.allowed_types
+ };
+
+ // force types on destination selector.
+ //this.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type];
+ }
+ },
+ clearSource: function (index) {
+ console.log('clearSource(' + index + ')');
+ // reset source account:
+ this.transactions[index].source_account = {
+ id: 0,
+ name: '',
+ type: '',
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: this.transactions[index].source_account.allowed_types
+ };
+ // reset destination allowed account types.
+ // this.transactions[index].destination_account.allowed_types = [];
+
+ // if there is a destination model, reset the types of the source
+ // by pretending we selected it again.
+ if (this.transactions[index].destination_account) {
+ this.selectedDestinationAccount(index, this.transactions[index].destination_account);
+ }
+ },
+ setTransactionType: function (type) {
+ this.transactionType = type;
+ },
+ deleteTransaction: function (index, event) {
+ event.preventDefault();
+ for (const key in this.transactions) {
+ if (
+ this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+ }
+ }
+
+ this.transactions.splice(index, 1);
+
+ for (const key in this.transactions) {
+ if (
+ this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+ }
+ }
+ },
+ clearDestination: function (index) {
+ console.log('clearDestination(' + index + ')');
+ // reset destination account:
+ console.log('Destination allowed types first:');
+ console.log(this.transactions[index].destination_account.allowed_types);
+ this.transactions[index].destination_account = {
+ id: 0,
+ name: '',
+ type: '',
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: this.transactions[index].destination_account.allowed_types
+ };
+ // reset destination allowed account types.
+ //this.transactions[index].source_account.allowed_types = [];
+
+ // if there is a source model, reset the types of the destination
+ // by pretending we selected it again.
+ if (this.transactions[index].source_account) {
+ this.selectedSourceAccount(index, this.transactions[index].source_account);
+ }
+
+ console.log('Destination allowed types after:');
+ console.log(this.transactions[index].destination_account.allowed_types);
+ },
+ getGroup: function () {
+
+ const page = window.location.href.split('/');
+ const groupId = page[page.length - 1];
+
+
+ const uri = './api/v1/transactions/' + groupId + '?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
+ console.log(uri);
+
+ // fill in transactions array.
+ axios.get(uri)
+ .then(response => {
+ console.log(response.data.data);
+ this.group_title = response.data.data.attributes.group_title;
+ let transactions = response.data.data.attributes.transactions.reverse();
+ for (let key in transactions) {
+ if (transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+ let transaction = transactions[key];
+ console.log(transactions[key]);
+ this.transactions.push({
+ description: transaction.description,
+ date: transaction.date.substr(0, 10),
+ amount: this.positiveAmount(transaction.amount),
+ category: transaction.category_name,
+ errors: {
+ source_account: [],
+ destination_account: [],
+ description: [],
+ amount: [],
+ date: [],
+ budget_id: [],
+ foreign_amount: [],
+ category: [],
+ piggy_bank: [],
+ tags: [],
+ // custom fields:
+ custom_errors: {
+ interest_date: [],
+ book_date: [],
+ process_date: [],
+ due_date: [],
+ payment_date: [],
+ invoice_date: [],
+ internal_reference: [],
+ notes: [],
+ attachments: [],
+ },
+ },
+ budget: transaction.budget_id,
+ tags: transaction.tags,
+ custom_fields: {
+ interest_date: transaction.interest_date,
+ book_date: transaction.book_date,
+ process_date: transaction.process_date,
+ due_date: transaction.due_date,
+ payment_date: transaction.payment_date,
+ invoice_date: transaction.invoice_date,
+ internal_reference: transaction.internal_reference,
+ notes: transaction.notes
+ },
+ foreign_amount: {
+ amount: this.positiveAmount(transaction.foreign_amount),
+ currency_id: transaction.foreign_currency_id
+ },
+ source_account: {
+ id: transaction.source_id,
+ name: transaction.source_name,
+ type: transaction.source_type,
+ // i dont know these
+ currency_id: transaction.currency_id,
+ currency_name: transaction.currency_name,
+ currency_code: transaction.currency_code,
+ currency_decimal_places: transaction.currency_decimal_places,
+ allowed_types: [transaction.source_type]
+ },
+ destination_account: {
+ id: transaction.destination_id,
+ name: transaction.destination_name,
+ type: transaction.destination_type,
+ currency_id: transaction.currency_id,
+ currency_name: transaction.currency_name,
+ currency_code: transaction.currency_code,
+ currency_decimal_places: transaction.currency_decimal_places,
+ allowed_types: [transaction.destination_type]
+ }
+ });
+ }
+
+ }
+ })
+ .catch(error => {
+ console.error('Some error.');
+ });
+ },
+ convertData: function () {
+ let data = {
+ 'transactions': [],
+ };
+ let tagList = [];
+ let transactionType;
+ let firstSource;
+ let firstDestination;
+ let foreignAmount = null;
+ let foreignCurrency = null;
+ let currentArray;
+ let sourceId;
+ let sourceName;
+ let destId;
+ let destName;
+ let date;
+
+ if (this.transactions.length > 1) {
+ data.group_title = this.group_title;
+ }
+
+ // get transaction type from first transaction
+ transactionType = this.transactionType ? this.transactionType.toLowerCase() : 'invalid';
+
+ // if the transaction type is invalid, might just be that we can deduce it from
+ // the presence of a source or destination account
+ firstSource = this.transactions[0].source_account.type;
+ firstDestination = this.transactions[0].destination_account.type;
+
+ if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstSource)) {
+ //console.log('Assumed this is a withdrawal.');
+ transactionType = 'withdrawal';
+ }
+
+ if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstDestination)) {
+ //console.log('Assumed this is a deposit.');
+ transactionType = 'deposit';
+ }
+
+
+ for (let key in this.transactions) {
+ if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+
+ sourceId = this.transactions[key].source_account.id;
+ sourceName = this.transactions[key].source_account.name;
+ destId = this.transactions[key].destination_account.id;
+ destName = this.transactions[key].destination_account.name;
+
+ date = this.transactions[key].date;
+ if (key > 0) {
+ date = this.transactions[0].date;
+ }
+
+ // if type is 'withdrawal' and destination is empty, cash withdrawal.
+ if (transactionType === 'withdrawal' && '' === destName) {
+ destId = window.cashAccountId;
+ }
+
+ // if type is 'deposit' and source is empty, cash deposit.
+ if (transactionType === 'deposit' && '' === sourceName) {
+ sourceId = window.cashAccountId;
+ }
+
+ // if key is over 0 and type is withdrawal or transfer, take source from key 0.
+ if (key > 0 && (transactionType.toLowerCase() === 'withdrawal' || transactionType.toLowerCase() === 'transfer')) {
+ sourceId = this.transactions[0].source_account.id;
+ sourceName = this.transactions[0].source_account.name;
+ }
+
+ // if key is over 0 and type is deposit or transfer, take destination from key 0.
+ if (key > 0 && (transactionType.toLowerCase() === 'deposit' || transactionType.toLowerCase() === 'transfer')) {
+ destId = this.transactions[0].destination_account.id;
+ destName = this.transactions[0].destination_account.name;
+ }
+
+ tagList = [];
+ foreignAmount = null;
+ foreignCurrency = null;
+ // loop tags
+ for (let tagKey in this.transactions[key].tags) {
+ if (this.transactions[key].tags.hasOwnProperty(tagKey) && /^0$|^[1-9]\d*$/.test(tagKey) && key <= 4294967294) {
+ tagList.push(this.transactions[key].tags[tagKey].text);
+ }
+ }
+
+ // set foreign currency info:
+ if (this.transactions[key].foreign_amount.amount !== '' && parseFloat(this.transactions[key].foreign_amount.amount) !== .00) {
+ foreignAmount = this.transactions[key].foreign_amount.amount;
+ foreignCurrency = this.transactions[key].foreign_amount.currency_id;
+ }
+ if (foreignCurrency === this.transactions[key].currency_id) {
+ foreignAmount = null;
+ foreignCurrency = null;
+ }
+
+ // correct some id's
+ if (0 === destId) {
+ destId = null;
+ }
+ if (0 === sourceId) {
+ sourceId = null;
+ }
+
+ currentArray =
+ {
+ type: transactionType,
+ date: date,
+
+ amount: this.transactions[key].amount,
+ currency_id: this.transactions[key].currency_id,
+
+ description: this.transactions[key].description,
+
+ source_id: sourceId,
+ source_name: sourceName,
+
+ destination_id: destId,
+ destination_name: destName,
+
+
+ category_name: this.transactions[key].category,
+ //budget_id: this.transactions[key].budget,
+ //piggy_bank_id: this.transactions[key].piggy_bank,
+
+
+ interest_date: this.transactions[key].custom_fields.interest_date,
+ book_date: this.transactions[key].custom_fields.book_date,
+ process_date: this.transactions[key].custom_fields.process_date,
+ due_date: this.transactions[key].custom_fields.due_date,
+ payment_date: this.transactions[key].custom_fields.payment_date,
+ invoice_date: this.transactions[key].custom_fields.invoice_date,
+ internal_reference: this.transactions[key].custom_fields.internal_reference,
+ notes: this.transactions[key].custom_fields.notes
+ };
+
+ if (tagList.length > 0) {
+ currentArray.tags = tagList;
+ }
+ if (null !== foreignAmount) {
+ currentArray.foreign_amount = foreignAmount;
+ currentArray.foreign_currency_id = foreignCurrency;
+ }
+ // set budget id and piggy ID.
+ if (parseInt(this.transactions[key].budget) > 0) {
+ currentArray.budget_id = parseInt(this.transactions[key].budget);
+ }
+ if (parseInt(this.transactions[key].piggy_bank) > 0) {
+ currentArray.piggy_bank_id = parseInt(this.transactions[key].piggy_bank);
+ }
+
+ data.transactions.push(currentArray);
+ }
+ }
+ //console.log(data);
+
+ return data;
+ },
+ submit: function (e) {
+ console.log('I am submit');
+ const page = window.location.href.split('/');
+ const groupId = page[page.length - 1];
+ const uri = './api/v1/transactions/' + groupId + '?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
+ const data = this.convertData();
+
+ let button = $(e.currentTarget);
+ button.prop("disabled", true);
+
+ axios.put(uri, data)
+ .then(response => {
+ if (this.returnAfter) {
+ // do message:
+ this.success_message = '<a href="transactions/show/' + response.data.data.id + '">The transaction</a> has been updated.';
+ this.error_message = '';
+ button.prop("disabled", false);
+ // TODO better
+ if (this.resetFormAfter) {
+ this.getGroup();
+ }
+
+ } else {
+ window.location.href = 'transactions/show/' + response.data.data.id + '?message=updated';
+ }
+ }).catch(error => {
+ // give user errors things back.
+ // something something render errors.
+ this.parseErrors(error.response.data);
+ // something.
+ button.prop("disabled", false);
+ });
+ if (e) {
+ e.preventDefault();
+ }
+ },
+ addTransaction: function (e) {
+ this.transactions.push({
+ description: "",
+ date: "",
+ amount: "",
+ category: "",
+ piggy_bank: 0,
+ errors: {
+ source_account: [],
+ destination_account: [],
+ description: [],
+ amount: [],
+ date: [],
+ budget_id: [],
+ foreign_amount: [],
+ category: [],
+ piggy_bank: [],
+ tags: [],
+ // custom fields:
+ custom_errors: {
+ interest_date: [],
+ book_date: [],
+ process_date: [],
+ due_date: [],
+ payment_date: [],
+ invoice_date: [],
+ internal_reference: [],
+ notes: [],
+ attachments: [],
+ },
+ },
+ budget: 0,
+ tags: [],
+ custom_fields: {
+ "interest_date": "",
+ "book_date": "",
+ "process_date": "",
+ "due_date": "",
+ "payment_date": "",
+ "invoice_date": "",
+ "internal_reference": "",
+ "notes": "",
+ "attachments": []
+ },
+ foreign_amount: {
+ amount: "",
+ currency_id: 0
+ },
+ source_account: {
+ id: 0,
+ name: "",
+ type: "",
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: []
+ },
+ destination_account: {
+ id: 0,
+ name: "",
+ type: "",
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: []
+ }
+ });
+ if (e) {
+ e.preventDefault();
+ }
+ }
+ },
+
+
+ data() {
+ return {
+ group: this.groupId,
+ error_message: "",
+ success_message: "",
+ transactions: [],
+ group_title: "",
+ returnAfter: false,
+ transactionType: null,
+ group_title_errors: [],
+ resetButtonDisabled: true,
+ }
+ }
+ }
+</script>
+
+<style scoped>
+
+</style>
\ No newline at end of file
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 3dbcd87920..b74d2b0c26 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -852,6 +852,7 @@ return [
'deleted_transfer' => 'Successfully deleted transfer ":description"',
'stored_journal' => 'Successfully created new transaction ":description"',
'stored_journal_no_descr' => 'Successfully created your new transaction',
+ 'updated_journal_no_descr' => 'Successfully updated your transaction',
'select_transactions' => 'Select transactions',
'rule_group_select_transactions' => 'Apply ":title" to transactions',
'rule_select_transactions' => 'Apply ":title" to transactions',
diff --git a/resources/views/v1/transactions/create.twig b/resources/views/v1/transactions/create.twig
index 353f56b092..31a305aac8 100644
--- a/resources/views/v1/transactions/create.twig
+++ b/resources/views/v1/transactions/create.twig
@@ -6,6 +6,8 @@
{% block content %}
+ {# TODO attachments #}
+
<create-transaction></create-transaction>
diff --git a/resources/views/v1/transactions/edit.twig b/resources/views/v1/transactions/edit.twig
new file mode 100644
index 0000000000..ab3b4c55c0
--- /dev/null
+++ b/resources/views/v1/transactions/edit.twig
@@ -0,0 +1,288 @@
+{% extends "./layout/default" %}
+
+{% block breadcrumbs %}
+ {{ Breadcrumbs.render(Route.getCurrentRoute.getName, transactionGroup) }}
+ <edit-transaction></edit-transaction>
+{% endblock %}
+
+{% block content %}
+
+ {#
+ <form method="POST" action="{{ route('transactions.update',journal.id) }}" accept-charset="UTF-8" class="form-horizontal" id="update"
+ enctype="multipart/form-data">
+
+ <input name="_token" type="hidden" value="{{ csrf_token() }}">
+ <input type="hidden" name="id" value="{{ journal.id }}"/>
+ <input type="hidden" name="what" value="{{ what }}"/>
+
+ {% if errors.all|length > 0 %}
+ <div class="row">
+ <div class="col-lg-12">
+ <h3 class="text-danger">{{ 'errors'|_ }}</h3>
+ <ul>
+ {% for err in errors.all %}
+ <li class="text-danger">{{ err }}</li>
+ {% endfor %}
+ </ul>
+ </div>
+ </div>
+ {% endif %}
+
+
+ <div class="row">
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
+ <div class="box box-primary">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'mandatoryFields'|_ }}</h3>
+ </div>
+ <div class="box-body">
+
+ <!-- ALWAYS AVAILABLE -->
+ {{ ExpandedForm.text('description',journal.description) }}
+
+ <!-- SELECTABLE SOURCE ACCOUNT ONLY FOR WITHDRAWALS AND TRANSFERS -->
+ {% if what == 'transfer' or what == 'withdrawal' %}
+ {{ ExpandedForm.longAccountList('source_id', data.source_id, {label: trans('form.asset_source_account')}) }}
+ {% endif %}
+
+ <!-- FREE FORMAT SOURCE ACCOUNT ONLY FOR DEPOSITS -->
+ {% if what == 'deposit' %}
+ {{ ExpandedForm.text('source_name',data.source_name, {label: trans('form.revenue_account')}) }}
+ {% endif %}
+
+ <!-- FREE FORMAT DESTINATION ACCOUNT ONLY FOR EXPENSES -->
+ {% if what == 'withdrawal' %}
+ {{ ExpandedForm.text('destination_name',data.destination_name, {label: trans('form.expense_account')}) }}
+ {% endif %}
+
+ <!-- SELECTABLE DESTINATION ACCOUNT ONLY FOR TRANSFERS AND DEPOSITS -->
+ {% if what == 'transfer' or what == 'deposit' %}
+ {{ ExpandedForm.longAccountList('destination_id', data.destination_id, {label: trans('form.asset_destination_account')} ) }}
+ {% endif %}
+
+ <!-- ALWAYS SHOW AMOUNT -->
+ {{ ExpandedForm.amount('amount',data.amount, {'currency' : data.currency}) }}
+
+ <!-- INSTRUCTIONS FOR EXCHANGE RATES -->
+ {{ ExpandedForm.staticText('exchange_rate_instruction','(here be text)') }}
+
+ {{ ExpandedForm.nonSelectableAmount('native_amount', data.native_amount, {currency: data.native_currency}) }}
+
+ {{ ExpandedForm.nonSelectableAmount('source_amount', data.source_amount, {currency: data.source_currency }) }}
+
+ {{ ExpandedForm.nonSelectableAmount('destination_amount', data.destination_amount, {currency: data.destination_currency }) }}
+
+ <!-- ALWAYS SHOW DATE -->
+ {{ ExpandedForm.date('date',data['date']) }}
+ </div>
+ </div>
+
+ </div>
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'optionalFields'|_ }}</h3>
+ </div>
+ <div class="box-body">
+ {% if what == 'withdrawal' %}
+ {% if budgetList|length > 1 %}
+ {{ ExpandedForm.select('budget_id', budgetList, data['budget_id']) }}
+ {% else %}
+ {{ ExpandedForm.select('budget_id', budgetList, data['budget_id'], {helpText: trans('firefly.no_budget_pointer', {link: route('budgets.index')})}) }}
+ {% endif %}
+ {% endif %}
+ {{ ExpandedForm.text('category',data['category']) }}
+ {{ ExpandedForm.text('tags') }}
+
+ {% if data.bill_id != null %}
+ {{ ExpandedForm.checkbox('keep_bill_id',1,true, {'helpText': trans('firefly.journal_link_bill', {name: data.bill_name,route: route('bills.show', [data.bill_id])})} ) }}
+ {% endif %}
+
+ </div>
+ </div>
+
+
+ {% if
+ not optionalFields.interest_date or
+ not optionalFields.book_date or
+ not optionalFields.process_date or
+ not optionalFields.due_date or
+ not optionalFields.payment_date or
+ not optionalFields.invoice_date or
+ not optionalFields.internal_reference or
+ not optionalFields.notes or
+ not optionalFields.attachments %}
+ <p class="text-center text-success"><i class="fa fa-info-circle"></i>
+ <em>{{ trans('firefly.hidden_fields_preferences', {link: route('preferences.index')})|raw }}</em></p>
+ {% endif %}
+ {% if
+ optionalFields.interest_date or
+ optionalFields.book_date or
+ optionalFields.process_date or
+ optionalFields.due_date or
+ optionalFields.payment_date or
+ optionalFields.invoice_date or
+ data.interest_date or
+ data.book_date or
+ data.process_date or
+ data.due_date or
+ data.payment_date %}
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'optional_field_meta_dates'|_ }}</h3>
+ </div>
+ <div class="box-body">
+
+ {% if optionalFields.interest_date or data['interest_date'] %}
+ {{ ExpandedForm.date('interest_date',data['interest_date']) }}
+ {% endif %}
+
+ {% if optionalFields.book_date or data['book_date'] %}
+ {{ ExpandedForm.date('book_date',data['book_date']) }}
+ {% endif %}
+
+ {% if optionalFields.process_date or data['process_date'] %}
+ {{ ExpandedForm.date('process_date',data['process_date']) }}
+ {% endif %}
+
+ {% if optionalFields.due_date or data['due_date'] %}
+ {{ ExpandedForm.date('due_date',data['due_date']) }}
+ {% endif %}
+
+ {% if optionalFields.payment_date or data['payment_date'] %}
+ {{ ExpandedForm.date('payment_date',data['payment_date']) }}
+ {% endif %}
+
+ {% if optionalFields.invoice_date or data['invoice_date'] %}
+ {{ ExpandedForm.date('invoice_date',data['invoice_date']) }}
+ {% endif %}
+
+ </div>
+ </div>
+ {% endif %}
+
+
+ {% if
+ optionalFields.internal_reference or
+ optionalFields.notes or
+ data['interal_reference'] or
+ data['notes'] %}
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'optional_field_meta_business'|_ }}</h3>
+ </div>
+ <div class="box-body">
+ {% if optionalFields.internal_reference or data['interal_reference'] %}
+ {{ ExpandedForm.text('internal_reference', data['interal_reference']) }}
+ {% endif %}
+
+ {% if optionalFields.notes or data['notes'] %}
+ {{ ExpandedForm.textarea('notes', data['notes'], {helpText: trans('firefly.field_supports_markdown')}) }}
+ {% endif %}
+
+ </div>
+ </div>
+ {% endif %}
+
+ {% if optionalFields.attachments or journal.attachments|length > 0 %}
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'optional_field_attachments'|_ }}</h3>
+ </div>
+ <div class="box-body">
+ {% if journal.attachments|length > 0 %}
+ <div id="att_holder_attachments" class="form-group">
+ <label class="col-sm-4 control-label">
+ {{ trans('form.existing_attachments') }}
+ </label>
+ <div class="col-sm-8">
+ {% for att in journal.attachments %}
+ <div class="row att_row" data-id="{{ att.id }}">
+ <div class="col-lg-1"><a href="{{ route('attachments.delete', att.id) }}" data-id="{{ att.id }}" class="del_att btn btn-danger btn-xs"><i class="fa fa-trash"></i></a></div>
+ <div class="col-lg-11">
+ <a href="{{ route('attachments.view', att.id) }}" title="{{ att.filename }}">
+ {% if att.title %}
+ {{ att.title }} ({{ att.filename }})
+ {% else %}
+ {{ att.filename }}
+ {% endif %}
+ </a>
+ ({{ att.size|filesize }})
+ </div>
+ </div>
+ {% endfor %}
+ </div>
+ </div>
+ {% endif %}
+
+ {{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
+
+ </div>
+ </div>
+ {% endif %}
+
+ <!-- panel for options -->
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'options'|_ }}</h3>
+ </div>
+ <div class="box-body">
+ {{ ExpandedForm.optionsList('update','transaction') }}
+
+ <div class="form-group" id="do_split_holder">
+ <label for="ffInput_do_split" class="col-sm-4 control-label">{{ 'do_split'|_ }}</label>
+
+ <div class="col-sm-8">
+ <p class="form-control-static">
+ <a href="{{ route('transactions.split.edit', journal.id) }}">{{ ('split_this_'~what)|_ }}</a>
+ </p>
+ </div>
+ </div>
+ </div>
+ <div class="box-footer">
+ <button type="submit" class="pull-right btn btn-success">{{ ('update_' ~ what)|_ }}</button>
+ </div>
+ </div>
+ </div>
+ </div>
+ <input type="hidden" name="source_account_currency" value="0"/>
+ <input type="hidden" name="destination_account_currency" value="0"/>
+ </form>
+ #}
+
+{% endblock %}
+{% block scripts %}
+ <script type="text/javascript">
+ var allowedOpposingTypes = {{ allowedOpposingTypes|json_encode|raw }};
+ var accountToTypes = {{ accountToTypes|json_encode|raw }};
+ var defaultCurrency = {{ defaultCurrency.toArray()|json_encode|raw }};
+ var cashAccountId = {{ cash.id }};
+ </script>
+ {#
+ <script type="text/javascript">
+ var what = "{{ what }}";
+ </script>
+ <script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_VERSION }}"></script>
+ <script type="text/javascript" src="v1/js/ff/common/autocomplete.js?v={{ FF_VERSION }}"></script>
+ <script type="text/javascript" src="v1/js/lib/bootstrap-tagsinput.min.js?v={{ FF_VERSION }}"></script>
+ <script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}"></script>
+ <script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}"></script>
+ <script type="text/javascript" src="v1/jscript/accounts?ext=.js&amp;v={{ FF_VERSION }}"></script>
+ <script type="text/javascript" src="v1/jscript/currencies?ext=.js&amp;v={{ FF_VERSION }}"></script>
+ <script type="text/javascript">
+ var journal = {{ journal.toArray()|json_encode|raw }};
+ var journalData = {{ data|json_encode|raw }};
+ var exchangeRateInstructions = "{{ 'exchange_rate_instructions'|_|escape('js') }}";
+ var transferInstructions = "{{ 'transfer_exchange_rate_instructions'|_|escape('js') }}";
+ </script>
+ <script type="text/javascript" src="v1/js/ff/transactions/single/common.js?v={{ FF_VERSION }}"></script>
+ <script type="text/javascript" src="v1/js/ff/transactions/single/edit.js?v={{ FF_VERSION }}"></script>
+#}
+{% endblock %}
+{% block styles %}
+ {#
+ <link href="v1/css/bootstrap-tagsinput.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
+ <link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
+ <link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
+ #}
+{% endblock %}
diff --git a/resources/views/v1/transactions/show.twig b/resources/views/v1/transactions/show.twig
index 4668632afc..1b17cead18 100644
--- a/resources/views/v1/transactions/show.twig
+++ b/resources/views/v1/transactions/show.twig
@@ -19,6 +19,22 @@
</div>
</div>
{% endif %}
+
+ {% if message == 'updated' %}
+ <div class="row">
+ <div class="col-lg-12">
+ <div class="alert alert-success alert-dismissible" role="alert">
+ <button type="button" class="close" data-dismiss="alert">
+ <span>&times;</span><span class="sr-only">{{ 'close'|_ }}</span>
+ </button>
+ <strong>{{ 'flash_success'|_ }}</strong>
+ {{ trans('firefly.updated_journal_no_descr') }}
+
+ </div>
+ </div>
+ </div>
+ {% endif %}
+
<div class="row">
<div class="col-lg-6">
<div class="box box-primary">
@@ -55,498 +71,503 @@
<div class="btn-group btn-group-xs">
<a href="{{ route('transactions.edit', [transactionGroup.id]) }}" class="btn btn-default"><i class="fa fa-pencil"></i> {{ 'edit'|_ }}</a>
{% if type != 'Opening balance' and type != 'Reconciliation' %}
- <a href="{{ route('transactions.clone', [transactionGroup.id]) }}" class="btn btn-default"><i class="fa fa-copy"></i> {{ 'clone'|_ }}</a>
- {% if type != 'Withdrawal' %}
- <a href="{{ route('transactions.convert', [transactionGroup.id, 'withdrawal']) }}" class="btn btn-default"><i class="fa fa-exchange"></i> {{ 'convert_to_withdrawal'|_ }}</a>
- {% endif %}
- {% if type != 'Deposit' %}
- <a href="{{ route('transactions.convert', [transactionGroup.id, 'deposit']) }}" class="btn btn-default"><i class="fa fa-exchange"></i> {{ 'convert_to_deposit'|_ }}</a>
- {% endif %}
- {% if type != 'Transfer' %}
- <a href="{{ route('transactions.convert', [transactionGroup.id, 'transfer']) }}" class="btn btn-default"><i class="fa fa-exchange"></i> {{ 'convert_to_transfer'|_ }}</a>
- {% endif %}
+ {#<a href="{{ route('transactions.clone', [transactionGroup.id]) }}" class="btn btn-default"><i class="fa fa-copy"></i> {{ 'clone'|_ }}</a>#}
+
+ {#
+ {% if type != 'Withdrawal' %}
+ <a href="{{ route('transactions.convert', [transactionGroup.id, 'withdrawal']) }}" class="btn btn-default"><i class="fa fa-exchange"></i> {{ 'convert_to_withdrawal'|_ }}</a>
{% endif %}
- <a href="{{ route('transactions.delete', [transactionGroup.id]) }}" class="btn btn-danger"><i class="fa fa-trash"></i> {{ 'delete'|_ }}</a>
- </div>
+ {% if type != 'Deposit' %}
+ <a href="{{ route('transactions.convert', [transactionGroup.id, 'deposit']) }}" class="btn btn-default"><i class="fa fa-exchange"></i> {{ 'convert_to_deposit'|_ }}</a>
+ {% endif %}
+ {% if type != 'Transfer' %}
+ <a href="{{ route('transactions.convert', [transactionGroup.id, 'transfer']) }}" class="btn btn-default"><i class="fa fa-exchange"></i> {{ 'convert_to_transfer'|_ }}</a>
+ {% endif %}
+ #}
+ {% endif %}
+ {#
+ <a href="{{ route('transactions.delete', [transactionGroup.id]) }}" class="btn btn-danger"><i class="fa fa-trash"></i> {{ 'delete'|_ }}</a>
+ #}
</div>
</div>
</div>
- <div class="col-lg-6">
- <div class="box box-primary">
- <div class="box-header with-border">
- <h3 class="box-title">{{ 'transaction_journal_meta'|_ }}</h3>
- </div>
- <div class="box-body no-padding">
- <table class="table table-hover">
- <tbody>
- {% if type != 'Withdrawal' or splits == 1 %}
- <tr>
- <td>
- {{ 'source_accounts'|_ }}
- </td>
- <td>
- {% for journal in groupArray.transactions %}
- <a href="{{ route('accounts.show',journal.source_id) }}"
- title="{{ journal.source_iban|default(journal.source_name) }}">
- {{ journal.source_name }}
- </a>
- {% if loop.index0 != groupArray.transactions|length -1 %}, {% endif %}
- {% endfor %}
- </td>
- </tr>
- {% endif %}
-
- {% if type != 'Deposit' or splits == 1 %}
- <tr>
- <td>
- {{ 'destination_accounts'|_ }}
+ </div>
+ <div class="col-lg-6">
+ <div class="box box-primary">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'transaction_journal_meta'|_ }}</h3>
+ </div>
+ <div class="box-body no-padding">
+ <table class="table table-hover">
+ <tbody>
+ {% if type != 'Withdrawal' or splits == 1 %}
+ <tr>
+ <td>
+ {{ 'source_accounts'|_ }}
+ </td>
+ <td>
+ {% for journal in groupArray.transactions %}
+ <a href="{{ route('accounts.show',journal.source_id) }}"
+ title="{{ journal.source_iban|default(journal.source_name) }}">
+ {{ journal.source_name }}
+ </a>
+ {% if loop.index0 != groupArray.transactions|length -1 %}, {% endif %}
+ {% endfor %}
+ </td>
+ </tr>
+ {% endif %}
- </td>
- <td>
- {% for journal in groupArray.transactions %}
- <a href="{{ route('accounts.show',journal.source_id) }}"
- title="{{ journal.destination_iban|default(journal.destination_name) }}">
- {{ journal.destination_name }}
- </a>
- {% if loop.index0 != groupArray.transactions|length -1 %}, {% endif %}
- {% endfor %}
- </td>
- </tr>
- {% endif %}
+ {% if type != 'Deposit' or splits == 1 %}
<tr>
- <td style="width:30%;">{{ 'total_amount'|_ }}</td>
<td>
- {% for amount in amounts %}
- {% if type == 'Withdrawal' or type == 'Deposit' %}
- {{ formatAmountBySymbol(amount.amount*-1,amount.symbol, amount.decimal_places) }},
- {% elseif type == 'Transfer' %}
- <span class="text-info">
- {{ formatAmountBySymbol(amount.amount, amount.symbol, amount.decimal_places, false) }},
- </span>
- {% endif %}
+ {{ 'destination_accounts'|_ }}
+
+ </td>
+ <td>
+ {% for journal in groupArray.transactions %}
+ <a href="{{ route('accounts.show',journal.source_id) }}"
+ title="{{ journal.destination_iban|default(journal.destination_name) }}">
+ {{ journal.destination_name }}
+ </a>
+ {% if loop.index0 != groupArray.transactions|length -1 %}, {% endif %}
{% endfor %}
</td>
</tr>
- </tbody>
- </table>
- </div>
+ {% endif %}
+ <tr>
+ <td style="width:30%;">{{ 'total_amount'|_ }}</td>
+ <td>
+ {% for amount in amounts %}
+ {% if type == 'Withdrawal' or type == 'Deposit' %}
+ {{ formatAmountBySymbol(amount.amount*-1,amount.symbol, amount.decimal_places) }},
+ {% elseif type == 'Transfer' %}
+ <span class="text-info">
+ {{ formatAmountBySymbol(amount.amount, amount.symbol, amount.decimal_places, false) }},
+ </span>
+ {% endif %}
+ {% endfor %}
+ </td>
+ </tr>
+ </tbody>
+ </table>
</div>
</div>
</div>
- <div class="row">
+</div>
+<div class="row">
- </div>
- {% if splits > 1 %}
- <div class="row">
- <div class="col-lg-12">
- <h3>{{ 'splits'|_ }}</h3>
- </div>
- </div>
- {% endif %}
- {% set boxSize=12 %}
- {% if(splits == 2) %}
- {% set boxSize=6 %}
- {% endif %}
- {% if (splits > 2) %}
- {% set boxSize = 4 %}
- {% endif %}
+</div>
+{% if splits > 1 %}
<div class="row">
- {% for index,journal in groupArray.transactions %}
- <div class="col-lg-{{ boxSize }}">
- <div class="box">
- <div class="box-header with-border">
- <h3 class="box-title">
- {{ journal.description }}
- {% if journal.reconciled %}
- <i class="fa fa-check"></i>
- {% endif %}
- {% if splits > 1 %}
- <small>
- {{ index+1 }} / {{ splits }}
- </small>
- {% endif %}
- </h3>
- </div>
- <div class="box-body no-padding">
- <table class="table">
- <tr>
- <td colspan="2">
- <a href="{{ route('accounts.show', journal.source_id) }}"
- title="{{ journal.source_iban|default(journal.source_name) }}">{{ journal.source_name }}</a> &rarr;
+ <div class="col-lg-12">
+ <h3>{{ 'splits'|_ }}</h3>
+ </div>
+ </div>
+{% endif %}
+{% set boxSize=12 %}
+{% if(splits == 2) %}
+ {% set boxSize=6 %}
+{% endif %}
+{% if (splits > 2) %}
+ {% set boxSize = 4 %}
+{% endif %}
+<div class="row">
+ {% for index,journal in groupArray.transactions %}
+ <div class="col-lg-{{ boxSize }}">
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">
+ {{ journal.description }}
+ {% if journal.reconciled %}
+ <i class="fa fa-check"></i>
+ {% endif %}
+ {% if splits > 1 %}
+ <small>
+ {{ index+1 }} / {{ splits }}
+ </small>
+ {% endif %}
+ </h3>
+ </div>
+ <div class="box-body no-padding">
+ <table class="table">
+ <tr>
+ <td colspan="2">
+ <a href="{{ route('accounts.show', journal.source_id) }}"
+ title="{{ journal.source_iban|default(journal.source_name) }}">{{ journal.source_name }}</a> &rarr;
+ {% if type == 'Withdrawal' or type == 'Deposit' %}
+ {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
+ {% elseif type == 'Transfer' %}
+ <span class="text-info">
+ {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places, false) }}
+ </span>
+ {% endif %}
+
+ <!-- do foreign amount -->
+ {% if null != journal.foreign_amount %}
{% if type == 'Withdrawal' or type == 'Deposit' %}
- {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
+ ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }})
{% elseif type == 'Transfer' %}
<span class="text-info">
- {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places, false) }}
- </span>
- {% endif %}
-
- <!-- do foreign amount -->
- {% if null != journal.foreign_amount %}
- {% if type == 'Withdrawal' or type == 'Deposit' %}
- ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }})
- {% elseif type == 'Transfer' %}
- <span class="text-info">
- ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places, false) }})
- </span>
- {% endif %}
+ ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places, false) }})
+ </span>
{% endif %}
+ {% endif %}
- &rarr;
- <a href="{{ route('accounts.show', journal.destination_id) }}"
- title="{{ journal.destination_iban|default(journal.destination_name) }}">{{ journal.destination_name }}</a>
- </td>
+ &rarr;
+ <a href="{{ route('accounts.show', journal.destination_id) }}"
+ title="{{ journal.destination_iban|default(journal.destination_name) }}">{{ journal.destination_name }}</a>
+ </td>
+ </tr>
+ {% if null != journal.category_id %}
+ <tr>
+ <td style="width:30%;">{{ 'category'|_ }}</td>
+ <td><a href="{{ route('categories.show', [journal.category_id]) }}">{{ journal.category_name }}</a></td>
</tr>
- {% if null != journal.category_id %}
- <tr>
- <td style="width:30%;">{{ 'category'|_ }}</td>
- <td><a href="{{ route('categories.show', [journal.category_id]) }}">{{ journal.category_name }}</a></td>
- </tr>
- {% endif %}
- {% if null != journal.budget_id and type == 'Withdrawal' %}
- <tr>
- <td>{{ 'budget'|_ }}</td>
- <td><a href="{{ route('budgets.show', [journal.budget_id]) }}">{{ journal.budget_name }}</a></td>
- </tr>
- {% endif %}
- {% if null != journal.bill_id and type == 'Withdrawal' %}
+ {% endif %}
+ {% if null != journal.budget_id and type == 'Withdrawal' %}
+ <tr>
+ <td>{{ 'budget'|_ }}</td>
+ <td><a href="{{ route('budgets.show', [journal.budget_id]) }}">{{ journal.budget_name }}</a></td>
+ </tr>
+ {% endif %}
+ {% if null != journal.bill_id and type == 'Withdrawal' %}
+ <tr>
+ <td>{{ 'bill'|_ }}</td>
+ <td><a href="{{ route('bills.show', [journal.bill_id]) }}">{{ journal.bill_name }}</a></td>
+ </tr>
+ {% endif %}
+ <!-- other fields -->
+ {% for dateField in ['interest_date','book_date','process_date','due_date','payment_date','invoice_date'] %}
+ {% if journalHasMeta(journal.transaction_journal_id, dateField) %}
<tr>
- <td>{{ 'bill'|_ }}</td>
- <td><a href="{{ route('bills.show', [journal.bill_id]) }}">{{ journal.bill_name }}</a></td>
+ <td>{{ trans('list.'~dateField) }}</td>
+ <td>{{ journalGetMetaDate(journal.transaction_journal_id, dateField).formatLocalized(monthAndDayFormat) }}</td>
</tr>
{% endif %}
- <!-- other fields -->
- {% for dateField in ['interest_date','book_date','process_date','due_date','payment_date','invoice_date'] %}
- {% if journalHasMeta(journal.transaction_journal_id, dateField) %}
- <tr>
- <td>{{ trans('list.'~dateField) }}</td>
- <td>{{ journalGetMetaDate(journal.transaction_journal_id, dateField).formatLocalized(monthAndDayFormat) }}</td>
- </tr>
- {% endif %}
- {% endfor %}
- {% for metaField in ['external_id','bunq_payment_id','internal_reference','sepa_batch_id','sepa_ct_id','sepa_ct_op','sepa_db','sepa_country','sepa_cc','sepa_ep','sepa_ci'] %}
- {% if journalHasMeta(journal.transaction_journal_id, metaField) %}
- <tr>
- <td>{{ trans('list.'~metaField) }}</td>
- <td>{{ journalGetMetaField(journal.transaction_journal_id, metaField) }}</td>
- </tr>
- {% endif %}
- {% endfor %}
- {% if null != journal.notes and '' != journal.notes %}
+ {% endfor %}
+ {% for metaField in ['external_id','bunq_payment_id','internal_reference','sepa_batch_id','sepa_ct_id','sepa_ct_op','sepa_db','sepa_country','sepa_cc','sepa_ep','sepa_ci'] %}
+ {% if journalHasMeta(journal.transaction_journal_id, metaField) %}
<tr>
- <td>{{ trans('list.notes') }}</td>
- <td class="markdown">{{ journal.notes|markdown }}</td>
+ <td>{{ trans('list.'~metaField) }}</td>
+ <td>{{ journalGetMetaField(journal.transaction_journal_id, metaField) }}</td>
</tr>
{% endif %}
- {% if journal.tags|length > 0 %}
+ {% endfor %}
+ {% if null != journal.notes and '' != journal.notes %}
+ <tr>
+ <td>{{ trans('list.notes') }}</td>
+ <td class="markdown">{{ journal.notes|markdown }}</td>
+ </tr>
+ {% endif %}
+ {% if journal.tags|length > 0 %}
+ <tr>
+ <td>{{ 'tags'|_ }}</td>
+ <td>
+ {% for tag in journal.tags %}
+ <h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show', tag) }}">
+ <i class="fa fa-fw fa-tag"></i>
+ {{ tag }}</a>
+ </h4>
+ {% endfor %}
+ </td>
+ </tr>
+ {% endif %}
+ </table>
+ </div>
+ </div>
+
+ <!-- Transaction links -->
+ {% if links[journal.transaction_journal_id]|length > 0 %}
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">
+ {{ 'journal_links'|_ }}
+ </h3>
+ </div>
+ <div class="box-body no-padding">
+ <table class="table">
+ {% for link in links[journal.transaction_journal_id] %}
<tr>
- <td>{{ 'tags'|_ }}</td>
- <td>
- {% for tag in journal.tags %}
- <h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show', tag) }}">
- <i class="fa fa-fw fa-tag"></i>
- {{ tag }}</a>
- </h4>
- {% endfor %}
+ <td style="width:30%;">
+ <div class="btn-group btn-group-xs">
+ <a href="#" class="btn btn-default"><i class="fa fa-pencil"></i></a>
+ <a href="#" class="btn btn-danger"><i class="fa fa-trash"></i></a>
+ </div>
+ </td>
+ <td>{{ link.link }} "<a href="{{ route('transactions.show', link.group) }}"
+ title="{{ link.description }}">{{ link.description }}</a>"
+
+ ({{ link.amount|raw }})
+ {% if '' != link.foreign_amount %}
+ ({{ link.foreign_amount|raw }})
+ {% endif %}
</td>
</tr>
- {% endif %}
+ {% endfor %}
+
</table>
</div>
</div>
+ {% endif %}
- <!-- Transaction links -->
- {% if links[journal.transaction_journal_id]|length > 0 %}
- <div class="box">
- <div class="box-header with-border">
- <h3 class="box-title">
- {{ 'journal_links'|_ }}
- </h3>
- </div>
- <div class="box-body no-padding">
- <table class="table">
- {% for link in links[journal.transaction_journal_id] %}
- <tr>
- <td style="width:30%;">
- <div class="btn-group btn-group-xs">
- <a href="#" class="btn btn-default"><i class="fa fa-pencil"></i></a>
- <a href="#" class="btn btn-danger"><i class="fa fa-trash"></i></a>
- </div>
- </td>
- <td>{{ link.link }} "<a href="{{ route('transactions.show', link.group) }}"
- title="{{ link.description }}">{{ link.description }}</a>"
-
- ({{ link.amount|raw }})
- {% if '' != link.foreign_amount %}
- ({{ link.foreign_amount|raw }})
- {% endif %}
- </td>
- </tr>
- {% endfor %}
-
- </table>
- </div>
+ <!-- Attachments -->
+ {% if attachments[journal.transaction_journal_id]|length > 0 %}
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'attachments'|_ }}</h3>
</div>
- {% endif %}
-
- <!-- Attachments -->
- {% if attachments[journal.transaction_journal_id]|length > 0 %}
- <div class="box">
- <div class="box-header with-border">
- <h3 class="box-title">{{ 'attachments'|_ }}</h3>
- </div>
- <div class="box-body table-responsive no-padding">
- <table class="table table-hover">
- {% for attachment in attachments[journal.transaction_journal_id] %}
- <tr>
- <td style="width:30%;">
- <div class="btn-group btn-group-xs">
- <a href="{{ route('attachments.edit', attachment.id) }}" class="btn btn-default"><i
- class="fa fa-pencil"></i></a>
- <a href="{{ route('attachments.delete', attachment.id) }}" class="btn btn-danger"><i
- class="fa fa-trash"></i></a>
- {% if attachment.file_exists %}
- <a href="{{ route('attachments.download', attachment.id) }}" class="btn btn-default"><i
- class="fa fa-download"></i></a>
- {% endif %}
- {% if not attachment.file_exists %}
- <a href="#" class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i></a>
- {% endif %}
- </div>
- </td>
- <td>
+ <div class="box-body table-responsive no-padding">
+ <table class="table table-hover">
+ {% for attachment in attachments[journal.transaction_journal_id] %}
+ <tr>
+ <td style="width:30%;">
+ <div class="btn-group btn-group-xs">
+ <a href="{{ route('attachments.edit', attachment.id) }}" class="btn btn-default"><i
+ class="fa fa-pencil"></i></a>
+ <a href="{{ route('attachments.delete', attachment.id) }}" class="btn btn-danger"><i
+ class="fa fa-trash"></i></a>
{% if attachment.file_exists %}
- <i class="fa {{ attachment.mime|mimeIcon }}"></i>
- <a href="{{ route('attachments.view', attachment.id) }}" title="{{ attachment.filename }}">
- {% if attachment.title %}
- {{ attachment.title }}
- {% else %}
- {{ attachment.filename }}
- {% endif %}
- </a>
- ({{ attachment.size|filesize }})
- {% if null != attachment.notes and '' != attachment.notes %}
- {{ attachment.notes|markdown }}
- {% endif %}
+ <a href="{{ route('attachments.download', attachment.id) }}" class="btn btn-default"><i
+ class="fa fa-download"></i></a>
{% endif %}
{% if not attachment.file_exists %}
- <i class="fa fa-fw fa-exclamation-triangle"></i>
+ <a href="#" class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i></a>
+ {% endif %}
+ </div>
+ </td>
+ <td>
+ {% if attachment.file_exists %}
+ <i class="fa {{ attachment.mime|mimeIcon }}"></i>
+ <a href="{{ route('attachments.view', attachment.id) }}" title="{{ attachment.filename }}">
{% if attachment.title %}
{{ attachment.title }}
{% else %}
{{ attachment.filename }}
{% endif %}
- <br>
- <span class="text-danger">{{ 'attachment_not_found'|_ }}</span>
+ </a>
+ ({{ attachment.size|filesize }})
+ {% if null != attachment.notes and '' != attachment.notes %}
+ {{ attachment.notes|markdown }}
{% endif %}
- </td>
- </tr>
- {% endfor %}
- </table>
- </div>
- </div>
- {% endif %}
-
- <!-- Piggy bank events -->
- {% if events[journal.transaction_journal_id]|length > 0 %}
- <div class="box">
- <div class="box-header with-border">
- <h3 class="box-title">{{ 'piggy_events'|_ }}</h3>
- </div>
- <div class="box-body table-responsive no-padding">
- <table class="table table-hover">
- {% for event in events[journal.transaction_journal_id] %}
- <tr>
- <td style="width:30%;">{{ event.amount|raw }}</td>
- <td>
- <a href="{{ route('piggy-banks.show', [event.piggy_id]) }}">{{ event.piggy }}</a></td>
-
- </tr>
- {% endfor %}
- </table>
- </div>
+ {% endif %}
+ {% if not attachment.file_exists %}
+ <i class="fa fa-fw fa-exclamation-triangle"></i>
+ {% if attachment.title %}
+ {{ attachment.title }}
+ {% else %}
+ {{ attachment.filename }}
+ {% endif %}
+ <br>
+ <span class="text-danger">{{ 'attachment_not_found'|_ }}</span>
+ {% endif %}
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
</div>
- {% endif %}
- </div>
- {% endfor %}
-
- </div>
-{% endblock %}
-{% block scripts %}
-{% endblock %}
-
- {#
+ </div>
+ {% endif %}
- {% if links.count > 0 %}
+ <!-- Piggy bank events -->
+ {% if events[journal.transaction_journal_id]|length > 0 %}
<div class="box">
<div class="box-header with-border">
- <h3 class="box-title">{{ 'journal_links'|_ }}</h3>
+ <h3 class="box-title">{{ 'piggy_events'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
- {% for link in links %}
+ {% for event in events[journal.transaction_journal_id] %}
<tr>
+ <td style="width:30%;">{{ event.amount|raw }}</td>
<td>
- <div class="btn-group btn-group-xs">
- <a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a>
- <a href="{{ route('transactions.link.switch', [link.id]) }}" class="btn btn-default"><i
- class="fa fa-fw fa-arrows-h"></i></a>
- </div>
- </td>
- <td>
- {{ ('this_'~(what|lower))|_ }}
- {% if link.source.id == journal.id %}
- {{ journalLinkTranslation('outward', link.linkType.outward) }}
- <a href="{{ route('transactions.show',link.destination.id) }}">
- #{{ link.destination.id }}: {{ link.destination.description }}
- </a>
- ({{ link.destination|journalTotalAmount }})
- {% else %}
- {{ journalLinkTranslation('inward', link.linkType.inward) }}
- <a href="{{ route('transactions.show',link.source.id) }}">
- #{{ link.source.id }}: {{ link.source.description }}</a>
- ({{ link.source|journalTotalAmount }})
- {% endif %}
- {% if link.notes.count == 1 %}
- <br/>
- {{ link.notes.first.text|markdown }}
- {% endif %}
- </td>
+ <a href="{{ route('piggy-banks.show', [event.piggy_id]) }}">{{ event.piggy }}</a></td>
+
</tr>
{% endfor %}
</table>
</div>
</div>
- <p>
-
- </p>
{% endif %}
</div>
- </div>
- <div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
+ {% endfor %}
+
+</div>
+{% endblock %}
+{% block scripts %}
+{% endblock %}
+
+{#
+
+ {% if links.count > 0 %}
<div class="box">
<div class="box-header with-border">
- <h3 class="box-title">{{ 'transactions'|_ }}</h3>
+ <h3 class="box-title">{{ 'journal_links'|_ }}</h3>
</div>
- <div class="box-body no-padding">
- <table class="table table-bordered table-striped">
- <thead>
- <tr>
- <th class="hidden-md hidden-sm hidden-xs">{{ trans('list.description') }}</th>
- <th>{{ trans('list.source_account') }}</th>
- <th>{{ trans('list.destination_account') }}</th>
- <th>{{ trans('list.amount') }}</th>
- <th class="hidden-md hidden-xs">{{ trans('list.budget') }}</th>
- <th class="hidden-md hidden-xs">{{ trans('list.category') }}</th>
- </tr>
- </thead>
- <tbody>
-
- {% set maxIdentifier = ((transactions|length) / 2) -1 %}
- {% for x in 0..maxIdentifier %}
+ <div class="box-body table-responsive no-padding">
+ <table class="table table-hover">
+ {% for link in links %}
<tr>
- {% for transaction in transactions %}
- {% if
- ((transaction.type == 'Withdrawal') and transaction.identifier == x and transaction.amount < 0)
- or
- ((transaction.type == 'Deposit' or transaction.type == 'Transfer') and transaction.identifier == x and transaction.amount > 0) %}
- <td class="hidden-md hidden-sm hidden-xs">
- {% if transaction.description == "" %}
- {{ journal.description }}
- {% else %}
- {{ transaction.description }}
- {% endif %}
- </td>
- <td>
- {% if transaction.source_type == 'Cash account' %}
- <span class="text-success">({{ 'cash'|_ }})</span>
- {% else %}
- <a href="{{ route('accounts.show', transaction.source_id) }}">{{ transaction.source_name }}</a>
- {% endif %}
- </td>
- <td>
- {% if transaction.destination_type == 'Cash account' %}
- <span class="text-success">({{ 'cash'|_ }})</span>
- {% else %}
- <a href="{{ route('accounts.show', transaction.destination_id) }}">{{ transaction.destination_name }}</a>
- {% endif %}
-
- </td>
- <td>
- {{ transaction|transactionXArrayAmount }}
- </td>
- <td class="hidden-md hidden-xs">
- {% if transaction.budget_id %}
- <a href="{{ route('budgets.show', transaction.budget_id) }}"
- title="{{ transaction.budget_name }}">{{ transaction.budget_name }}</a>
- {% endif %}
- </td>
- <td class="hidden-md hidden-xs">
- {% if transaction.category_id %}
- <a href="{{ route('categories.show', transaction.category_id) }}"
- title="{{ transaction.category_name }}">{{ transaction.category_name }}</a>
- {% endif %}
- </td>
+ <td>
+ <div class="btn-group btn-group-xs">
+ <a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a>
+ <a href="{{ route('transactions.link.switch', [link.id]) }}" class="btn btn-default"><i
+ class="fa fa-fw fa-arrows-h"></i></a>
+ </div>
+ </td>
+ <td>
+ {{ ('this_'~(what|lower))|_ }}
+ {% if link.source.id == journal.id %}
+ {{ journalLinkTranslation('outward', link.linkType.outward) }}
+ <a href="{{ route('transactions.show',link.destination.id) }}">
+ #{{ link.destination.id }}: {{ link.destination.description }}
+ </a>
+ ({{ link.destination|journalTotalAmount }})
+ {% else %}
+ {{ journalLinkTranslation('inward', link.linkType.inward) }}
+ <a href="{{ route('transactions.show',link.source.id) }}">
+ #{{ link.source.id }}: {{ link.source.description }}</a>
+ ({{ link.source|journalTotalAmount }})
{% endif %}
- {% endfor %}
-
+ {% if link.notes.count == 1 %}
+ <br/>
+ {{ link.notes.first.text|markdown }}
+ {% endif %}
+ </td>
</tr>
{% endfor %}
- </tbody>
</table>
</div>
</div>
+ <p>
+
+ </p>
+ {% endif %}
+ </div>
+</div>
+<div class="row">
+ <div class="col-lg-12 col-md-12 col-sm-12">
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'transactions'|_ }}</h3>
+ </div>
+ <div class="box-body no-padding">
+ <table class="table table-bordered table-striped">
+ <thead>
+ <tr>
+ <th class="hidden-md hidden-sm hidden-xs">{{ trans('list.description') }}</th>
+ <th>{{ trans('list.source_account') }}</th>
+ <th>{{ trans('list.destination_account') }}</th>
+ <th>{{ trans('list.amount') }}</th>
+ <th class="hidden-md hidden-xs">{{ trans('list.budget') }}</th>
+ <th class="hidden-md hidden-xs">{{ trans('list.category') }}</th>
+ </tr>
+ </thead>
+ <tbody>
+
+ {% set maxIdentifier = ((transactions|length) / 2) -1 %}
+ {% for x in 0..maxIdentifier %}
+ <tr>
+ {% for transaction in transactions %}
+ {% if
+ ((transaction.type == 'Withdrawal') and transaction.identifier == x and transaction.amount < 0)
+ or
+ ((transaction.type == 'Deposit' or transaction.type == 'Transfer') and transaction.identifier == x and transaction.amount > 0) %}
+ <td class="hidden-md hidden-sm hidden-xs">
+ {% if transaction.description == "" %}
+ {{ journal.description }}
+ {% else %}
+ {{ transaction.description }}
+ {% endif %}
+ </td>
+ <td>
+ {% if transaction.source_type == 'Cash account' %}
+ <span class="text-success">({{ 'cash'|_ }})</span>
+ {% else %}
+ <a href="{{ route('accounts.show', transaction.source_id) }}">{{ transaction.source_name }}</a>
+ {% endif %}
+ </td>
+ <td>
+ {% if transaction.destination_type == 'Cash account' %}
+ <span class="text-success">({{ 'cash'|_ }})</span>
+ {% else %}
+ <a href="{{ route('accounts.show', transaction.destination_id) }}">{{ transaction.destination_name }}</a>
+ {% endif %}
+
+ </td>
+ <td>
+ {{ transaction|transactionXArrayAmount }}
+ </td>
+ <td class="hidden-md hidden-xs">
+ {% if transaction.budget_id %}
+ <a href="{{ route('budgets.show', transaction.budget_id) }}"
+ title="{{ transaction.budget_name }}">{{ transaction.budget_name }}</a>
+ {% endif %}
+ </td>
+ <td class="hidden-md hidden-xs">
+ {% if transaction.category_id %}
+ <a href="{{ route('categories.show', transaction.category_id) }}"
+ title="{{ transaction.category_name }}">{{ transaction.category_name }}</a>
+ {% endif %}
+ </td>
+ {% endif %}
+ {% endfor %}
+
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
</div>
</div>
+</div>
- <div class="modal fade" tabindex="-1" role="dialog" id="linkJournalModal">
- <form action="{{ route('transactions.link.store', [journal.id]) }}" method="post" class="form-horizontal">
- <input type="hidden" name="_token" value="{{ csrf_token() }}">
- <div class="modal-dialog modal-lg">
- <div class="modal-content">
- <div class="modal-header">
- <h4 class="modal-title">{{ 'link_to_other_transaction'|_ }}</h4>
- </div>
- <div class="modal-body" id="helpBody">
- <p>{{ 'select_transaction_to_link'|_ }}</p>
- <div class="form-group">
- <label for="link_type" class="col-sm-2 control-label">{{ 'this_transaction'|_ }}</label>
- <div class="col-sm-10">
- <select id="link_type" class="form-control" name="link_type">
- {% for linkType in linkTypes %}
- <option label="{{ journalLinkTranslation('inward', linkType.inward) }}"
- value="{{ linkType.id }}_inward">{{ journalLinkTranslation('inward', linkType.inward) }}</option>
- <option label="{{ journalLinkTranslation('outward', linkType.outward) }}"
- value="{{ linkType.id }}_outward">{{ journalLinkTranslation('outward', linkType.outward) }}</option>
- {% endfor %}
- </select>
- </div>
+<div class="modal fade" tabindex="-1" role="dialog" id="linkJournalModal">
+ <form action="{{ route('transactions.link.store', [journal.id]) }}" method="post" class="form-horizontal">
+ <input type="hidden" name="_token" value="{{ csrf_token() }}">
+ <div class="modal-dialog modal-lg">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h4 class="modal-title">{{ 'link_to_other_transaction'|_ }}</h4>
+ </div>
+ <div class="modal-body" id="helpBody">
+ <p>{{ 'select_transaction_to_link'|_ }}</p>
+ <div class="form-group">
+ <label for="link_type" class="col-sm-2 control-label">{{ 'this_transaction'|_ }}</label>
+ <div class="col-sm-10">
+ <select id="link_type" class="form-control" name="link_type">
+ {% for linkType in linkTypes %}
+ <option label="{{ journalLinkTranslation('inward', linkType.inward) }}"
+ value="{{ linkType.id }}_inward">{{ journalLinkTranslation('inward', linkType.inward) }}</option>
+ <option label="{{ journalLinkTranslation('outward', linkType.outward) }}"
+ value="{{ linkType.id }}_outward">{{ journalLinkTranslation('outward', linkType.outward) }}</option>
+ {% endfor %}
+ </select>
</div>
- <div class="form-group">
- <label for="link_other" class="col-sm-2 control-label">{{ 'transaction'|_ }}</label>
- <div class="col-sm-10">
- <input type="text" name="link_other" autocomplete="off" id="link_other" value="" class="form-control">
- <p class="help-block">{{ 'to_link_not_found'|_ }}</p>
- <input type="hidden" name="link_journal_id" value="0">
- </div>
+ </div>
+ <div class="form-group">
+ <label for="link_other" class="col-sm-2 control-label">{{ 'transaction'|_ }}</label>
+ <div class="col-sm-10">
+ <input type="text" name="link_other" autocomplete="off" id="link_other" value="" class="form-control">
+ <p class="help-block">{{ 'to_link_not_found'|_ }}</p>
+ <input type="hidden" name="link_journal_id" value="0">
</div>
- <div class="form-group">
- <label for="notes" class="col-sm-2 control-label">{{ 'notes'|_ }}</label>
- <div class="col-sm-10">
- <textarea id="notes" name="notes" class="form-control"></textarea>
- </div>
+ </div>
+ <div class="form-group">
+ <label for="notes" class="col-sm-2 control-label">{{ 'notes'|_ }}</label>
+ <div class="col-sm-10">
+ <textarea id="notes" name="notes" class="form-control"></textarea>
</div>
+ </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">{{ 'close'|_ }}</button>
- <button type="submit" class="btn btn-primary">{{ 'submit'|_ }}</button>
- </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">{{ 'close'|_ }}</button>
+ <button type="submit" class="btn btn-primary">{{ 'submit'|_ }}</button>
</div>
</div>
- </form>
- </div>
+ </div>
+ </form>
+</div>
#}
diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php
index aded11299e..1797c9818e 100644
--- a/routes/breadcrumbs.php
+++ b/routes/breadcrumbs.php
@@ -1030,10 +1030,14 @@ try {
Breadcrumbs::register(
'transactions.edit',
- function (BreadcrumbsGenerator $breadcrumbs, TransactionJournal $journal) {
- $breadcrumbs->parent('transactions.show', $journal);
+ function (BreadcrumbsGenerator $breadcrumbs, TransactionGroup $group) {
+ $breadcrumbs->parent('transactions.show', $group);
+
+ /** @var TransactionJournal $first */
+ $first = $group->transactionJournals()->first();
+
$breadcrumbs->push(
- trans('breadcrumbs.edit_journal', ['description' => limitStringLength($journal->description)]), route('transactions.edit', [$journal->id])
+ trans('breadcrumbs.edit_journal', ['description' => limitStringLength($first->description)]), route('transactions.edit', [$group->id])
);
}
);
diff --git a/routes/web.php b/routes/web.php
index d5c79fa74e..373a7ae5a9 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -554,7 +554,6 @@ Route::group(
Route::get('tags', ['uses' => 'Json\AutoCompleteController@tags', 'as' => 'autocomplete.tags']);
-
// TODO improve 3 routes:
//Route::get('transaction-journals/all', ['uses' => 'Json\AutoCompleteController@allTransactionJournals', 'as' => 'all-transaction-journals']);
//Route::get('transaction-journals/with-id/{tj}', ['uses' => 'Json\AutoCompleteController@journalsWithId', 'as' => 'journals-with-id']);
@@ -891,7 +890,16 @@ Route::group(
Route::get('create', ['uses' => 'Transaction\CreateController@create', 'as' => 'create']);
Route::post('store', ['uses' => 'Transaction\CreateController@store', 'as' => 'store']);
+ // edit group
+ Route::get('edit/{transactionGroup}', ['uses' => 'Transaction\EditController@edit', 'as' => 'edit']);
+ Route::post('update', ['uses' => 'Transaction\EditController@update', 'as' => 'update']);
+
+ // delete group
+ Route::get('delete/{transactionGroup}', ['uses' => 'Transaction\DeleteController@delete', 'as' => 'delete']);
+ Route::post('destroy/{transactionGroup}', ['uses' => 'Transaction\DeleteController@destroy', 'as' => 'destroy']);
+ // clone group:
+ Route::get('clone/{transactionGroup}', ['uses' => 'Transaction\CloneController@clone', 'as' => 'clone']);
Route::get('debug/{tj}', ['uses' => 'Transaction\SingleController@debugShow', 'as' => 'debug']);
Route::get('debug/{tj}', ['uses' => 'Transaction\SingleController@debugShow', 'as' => 'debug']);
@@ -913,13 +921,13 @@ Route::group(
function () {
// TODO improve these routes
- Route::get('edit/{tj}', ['uses' => 'SingleController@edit', 'as' => 'edit']);
- Route::get('delete/{tj}', ['uses' => 'SingleController@delete', 'as' => 'delete']);
+ //Route::get('edit/{tj}', ['uses' => 'SingleController@edit', 'as' => 'edit']);
+ //
//Route::post('store', ['uses' => 'SingleController@store', 'as' => 'store'])->where(['what' => 'withdrawal|deposit|transfer']);
- Route::post('update/{tj}', ['uses' => 'SingleController@update', 'as' => 'update']);
- Route::post('destroy/{tj}', ['uses' => 'SingleController@destroy', 'as' => 'destroy']);
- Route::get('clone/{tj}', ['uses' => 'SingleController@cloneTransaction', 'as' => 'clone']);
- Route::get('{tj}/{type}', ['uses' => 'ConvertController@index', 'as' => 'convert']);
+ //Route::post('update/{tj}', ['uses' => 'SingleController@update', 'as' => 'update']);
+ //
+ //Route::get('clone/{tj}', ['uses' => 'SingleController@cloneTransaction', 'as' => 'clone']);
+ //Route::get('{tj}/{type}', ['uses' => 'ConvertController@index', 'as' => 'convert']);
// TODO end of improvement.
}
);