mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 14:26:58 +00:00
Add some stuff for edge cases.
This commit is contained in:
@@ -26,6 +26,7 @@ namespace FireflyIII\Http\Controllers\Transaction;
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
@@ -64,6 +65,9 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$cash = $repository->getCashAccount();
|
||||
$objectType = TransactionType::WITHDRAWAL;
|
||||
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
|
||||
$subTitle = (string)trans('breadcrumbs.create_new_transaction');
|
||||
@@ -82,7 +86,9 @@ class CreateController extends Controller
|
||||
|
||||
return view(
|
||||
'transactions.create',
|
||||
compact('subTitleIcon', 'objectType', 'subTitle', 'defaultCurrency', 'optionalFields', 'preFilled', 'allowedOpposingTypes', 'accountToTypes')
|
||||
compact('subTitleIcon', 'cash',
|
||||
'objectType', 'subTitle', 'defaultCurrency',
|
||||
'optionalFields', 'preFilled', 'allowedOpposingTypes', 'accountToTypes')
|
||||
);
|
||||
}
|
||||
|
||||
|
433
public/v1/js/app.js
vendored
433
public/v1/js/app.js
vendored
@@ -51352,7 +51352,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", ""]);
|
||||
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
|
||||
|
||||
@@ -51419,16 +51419,29 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
return this.error.length > 0;
|
||||
},
|
||||
changeData: function changeData() {
|
||||
if ('' === this.transactionType) {
|
||||
$(this.$refs.cur).text(this.sourceAccount.currency_name);
|
||||
// reset of all are empty:
|
||||
//console.log('Type "' + this.transactionType + '"');
|
||||
//console.log('Source "' + this.source.name + '"');
|
||||
//console.log('Dest "' + this.destination.name + '"');
|
||||
if (!this.transactionType && !this.source.name && !this.destination.name) {
|
||||
$(this.$refs.cur).text('');
|
||||
return;
|
||||
}
|
||||
if ('' === this.transactionType && '' !== this.source.currency_name) {
|
||||
$(this.$refs.cur).text(this.source.currency_name);
|
||||
return;
|
||||
}
|
||||
if ('' === this.transactionType && '' !== this.destination.currency_name) {
|
||||
$(this.$refs.cur).text(this.destination.currency_name);
|
||||
return;
|
||||
}
|
||||
if (this.transactionType === 'Withdrawal' || this.transactionType === 'Transfer') {
|
||||
$(this.$refs.cur).text(this.sourceAccount.currency_name);
|
||||
$(this.$refs.cur).text(this.source.currency_name);
|
||||
return;
|
||||
}
|
||||
if (this.transactionType === 'Deposit') {
|
||||
$(this.$refs.cur).text(this.destinationAccount.currency_name);
|
||||
$(this.$refs.cur).text(this.destination.currency_name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -52132,7 +52145,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", ""]);
|
||||
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", ""]);
|
||||
|
||||
// exports
|
||||
|
||||
@@ -52250,8 +52263,10 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
},
|
||||
accountTypeFilters: function accountTypeFilters() {
|
||||
var types = this.accountTypeFilters.join(',');
|
||||
//console.log(this.inputName + '[' + this.index + '] is now searching for: ' + types);
|
||||
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&query=";
|
||||
},
|
||||
name: function name() {
|
||||
console.log('Trigger watch on name.');
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -54629,7 +54644,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", ""]);
|
||||
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", ""]);
|
||||
|
||||
// exports
|
||||
|
||||
@@ -54640,8 +54655,6 @@ 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\
|
||||
|
||||
"use strict";
|
||||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__GroupDescription__ = __webpack_require__(14);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__GroupDescription___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__GroupDescription__);
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -54841,12 +54854,17 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
/* harmony default export */ __webpack_exports__["default"] = ({
|
||||
name: "CreateTransaction",
|
||||
components: { GroupDescription: __WEBPACK_IMPORTED_MODULE_0__GroupDescription___default.a },
|
||||
components: {},
|
||||
mounted: function mounted() {
|
||||
this.addTransaction();
|
||||
},
|
||||
@@ -54864,6 +54882,11 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
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;
|
||||
@@ -54889,6 +54912,39 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
|
||||
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;
|
||||
@@ -54904,8 +54960,6 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
foreignAmount = this.transactions[key].foreign_amount.amount;
|
||||
foreignCurrency = this.transactions[key].foreign_amount.currency_id;
|
||||
}
|
||||
console.log(foreignCurrency);
|
||||
console.log(this.transactions[key].currency_id);
|
||||
if (foreignCurrency === this.transactions[key].currency_id) {
|
||||
foreignAmount = null;
|
||||
foreignCurrency = null;
|
||||
@@ -54913,18 +54967,18 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
|
||||
currentArray = {
|
||||
type: transactionType,
|
||||
date: this.transactions[key].date,
|
||||
date: date,
|
||||
|
||||
amount: this.transactions[key].amount,
|
||||
currency_id: this.transactions[key].currency_id,
|
||||
|
||||
description: this.transactions[key].description,
|
||||
|
||||
source_id: this.transactions[key].source_account.id,
|
||||
source_name: this.transactions[key].source_account.name,
|
||||
source_id: sourceId,
|
||||
source_name: sourceName,
|
||||
|
||||
destination_id: this.transactions[key].destination_account.id,
|
||||
destination_name: this.transactions[key].destination_account.name,
|
||||
destination_id: destId,
|
||||
destination_name: destName,
|
||||
|
||||
category_name: this.transactions[key].category,
|
||||
//budget_id: this.transactions[key].budget,
|
||||
@@ -54968,14 +55022,23 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
|
||||
var uri = './api/v1/transactions?_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) {
|
||||
// do message:
|
||||
_this.success_message = 'The transaction has been stored.';
|
||||
_this.invalid_submission = '';
|
||||
if (_this.resetFormAfter) {
|
||||
_this.addTransaction();
|
||||
}
|
||||
} else {
|
||||
window.location.href = 'transactions/show/' + response.data.data.id + '?message=created';
|
||||
}
|
||||
}).catch(function (error) {
|
||||
// give user errors things back.
|
||||
// something something render errors.
|
||||
|
||||
console.log(error.response.data);
|
||||
_this.parseErrors(error.response.data);
|
||||
// something.
|
||||
});
|
||||
@@ -55019,6 +55082,8 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
this.invalid_submission = "";
|
||||
if (errors.message.length > 0) {
|
||||
this.invalid_submission = "There was something wrong with your submission. Please check out the errors below.";
|
||||
} else {
|
||||
this.invalid_submission = '';
|
||||
}
|
||||
var transactionIndex = void 0;
|
||||
var fieldName = void 0;
|
||||
@@ -55058,6 +55123,9 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
}
|
||||
}
|
||||
},
|
||||
resetTransactions: function resetTransactions() {
|
||||
this.transactions = [];
|
||||
},
|
||||
addTransaction: function addTransaction(e) {
|
||||
this.transactions.push({
|
||||
description: "",
|
||||
@@ -55092,7 +55160,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
budget: 0,
|
||||
tags: [],
|
||||
custom_fields: {
|
||||
"interest_date": "2010-01-01",
|
||||
"interest_date": "",
|
||||
"book_date": "",
|
||||
"process_date": "",
|
||||
"due_date": "",
|
||||
@@ -55110,10 +55178,6 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
id: 0,
|
||||
name: "",
|
||||
type: "",
|
||||
//currency_id: window.defaultCurrency.id,
|
||||
//currency_name: window.defaultCurrency.name,
|
||||
//currency_code: window.defaultCurrency.code,
|
||||
//currency_decimal_places: window.defaultCurrency.decimal_places,
|
||||
currency_id: 0,
|
||||
currency_name: '',
|
||||
currency_code: '',
|
||||
@@ -55124,10 +55188,6 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
id: 0,
|
||||
name: "",
|
||||
type: "",
|
||||
//currency_id: window.defaultCurrency.id,
|
||||
//currency_name: window.defaultCurrency.name,
|
||||
//currency_code: window.defaultCurrency.code,
|
||||
//currency_decimal_places: window.defaultCurrency.decimal_places,
|
||||
currency_id: 0,
|
||||
currency_name: '',
|
||||
currency_code: '',
|
||||
@@ -55138,6 +55198,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
console.log(this.transactions);
|
||||
},
|
||||
setTransactionType: function setTransactionType(type) {
|
||||
this.transactionType = type;
|
||||
@@ -55145,17 +55206,13 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
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) {
|
||||
console.log('Transactions[' + key + '] exists: ' + this.transactions[key].description);
|
||||
}
|
||||
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) {
|
||||
console.log('New: Transactions[' + _key + '] exists: ' + this.transactions[_key].description);
|
||||
}
|
||||
if (this.transactions.hasOwnProperty(_key) && /^0$|^[1-9]\d*$/.test(_key) && _key <= 4294967294) {}
|
||||
}
|
||||
},
|
||||
limitSourceType: function limitSourceType(type) {
|
||||
@@ -55176,16 +55233,17 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
// 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
|
||||
};
|
||||
|
||||
// todo maybe replace the entire model?
|
||||
this.transactions[index].source_account.id = model.id;
|
||||
this.transactions[index].source_account.name = model.name;
|
||||
this.transactions[index].source_account.type = model.type;
|
||||
|
||||
this.transactions[index].source_account.currency_id = model.currency_id;
|
||||
this.transactions[index].source_account.currency_name = model.currency_name;
|
||||
this.transactions[index].source_account.currency_code = model.currency_code;
|
||||
this.transactions[index].source_account.currency_decimal_places = model.currency_decimal_places;
|
||||
// force types on destination selector.
|
||||
this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
|
||||
}
|
||||
@@ -55195,44 +55253,62 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
// cant change types, only name.
|
||||
this.transactions[index].destination_account.name = model;
|
||||
} else {
|
||||
|
||||
// todo maybe replace the entire model?
|
||||
this.transactions[index].destination_account.id = model.id;
|
||||
this.transactions[index].destination_account.name = model.name;
|
||||
this.transactions[index].destination_account.type = model.type;
|
||||
|
||||
this.transactions[index].destination_account.currency_id = model.currency_id;
|
||||
this.transactions[index].destination_account.currency_name = model.currency_name;
|
||||
this.transactions[index].destination_account.currency_code = model.currency_code;
|
||||
this.transactions[index].destination_account.currency_decimal_places = model.currency_decimal_places;
|
||||
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) {
|
||||
this.transactions[index].source_account.id = 0;
|
||||
this.transactions[index].source_account.name = "";
|
||||
this.transactions[index].source_account.type = "";
|
||||
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) {
|
||||
console.log('There is a destination account.');
|
||||
this.selectedDestinationAccount(index, this.transactions[index].destination_account);
|
||||
}
|
||||
},
|
||||
clearDestination: function clearDestination(index) {
|
||||
this.transactions[index].destination_account.id = 0;
|
||||
this.transactions[index].destination_account.name = "";
|
||||
this.transactions[index].destination_account.type = "";
|
||||
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) {
|
||||
console.log('There is a source account.');
|
||||
this.selectedSourceAccount(index, this.transactions[index].source_account);
|
||||
}
|
||||
}
|
||||
@@ -55247,7 +55323,12 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
group_title: "",
|
||||
transactions: [],
|
||||
group_title_errors: [],
|
||||
invalid_submission: ""
|
||||
invalid_submission: "",
|
||||
success_message: "",
|
||||
cash_account_id: 0,
|
||||
createAnother: false,
|
||||
resetFormAfter: false,
|
||||
resetButtonDisabled: true
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -55297,11 +55378,31 @@ var render = function() {
|
||||
])
|
||||
: _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(" " + _vm._s(_vm.success_message) + "\n ")
|
||||
]
|
||||
)
|
||||
])
|
||||
])
|
||||
: _vm._e(),
|
||||
_vm._v(" "),
|
||||
_vm.transactions.length > 1
|
||||
? _c("div", { staticClass: "row" }, [
|
||||
_c("div", { staticClass: "col-lg-6" }, [
|
||||
_c("div", { staticClass: "box" }, [
|
||||
_vm._m(1),
|
||||
_vm._m(2),
|
||||
_vm._v(" "),
|
||||
_c(
|
||||
"div",
|
||||
@@ -55325,9 +55426,10 @@ var render = function() {
|
||||
])
|
||||
: _vm._e(),
|
||||
_vm._v(" "),
|
||||
_c(
|
||||
"div",
|
||||
_vm._l(_vm.transactions, function(transaction, index) {
|
||||
return _c("div", [
|
||||
_c("div", { staticClass: "row" }, [
|
||||
return _c("div", { staticClass: "row" }, [
|
||||
_c("div", { staticClass: "col-lg-12" }, [
|
||||
_c("div", { staticClass: "box" }, [
|
||||
_c("div", { staticClass: "box-header with-border" }, [
|
||||
@@ -55591,16 +55693,139 @@ var render = function() {
|
||||
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-12" }, [
|
||||
_c("p", [
|
||||
_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", on: { click: _vm.submit } },
|
||||
[_vm._v("Submit")]
|
||||
),
|
||||
_vm._v(" "),
|
||||
_c(
|
||||
"button",
|
||||
{
|
||||
@@ -55611,31 +55836,10 @@ var render = function() {
|
||||
)
|
||||
])
|
||||
])
|
||||
]),
|
||||
_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(2),
|
||||
_vm._v(" "),
|
||||
_vm._m(3),
|
||||
_vm._v(" "),
|
||||
_c("div", { staticClass: "box-footer" }, [
|
||||
_c("div", { staticClass: "btn-group" }, [
|
||||
_c(
|
||||
"button",
|
||||
{ staticClass: "btn btn-success", on: { click: _vm.submit } },
|
||||
[_vm._v("Submit")]
|
||||
)
|
||||
])
|
||||
])
|
||||
])
|
||||
])
|
||||
]),
|
||||
_vm._v(" "),
|
||||
_c("pre", [_vm._v(_vm._s(_vm.$data))])
|
||||
],
|
||||
2
|
||||
]
|
||||
)
|
||||
}
|
||||
var staticRenderFns = [
|
||||
@@ -55656,6 +55860,23 @@ var staticRenderFns = [
|
||||
[_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
|
||||
@@ -55673,32 +55894,10 @@ var staticRenderFns = [
|
||||
var _h = _vm.$createElement
|
||||
var _c = _vm._self._c || _h
|
||||
return _c("div", { staticClass: "box-header with-border" }, [
|
||||
_c("h3", { staticClass: "box-title splitTitle" }, [
|
||||
_c("h3", { staticClass: "box-title" }, [
|
||||
_vm._v("\n Submission\n ")
|
||||
])
|
||||
])
|
||||
},
|
||||
function() {
|
||||
var _vm = this
|
||||
var _h = _vm.$createElement
|
||||
var _c = _vm._self._c || _h
|
||||
return _c("div", { staticClass: "box-body" }, [
|
||||
_c("div", { staticClass: "checkbox" }, [
|
||||
_c("label", [
|
||||
_c("input", {
|
||||
attrs: {
|
||||
id: "transaction_return_to_form",
|
||||
name: "create_another",
|
||||
type: "checkbox",
|
||||
value: "1"
|
||||
}
|
||||
}),
|
||||
_vm._v(
|
||||
"\n After storing, return here to create another one.\n "
|
||||
)
|
||||
])
|
||||
])
|
||||
])
|
||||
}
|
||||
]
|
||||
render._withStripped = true
|
||||
|
@@ -104,8 +104,10 @@
|
||||
},
|
||||
accountTypeFilters() {
|
||||
let types = this.accountTypeFilters.join(',');
|
||||
//console.log(this.inputName + '[' + this.index + '] is now searching for: ' + types);
|
||||
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&query=";
|
||||
},
|
||||
name() {
|
||||
console.log('Trigger watch on name.');
|
||||
}
|
||||
},
|
||||
methods:
|
||||
|
@@ -52,16 +52,29 @@
|
||||
return this.error.length > 0;
|
||||
},
|
||||
changeData: function () {
|
||||
if ('' === this.transactionType) {
|
||||
$(this.$refs.cur).text(this.sourceAccount.currency_name);
|
||||
// reset of all are empty:
|
||||
//console.log('Type "' + this.transactionType + '"');
|
||||
//console.log('Source "' + this.source.name + '"');
|
||||
//console.log('Dest "' + this.destination.name + '"');
|
||||
if (!this.transactionType && !this.source.name && !this.destination.name) {
|
||||
$(this.$refs.cur).text('');
|
||||
return;
|
||||
}
|
||||
if ('' === this.transactionType && '' !== this.source.currency_name) {
|
||||
$(this.$refs.cur).text(this.source.currency_name);
|
||||
return;
|
||||
}
|
||||
if ('' === this.transactionType && '' !== this.destination.currency_name) {
|
||||
$(this.$refs.cur).text(this.destination.currency_name);
|
||||
return;
|
||||
}
|
||||
if (this.transactionType === 'Withdrawal' || this.transactionType === 'Transfer') {
|
||||
$(this.$refs.cur).text(this.sourceAccount.currency_name);
|
||||
$(this.$refs.cur).text(this.source.currency_name);
|
||||
return;
|
||||
}
|
||||
if (this.transactionType === 'Deposit') {
|
||||
$(this.$refs.cur).text(this.destinationAccount.currency_name);
|
||||
$(this.$refs.cur).text(this.destination.currency_name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@@ -22,7 +22,6 @@
|
||||
<form method="POST" action="transactions/store" 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="invalid_submission !== ''">
|
||||
<div class="col-lg-12">
|
||||
<div class="alert alert-danger alert-dismissible" role="alert">
|
||||
@@ -33,6 +32,15 @@
|
||||
</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">×</span></button>
|
||||
<strong>Success!</strong> {{ success_message }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-if="transactions.length > 1">
|
||||
<div class="col-lg-6">
|
||||
<div class="box">
|
||||
@@ -51,8 +59,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-for="(transaction, index) in transactions">
|
||||
<div class="row">
|
||||
<div>
|
||||
<div class="row" v-for="(transaction, index) in transactions">
|
||||
<div class="col-lg-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
@@ -155,54 +163,51 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<p>
|
||||
<div class="box-footer" v-if="transactions.length-1 === index">
|
||||
<button class="btn btn-primary" @click="addTransaction">Add another split</button>
|
||||
</p>
|
||||
</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 splitTitle">
|
||||
<h3 class="box-title">
|
||||
Submission
|
||||
</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input id="transaction_return_to_form" name="create_another" type="checkbox" value="1">
|
||||
<input v-model="createAnother" name="create_another" type="checkbox">
|
||||
After storing, return here to create another one.
|
||||
</label>
|
||||
<label v-bind:class="{ 'text-muted': this.createAnother === false}">
|
||||
<input v-model="resetFormAfter" :disabled="this.createAnother === false"
|
||||
name="reset_form" type="checkbox">
|
||||
Reset form after submission
|
||||
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<div class="btn-group">
|
||||
|
||||
<button class="btn btn-success" @click="submit">Submit</button>
|
||||
<button class="btn btn-primary" @click="addTransaction">Add another split</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<pre>{{ $data }}</pre>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import GroupDescription from "./GroupDescription";
|
||||
|
||||
export default {
|
||||
name: "CreateTransaction",
|
||||
components: {GroupDescription},
|
||||
components: {},
|
||||
mounted() {
|
||||
this.addTransaction();
|
||||
},
|
||||
@@ -221,6 +226,11 @@
|
||||
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;
|
||||
@@ -234,7 +244,6 @@
|
||||
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';
|
||||
@@ -245,8 +254,42 @@
|
||||
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;
|
||||
@@ -262,8 +305,6 @@
|
||||
foreignAmount = this.transactions[key].foreign_amount.amount;
|
||||
foreignCurrency = this.transactions[key].foreign_amount.currency_id;
|
||||
}
|
||||
console.log(foreignCurrency);
|
||||
console.log(this.transactions[key].currency_id);
|
||||
if (foreignCurrency === this.transactions[key].currency_id) {
|
||||
foreignAmount = null;
|
||||
foreignCurrency = null;
|
||||
@@ -272,18 +313,18 @@
|
||||
currentArray =
|
||||
{
|
||||
type: transactionType,
|
||||
date: this.transactions[key].date,
|
||||
date: date,
|
||||
|
||||
amount: this.transactions[key].amount,
|
||||
currency_id: this.transactions[key].currency_id,
|
||||
|
||||
description: this.transactions[key].description,
|
||||
|
||||
source_id: this.transactions[key].source_account.id,
|
||||
source_name: this.transactions[key].source_account.name,
|
||||
source_id: sourceId,
|
||||
source_name: sourceName,
|
||||
|
||||
destination_id: this.transactions[key].destination_account.id,
|
||||
destination_name: this.transactions[key].destination_account.name,
|
||||
destination_id: destId,
|
||||
destination_name: destName,
|
||||
|
||||
|
||||
category_name: this.transactions[key].category,
|
||||
@@ -326,15 +367,24 @@
|
||||
submit(e) {
|
||||
const uri = './api/v1/transactions?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
|
||||
const data = this.convertData();
|
||||
|
||||
if (this.resetFormAfter) {
|
||||
this.resetTransactions();
|
||||
}
|
||||
axios.post(uri, data)
|
||||
.then(response => {
|
||||
if (this.createAnother) {
|
||||
// do message:
|
||||
this.success_message = 'The transaction has been stored.';
|
||||
this.invalid_submission = '';
|
||||
if (this.resetFormAfter) {
|
||||
this.addTransaction();
|
||||
}
|
||||
} else {
|
||||
window.location.href = 'transactions/show/' + response.data.data.id + '?message=created';
|
||||
}
|
||||
}).catch(error => {
|
||||
// give user errors things back.
|
||||
// something something render errors.
|
||||
|
||||
console.log(error.response.data);
|
||||
this.parseErrors(error.response.data);
|
||||
// something.
|
||||
});
|
||||
@@ -377,6 +427,8 @@
|
||||
this.invalid_submission = "";
|
||||
if (errors.message.length > 0) {
|
||||
this.invalid_submission = "There was something wrong with your submission. Please check out the errors below.";
|
||||
} else {
|
||||
this.invalid_submission = '';
|
||||
}
|
||||
let transactionIndex;
|
||||
let fieldName;
|
||||
@@ -419,6 +471,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
resetTransactions: function () {
|
||||
this.transactions = [];
|
||||
},
|
||||
addTransaction: function (e) {
|
||||
this.transactions.push({
|
||||
description: "",
|
||||
@@ -453,7 +508,7 @@
|
||||
budget: 0,
|
||||
tags: [],
|
||||
custom_fields: {
|
||||
"interest_date": "2010-01-01",
|
||||
"interest_date": "",
|
||||
"book_date": "",
|
||||
"process_date": "",
|
||||
"due_date": "",
|
||||
@@ -471,10 +526,6 @@
|
||||
id: 0,
|
||||
name: "",
|
||||
type: "",
|
||||
//currency_id: window.defaultCurrency.id,
|
||||
//currency_name: window.defaultCurrency.name,
|
||||
//currency_code: window.defaultCurrency.code,
|
||||
//currency_decimal_places: window.defaultCurrency.decimal_places,
|
||||
currency_id: 0,
|
||||
currency_name: '',
|
||||
currency_code: '',
|
||||
@@ -485,10 +536,6 @@
|
||||
id: 0,
|
||||
name: "",
|
||||
type: "",
|
||||
//currency_id: window.defaultCurrency.id,
|
||||
//currency_name: window.defaultCurrency.name,
|
||||
//currency_code: window.defaultCurrency.code,
|
||||
//currency_decimal_places: window.defaultCurrency.decimal_places,
|
||||
currency_id: 0,
|
||||
currency_name: '',
|
||||
currency_code: '',
|
||||
@@ -499,6 +546,7 @@
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
console.log(this.transactions);
|
||||
},
|
||||
setTransactionType: function (type) {
|
||||
this.transactionType = type;
|
||||
@@ -508,7 +556,6 @@
|
||||
for (const key in this.transactions) {
|
||||
if (
|
||||
this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||
console.log('Transactions[' + key + '] exists: ' + this.transactions[key].description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,7 +564,6 @@
|
||||
for (const key in this.transactions) {
|
||||
if (
|
||||
this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||
console.log('New: Transactions[' + key + '] exists: ' + this.transactions[key].description);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -539,16 +585,17 @@
|
||||
// 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
|
||||
};
|
||||
|
||||
// todo maybe replace the entire model?
|
||||
this.transactions[index].source_account.id = model.id;
|
||||
this.transactions[index].source_account.name = model.name;
|
||||
this.transactions[index].source_account.type = model.type;
|
||||
|
||||
this.transactions[index].source_account.currency_id = model.currency_id;
|
||||
this.transactions[index].source_account.currency_name = model.currency_name;
|
||||
this.transactions[index].source_account.currency_code = model.currency_code;
|
||||
this.transactions[index].source_account.currency_decimal_places = model.currency_decimal_places;
|
||||
// force types on destination selector.
|
||||
this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
|
||||
}
|
||||
@@ -558,44 +605,62 @@
|
||||
// cant change types, only name.
|
||||
this.transactions[index].destination_account.name = model;
|
||||
} else {
|
||||
|
||||
// todo maybe replace the entire model?
|
||||
this.transactions[index].destination_account.id = model.id;
|
||||
this.transactions[index].destination_account.name = model.name;
|
||||
this.transactions[index].destination_account.type = model.type;
|
||||
|
||||
this.transactions[index].destination_account.currency_id = model.currency_id;
|
||||
this.transactions[index].destination_account.currency_name = model.currency_name;
|
||||
this.transactions[index].destination_account.currency_code = model.currency_code;
|
||||
this.transactions[index].destination_account.currency_decimal_places = model.currency_decimal_places;
|
||||
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) {
|
||||
this.transactions[index].source_account.id = 0;
|
||||
this.transactions[index].source_account.name = "";
|
||||
this.transactions[index].source_account.type = "";
|
||||
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) {
|
||||
console.log('There is a destination account.');
|
||||
this.selectedDestinationAccount(index, this.transactions[index].destination_account);
|
||||
}
|
||||
},
|
||||
clearDestination: function (index) {
|
||||
this.transactions[index].destination_account.id = 0;
|
||||
this.transactions[index].destination_account.name = "";
|
||||
this.transactions[index].destination_account.type = "";
|
||||
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) {
|
||||
console.log('There is a source account.');
|
||||
this.selectedSourceAccount(index, this.transactions[index].source_account);
|
||||
}
|
||||
}
|
||||
@@ -610,7 +675,12 @@
|
||||
group_title: "",
|
||||
transactions: [],
|
||||
group_title_errors: [],
|
||||
invalid_submission: ""
|
||||
invalid_submission: "",
|
||||
success_message: "",
|
||||
cash_account_id: 0,
|
||||
createAnother: false,
|
||||
resetFormAfter: false,
|
||||
resetButtonDisabled: true,
|
||||
};
|
||||
},
|
||||
}
|
||||
|
@@ -255,6 +255,7 @@
|
||||
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">
|
||||
|
@@ -1,260 +1 @@
|
||||
{% extends "./layout/default" %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, what) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form method="POST" action="{{ route('transactions.store') }}" accept-charset="UTF-8" class="form-horizontal" id="store" enctype="multipart/form-data">
|
||||
<input name="_token" type="hidden" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="what" value="{{ what }}"/>
|
||||
|
||||
<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">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">{{ 'quickswitch'|_ }}</label>
|
||||
|
||||
<div class="col-sm-8" id="switch-box">
|
||||
<div class="btn-group btn-group-justified">
|
||||
<a href="#" data-what="withdrawal" class="switch btn btn-default"> {{ 'withdrawal'|_ }}</a>
|
||||
<a href="#" data-what="deposit" class="switch btn btn-default"> {{ 'deposit'|_ }}</a>
|
||||
<a href="#" data-what="transfer" class="switch btn btn-default">{{ 'transfer'|_ }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{# DESCRIPTION IS ALWAYS AVAILABLE #}
|
||||
{{ ExpandedForm.text('description') }}
|
||||
|
||||
{# SELECTABLE SOURCE ACCOUNT ONLY FOR WITHDRAWALS AND TRANSFERS #}
|
||||
{{ ExpandedForm.activeLongAccountList('source_id', null, {label: trans('form.asset_source_account') }) }}
|
||||
|
||||
{# FREE FORMAT SOURCE ACCOUNT ONLY FOR DEPOSITS #}
|
||||
{{ ExpandedForm.text('source_name', null, {label: trans('form.revenue_account')}) }}
|
||||
|
||||
{# FREE FORMAT DESTINATION ACCOUNT ONLY FOR EXPENSES #}
|
||||
{{ ExpandedForm.text('destination_name', null, {label: trans('form.expense_account')}) }}
|
||||
|
||||
{# SELECTABLE DESTINATION ACCOUNT ONLY FOR TRANSFERS AND DEPOSITS #}
|
||||
{{ ExpandedForm.activeLongAccountList('destination_id', null, {label: trans('form.asset_destination_account')} ) }}
|
||||
|
||||
{# ALWAYS SHOW AMOUNT #}
|
||||
<!-- A -->
|
||||
{{ ExpandedForm.amount('amount') }}
|
||||
<!-- B -->
|
||||
|
||||
{# INSTRUCTIONS FOR EXCHANGE RATES #}
|
||||
{{ ExpandedForm.staticText('exchange_rate_instruction','(here be text)') }}
|
||||
|
||||
{{ ExpandedForm.nonSelectableAmount('native_amount') }}
|
||||
|
||||
{{ ExpandedForm.nonSelectableAmount('source_amount') }}
|
||||
|
||||
{{ ExpandedForm.nonSelectableAmount('destination_amount') }}
|
||||
|
||||
{# ALWAYS SHOW DATE #}
|
||||
{{ ExpandedForm.date('date', preFilled.date|default(phpdate('Y-m-d'))) }}
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="transaction-btn btn btn-success pull-right">
|
||||
{{ trans('form.store_new_'~what) }}
|
||||
</button>
|
||||
</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">{{ 'optional_field_meta_data'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{# BUDGET ONLY WHEN CREATING A WITHDRAWAL #}
|
||||
{% if budgets|length > 1 %}
|
||||
{{ ExpandedForm.select('budget_id', budgets, null) }}
|
||||
{% else %}
|
||||
{{ ExpandedForm.select('budget_id', budgets, null, {helpText: trans('firefly.no_budget_pointer', {link: route('budgets.index')})}) }}
|
||||
{% endif %}
|
||||
|
||||
{# CATEGORY ALWAYS #}
|
||||
{{ ExpandedForm.text('category') }}
|
||||
|
||||
{# TAGS #}
|
||||
{{ ExpandedForm.text('tags') }}
|
||||
|
||||
{# RELATE THIS TRANSFER TO A PIGGY BANK #}
|
||||
<!-- C -->
|
||||
{{ ExpandedForm.piggyBankList('piggy_bank_id', 0) }}
|
||||
<!-- D -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# explain if necessary #}
|
||||
{% 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 %}
|
||||
|
||||
{# box for dates #}
|
||||
{% if
|
||||
optionalFields.interest_date or optionalFields.book_date or optionalFields.process_date
|
||||
or optionalFields.due_date or optionalFields.payment_date
|
||||
or optionalFields.invoice_date %}
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'optional_field_meta_dates'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
|
||||
{# INTEREST DATE #}
|
||||
{% if optionalFields.interest_date %}
|
||||
{{ ExpandedForm.date('interest_date') }}
|
||||
{% endif %}
|
||||
|
||||
{# BOOK DATE #}
|
||||
{% if optionalFields.book_date %}
|
||||
{{ ExpandedForm.date('book_date') }}
|
||||
{% endif %}
|
||||
|
||||
{# PROCESSING DATE #}
|
||||
{% if optionalFields.process_date %}
|
||||
{{ ExpandedForm.date('process_date') }}
|
||||
{% endif %}
|
||||
|
||||
{# DUE DATE #}
|
||||
{% if optionalFields.due_date %}
|
||||
{{ ExpandedForm.date('due_date') }}
|
||||
{% endif %}
|
||||
|
||||
{# PAYMENT DATE #}
|
||||
{% if optionalFields.payment_date %}
|
||||
{{ ExpandedForm.date('payment_date') }}
|
||||
{% endif %}
|
||||
|
||||
{# INVOICE DATE #}
|
||||
{% if optionalFields.invoice_date %}
|
||||
{{ ExpandedForm.date('invoice_date') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# box for business fields #}
|
||||
{% if optionalFields.internal_reference or optionalFields.notes %}
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'optional_field_meta_business'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
|
||||
{# REFERENCE #}
|
||||
{% if optionalFields.internal_reference %}
|
||||
{{ ExpandedForm.text('internal_reference') }}
|
||||
{% endif %}
|
||||
|
||||
{# NOTES #}
|
||||
{% if optionalFields.notes %}
|
||||
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# box for attachments #}
|
||||
{% if optionalFields.attachments %}
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'optional_field_attachments'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{# ATTACHMENTS #}
|
||||
{% if optionalFields.attachments %}
|
||||
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
|
||||
{% endif %}
|
||||
</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('create','transaction') }}
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="transaction-btn btn btn-success pull-right">
|
||||
{{ trans('form.store_new_'~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 what = "{{ what }}";
|
||||
|
||||
// some titles and names:
|
||||
var txt = [];
|
||||
var title = [];
|
||||
var breadcrumbs = [];
|
||||
var middleCrumbName = [];
|
||||
var middleCrumbUrl = [];
|
||||
var button = [];
|
||||
var exchangeRateInstructions = "{{ 'exchange_rate_instructions'|_|escape('js') }}";
|
||||
var transferInstructions = "{{ 'transfer_exchange_rate_instructions'|_|escape('js') }}";
|
||||
|
||||
{% for type in {0:'withdrawal',1:'deposit',2:'transfer'} %}
|
||||
|
||||
txt['{{ type }}'] = '{{ type|_ }}';
|
||||
title['{{ type }}'] = '{{ trans('form.add_new_' ~ type) }}';
|
||||
breadcrumbs['{{ type }}'] = '{{ trans('breadcrumbs.create_' ~ type) }}';
|
||||
middleCrumbName['{{ type }}'] = '{{ trans('breadcrumbs.' ~ type ~ '_list') }}';
|
||||
middleCrumbUrl['{{ type }}'] = '{{ route('transactions.index', type) }}';
|
||||
button['{{ type }}'] = '{{ trans('form.store_new_' ~ type) }}';
|
||||
{% endfor %}
|
||||
|
||||
// some code for the foreign amount logic:
|
||||
var useAccountCurrency = {% if preFilled.amount_currency_id_amount > 0 %}false{% else %}true{% endif %};
|
||||
var overruleCurrency = {{ preFilled.amount_currency_id_amount|default(0) }};
|
||||
|
||||
</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/modernizr-custom.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/jscript/accounts?ext=.js&v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="v1/jscript/currencies?ext=.js&v={{ FF_VERSION }}"></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/create.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 %}
|
||||
<!-- DO NOT USE ME -->
|
||||
|
Reference in New Issue
Block a user