put adjustment into formData

This commit is contained in:
Edmond Teh
2020-09-25 18:34:55 +08:00
parent e616689ef1
commit b99e88187a
+10 -8
View File
@@ -284,7 +284,7 @@
Adjustment
</td>
<td class="subtotal text-center">
{{ adjustment || 'auto' }}
{{ form.formData.adjustment || 'auto' }}
</td>
<td>
&nbsp;
@@ -520,6 +520,7 @@ export default {
marking: this.booking_details.marking,
gst_id: '',
reg_no: '',
adjustment: '',
lines: []
},
addLine: {
@@ -547,8 +548,7 @@ export default {
total: 0,
role: null,
currentStatus: null,
statuses: [],
adjustment: 0
statuses: []
}
},
computed: {
@@ -577,6 +577,8 @@ export default {
},
gst_id: {
},
adjustment: {
}
},
addLine: {
@@ -683,7 +685,7 @@ export default {
setTotal: function () {
if (this.form.formData.lines.length < 1) {
this.subtotal = 0
this.adjustment = 0
this.form.formData.adjustment = 0
this.total = this.billing_charge // Temporary fix. Will return error if GST is implemented.
return
}
@@ -693,11 +695,11 @@ export default {
// Set Adjustment if CNY total is equal to Invoice CNY Total
const cnyTotal = this.form.formData.lines.map(l => +l.unit_price_rmb * +l.quantity).reduce((a, b) => a + b)
if (cnyTotal === this.amount) {
this.adjustment = parseFloat(+this.bia - +this.subtotal - this.billing_charge).toFixed(2)
this.form.formData.adjustment = parseFloat(+this.bia - +this.subtotal - this.billing_charge).toFixed(2)
} else {
this.adjustment = 0
this.form.formData.adjustment = 0
}
this.total = parseFloat(+this.subtotal + (+this.subtotal * (+this.tax || 0) / 100) + +this.billing_charge + +this.adjustment).toFixed(2)
this.total = parseFloat(+this.subtotal + (+this.subtotal * (+this.tax || 0) / 100) + +this.billing_charge + +this.form.formData.adjustment).toFixed(2)
},
clearAddLine: function () {
this.form.addLine.order = null
@@ -785,7 +787,7 @@ export default {
this.currentStatus = resp.data.status[resp.data.status.length - 1].status
this.adjustment = resp.data.adjustment
this.form.formData.adjustment = resp.data.adjustment
this.setTotal()
})