Catch some more weird exceptions.

This commit is contained in:
James Cole 2020-03-11 10:39:53 +01:00
parent f375934b41
commit f6ecb143fe
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 25 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -63,9 +63,6 @@
changeData: function () {
let transactionType = this.transactionType;
// reset of all are empty:
//console.log('Type "' + transactionType + '"');
//console.log('Source "' + this.source.name + '"');
//console.log('Dest "' + this.destination.name + '"');
if (!transactionType && !this.source.name && !this.destination.name) {
$(this.$refs.cur).text('');
@ -82,15 +79,35 @@
$(this.$refs.cur).text(this.destination.currency_name);
return;
}
// for normal transactions, the source leads the currency
if (transactionType.toLowerCase() === 'withdrawal' ||
transactionType.toLowerCase() === 'reconciliation' ||
transactionType.toLowerCase() === 'transfer') {
$(this.$refs.cur).text(this.source.currency_name);
return;
}
if (transactionType === 'Deposit') {
// for deposits, the destination leads the currency
// but source must not be a liability
if (transactionType.toLowerCase() === 'deposit'
&&
!('debt' === this.source.type.toLowerCase() ||
'loan' === this.source.type.toLowerCase() ||
'mortgage' === this.source.type.toLowerCase()
)
) {
$(this.$refs.cur).text(this.destination.currency_name);
}
// for deposits, the destination leads the currency
// unless source is liability, then source leads:
if (transactionType.toLowerCase() === 'deposit'
&&
('debt' === this.source.type.toLowerCase() ||
'loan' === this.source.type.toLowerCase() ||
'mortgage' === this.source.type.toLowerCase()
)
) {
$(this.$refs.cur).text(this.source.currency_name);
}
}
},
watch: {

View File

@ -21,14 +21,10 @@
<template>
<!--
Show if:
- more than one currency enabled, always show
- if just one, but is deposit or withdrawal
- one or more currencies.
-->
<div class="form-group" v-bind:class="{ 'has-error': hasError()}" v-if="
this.enabledCurrencies.length > 1 ||
(this.enabledCurrencies.length >= 1 && ('deposit' === this.transactionType.toLowerCase() || 'withdrawal' === this.transactionType.toLowerCase()))
">
this.enabledCurrencies.length >= 1">
<div class="col-sm-8 col-sm-offset-4 text-sm">
{{ $t('form.foreign_amount') }}
</div>