Fix various bugs (very descriptive I know)

This commit is contained in:
James Cole
2021-06-30 06:45:19 +02:00
parent 7195f198a6
commit 7bd1041820
3 changed files with 39 additions and 30 deletions

View File

@@ -73,7 +73,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*/ */
public function find(int $piggyBankId): ?PiggyBank public function find(int $piggyBankId): ?PiggyBank
{ {
$piggyBank = $this->user->piggyBanks()->find($piggyBankId); return $this->user->piggyBanks()->find($piggyBankId);
} }
/** /**

View File

@@ -234,7 +234,7 @@ export default {
return axios.post(url, data); return axios.post(url, data);
}, },
handleSubmissionResponse: function (response) { handleSubmissionResponse: function (response) {
//console.log('In handleSubmissionResponse()'); console.log('In handleSubmissionResponse()');
// save some meta data: // save some meta data:
this.returnedGroupId = parseInt(response.data.data.id); this.returnedGroupId = parseInt(response.data.data.id);
this.returnedGroupTitle = null === response.data.data.attributes.group_title ? response.data.data.attributes.transactions[0].description : response.data.data.attributes.group_title; this.returnedGroupTitle = null === response.data.data.attributes.group_title ? response.data.data.attributes.transactions[0].description : response.data.data.attributes.group_title;
@@ -282,11 +282,14 @@ export default {
if (response.journals.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) { if (response.journals.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {
let journalId = response.journals[i]; let journalId = response.journals[i];
let hasAttachments = submission.transactions[i].attachments; let hasAttachments = submission.transactions[i].attachments;
// console.log('Decided that ' + journalId); console.log('Decided that ' + journalId);
// console.log(hasAttachments); console.log(hasAttachments);
if (hasAttachments) { if (hasAttachments) {
// console.log('upload!'); console.log('upload!');
this.updateField({index: i, field: 'transaction_journal_id', value: journalId}); this.updateField({index: i, field: 'transaction_journal_id', value: journalId});
// set upload trigger?
this.updateField({index: i, field: 'uploadTrigger', value: true});
//this.transactions[i].uploadTrigger = true;
anyAttachments = true; anyAttachments = true;
} }
} }
@@ -302,11 +305,12 @@ export default {
this.updateField({index: payload.index, field: 'attachments', value: true}); this.updateField({index: payload.index, field: 'attachments', value: true});
}, },
finaliseSubmission: function () { finaliseSubmission: function () {
console.log('finaliseSubmission');
if (0 === this.submittedAttachments) { if (0 === this.submittedAttachments) {
// console.log('submittedAttachments = ' + this.submittedAttachments); console.log('submittedAttachments = ' + this.submittedAttachments);
return; return;
} }
//console.log('In finaliseSubmission'); console.log('In finaliseSubmission');
if (false === this.createAnother) { if (false === this.createAnother) {
window.location.href = (window.previousURL ?? '/') + '?transaction_group_id=' + this.returnedGroupId + '&message=created'; window.location.href = (window.previousURL ?? '/') + '?transaction_group_id=' + this.returnedGroupId + '&message=created';
return; return;
@@ -318,7 +322,7 @@ export default {
this.errorMessage = ''; this.errorMessage = '';
this.successMessage = this.$t('firefly.transaction_stored_link', {ID: this.returnedGroupId, title: this.returnedGroupTitle}); this.successMessage = this.$t('firefly.transaction_stored_link', {ID: this.returnedGroupId, title: this.returnedGroupTitle});
} }
console.log('here we are');
// enable flags: // enable flags:
this.enableSubmit = true; this.enableSubmit = true;
this.submittedTransaction = false; this.submittedTransaction = false;
@@ -359,7 +363,7 @@ export default {
*/ */
submitTransaction: function (event) { submitTransaction: function (event) {
event.preventDefault(); event.preventDefault();
// console.log('submitTransaction()'); console.log('submitTransaction()');
// disable the submit button: // disable the submit button:
this.enableSubmit = false; this.enableSubmit = false;

View File

@@ -298,7 +298,7 @@ export default {
if (0 === index) { if (0 === index) {
this.transactionType = array.type.charAt(0).toUpperCase() + array.type.slice(1); this.transactionType = array.type.charAt(0).toUpperCase() + array.type.slice(1);
// See reference nr. 5 // See reference nr. 5
this.sourceAllowedTypes = [array.source_type]; this.sourceAllowedTypes = [array.source_type];
this.destinationAllowedTypes = [array.destination_type]; this.destinationAllowedTypes = [array.destination_type];
this.date = array.date.substring(0, 16); this.date = array.date.substring(0, 16);
@@ -384,14 +384,14 @@ export default {
} }
// add meta data to promise context. // add meta data to promise context.
promises.push(Promise.resolve( promises.push(Promise.resolve(
{ {
link: link, link: link,
journalId: journalId, journalId: journalId,
opposingId: opposingId, opposingId: opposingId,
index: index, index: index,
direction: linkDirection direction: linkDirection
} }
)); ));
// get stuff from the API: // get stuff from the API:
@@ -533,7 +533,7 @@ export default {
this.transactions.push(newTransaction); this.transactions.push(newTransaction);
}, },
submitTransaction: function (event) { submitTransaction: function (event) {
// console.log('submitTransaction()'); console.log('submitTransaction()');
event.preventDefault(); event.preventDefault();
this.enableSubmit = false; this.enableSubmit = false;
let submission = {transactions: []}; let submission = {transactions: []};
@@ -559,7 +559,7 @@ export default {
// loop each transaction (edited by the user): // loop each transaction (edited by the user):
// console.log('Start of loop submitTransaction'); // console.log('Start of loop submitTransaction');
for (let i in this.transactions) { for (let i in this.transactions) {
// console.log('Index ' + i); console.log('Index ' + i);
if (this.transactions.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) { if (this.transactions.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {
// console.log('Has index ' + i); // console.log('Has index ' + i);
// original transaction present: // original transaction present:
@@ -573,17 +573,21 @@ export default {
// source and destination are overruled in some cases: // source and destination are overruled in some cases:
if (i > 0) { if (i > 0) {
console.log('i > 0');
diff.type = this.transactionType.toLowerCase(); diff.type = this.transactionType.toLowerCase();
if ('deposit' === this.transactionType.toLowerCase() || 'transfer' === this.transactionType.toLowerCase()) { if ('deposit' === this.transactionType.toLowerCase() || 'transfer' === this.transactionType.toLowerCase()) {
// set destination to be whatever is in transaction zero: // set destination to be whatever is in transaction zero:
currentTransaction.destination_account_name = this.originalTransactions[0].destination_account_name; // of the edited transaction
currentTransaction.destination_account_id = this.originalTransactions[0].destination_account_id; currentTransaction.destination_account_name = this.transactions[0].destination_account_name;
currentTransaction.destination_account_id = this.transactions[0].destination_account_id;
console.log('Destination is now: #' + currentTransaction.destination_account_id + ': ' + currentTransaction.destination_account_name);
} }
if ('withdrawal' === this.transactionType.toLowerCase() || 'transfer' === this.transactionType.toLowerCase()) { if ('withdrawal' === this.transactionType.toLowerCase() || 'transfer' === this.transactionType.toLowerCase()) {
// set source to be whatever is in transaction zero: // set source to be whatever is in transaction zero:
currentTransaction.source_account_name = this.originalTransactions[0].source_account_name; currentTransaction.source_account_name = this.transactions[0].source_account_name;
currentTransaction.source_account_id = this.originalTransactions[0].source_account_id; currentTransaction.source_account_id = this.transactions[0].source_account_id;
console.log('Source is now: #' + currentTransaction.source_account_id + ': ' + currentTransaction.source_account_name);
} }
} }
@@ -607,11 +611,11 @@ export default {
// console.log('we skip!'); // console.log('we skip!');
continue; continue;
} }
if ('foreign_currency_id' === submissionFieldName && 0 === currentTransaction[fieldName] ) { if ('foreign_currency_id' === submissionFieldName && 0 === currentTransaction[fieldName]) {
// console.log('we skip!'); // console.log('we skip!');
continue; continue;
} }
if ('foreign_currency_id' === submissionFieldName && '0' === currentTransaction[fieldName] ) { if ('foreign_currency_id' === submissionFieldName && '0' === currentTransaction[fieldName]) {
// console.log('we skip!'); // console.log('we skip!');
continue; continue;
} }
@@ -666,7 +670,7 @@ export default {
if (typeof currentTransaction.selectedAttachments !== 'undefined' && true === currentTransaction.selectedAttachments) { if (typeof currentTransaction.selectedAttachments !== 'undefined' && true === currentTransaction.selectedAttachments) {
shouldUpload = true; shouldUpload = true;
} }
if(true === shouldSubmit) { if (true === shouldSubmit) {
// set the date to whatever the date is: // set the date to whatever the date is:
diff.date = this.date; diff.date = this.date;
} }
@@ -695,12 +699,13 @@ export default {
}, },
submitData: function (shouldSubmit, submission) { submitData: function (shouldSubmit, submission) {
// console.log('submitData'); console.log('submitData');
// console.log(submission); console.log(submission);
if (!shouldSubmit) { if (!shouldSubmit) {
// console.log('No need to submit transaction.'); // console.log('No need to submit transaction.');
return Promise.resolve({}); return Promise.resolve({});
} }
const url = './api/v1/transactions/' + this.groupId; const url = './api/v1/transactions/' + this.groupId;
return axios.put(url, submission); return axios.put(url, submission);
@@ -730,7 +735,7 @@ export default {
} }
} }
journals = journals.reverse(); journals = journals.reverse();
return Promise.resolve({journals:journals}); return Promise.resolve({journals: journals});
}, },
submitLinks: function (shouldSubmit) { submitLinks: function (shouldSubmit) {
//console.log('submitLinks()'); //console.log('submitLinks()');