add adjustment to frontend

This commit is contained in:
Edmond Teh
2020-09-25 18:26:27 +08:00
parent b823152a51
commit e616689ef1
+37 -22
View File
@@ -266,18 +266,6 @@
</tr>
</tbody>
<tfoot>
<tr class="subtotal-line">
<td colspan="5"/>
<td class="subtotal-title text-center">
Rounding
</td>
<td class="subtotal text-center">
plus or minus some number
</td>
<td>
&nbsp;
</td>
</tr>
<tr class="subtotal-line">
<td colspan="5"/>
<td class="subtotal-title text-center">
@@ -290,13 +278,25 @@
&nbsp;
</td>
</tr>
<tr class="subtotal-line">
<td colspan="5"/>
<td class="subtotal-title text-center">
Adjustment
</td>
<td class="subtotal text-center">
{{ adjustment || 'auto' }}
</td>
<td>
&nbsp;
</td>
</tr>
<tr class="service-charge">
<td colspan="5"/>
<td class="subtotal-title text-center">
Service Charge
Billing Charge
</td>
<td class="subtotal text-center">
{{ service_charge }}
{{ billing_charge }}
</td>
<td>
&nbsp;
@@ -504,7 +504,8 @@ export default {
amount: null,
user_bankslip_path: null,
china_bankslip_path: null,
marking: null
marking: null,
billing_charge: null
}
}
}
@@ -536,7 +537,7 @@ export default {
}
},
rate: 0,
service_charge: 0,
billing_charge: 0,
amount: 0,
bia: 0,
invoice_total: 0,
@@ -546,7 +547,8 @@ export default {
total: 0,
role: null,
currentStatus: null,
statuses: []
statuses: [],
adjustment: 0
}
},
computed: {
@@ -620,7 +622,8 @@ export default {
tax,
bia,
amount,
rate
rate,
billing_charge
} = this.booking_details
this.form.formData.marking = marking
@@ -628,8 +631,8 @@ export default {
this.amount = amount
this.bia = bia
this.rate = rate
this.service_charge = parseFloat(this.bia - (this.amount / this.rate)).toFixed(2)
this.total = this.service_charge // Will not work if there is tax. Temporary fix.
this.billing_charge = billing_charge
this.total = this.billing_charge // Will not work if there is tax. Temporary fix.
}
},
mounted () {
@@ -680,11 +683,21 @@ export default {
setTotal: function () {
if (this.form.formData.lines.length < 1) {
this.subtotal = 0
this.total = this.service_charge // Temporary fix. Will return error if GST is implemented.
this.adjustment = 0
this.total = this.billing_charge // Temporary fix. Will return error if GST is implemented.
return
}
this.subtotal = parseFloat(this.form.formData.lines.map(line => line.total).reduce((a, b) => parseFloat(a) + parseFloat(b))).toFixed(2)
this.total = parseFloat(+this.subtotal + (+this.subtotal * (+this.tax || 0) / 100) + +this.service_charge).toFixed(2)
// 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)
} else {
this.adjustment = 0
}
this.total = parseFloat(+this.subtotal + (+this.subtotal * (+this.tax || 0) / 100) + +this.billing_charge + +this.adjustment).toFixed(2)
},
clearAddLine: function () {
this.form.addLine.order = null
@@ -772,6 +785,8 @@ export default {
this.currentStatus = resp.data.status[resp.data.status.length - 1].status
this.adjustment = resp.data.adjustment
this.setTotal()
})
},