mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-21 19:47:48 +00:00
Various updates.
This commit is contained in:
@@ -460,6 +460,13 @@ export default {
|
||||
shouldSubmit = true;
|
||||
}
|
||||
let transactionCount = this.originalTransactions.length;
|
||||
let newTransactionCount = this.transactions.length;
|
||||
console.log('Found ' + this.transactions.length + ' split(s).');
|
||||
|
||||
if(newTransactionCount > 1 && typeof submission.group_title === 'undefined' && (null === this.originalGroupTitle || '' === this.originalGroupTitle)) {
|
||||
submission.group_title = this.transactions[0].description;
|
||||
}
|
||||
|
||||
for (let i in this.transactions) {
|
||||
if (this.transactions.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {
|
||||
// original transaction present?
|
||||
@@ -480,11 +487,41 @@ export default {
|
||||
'zoom_level', 'longitude', 'latitude'
|
||||
];
|
||||
|
||||
// source and destination may be overruled:
|
||||
if (i > 0) {
|
||||
diff.type = this.transactionType.toLowerCase();
|
||||
if ('Deposit' === this.transactionType || 'Transfer' === this.transactionType) {
|
||||
// set destination to be whatever is in transaction zero:
|
||||
currentTransaction.destination_account_name = this.originalTransactions[0].destination_account_name;
|
||||
currentTransaction.destination_account_id = this.originalTransactions[0].destination_account_id;
|
||||
}
|
||||
if ('Withdrawal' === this.transactionType || 'Transfer' === this.transactionType) {
|
||||
currentTransaction.source_account_name = this.originalTransactions[0].source_account_name;
|
||||
currentTransaction.source_account_id = this.originalTransactions[0].source_account_id;
|
||||
}
|
||||
console.log('Will overrule accounts for split ' + i);
|
||||
}
|
||||
|
||||
for (let ii in basicFields) {
|
||||
if (basicFields.hasOwnProperty(ii) && /^0$|^[1-9]\d*$/.test(ii) && ii <= 4294967294) {
|
||||
let fieldName = basicFields[ii];
|
||||
let submissionFieldName = fieldName;
|
||||
|
||||
// if the original is undefined and the new one is null, just skip it.
|
||||
if (currentTransaction[fieldName] === null && 'undefined' === typeof originalTransaction[fieldName]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentTransaction[fieldName] !== originalTransaction[fieldName]) {
|
||||
// some fields are ignored:
|
||||
if ('foreign_amount' === submissionFieldName && '' === currentTransaction[fieldName]) {
|
||||
continue;
|
||||
}
|
||||
if ('foreign_currency_id' === submissionFieldName && 0 === currentTransaction[fieldName]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// console.log('Index ' + i + ': Field ' + fieldName + ' updated ("' + originalTransaction[fieldName] + '" > "' + currentTransaction[fieldName] + '")');
|
||||
// console.log(originalTransaction[fieldName]);
|
||||
// console.log(currentTransaction[fieldName]);
|
||||
@@ -503,7 +540,7 @@ export default {
|
||||
if ('destination_account_name' === submissionFieldName) {
|
||||
submissionFieldName = 'destination_name';
|
||||
}
|
||||
// console.log('post: ' + submissionFieldName);
|
||||
|
||||
|
||||
diff[submissionFieldName] = currentTransaction[fieldName];
|
||||
shouldSubmit = true;
|
||||
@@ -574,12 +611,15 @@ export default {
|
||||
dateStr = toW3CString(theDate);
|
||||
diff.date = dateStr;
|
||||
}
|
||||
if (Object.keys(diff).length === 0 && transactionCount > 1) {
|
||||
console.log('Now at index ' + i);
|
||||
console.log(Object.keys(diff).length);
|
||||
if (Object.keys(diff).length === 0 && newTransactionCount > 1) {
|
||||
console.log('Will submit just the ID!');
|
||||
diff.transaction_journal_id = originalTransaction.transaction_journal_id;
|
||||
submission.transactions.push(lodashClonedeep(diff));
|
||||
shouldSubmit = true;
|
||||
} else if (Object.keys(diff).length !== 0) {
|
||||
diff.transaction_journal_id = originalTransaction.transaction_journal_id;
|
||||
diff.transaction_journal_id = originalTransaction.transaction_journal_id ?? 0;
|
||||
submission.transactions.push(lodashClonedeep(diff));
|
||||
shouldSubmit = true;
|
||||
}
|
||||
@@ -637,6 +677,7 @@ export default {
|
||||
console.log('submitUpdate');
|
||||
this.inError = false;
|
||||
const url = './api/v1/transactions/' + this.groupId;
|
||||
console.log(JSON.stringify(submission));
|
||||
console.log(submission);
|
||||
axios.put(url, submission)
|
||||
.then(response => {
|
||||
|
Reference in New Issue
Block a user