diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php index 25c7c303bd..a364583632 100644 --- a/app/Validation/TransactionValidation.php +++ b/app/Validation/TransactionValidation.php @@ -444,11 +444,11 @@ trait TransactionValidation } $type = $this->getTransactionType($transactionGroup, $transactions); - // compare source ID's, destination ID's, source names and destination names. + // compare source IDs, destination IDs, source names and destination names. // I think I can get away with one combination being equal, as long as the rest // of the code picks up on this as well. // either way all fields must be blank or all equal - // but if ID's are equal don't bother with the names. + // but if IDs are equal don't bother with the names. $comparison = $this->collectComparisonData($transactions); $result = $this->compareAccountData($type, $comparison); if (false === $result) { diff --git a/resources/assets/js/components/transactions/EditTransaction.vue b/resources/assets/js/components/transactions/EditTransaction.vue index d366b08427..1540896f3e 100644 --- a/resources/assets/js/components/transactions/EditTransaction.vue +++ b/resources/assets/js/components/transactions/EditTransaction.vue @@ -128,6 +128,7 @@ v-model="transaction.amount" :destination="transaction.destination_account" :error="transaction.errors.amount" + :index="index" :source="transaction.source_account" :transactionType="transactionType" > @@ -522,16 +523,24 @@ export default { transactionType = 'deposit'; } + // get currency from first transaction. overrule the rest + let currencyId = this.transactions[0].source_account.currency_id; + + if ('deposit' === transactionType) { + currencyId = this.transactions[0].destination_account.currency_id; + } + console.log('Overruled currency ID to ' + currencyId); + for (let key in this.transactions) { if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) { - data.transactions.push(this.convertDataRow(this.transactions[key], key, transactionType)); + data.transactions.push(this.convertDataRow(this.transactions[key], key, transactionType, currencyId)); } } //console.log(data); return data; }, - convertDataRow(row, index, transactionType) { + convertDataRow(row, index, transactionType, currencyId) { let tagList = []; let foreignAmount = null; let foreignCurrency = null; @@ -547,14 +556,17 @@ export default { destName = row.destination_account.name; // depends on the transaction type, where we get the currency. - if ('withdrawal' === transactionType || 'transfer' === transactionType) { - row.currency_id = row.source_account.currency_id; - // console.log('Overruled currency ID to ' + row.currency_id); - } - if ('deposit' === transactionType) { - row.currency_id = row.destination_account.currency_id; - // console.log('Overruled currency ID to ' + row.currency_id); - } + // if ('withdrawal' === transactionType || 'transfer' === transactionType) { + // row.currency_id = row.source_account.currency_id; + // console.log('Overruled currency ID to ' + row.currency_id); + // } + // if ('deposit' === transactionType) { + // row.currency_id = row.destination_account.currency_id; + // console.log('Overruled currency ID to ' + row.currency_id); + // } + + row.currency_id = currencyId; + console.log('Final currency ID = ' + currencyId); date = row.date; if (index > 0) {