diff --git a/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.ts b/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.ts index 7492698f..b16516d3 100644 --- a/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.ts +++ b/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.ts @@ -538,29 +538,35 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { } }; } - payChange() { - const subtotal = this.sf7.value.prePay + this.sf7.value.toPay + this.sf7.value.oilCardPay + this.sf7.value.receiptPay || 0; - const oilCardPay = this.sf7.value.oilCardPay || 0; - this.service - .request(this.service.$api_getCalculatedSurcharge + `?totalFreight=${subtotal}&fuelCardAmount=${oilCardPay}`) - .subscribe(res => { - if (res) { - this.sf7.setValue('/appendFee', res.surcharge); - this.sf7.setValue('/subtotal', subtotal); - this.sf7.setValue('/total', subtotal + res.surcharge); - this.service - .request(this.service.$api_getcalculatedServiceRate + `?invoiceAmount=${subtotal + res.surcharge}&totalFreight=${subtotal}`) - .subscribe(res => { - if (res) { - this.currentRate = res.rate; - } else { - this.service.msgSrv.error(res.msg); - } - }); - } else { - this.service.msgSrv.error(res.msg); - } - }); + payChange(value?: any) { + let subtotal: any ={} + let oilCardPay: any ={} + if(value) { + subtotal = (value.prePay +value.toPay + value.oilCardPay + value.receiptPay) || 0; + oilCardPay = value.oilCardPay || 0; + } else { + subtotal = (this.sf7.value.prePay + this.sf7.value.toPay + this.sf7.value.oilCardPay + this.sf7.value.receiptPay) || 0; + oilCardPay = this.sf7.value.oilCardPay || 0; + } + console.log(this.sf7.value) + + this.service.request(this.service.$api_getCalculatedSurcharge + `?totalFreight=${subtotal}&fuelCardAmount=${oilCardPay}`).subscribe(res => { + if (res) { + this.sf7.setValue('/appendFee', res.surcharge); + this.sf7.setValue('/subtotal', subtotal); + this.sf7.setValue('/total', subtotal + res.surcharge); + this.service.request(this.service.$api_getcalculatedServiceRate + `?invoiceAmount=${subtotal + res.surcharge}&totalFreight=${subtotal}`).subscribe(res => { + if (res) { + this.currentRate = res.rate * 100; + } else { + this.service.msgSrv.error(res.msg); + } + }); + } else { + this.service.msgSrv.error(res.msg); + } + }); + } addStartInfo(event: any) { @@ -922,10 +928,12 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { toPay: res?.shippingInformationVO?.toPay, oilCardPay: res?.shippingInformationVO?.oilCardPay, receiptPay: res?.shippingInformationVO?.receiptPay, - // subtotal: res?.shippingInformationVO?.oilCardPay , + subtotal: res?.shippingInformationVO?.totalFee, + total: res?.shippingInformationVO?.totalFee, appendFee: res?.shippingInformationVO?.appendFee, paymentDays: res?.paymentDays }; + this.payChange(this.sf7data); } backBillChange() { const modalRef = this.modalService.create({