Different currency_code auto convert issue fixed..
This commit is contained in:
parent
717c6d3e78
commit
ad675c53dd
|
|
@ -30,7 +30,7 @@ export default class Money {
|
|||
let prefix = this.currency.getPrefix();
|
||||
let suffix = this.currency.getSuffix();
|
||||
|
||||
value = number_format(amount, this.currency.getPrecision(), decimals, thousands);
|
||||
value = this.number_format(amount, this.currency.getPrecision(), decimals, thousands);
|
||||
|
||||
return (negative ? '-' : '') + prefix + value + suffix;
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ export default class Money {
|
|||
return rounded ? this.getRoundedAmount() : this.amount;
|
||||
}
|
||||
|
||||
getRoundedAmount(){
|
||||
getRoundedAmount() {
|
||||
return this.round(this.amount);
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ export default class Money {
|
|||
return this;
|
||||
}
|
||||
|
||||
round(amount, mode){
|
||||
round(amount, mode) {
|
||||
let precision = this.currency.getPrecision();
|
||||
var amount_sign = amount >= 0 ? 1 : -1;
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ export default class Money {
|
|||
}
|
||||
}
|
||||
|
||||
isMutable(){
|
||||
isMutable() {
|
||||
return this.mutable === true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,29 +122,30 @@ const app = new Vue({
|
|||
let rate = this.form.currency_rate;
|
||||
let precision = this.currency.precision;
|
||||
|
||||
let amount = parseFloat(this.form.document_default_amount).toFixed(precision);
|
||||
let amount = parseFloat(this.form.amount).toFixed(precision);
|
||||
let paid_amount = parseFloat(this.form.paid_amount).toFixed(precision);
|
||||
let total_amount = parseFloat(amount - paid_amount).toFixed(precision);
|
||||
let total_amount = parseFloat(this.form.document_default_amount - paid_amount).toFixed(precision);
|
||||
let error_amount = 0;
|
||||
|
||||
if (this.form.document_currency_code != code) {
|
||||
let converted_amount = this.convertBetween(amount, code, rate, this.form.document_currency_code, this.form.document_currency_rate);
|
||||
|
||||
amount = parseFloat(converted_amount).toFixed(precision);
|
||||
}
|
||||
|
||||
if (amount > total_amount) {
|
||||
error_amount = total_amount;
|
||||
// for default rate 1 and change currency rate 30
|
||||
if (parseFloat(amount) > parseFloat(total_amount) || (rate >= 1)) {
|
||||
error_amount = total_amount;
|
||||
|
||||
if (this.form.document_currency_code != code) {
|
||||
let converted_amount = this.convertBetween(total_amount, this.form.document_currency_code, this.form.document_currency_rate, code, rate);
|
||||
if (this.form.document_currency_code != code) {
|
||||
let converted_amount = this.convertBetween(total_amount, this.form.document_currency_code, this.form.document_currency_rate, code, rate);
|
||||
|
||||
error_amount = parseFloat(converted_amount).toFixed(precision);
|
||||
error_amount = parseFloat(converted_amount).toFixed(precision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let form_amount = (error_amount) ? error_amount : amount;
|
||||
this.form.pay_in_full = true;
|
||||
let form_amount = (error_amount) ? error_amount : amount;
|
||||
this.form.amount = parseFloat(form_amount).toFixed(precision);
|
||||
this.form.default_amount = parseFloat(this.form.document_default_amount).toFixed(precision);
|
||||
},
|
||||
|
|
@ -158,19 +159,22 @@ const app = new Vue({
|
|||
return;
|
||||
}
|
||||
|
||||
this.form.error_amount = 0;
|
||||
|
||||
let code = this.form.currency_code;
|
||||
let rate = this.form.currency_rate;
|
||||
let precision = this.currency.precision;
|
||||
|
||||
let paid_amount = parseFloat(this.form.paid_amount).toFixed(precision);
|
||||
let total_amount = parseFloat(this.form.document_default_amount - paid_amount).toFixed(precision);
|
||||
let error_amount = 0;
|
||||
|
||||
if (this.form.document_currency_code != code) {
|
||||
let rate = (this.form.pay_in_full) ? parseFloat(this.form.amount / this.form.document_default_amount).toFixed(4): this.form.currency_rate;
|
||||
let precision = this.currency.precision;
|
||||
let paid_amount = parseFloat(this.form.paid_amount).toFixed(precision);
|
||||
let total_amount = parseFloat(amount - paid_amount).toFixed(precision);
|
||||
let converted_amount = this.convertBetween(amount, code, rate, this.form.document_currency_code, this.form.document_currency_rate);
|
||||
let error_amount = 0;
|
||||
|
||||
amount = parseFloat(converted_amount).toFixed(precision);
|
||||
|
||||
if (amount > total_amount) {
|
||||
if (parseFloat(amount) > parseFloat(total_amount)) {
|
||||
error_amount = total_amount;
|
||||
|
||||
if (this.form.document_currency_code != code) {
|
||||
|
|
@ -180,11 +184,20 @@ const app = new Vue({
|
|||
}
|
||||
}
|
||||
|
||||
this.form.default_amount = (error_amount) ? error_amount : amount;
|
||||
this.form.default_amount = amount;
|
||||
|
||||
if (error_amount) {
|
||||
this.form.error_amount = error_amount;
|
||||
//this.form.error_amount = new Money(this.form.currency_code, error_amount, true).format();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onChangeRatePayment(rate) {
|
||||
onChangeRatePayment(event) {
|
||||
this.$forceUpdate();
|
||||
|
||||
this.form.currency_rate = event.target.value;
|
||||
|
||||
this.onChangeAmount(this.form.amount);
|
||||
},
|
||||
|
||||
|
|
@ -195,9 +208,11 @@ const app = new Vue({
|
|||
return;
|
||||
}
|
||||
|
||||
let rate = parseFloat(this.form.amount / this.form.document_default_amount).toFixed(4);
|
||||
let document_rate = parseFloat(this.form.document_currency_rate) / parseFloat(this.form.document_default_amount);
|
||||
|
||||
this.form.currency_rate = rate;
|
||||
let rate = parseFloat(document_rate * this.form.amount).toFixed(4);
|
||||
|
||||
this.form.currency_rate = parseFloat(rate);
|
||||
|
||||
this.onChangeAmount(this.form.amount);
|
||||
},
|
||||
|
|
@ -208,7 +223,7 @@ const app = new Vue({
|
|||
let precision = this.currency.precision;
|
||||
let amount = parseFloat(this.form.amount).toFixed(precision);
|
||||
let paid_amount = parseFloat(this.form.paid_amount).toFixed(precision);
|
||||
let total_amount = parseFloat(this.form.amount - paid_amount).toFixed(precision);
|
||||
let total_amount = parseFloat(this.form.document_default_amount - paid_amount).toFixed(precision);
|
||||
let error_amount = 0;
|
||||
|
||||
if (this.form.document_currency_code != code) {
|
||||
|
|
@ -217,7 +232,7 @@ const app = new Vue({
|
|||
amount = parseFloat(converted_amount).toFixed(precision);
|
||||
}
|
||||
|
||||
if (amount > total_amount) {
|
||||
if (parseFloat(amount) > parseFloat(total_amount)) {
|
||||
error_amount = total_amount;
|
||||
|
||||
if (this.form.document_currency_code != code) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
v-show="form.document_currency_code == form.currency_code"
|
||||
name="amount"
|
||||
label="{{ trans('general.amount') }}"
|
||||
value="{{ $document->grand_total }}"
|
||||
value="{{ $amount }}"
|
||||
autofocus="autofocus"
|
||||
:currency="$currency"
|
||||
dynamicCurrency="currency"
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
<x-form.group.money
|
||||
name="amount"
|
||||
label="{{ trans('general.amount') }}"
|
||||
value="{{ $document->grand_total }}"
|
||||
value="{{ $amount }}"
|
||||
v-model="form.amount"
|
||||
autofocus="autofocus"
|
||||
:currency="$currency"
|
||||
|
|
@ -65,6 +65,16 @@
|
|||
input="onChangeAmount($event)"
|
||||
/>
|
||||
|
||||
<div class="sm:col-span-6 grid sm:grid-cols-6 gap-x-4 -mt-6" v-if="form.error_amount">
|
||||
<div class="relative col-span-6 text-xs flex mt-5">
|
||||
<div class="rounded-xl px-5 py-3 bg-red-100">
|
||||
<div class="w-auto text-xs mr-2 text-red-600"
|
||||
v-html="'{{ trans('messages.error.over_payment', ['amount' => '#amount']) }}'.replace('#amount', form.error_amount)"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-2 text-xs absolute right-0 top-1">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<x-form.input.checkbox
|
||||
|
|
@ -81,7 +91,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-6 grid sm:grid-cols-6 gap-x-4" v-if="form.document_currency_code != form.currency_code">
|
||||
<div class="sm:col-span-6 grid sm:grid-cols-6 gap-x-4 -mt-2" v-if="form.document_currency_code != form.currency_code">
|
||||
<x-form.group.text
|
||||
name="currency_rate"
|
||||
label="{{ trans_choice('general.currency_rates', 1) }}"
|
||||
|
|
@ -126,8 +136,8 @@
|
|||
|
||||
<x-form.input.hidden name="document_id" :value="$document->id" />
|
||||
<x-form.input.hidden name="category_id" :value="$document->category->id" />
|
||||
<x-form.input.hidden name="paid_amount" :value="$document->paid" />
|
||||
<x-form.input.hidden name="amount" :value="$document->grand_total" />
|
||||
<x-form.input.hidden name="paid_amount" :value="$document->paid_amount" />
|
||||
<x-form.input.hidden name="amount" :value="$amount" />
|
||||
<x-form.input.hidden name="currency_code" :value="$document->currency_code" />
|
||||
<x-form.input.hidden name="currency_rate" :value="$document->currency_rate" v-if="form.document_currency_code == form.currency_code" />
|
||||
<x-form.input.hidden name="company_currency_code" :value="default_currency()" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue