diff --git a/src/app/domains/pos/modules/landing/store/main.store.ts b/src/app/domains/pos/modules/landing/store/main.store.ts index 167c100..989b47a 100644 --- a/src/app/domains/pos/modules/landing/store/main.store.ts +++ b/src/app/domains/pos/modules/landing/store/main.store.ts @@ -83,14 +83,24 @@ export class PosLandingStore { readonly payments = computed(() => this.state$().payments); readonly orderPricingInfo = computed(() => { - const totalAmount = 0; - const taxAmount = totalAmount * 0.1; + let totalAmount = 0; + let taxAmount = 0; + let totalBaseAmount = 0; + let discountAmount = 0; + + this.inOrderGoods().forEach((inOrderGood) => { + totalBaseAmount += parseInt(inOrderGood.base_total_amount + '') || 0; + totalAmount += parseInt(inOrderGood.total_amount + '') || 0; + taxAmount += parseInt(inOrderGood.tax_amount + '') || 0; + discountAmount += parseInt(inOrderGood.discount_amount + '') || 0; + }); + return { totalItems: this.inOrderGoods().length, - totalBaseAmount: this.inOrderGoods().reduce((acc, curr) => acc + curr.base_total_amount, 0), - totalAmount: this.inOrderGoods().reduce((acc, curr) => acc + curr.total_amount, 0), - taxAmount: this.inOrderGoods().reduce((acc, curr) => acc + curr.tax_amount, 0), - discountAmount: this.inOrderGoods().reduce((acc, curr) => acc + curr.discount_amount, 0), + totalBaseAmount, + totalAmount, + taxAmount, + discountAmount, payableAmount: totalAmount + taxAmount, }; }); diff --git a/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.ts b/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.ts index cf87936..4fdd4a8 100644 --- a/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.ts +++ b/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.ts @@ -168,8 +168,8 @@ export class AmountPercentageInputComponent { const amountValue = (this.baseAmount * percentageValue) / 100; this.lastValidAmount = Number.isFinite(amountValue) ? amountValue : 0; - this.percentageControl.setValue(this.lastValidPercentage); - this.amountControl.setValue(this.lastValidAmount); + this.percentageControl.setValue(this.lastValidPercentage, { emitEvent: false }); + this.amountControl.setValue(this.lastValidAmount, { emitEvent: false }); this.preparedLabel.set(this.prepareLabel(true)); } @@ -189,8 +189,8 @@ export class AmountPercentageInputComponent { : '0'; this.lastValidPercentage = this.parseValue(percentageValue); - this.amountControl.setValue(this.lastValidAmount); - this.percentageControl.setValue(percentageValue); + this.amountControl.setValue(this.lastValidAmount, { emitEvent: false }); + this.percentageControl.setValue(percentageValue, { emitEvent: false }); this.preparedLabel.set(this.prepareLabel(false)); }