2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

feat: add applied coupons count

This commit is contained in:
AbleKSaju 2024-10-08 12:25:18 +05:30
parent 6e2fdfc5be
commit 81cc3407f2
3 changed files with 21 additions and 1 deletions

View File

@ -203,6 +203,7 @@ export default defineComponent({
);
await updatePricingRule(this.sinvDoc);
this.$emit('setCouponsCount', this.sinvDoc.coupons?.length);
},
},
});

View File

@ -38,6 +38,7 @@
<CouponCodeModal
:open-modal="openCouponCodeModal"
@set-coupons-count="setCouponsCount"
@toggle-modal="toggleModal"
/>
@ -48,6 +49,7 @@
@set-cash-amount="setCashAmount"
@set-transfer-amount="setTransferAmount"
@set-transfer-ref-no="setTransferRefNo"
@set-coupons-count="setCouponsCount"
@set-transfer-clearance-date="setTransferClearanceDate"
/>
@ -691,6 +693,7 @@ export default defineComponent({
async activated() {
toggleSidebar(false);
validateIsPosSettingsSet(fyo);
this.setCouponCodeDoc();
this.setSinvDoc();
this.setDefaultCustomer();
await this.setItemQtyMap();
@ -790,6 +793,14 @@ export default defineComponent({
isPOS: true,
}) as SalesInvoice;
},
setCouponCodeDoc() {
this.coupons = this.fyo.doc.getNewDoc(
ModelNameEnum.AppliedCouponCodes
) as AppliedCouponCodes;
},
setAppliedCoupons() {
this.appliedCoupons = this.sinvDoc.coupons as AppliedCouponCodes[];
},
setTotalQuantity() {
this.totalQuantity = getTotalQuantity(
this.sinvDoc.items as SalesInvoiceItem[]
@ -798,6 +809,9 @@ export default defineComponent({
setTotalTaxedAmount() {
this.totalTaxedAmount = getTotalTaxedAmount(this.sinvDoc as SalesInvoice);
},
setCouponsCount(value: number) {
this.appliedCouponsCount = value;
},
async setLoyaltyPoints(value: number) {
this.appliedLoyaltyPoints = value;

View File

@ -169,7 +169,7 @@
class="w-full bg-blue-500"
style="padding: 1.35rem"
:disabled="disableSubmitButton"
@click="$emit('createTransaction')"
@click="submitTransaction()"
>
<slot>
<p class="uppercase text-lg text-white font-semibold">
@ -224,6 +224,7 @@ export default defineComponent({
'setTransferClearanceDate',
'setTransferRefNo',
'toggleModal',
'setCouponsCount',
],
setup() {
return {
@ -320,6 +321,10 @@ export default defineComponent({
this.$emit('setTransferAmount', fyo.pesa(0));
this.$emit('setCashAmount', this.sinvDoc?.grandTotal);
},
submitTransaction() {
this.$emit('createTransaction');
this.$emit('setCouponsCount', 0);
},
},
});
</script>