mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 02:52:44 +00:00
Attempt to fix uploads.
This commit is contained in:
@@ -59,7 +59,6 @@
|
|||||||
//console.log('Dest "' + this.destination.name + '"');
|
//console.log('Dest "' + this.destination.name + '"');
|
||||||
if (!transactionType && !this.source.name && !this.destination.name) {
|
if (!transactionType && !this.source.name && !this.destination.name) {
|
||||||
$(this.$refs.cur).text('');
|
$(this.$refs.cur).text('');
|
||||||
console.log('A');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(null === transactionType) {
|
if(null === transactionType) {
|
||||||
@@ -68,28 +67,19 @@
|
|||||||
|
|
||||||
if ('' === transactionType && '' !== this.source.currency_name) {
|
if ('' === transactionType && '' !== this.source.currency_name) {
|
||||||
$(this.$refs.cur).text(this.source.currency_name);
|
$(this.$refs.cur).text(this.source.currency_name);
|
||||||
console.log('B');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ('' === transactionType && '' !== this.destination.currency_name) {
|
if ('' === transactionType && '' !== this.destination.currency_name) {
|
||||||
$(this.$refs.cur).text(this.destination.currency_name);
|
$(this.$refs.cur).text(this.destination.currency_name);
|
||||||
console.log('C');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (transactionType === 'Withdrawal' || transactionType === 'Transfer') {
|
if (transactionType === 'Withdrawal' || transactionType === 'Transfer') {
|
||||||
$(this.$refs.cur).text(this.source.currency_name);
|
$(this.$refs.cur).text(this.source.currency_name);
|
||||||
console.log('D');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (transactionType === 'Deposit') {
|
if (transactionType === 'Deposit') {
|
||||||
$(this.$refs.cur).text(this.destination.currency_name);
|
$(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: {
|
watch: {
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<form method="POST" action="transactions/store" accept-charset="UTF-8" class="form-horizontal" id="store"
|
<form method="POST" action="#" accept-charset="UTF-8" class="form-horizontal" id="store"
|
||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data">
|
||||||
<input name="_token" type="hidden" value="xxx">
|
<input name="_token" type="hidden" value="xxx">
|
||||||
<div class="row" v-if="error_message !== ''">
|
<div class="row" v-if="error_message !== ''">
|
||||||
@@ -164,7 +164,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer" v-if="transactions.length-1 === index">
|
<div class="box-footer" v-if="transactions.length-1 === index">
|
||||||
<button class="btn btn-primary" @click="addTransaction">Add another split</button>
|
<button class="btn btn-primary" @click="addTransactionToArray">Add another split</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -208,7 +208,7 @@
|
|||||||
name: "CreateTransaction",
|
name: "CreateTransaction",
|
||||||
components: {},
|
components: {},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.addTransaction();
|
this.addTransactionToArray();
|
||||||
},
|
},
|
||||||
ready() {
|
ready() {
|
||||||
|
|
||||||
@@ -218,18 +218,9 @@
|
|||||||
let data = {
|
let data = {
|
||||||
'transactions': [],
|
'transactions': [],
|
||||||
};
|
};
|
||||||
let tagList = [];
|
|
||||||
let transactionType;
|
let transactionType;
|
||||||
let firstSource;
|
let firstSource;
|
||||||
let firstDestination;
|
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) {
|
if (this.transactions.length > 1) {
|
||||||
data.group_title = this.group_title;
|
data.group_title = this.group_title;
|
||||||
@@ -244,26 +235,38 @@
|
|||||||
firstDestination = this.transactions[0].destination_account.type;
|
firstDestination = this.transactions[0].destination_account.type;
|
||||||
|
|
||||||
if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstSource)) {
|
if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstSource)) {
|
||||||
//console.log('Assumed this is a withdrawal.');
|
|
||||||
transactionType = 'withdrawal';
|
transactionType = 'withdrawal';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstDestination)) {
|
if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstDestination)) {
|
||||||
//console.log('Assumed this is a deposit.');
|
|
||||||
transactionType = 'deposit';
|
transactionType = 'deposit';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (let key in this.transactions) {
|
for (let key in this.transactions) {
|
||||||
if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||||
|
data.transactions.push(this.convertDataRow(this.transactions[key], key, transactionType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
convertDataRow(row, index, transactionType) {
|
||||||
|
let tagList = [];
|
||||||
|
let foreignAmount = null;
|
||||||
|
let foreignCurrency = null;
|
||||||
|
let currentArray;
|
||||||
|
let sourceId;
|
||||||
|
let sourceName;
|
||||||
|
let destId;
|
||||||
|
let destName;
|
||||||
|
let date;
|
||||||
|
|
||||||
sourceId = this.transactions[key].source_account.id;
|
sourceId = this.transactions[index].source_account.id;
|
||||||
sourceName = this.transactions[key].source_account.name;
|
sourceName = this.transactions[index].source_account.name;
|
||||||
destId = this.transactions[key].destination_account.id;
|
destId = this.transactions[index].destination_account.id;
|
||||||
destName = this.transactions[key].destination_account.name;
|
destName = this.transactions[index].destination_account.name;
|
||||||
|
|
||||||
date = this.transactions[key].date;
|
date = this.transactions[index].date;
|
||||||
if (key > 0) {
|
if (index > 0) {
|
||||||
date = this.transactions[0].date;
|
date = this.transactions[0].date;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,14 +280,14 @@
|
|||||||
sourceId = window.cashAccountId;
|
sourceId = window.cashAccountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if key is over 0 and type is withdrawal or transfer, take source from key 0.
|
// if index is over 0 and type is withdrawal or transfer, take source from key 0.
|
||||||
if (key > 0 && (transactionType.toLowerCase() === 'withdrawal' || transactionType.toLowerCase() === 'transfer')) {
|
if (index > 0 && (transactionType.toLowerCase() === 'withdrawal' || transactionType.toLowerCase() === 'transfer')) {
|
||||||
sourceId = this.transactions[0].source_account.id;
|
sourceId = this.transactions[0].source_account.id;
|
||||||
sourceName = this.transactions[0].source_account.name;
|
sourceName = this.transactions[0].source_account.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if key is over 0 and type is deposit or transfer, take destination from key 0.
|
// if index is over 0 and type is deposit or transfer, take destination from key 0.
|
||||||
if (key > 0 && (transactionType.toLowerCase() === 'deposit' || transactionType.toLowerCase() === 'transfer')) {
|
if (index > 0 && (transactionType.toLowerCase() === 'deposit' || transactionType.toLowerCase() === 'transfer')) {
|
||||||
destId = this.transactions[0].destination_account.id;
|
destId = this.transactions[0].destination_account.id;
|
||||||
destName = this.transactions[0].destination_account.name;
|
destName = this.transactions[0].destination_account.name;
|
||||||
}
|
}
|
||||||
@@ -293,18 +296,18 @@
|
|||||||
foreignAmount = null;
|
foreignAmount = null;
|
||||||
foreignCurrency = null;
|
foreignCurrency = null;
|
||||||
// loop tags
|
// loop tags
|
||||||
for (let tagKey in this.transactions[key].tags) {
|
for (let tagKey in row.tags) {
|
||||||
if (this.transactions[key].tags.hasOwnProperty(tagKey) && /^0$|^[1-9]\d*$/.test(tagKey) && key <= 4294967294) {
|
if (row.tags.hasOwnProperty(tagKey) && /^0$|^[1-9]\d*$/.test(tagKey) && key <= 4294967294) {
|
||||||
tagList.push(this.transactions[key].tags[tagKey].text);
|
tagList.push(row.tags[tagKey].text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set foreign currency info:
|
// set foreign currency info:
|
||||||
if (this.transactions[key].foreign_amount.amount !== '' && parseFloat(this.transactions[key].foreign_amount.amount) !== .00) {
|
if (row.foreign_amount.amount !== '' && parseFloat(row.foreign_amount.amount) !== .00) {
|
||||||
foreignAmount = this.transactions[key].foreign_amount.amount;
|
foreignAmount = row.foreign_amount.amount;
|
||||||
foreignCurrency = this.transactions[key].foreign_amount.currency_id;
|
foreignCurrency = row.foreign_amount.currency_id;
|
||||||
}
|
}
|
||||||
if (foreignCurrency === this.transactions[key].currency_id) {
|
if (foreignCurrency === row.currency_id) {
|
||||||
foreignAmount = null;
|
foreignAmount = null;
|
||||||
foreignCurrency = null;
|
foreignCurrency = null;
|
||||||
}
|
}
|
||||||
@@ -322,10 +325,10 @@
|
|||||||
type: transactionType,
|
type: transactionType,
|
||||||
date: date,
|
date: date,
|
||||||
|
|
||||||
amount: this.transactions[key].amount,
|
amount: row.amount,
|
||||||
currency_id: this.transactions[key].currency_id,
|
currency_id: row.currency_id,
|
||||||
|
|
||||||
description: this.transactions[key].description,
|
description: row.description,
|
||||||
|
|
||||||
source_id: sourceId,
|
source_id: sourceId,
|
||||||
source_name: sourceName,
|
source_name: sourceName,
|
||||||
@@ -334,19 +337,19 @@
|
|||||||
destination_name: destName,
|
destination_name: destName,
|
||||||
|
|
||||||
|
|
||||||
category_name: this.transactions[key].category,
|
category_name: row.category,
|
||||||
//budget_id: this.transactions[key].budget,
|
//budget_id: row.budget,
|
||||||
//piggy_bank_id: this.transactions[key].piggy_bank,
|
//piggy_bank_id: row.piggy_bank,
|
||||||
|
|
||||||
|
|
||||||
interest_date: this.transactions[key].custom_fields.interest_date,
|
interest_date: row.custom_fields.interest_date,
|
||||||
book_date: this.transactions[key].custom_fields.book_date,
|
book_date: row.custom_fields.book_date,
|
||||||
process_date: this.transactions[key].custom_fields.process_date,
|
process_date: row.custom_fields.process_date,
|
||||||
due_date: this.transactions[key].custom_fields.due_date,
|
due_date: row.custom_fields.due_date,
|
||||||
payment_date: this.transactions[key].custom_fields.payment_date,
|
payment_date: row.custom_fields.payment_date,
|
||||||
invoice_date: this.transactions[key].custom_fields.invoice_date,
|
invoice_date: row.custom_fields.invoice_date,
|
||||||
internal_reference: this.transactions[key].custom_fields.internal_reference,
|
internal_reference: row.custom_fields.internal_reference,
|
||||||
notes: this.transactions[key].custom_fields.notes
|
notes: row.custom_fields.notes
|
||||||
};
|
};
|
||||||
|
|
||||||
if (tagList.length > 0) {
|
if (tagList.length > 0) {
|
||||||
@@ -357,20 +360,15 @@
|
|||||||
currentArray.foreign_currency_id = foreignCurrency;
|
currentArray.foreign_currency_id = foreignCurrency;
|
||||||
}
|
}
|
||||||
// set budget id and piggy ID.
|
// set budget id and piggy ID.
|
||||||
if (parseInt(this.transactions[key].budget) > 0) {
|
if (parseInt(row.budget) > 0) {
|
||||||
currentArray.budget_id = parseInt(this.transactions[key].budget);
|
currentArray.budget_id = parseInt(row.budget);
|
||||||
}
|
}
|
||||||
if (parseInt(this.transactions[key].piggy_bank) > 0) {
|
if (parseInt(row.piggy_bank) > 0) {
|
||||||
currentArray.piggy_bank_id = parseInt(this.transactions[key].piggy_bank);
|
currentArray.piggy_bank_id = parseInt(row.piggy_bank);
|
||||||
}
|
}
|
||||||
|
return currentArray;
|
||||||
data.transactions.push(currentArray);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//console.log(data);
|
|
||||||
|
|
||||||
return data;
|
|
||||||
},
|
},
|
||||||
|
// submit transaction
|
||||||
submit(e) {
|
submit(e) {
|
||||||
const uri = './api/v1/transactions?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
|
const uri = './api/v1/transactions?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
|
||||||
const data = this.convertData();
|
const data = this.convertData();
|
||||||
@@ -381,9 +379,10 @@
|
|||||||
let button = $(e.currentTarget);
|
let button = $(e.currentTarget);
|
||||||
button.prop("disabled", true);
|
button.prop("disabled", true);
|
||||||
|
|
||||||
axios.post(uri, data)
|
axions.post(uri, data).then(response => {
|
||||||
.then(response => {
|
// send user onwards.
|
||||||
if (this.createAnother) {
|
if (this.createAnother) {
|
||||||
|
console.log('Will create another.');
|
||||||
// do message:
|
// do message:
|
||||||
this.success_message = '<a href="transactions/show/' + response.data.data.id + '">The transaction</a> has been stored.';
|
this.success_message = '<a href="transactions/show/' + response.data.data.id + '">The transaction</a> has been stored.';
|
||||||
this.error_message = '';
|
this.error_message = '';
|
||||||
@@ -392,15 +391,19 @@
|
|||||||
}
|
}
|
||||||
button.prop("disabled", false);
|
button.prop("disabled", false);
|
||||||
} else {
|
} else {
|
||||||
|
console.log('Will redirect to transaction.');
|
||||||
window.location.href = 'transactions/show/' + response.data.data.id + '?message=created';
|
window.location.href = 'transactions/show/' + response.data.data.id + '?message=created';
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
// give user errors things back.
|
// give user errors things back.
|
||||||
// something something render errors.
|
// something something render errors.
|
||||||
|
console.error('Error in transaction submission.');
|
||||||
|
console.error(error);
|
||||||
this.parseErrors(error.response.data);
|
this.parseErrors(error.response.data);
|
||||||
// something.
|
// something.
|
||||||
button.prop("disabled", false);
|
button.prop("disabled", false);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -487,7 +490,7 @@
|
|||||||
resetTransactions: function () {
|
resetTransactions: function () {
|
||||||
this.transactions = [];
|
this.transactions = [];
|
||||||
},
|
},
|
||||||
addTransaction: function (e) {
|
addTransactionToArray: function (e) {
|
||||||
this.transactions.push({
|
this.transactions.push({
|
||||||
description: "",
|
description: "",
|
||||||
date: "",
|
date: "",
|
||||||
|
Reference in New Issue
Block a user