diff --git a/src/components/POS/Modern/ModernPOSSelectedItemTable.vue b/src/components/POS/Modern/ModernPOSSelectedItemTable.vue index a05bc4f5..07b5c1f2 100644 --- a/src/components/POS/Modern/ModernPOSSelectedItemTable.vue +++ b/src/components/POS/Modern/ModernPOSSelectedItemTable.vue @@ -43,7 +43,7 @@ :row="(row as SalesInvoiceItem)" @selected-row="selectedItemRow" @run-sinv-formulas="runSinvFormulas" - @toggle-modal="handleToggleModal" + @toggle-modal="$emit('toggleModal')" /> @@ -135,9 +135,6 @@ export default defineComponent({ }, }, methods: { - handleToggleModal(modal: string) { - this.$emit('toggleModal', modal); - }, async runSinvFormulas() { await this.sinvDoc.runFormulas(); }, diff --git a/src/components/POS/types.ts b/src/components/POS/types.ts index 17f45b92..e377208e 100644 --- a/src/components/POS/types.ts +++ b/src/components/POS/types.ts @@ -17,6 +17,20 @@ export type ModalName = | 'Alert' | 'CouponCode'; +export type PosEmits = + | 'addItem' + | 'toggleView' + | 'toggleModal' + | 'setCashAmount' + | 'setCouponsCount' + | 'routeToSinvList' + | 'setTransferRefNo' + | 'setLoyaltyPoints' + | 'setTransferAmount' + | 'createTransaction' + | 'selectedInvoiceName' + | 'setTransferClearanceDate'; + export interface POSItem { id?: number; image?: string; diff --git a/src/pages/POS/ClassicPOS.vue b/src/pages/POS/ClassicPOS.vue index cf13bb8a..ffc6f547 100644 --- a/src/pages/POS/ClassicPOS.vue +++ b/src/pages/POS/ClassicPOS.vue @@ -3,46 +3,56 @@ emitEvent('setLoyaltyPoints', points)" /> + emitEvent('selectedInvoiceName', invName) + " /> emitEvent('setCouponsCount', count)" /> emitEvent('setCashAmount', amount)" + @set-transfer-ref-no="(ref) => emitEvent('setTransferRefNo', ref)" + @set-coupons-count="(count) => emitEvent('setCouponsCount', count)" + @set-transfer-amount="(amount) => emitEvent('setTransferAmount', amount)" + @set-transfer-clearance-date=" + (date) => emitEvent('setTransferClearanceDate', date) + " + @create-transaction=" + (createTransaction) => emitEvent('createTransaction', createTransaction) + " /> - + await selectItem(await getItem(itemSearchTerm)) + async () => emitEvent('addItem', await getItem(itemSearchTerm) as Item) " @change="(item: string) =>itemSearchTerm= item" /> @@ -85,7 +95,7 @@ class="w-1/3" @item-selected=" async (name: string) => { - await selectItem(await getItem(name)); + emitEvent('addItem', await getItem(name) as Item); } " /> @@ -95,14 +105,14 @@ v-if="tableView" :items="items" :item-qty-map="itemQuantityMap as ItemQtyMap" - @add-item="selectItem" + @add-item="(item) => emitEvent('addItem', item)" /> emitEvent('addItem', item)" /> @@ -111,9 +121,9 @@ :loyalty-points="loyaltyPoints" :loyalty-program="loyaltyProgram" :applied-coupons-count="appliedCouponsCount" - @toggle-view="toggleView" - @toggle-modal="toggleModal" - @emit-route-to-sinv-list="emitRouteToSinvList" + @toggle-view="emitEvent('toggleView')" + @emit-route-to-sinv-list="emitEvent('routeToSinvList')" + @toggle-modal="(modalName) => emitEvent('toggleModal', modalName)" /> @@ -199,6 +209,7 @@ :read-only="true" :text-right="true" /> + + @@ -249,7 +261,7 @@ @@ -279,27 +291,21 @@ import { Item } from 'models/baseModels/Item/Item'; import Link from 'src/components/Controls/Link.vue'; import CouponCodeModal from './CouponCodeModal.vue'; import POSQuickActions from './POSQuickActions.vue'; -import { ModalName } from 'src/components/POS/types'; +import { PosEmits } from 'src/components/POS/types'; import SavedInvoiceModal from './SavedInvoiceModal.vue'; import OpenPOSShiftModal from './OpenPOSShiftModal.vue'; import ClosePOSShiftModal from './ClosePOSShiftModal.vue'; import Barcode from 'src/components/Controls/Barcode.vue'; -import { Payment } from 'models/baseModels/Payment/Payment'; import LoyaltyProgramModal from './LoyaltyProgramModal.vue'; +import { POSItem, ItemQtyMap } from 'src/components/POS/types'; import ItemsGrid from 'src/components/POS/Classic/ItemsGrid.vue'; import ItemsTable from 'src/components/POS/Classic/ItemsTable.vue'; import MultiLabelLink from 'src/components/Controls/MultiLabelLink.vue'; -import { InvoiceItem } from 'models/baseModels/InvoiceItem/InvoiceItem'; import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; import SelectedItemTable from 'src/components/POS/Classic/SelectedItemTable.vue'; import FloatingLabelFloatInput from 'src/components/POS/FloatingLabelFloatInput.vue'; import FloatingLabelCurrencyInput from 'src/components/POS/FloatingLabelCurrencyInput.vue'; import { AppliedCouponCodes } from 'models/baseModels/AppliedCouponCodes/AppliedCouponCodes'; -import { - ItemQtyMap, - ItemSerialNumbers, - POSItem, -} from 'src/components/POS/types'; export default defineComponent({ name: 'ClassicPOS', @@ -312,11 +318,11 @@ export default defineComponent({ ItemsTable, PaymentModal, MultiLabelLink, - CouponCodeModal, POSQuickActions, + CouponCodeModal, OpenPOSShiftModal, - SavedInvoiceModal, SelectedItemTable, + SavedInvoiceModal, ClosePOSShiftModal, LoyaltyProgramModal, FloatingLabelFloatInput, @@ -324,8 +330,10 @@ export default defineComponent({ }, props: { cashAmount: Money, + tableView: Boolean, itemDiscounts: Money, openAlertModal: Boolean, + isPosShiftOpen: Boolean, disablePayButton: Boolean, openPaymentModal: Boolean, openCouponCodeModal: Boolean, @@ -333,6 +341,10 @@ export default defineComponent({ openSavedInvoiceModal: Boolean, openLoyaltyProgramModal: Boolean, openAppliedCouponsModal: Boolean, + totalQuantity: { + type: Number, + default: 0, + }, loyaltyPoints: { type: Number, default: 0, @@ -364,78 +376,30 @@ export default defineComponent({ }, emits: [ 'addItem', + 'toggleView', 'toggleModal', 'setCustomer', 'clearValues', 'setCashAmount', 'setCouponsCount', 'routeToSinvList', + 'setTransferRefNo', 'setLoyaltyPoints', 'saveInvoiceAction', 'createTransaction', 'setTransferAmount', 'selectedInvoiceName', + 'setTransferClearanceDate', ], data() { return { - tableView: true, - - totalQuantity: 0, - totalTaxedAmount: fyo.pesa(0), additionalDiscounts: fyo.pesa(0), - - paymentDoc: {} as Payment, - itemSerialNumbers: {} as ItemSerialNumbers, - itemSearchTerm: '', - transferRefNo: undefined as string | undefined, - transferClearanceDate: undefined as Date | undefined, }; }, - computed: { - isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen, - }, methods: { - setTransferRefNo(ref: string) { - this.transferRefNo = ref; - }, - emitRouteToSinvList() { - this.$emit('routeToSinvList'); - }, - toggleView() { - this.tableView = !this.tableView; - }, - emitSetCashAmount(amount: Money) { - this.$emit('setCashAmount', amount); - }, - setTransferClearanceDate(date: Date) { - this.transferClearanceDate = date; - }, - emitCouponsCount(value: number) { - this.$emit('setCouponsCount', value); - }, - emitSetLoyaltyPoints(value: string) { - this.$emit('setLoyaltyPoints', value); - }, - emitSelectedInvoice(doc: InvoiceItem) { - this.$emit('selectedInvoiceName', doc); - }, - toggleModal(modal: ModalName, value: boolean) { - this.$emit('toggleModal', modal, value); - }, - emitCreateTransaction(shouldPrint = false) { - this.$emit('createTransaction', shouldPrint); - }, - emitSetTransferAmount(amount: Money = fyo.pesa(0)) { - this.$emit('setTransferAmount', amount); - }, - selectItem(item: POSItem | Item | undefined) { - this.$emit('addItem', item); - }, - openCouponModal() { - if (this.sinvDoc?.party && this.sinvDoc?.items?.length) { - this.toggleModal('CouponCode', true); - } + emitEvent(eventName: PosEmits, ...args: (string | boolean | Item)[]) { + this.$emit(eventName, ...args); }, getItem, }, diff --git a/src/pages/POS/ModernPOS.vue b/src/pages/POS/ModernPOS.vue index d323ce5a..5cf91cad 100644 --- a/src/pages/POS/ModernPOS.vue +++ b/src/pages/POS/ModernPOS.vue @@ -3,47 +3,56 @@ emitEvent('setLoyaltyPoints', points)" /> emitEvent('selectedInvoiceName', invName) + " /> emitEvent('setCouponsCount', count)" /> emitEvent('setCashAmount', amount)" + @set-transfer-ref-no="(ref) => emitEvent('setTransferRefNo', ref)" + @set-coupons-count="(count) => emitEvent('setCouponsCount', count)" + @set-transfer-amount="(amount) => emitEvent('setTransferAmount', amount)" + @set-transfer-clearance-date=" + (date) => emitEvent('setTransferClearanceDate', date) + " + @create-transaction=" + (createTransaction) => emitEvent('createTransaction', createTransaction) + " /> - + @@ -79,9 +88,10 @@ :df="sinvDoc?.fieldMap.party" @change="(value:string) => $emit('setCustomer',value)" /> + @@ -136,6 +146,7 @@ :read-only="true" :text-right="true" /> + @@ -186,7 +197,7 @@ @@ -229,7 +240,7 @@ :border="true" :value="itemSearchTerm" @keyup.enter=" - async () => await selectItem(await getItem(itemSearchTerm)) + async () => emitEvent('addItem', await getItem(itemSearchTerm) as Item) " @change="(item: string) =>itemSearchTerm= item" /> @@ -239,22 +250,24 @@ class="w-1/3" @item-selected=" async (name: string) => { - await selectItem(await getItem(name)); + emitEvent('addItem', await getItem(name) as Item); } " /> + emitEvent('addItem', item)" /> + emitEvent('addItem', item)" /> @@ -264,9 +277,9 @@ :loyalty-points="loyaltyPoints" :loyalty-program="loyaltyProgram" :applied-coupons-count="appliedCouponsCount" - @toggle-view="toggleView" - @toggle-modal="toggleModal" - @emit-route-to-sinv-list="emitRouteToSinvList" + @toggle-view="emitEvent('toggleView')" + @emit-route-to-sinv-list="emitEvent('routeToSinvList')" + @toggle-modal="(modalName) => emitEvent('toggleModal', modalName)" /> @@ -292,10 +305,9 @@ import OpenPOSShiftModal from './OpenPOSShiftModal.vue'; import SavedInvoiceModal from './SavedInvoiceModal.vue'; import Barcode from 'src/components/Controls/Barcode.vue'; import ClosePOSShiftModal from './ClosePOSShiftModal.vue'; -import { Payment } from 'models/baseModels/Payment/Payment'; import LoyaltyProgramModal from './LoyaltyProgramModal.vue'; -import { InvoiceItem } from 'models/baseModels/InvoiceItem/InvoiceItem'; import MultiLabelLink from 'src/components/Controls/MultiLabelLink.vue'; +import { POSItem, PosEmits, ItemQtyMap } from 'src/components/POS/types'; import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; import ModernPOSItemsGrid from 'src/components/POS/Modern/ModernPOSItemsGrid.vue'; import ModernPOSItemsTable from 'src/components/POS/Modern/ModernPOSItemsTable.vue'; @@ -304,12 +316,6 @@ import { SalesInvoiceItem } from 'models/baseModels/SalesInvoiceItem/SalesInvoic import FloatingLabelCurrencyInput from 'src/components/POS/FloatingLabelCurrencyInput.vue'; import { AppliedCouponCodes } from 'models/baseModels/AppliedCouponCodes/AppliedCouponCodes'; import ModernPOSSelectedItemTable from 'src/components/POS/Modern/ModernPOSSelectedItemTable.vue'; -import { - ItemQtyMap, - ItemSerialNumbers, - ModalName, - POSItem, -} from 'src/components/POS/types'; export default defineComponent({ name: 'ModernPos', @@ -335,8 +341,10 @@ export default defineComponent({ }, props: { cashAmount: Money, + tableView: Boolean, itemDiscounts: Money, openAlertModal: Boolean, + isPosShiftOpen: Boolean, disablePayButton: Boolean, openPaymentModal: Boolean, openKeyboardModal: Boolean, @@ -345,6 +353,10 @@ export default defineComponent({ openSavedInvoiceModal: Boolean, openLoyaltyProgramModal: Boolean, openAppliedCouponsModal: Boolean, + totalQuantity: { + type: Number, + default: 0, + }, loyaltyPoints: { type: Number, default: 0, @@ -376,6 +388,7 @@ export default defineComponent({ }, emits: [ 'addItem', + 'toggleView', 'toggleModal', 'setCustomer', 'clearValues', @@ -383,79 +396,31 @@ export default defineComponent({ 'setCouponsCount', 'routeToSinvList', 'setLoyaltyPoints', + 'setTransferRefNo', 'saveInvoiceAction', 'createTransaction', 'setTransferAmount', 'selectedInvoiceName', + 'setTransferClearanceDate', ], data() { return { - tableView: true, - - totalQuantity: 0, - totalTaxedAmount: fyo.pesa(0), additionalDiscounts: fyo.pesa(0), - paymentDoc: {} as Payment, - itemSerialNumbers: {} as ItemSerialNumbers, - selectedItemField: '', selectedItemRow: {} as SalesInvoiceItem, itemSearchTerm: '', - transferRefNo: undefined as string | undefined, - transferClearanceDate: undefined as Date | undefined, }; }, - computed: { - isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen, - }, methods: { - setTransferRefNo(ref: string) { - this.transferRefNo = ref; - }, - toggleView() { - this.tableView = !this.tableView; - }, - emitSetCashAmount(amount: Money) { - this.$emit('setCashAmount', amount); - }, - setTransferClearanceDate(date: Date) { - this.transferClearanceDate = date; - }, - emitCouponsCount(value: number) { - this.$emit('setCouponsCount', value); - }, - emitRouteToSinvList() { - this.$emit('routeToSinvList'); - }, - emitSetLoyaltyPoints(value: string) { - this.$emit('setLoyaltyPoints', value); - }, - emitSelectedInvoice(doc: InvoiceItem) { - this.$emit('selectedInvoiceName', doc); - }, - toggleModal(modal: ModalName, value: boolean) { - this.$emit('toggleModal', modal, value); - }, - emitCreateTransaction(shouldPrint = false) { - this.$emit('createTransaction', shouldPrint); + emitEvent(eventName: PosEmits, ...args: (string | boolean | Item)[]) { + this.$emit(eventName, ...args); }, selectedRow(row: SalesInvoiceItem, field: string) { this.selectedItemRow = row; this.selectedItemField = field; }, - emitSetTransferAmount(amount: Money = fyo.pesa(0)) { - this.$emit('setTransferAmount', amount); - }, - selectItem(item: POSItem | Item | undefined) { - this.$emit('addItem', item); - }, - openCouponModal() { - if (this.sinvDoc?.party && this.sinvDoc?.items?.length) { - this.toggleModal('CouponCode', true); - } - }, getItem, }, }); diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index b99dc3de..0d4c7eb0 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -12,10 +12,13 @@ @@ -529,11 +541,6 @@ export default defineComponent({ }); } }, - openCouponModal() { - if (this.sinvDoc.party && this.sinvDoc.items?.length) { - this.toggleModal('CouponCode', true); - } - }, async submitSinvDoc(shouldPrint: boolean) { this.sinvDoc.once('afterSubmit', async () => { showToast({ diff --git a/src/pages/POS/POSQuickActions.vue b/src/pages/POS/POSQuickActions.vue index 092d2b49..71dfe711 100644 --- a/src/pages/POS/POSQuickActions.vue +++ b/src/pages/POS/POSQuickActions.vue @@ -88,7 +88,7 @@ }" @click=" loyaltyPoints && sinvDoc?.party && sinvDoc?.items?.length - ? toggleModal('LoyaltyProgram', true) + ? $emit('toggleModal', 'LoyaltyProgram') : null " > @@ -254,7 +254,6 @@
@@ -249,7 +261,7 @@ @@ -279,27 +291,21 @@ import { Item } from 'models/baseModels/Item/Item'; import Link from 'src/components/Controls/Link.vue'; import CouponCodeModal from './CouponCodeModal.vue'; import POSQuickActions from './POSQuickActions.vue'; -import { ModalName } from 'src/components/POS/types'; +import { PosEmits } from 'src/components/POS/types'; import SavedInvoiceModal from './SavedInvoiceModal.vue'; import OpenPOSShiftModal from './OpenPOSShiftModal.vue'; import ClosePOSShiftModal from './ClosePOSShiftModal.vue'; import Barcode from 'src/components/Controls/Barcode.vue'; -import { Payment } from 'models/baseModels/Payment/Payment'; import LoyaltyProgramModal from './LoyaltyProgramModal.vue'; +import { POSItem, ItemQtyMap } from 'src/components/POS/types'; import ItemsGrid from 'src/components/POS/Classic/ItemsGrid.vue'; import ItemsTable from 'src/components/POS/Classic/ItemsTable.vue'; import MultiLabelLink from 'src/components/Controls/MultiLabelLink.vue'; -import { InvoiceItem } from 'models/baseModels/InvoiceItem/InvoiceItem'; import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; import SelectedItemTable from 'src/components/POS/Classic/SelectedItemTable.vue'; import FloatingLabelFloatInput from 'src/components/POS/FloatingLabelFloatInput.vue'; import FloatingLabelCurrencyInput from 'src/components/POS/FloatingLabelCurrencyInput.vue'; import { AppliedCouponCodes } from 'models/baseModels/AppliedCouponCodes/AppliedCouponCodes'; -import { - ItemQtyMap, - ItemSerialNumbers, - POSItem, -} from 'src/components/POS/types'; export default defineComponent({ name: 'ClassicPOS', @@ -312,11 +318,11 @@ export default defineComponent({ ItemsTable, PaymentModal, MultiLabelLink, - CouponCodeModal, POSQuickActions, + CouponCodeModal, OpenPOSShiftModal, - SavedInvoiceModal, SelectedItemTable, + SavedInvoiceModal, ClosePOSShiftModal, LoyaltyProgramModal, FloatingLabelFloatInput, @@ -324,8 +330,10 @@ export default defineComponent({ }, props: { cashAmount: Money, + tableView: Boolean, itemDiscounts: Money, openAlertModal: Boolean, + isPosShiftOpen: Boolean, disablePayButton: Boolean, openPaymentModal: Boolean, openCouponCodeModal: Boolean, @@ -333,6 +341,10 @@ export default defineComponent({ openSavedInvoiceModal: Boolean, openLoyaltyProgramModal: Boolean, openAppliedCouponsModal: Boolean, + totalQuantity: { + type: Number, + default: 0, + }, loyaltyPoints: { type: Number, default: 0, @@ -364,78 +376,30 @@ export default defineComponent({ }, emits: [ 'addItem', + 'toggleView', 'toggleModal', 'setCustomer', 'clearValues', 'setCashAmount', 'setCouponsCount', 'routeToSinvList', + 'setTransferRefNo', 'setLoyaltyPoints', 'saveInvoiceAction', 'createTransaction', 'setTransferAmount', 'selectedInvoiceName', + 'setTransferClearanceDate', ], data() { return { - tableView: true, - - totalQuantity: 0, - totalTaxedAmount: fyo.pesa(0), additionalDiscounts: fyo.pesa(0), - - paymentDoc: {} as Payment, - itemSerialNumbers: {} as ItemSerialNumbers, - itemSearchTerm: '', - transferRefNo: undefined as string | undefined, - transferClearanceDate: undefined as Date | undefined, }; }, - computed: { - isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen, - }, methods: { - setTransferRefNo(ref: string) { - this.transferRefNo = ref; - }, - emitRouteToSinvList() { - this.$emit('routeToSinvList'); - }, - toggleView() { - this.tableView = !this.tableView; - }, - emitSetCashAmount(amount: Money) { - this.$emit('setCashAmount', amount); - }, - setTransferClearanceDate(date: Date) { - this.transferClearanceDate = date; - }, - emitCouponsCount(value: number) { - this.$emit('setCouponsCount', value); - }, - emitSetLoyaltyPoints(value: string) { - this.$emit('setLoyaltyPoints', value); - }, - emitSelectedInvoice(doc: InvoiceItem) { - this.$emit('selectedInvoiceName', doc); - }, - toggleModal(modal: ModalName, value: boolean) { - this.$emit('toggleModal', modal, value); - }, - emitCreateTransaction(shouldPrint = false) { - this.$emit('createTransaction', shouldPrint); - }, - emitSetTransferAmount(amount: Money = fyo.pesa(0)) { - this.$emit('setTransferAmount', amount); - }, - selectItem(item: POSItem | Item | undefined) { - this.$emit('addItem', item); - }, - openCouponModal() { - if (this.sinvDoc?.party && this.sinvDoc?.items?.length) { - this.toggleModal('CouponCode', true); - } + emitEvent(eventName: PosEmits, ...args: (string | boolean | Item)[]) { + this.$emit(eventName, ...args); }, getItem, }, diff --git a/src/pages/POS/ModernPOS.vue b/src/pages/POS/ModernPOS.vue index d323ce5a..5cf91cad 100644 --- a/src/pages/POS/ModernPOS.vue +++ b/src/pages/POS/ModernPOS.vue @@ -3,47 +3,56 @@ emitEvent('setLoyaltyPoints', points)" /> emitEvent('selectedInvoiceName', invName) + " /> emitEvent('setCouponsCount', count)" /> emitEvent('setCashAmount', amount)" + @set-transfer-ref-no="(ref) => emitEvent('setTransferRefNo', ref)" + @set-coupons-count="(count) => emitEvent('setCouponsCount', count)" + @set-transfer-amount="(amount) => emitEvent('setTransferAmount', amount)" + @set-transfer-clearance-date=" + (date) => emitEvent('setTransferClearanceDate', date) + " + @create-transaction=" + (createTransaction) => emitEvent('createTransaction', createTransaction) + " /> - + @@ -79,9 +88,10 @@ :df="sinvDoc?.fieldMap.party" @change="(value:string) => $emit('setCustomer',value)" /> + @@ -136,6 +146,7 @@ :read-only="true" :text-right="true" /> + @@ -186,7 +197,7 @@ @@ -229,7 +240,7 @@ :border="true" :value="itemSearchTerm" @keyup.enter=" - async () => await selectItem(await getItem(itemSearchTerm)) + async () => emitEvent('addItem', await getItem(itemSearchTerm) as Item) " @change="(item: string) =>itemSearchTerm= item" /> @@ -239,22 +250,24 @@ class="w-1/3" @item-selected=" async (name: string) => { - await selectItem(await getItem(name)); + emitEvent('addItem', await getItem(name) as Item); } " /> + emitEvent('addItem', item)" /> + emitEvent('addItem', item)" /> @@ -264,9 +277,9 @@ :loyalty-points="loyaltyPoints" :loyalty-program="loyaltyProgram" :applied-coupons-count="appliedCouponsCount" - @toggle-view="toggleView" - @toggle-modal="toggleModal" - @emit-route-to-sinv-list="emitRouteToSinvList" + @toggle-view="emitEvent('toggleView')" + @emit-route-to-sinv-list="emitEvent('routeToSinvList')" + @toggle-modal="(modalName) => emitEvent('toggleModal', modalName)" /> @@ -292,10 +305,9 @@ import OpenPOSShiftModal from './OpenPOSShiftModal.vue'; import SavedInvoiceModal from './SavedInvoiceModal.vue'; import Barcode from 'src/components/Controls/Barcode.vue'; import ClosePOSShiftModal from './ClosePOSShiftModal.vue'; -import { Payment } from 'models/baseModels/Payment/Payment'; import LoyaltyProgramModal from './LoyaltyProgramModal.vue'; -import { InvoiceItem } from 'models/baseModels/InvoiceItem/InvoiceItem'; import MultiLabelLink from 'src/components/Controls/MultiLabelLink.vue'; +import { POSItem, PosEmits, ItemQtyMap } from 'src/components/POS/types'; import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; import ModernPOSItemsGrid from 'src/components/POS/Modern/ModernPOSItemsGrid.vue'; import ModernPOSItemsTable from 'src/components/POS/Modern/ModernPOSItemsTable.vue'; @@ -304,12 +316,6 @@ import { SalesInvoiceItem } from 'models/baseModels/SalesInvoiceItem/SalesInvoic import FloatingLabelCurrencyInput from 'src/components/POS/FloatingLabelCurrencyInput.vue'; import { AppliedCouponCodes } from 'models/baseModels/AppliedCouponCodes/AppliedCouponCodes'; import ModernPOSSelectedItemTable from 'src/components/POS/Modern/ModernPOSSelectedItemTable.vue'; -import { - ItemQtyMap, - ItemSerialNumbers, - ModalName, - POSItem, -} from 'src/components/POS/types'; export default defineComponent({ name: 'ModernPos', @@ -335,8 +341,10 @@ export default defineComponent({ }, props: { cashAmount: Money, + tableView: Boolean, itemDiscounts: Money, openAlertModal: Boolean, + isPosShiftOpen: Boolean, disablePayButton: Boolean, openPaymentModal: Boolean, openKeyboardModal: Boolean, @@ -345,6 +353,10 @@ export default defineComponent({ openSavedInvoiceModal: Boolean, openLoyaltyProgramModal: Boolean, openAppliedCouponsModal: Boolean, + totalQuantity: { + type: Number, + default: 0, + }, loyaltyPoints: { type: Number, default: 0, @@ -376,6 +388,7 @@ export default defineComponent({ }, emits: [ 'addItem', + 'toggleView', 'toggleModal', 'setCustomer', 'clearValues', @@ -383,79 +396,31 @@ export default defineComponent({ 'setCouponsCount', 'routeToSinvList', 'setLoyaltyPoints', + 'setTransferRefNo', 'saveInvoiceAction', 'createTransaction', 'setTransferAmount', 'selectedInvoiceName', + 'setTransferClearanceDate', ], data() { return { - tableView: true, - - totalQuantity: 0, - totalTaxedAmount: fyo.pesa(0), additionalDiscounts: fyo.pesa(0), - paymentDoc: {} as Payment, - itemSerialNumbers: {} as ItemSerialNumbers, - selectedItemField: '', selectedItemRow: {} as SalesInvoiceItem, itemSearchTerm: '', - transferRefNo: undefined as string | undefined, - transferClearanceDate: undefined as Date | undefined, }; }, - computed: { - isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen, - }, methods: { - setTransferRefNo(ref: string) { - this.transferRefNo = ref; - }, - toggleView() { - this.tableView = !this.tableView; - }, - emitSetCashAmount(amount: Money) { - this.$emit('setCashAmount', amount); - }, - setTransferClearanceDate(date: Date) { - this.transferClearanceDate = date; - }, - emitCouponsCount(value: number) { - this.$emit('setCouponsCount', value); - }, - emitRouteToSinvList() { - this.$emit('routeToSinvList'); - }, - emitSetLoyaltyPoints(value: string) { - this.$emit('setLoyaltyPoints', value); - }, - emitSelectedInvoice(doc: InvoiceItem) { - this.$emit('selectedInvoiceName', doc); - }, - toggleModal(modal: ModalName, value: boolean) { - this.$emit('toggleModal', modal, value); - }, - emitCreateTransaction(shouldPrint = false) { - this.$emit('createTransaction', shouldPrint); + emitEvent(eventName: PosEmits, ...args: (string | boolean | Item)[]) { + this.$emit(eventName, ...args); }, selectedRow(row: SalesInvoiceItem, field: string) { this.selectedItemRow = row; this.selectedItemField = field; }, - emitSetTransferAmount(amount: Money = fyo.pesa(0)) { - this.$emit('setTransferAmount', amount); - }, - selectItem(item: POSItem | Item | undefined) { - this.$emit('addItem', item); - }, - openCouponModal() { - if (this.sinvDoc?.party && this.sinvDoc?.items?.length) { - this.toggleModal('CouponCode', true); - } - }, getItem, }, }); diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index b99dc3de..0d4c7eb0 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -12,10 +12,13 @@ @@ -529,11 +541,6 @@ export default defineComponent({ }); } }, - openCouponModal() { - if (this.sinvDoc.party && this.sinvDoc.items?.length) { - this.toggleModal('CouponCode', true); - } - }, async submitSinvDoc(shouldPrint: boolean) { this.sinvDoc.once('afterSubmit', async () => { showToast({ diff --git a/src/pages/POS/POSQuickActions.vue b/src/pages/POS/POSQuickActions.vue index 092d2b49..71dfe711 100644 --- a/src/pages/POS/POSQuickActions.vue +++ b/src/pages/POS/POSQuickActions.vue @@ -88,7 +88,7 @@ }" @click=" loyaltyPoints && sinvDoc?.party && sinvDoc?.items?.length - ? toggleModal('LoyaltyProgram', true) + ? $emit('toggleModal', 'LoyaltyProgram') : null " > @@ -254,7 +254,6 @@
@@ -279,27 +291,21 @@ import { Item } from 'models/baseModels/Item/Item'; import Link from 'src/components/Controls/Link.vue'; import CouponCodeModal from './CouponCodeModal.vue'; import POSQuickActions from './POSQuickActions.vue'; -import { ModalName } from 'src/components/POS/types'; +import { PosEmits } from 'src/components/POS/types'; import SavedInvoiceModal from './SavedInvoiceModal.vue'; import OpenPOSShiftModal from './OpenPOSShiftModal.vue'; import ClosePOSShiftModal from './ClosePOSShiftModal.vue'; import Barcode from 'src/components/Controls/Barcode.vue'; -import { Payment } from 'models/baseModels/Payment/Payment'; import LoyaltyProgramModal from './LoyaltyProgramModal.vue'; +import { POSItem, ItemQtyMap } from 'src/components/POS/types'; import ItemsGrid from 'src/components/POS/Classic/ItemsGrid.vue'; import ItemsTable from 'src/components/POS/Classic/ItemsTable.vue'; import MultiLabelLink from 'src/components/Controls/MultiLabelLink.vue'; -import { InvoiceItem } from 'models/baseModels/InvoiceItem/InvoiceItem'; import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; import SelectedItemTable from 'src/components/POS/Classic/SelectedItemTable.vue'; import FloatingLabelFloatInput from 'src/components/POS/FloatingLabelFloatInput.vue'; import FloatingLabelCurrencyInput from 'src/components/POS/FloatingLabelCurrencyInput.vue'; import { AppliedCouponCodes } from 'models/baseModels/AppliedCouponCodes/AppliedCouponCodes'; -import { - ItemQtyMap, - ItemSerialNumbers, - POSItem, -} from 'src/components/POS/types'; export default defineComponent({ name: 'ClassicPOS', @@ -312,11 +318,11 @@ export default defineComponent({ ItemsTable, PaymentModal, MultiLabelLink, - CouponCodeModal, POSQuickActions, + CouponCodeModal, OpenPOSShiftModal, - SavedInvoiceModal, SelectedItemTable, + SavedInvoiceModal, ClosePOSShiftModal, LoyaltyProgramModal, FloatingLabelFloatInput, @@ -324,8 +330,10 @@ export default defineComponent({ }, props: { cashAmount: Money, + tableView: Boolean, itemDiscounts: Money, openAlertModal: Boolean, + isPosShiftOpen: Boolean, disablePayButton: Boolean, openPaymentModal: Boolean, openCouponCodeModal: Boolean, @@ -333,6 +341,10 @@ export default defineComponent({ openSavedInvoiceModal: Boolean, openLoyaltyProgramModal: Boolean, openAppliedCouponsModal: Boolean, + totalQuantity: { + type: Number, + default: 0, + }, loyaltyPoints: { type: Number, default: 0, @@ -364,78 +376,30 @@ export default defineComponent({ }, emits: [ 'addItem', + 'toggleView', 'toggleModal', 'setCustomer', 'clearValues', 'setCashAmount', 'setCouponsCount', 'routeToSinvList', + 'setTransferRefNo', 'setLoyaltyPoints', 'saveInvoiceAction', 'createTransaction', 'setTransferAmount', 'selectedInvoiceName', + 'setTransferClearanceDate', ], data() { return { - tableView: true, - - totalQuantity: 0, - totalTaxedAmount: fyo.pesa(0), additionalDiscounts: fyo.pesa(0), - - paymentDoc: {} as Payment, - itemSerialNumbers: {} as ItemSerialNumbers, - itemSearchTerm: '', - transferRefNo: undefined as string | undefined, - transferClearanceDate: undefined as Date | undefined, }; }, - computed: { - isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen, - }, methods: { - setTransferRefNo(ref: string) { - this.transferRefNo = ref; - }, - emitRouteToSinvList() { - this.$emit('routeToSinvList'); - }, - toggleView() { - this.tableView = !this.tableView; - }, - emitSetCashAmount(amount: Money) { - this.$emit('setCashAmount', amount); - }, - setTransferClearanceDate(date: Date) { - this.transferClearanceDate = date; - }, - emitCouponsCount(value: number) { - this.$emit('setCouponsCount', value); - }, - emitSetLoyaltyPoints(value: string) { - this.$emit('setLoyaltyPoints', value); - }, - emitSelectedInvoice(doc: InvoiceItem) { - this.$emit('selectedInvoiceName', doc); - }, - toggleModal(modal: ModalName, value: boolean) { - this.$emit('toggleModal', modal, value); - }, - emitCreateTransaction(shouldPrint = false) { - this.$emit('createTransaction', shouldPrint); - }, - emitSetTransferAmount(amount: Money = fyo.pesa(0)) { - this.$emit('setTransferAmount', amount); - }, - selectItem(item: POSItem | Item | undefined) { - this.$emit('addItem', item); - }, - openCouponModal() { - if (this.sinvDoc?.party && this.sinvDoc?.items?.length) { - this.toggleModal('CouponCode', true); - } + emitEvent(eventName: PosEmits, ...args: (string | boolean | Item)[]) { + this.$emit(eventName, ...args); }, getItem, }, diff --git a/src/pages/POS/ModernPOS.vue b/src/pages/POS/ModernPOS.vue index d323ce5a..5cf91cad 100644 --- a/src/pages/POS/ModernPOS.vue +++ b/src/pages/POS/ModernPOS.vue @@ -3,47 +3,56 @@ emitEvent('setLoyaltyPoints', points)" /> emitEvent('selectedInvoiceName', invName) + " /> emitEvent('setCouponsCount', count)" /> emitEvent('setCashAmount', amount)" + @set-transfer-ref-no="(ref) => emitEvent('setTransferRefNo', ref)" + @set-coupons-count="(count) => emitEvent('setCouponsCount', count)" + @set-transfer-amount="(amount) => emitEvent('setTransferAmount', amount)" + @set-transfer-clearance-date=" + (date) => emitEvent('setTransferClearanceDate', date) + " + @create-transaction=" + (createTransaction) => emitEvent('createTransaction', createTransaction) + " /> - + @@ -79,9 +88,10 @@ :df="sinvDoc?.fieldMap.party" @change="(value:string) => $emit('setCustomer',value)" /> + @@ -136,6 +146,7 @@ :read-only="true" :text-right="true" /> + @@ -186,7 +197,7 @@ @@ -229,7 +240,7 @@ :border="true" :value="itemSearchTerm" @keyup.enter=" - async () => await selectItem(await getItem(itemSearchTerm)) + async () => emitEvent('addItem', await getItem(itemSearchTerm) as Item) " @change="(item: string) =>itemSearchTerm= item" /> @@ -239,22 +250,24 @@ class="w-1/3" @item-selected=" async (name: string) => { - await selectItem(await getItem(name)); + emitEvent('addItem', await getItem(name) as Item); } " /> + emitEvent('addItem', item)" /> + emitEvent('addItem', item)" /> @@ -264,9 +277,9 @@ :loyalty-points="loyaltyPoints" :loyalty-program="loyaltyProgram" :applied-coupons-count="appliedCouponsCount" - @toggle-view="toggleView" - @toggle-modal="toggleModal" - @emit-route-to-sinv-list="emitRouteToSinvList" + @toggle-view="emitEvent('toggleView')" + @emit-route-to-sinv-list="emitEvent('routeToSinvList')" + @toggle-modal="(modalName) => emitEvent('toggleModal', modalName)" /> @@ -292,10 +305,9 @@ import OpenPOSShiftModal from './OpenPOSShiftModal.vue'; import SavedInvoiceModal from './SavedInvoiceModal.vue'; import Barcode from 'src/components/Controls/Barcode.vue'; import ClosePOSShiftModal from './ClosePOSShiftModal.vue'; -import { Payment } from 'models/baseModels/Payment/Payment'; import LoyaltyProgramModal from './LoyaltyProgramModal.vue'; -import { InvoiceItem } from 'models/baseModels/InvoiceItem/InvoiceItem'; import MultiLabelLink from 'src/components/Controls/MultiLabelLink.vue'; +import { POSItem, PosEmits, ItemQtyMap } from 'src/components/POS/types'; import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; import ModernPOSItemsGrid from 'src/components/POS/Modern/ModernPOSItemsGrid.vue'; import ModernPOSItemsTable from 'src/components/POS/Modern/ModernPOSItemsTable.vue'; @@ -304,12 +316,6 @@ import { SalesInvoiceItem } from 'models/baseModels/SalesInvoiceItem/SalesInvoic import FloatingLabelCurrencyInput from 'src/components/POS/FloatingLabelCurrencyInput.vue'; import { AppliedCouponCodes } from 'models/baseModels/AppliedCouponCodes/AppliedCouponCodes'; import ModernPOSSelectedItemTable from 'src/components/POS/Modern/ModernPOSSelectedItemTable.vue'; -import { - ItemQtyMap, - ItemSerialNumbers, - ModalName, - POSItem, -} from 'src/components/POS/types'; export default defineComponent({ name: 'ModernPos', @@ -335,8 +341,10 @@ export default defineComponent({ }, props: { cashAmount: Money, + tableView: Boolean, itemDiscounts: Money, openAlertModal: Boolean, + isPosShiftOpen: Boolean, disablePayButton: Boolean, openPaymentModal: Boolean, openKeyboardModal: Boolean, @@ -345,6 +353,10 @@ export default defineComponent({ openSavedInvoiceModal: Boolean, openLoyaltyProgramModal: Boolean, openAppliedCouponsModal: Boolean, + totalQuantity: { + type: Number, + default: 0, + }, loyaltyPoints: { type: Number, default: 0, @@ -376,6 +388,7 @@ export default defineComponent({ }, emits: [ 'addItem', + 'toggleView', 'toggleModal', 'setCustomer', 'clearValues', @@ -383,79 +396,31 @@ export default defineComponent({ 'setCouponsCount', 'routeToSinvList', 'setLoyaltyPoints', + 'setTransferRefNo', 'saveInvoiceAction', 'createTransaction', 'setTransferAmount', 'selectedInvoiceName', + 'setTransferClearanceDate', ], data() { return { - tableView: true, - - totalQuantity: 0, - totalTaxedAmount: fyo.pesa(0), additionalDiscounts: fyo.pesa(0), - paymentDoc: {} as Payment, - itemSerialNumbers: {} as ItemSerialNumbers, - selectedItemField: '', selectedItemRow: {} as SalesInvoiceItem, itemSearchTerm: '', - transferRefNo: undefined as string | undefined, - transferClearanceDate: undefined as Date | undefined, }; }, - computed: { - isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen, - }, methods: { - setTransferRefNo(ref: string) { - this.transferRefNo = ref; - }, - toggleView() { - this.tableView = !this.tableView; - }, - emitSetCashAmount(amount: Money) { - this.$emit('setCashAmount', amount); - }, - setTransferClearanceDate(date: Date) { - this.transferClearanceDate = date; - }, - emitCouponsCount(value: number) { - this.$emit('setCouponsCount', value); - }, - emitRouteToSinvList() { - this.$emit('routeToSinvList'); - }, - emitSetLoyaltyPoints(value: string) { - this.$emit('setLoyaltyPoints', value); - }, - emitSelectedInvoice(doc: InvoiceItem) { - this.$emit('selectedInvoiceName', doc); - }, - toggleModal(modal: ModalName, value: boolean) { - this.$emit('toggleModal', modal, value); - }, - emitCreateTransaction(shouldPrint = false) { - this.$emit('createTransaction', shouldPrint); + emitEvent(eventName: PosEmits, ...args: (string | boolean | Item)[]) { + this.$emit(eventName, ...args); }, selectedRow(row: SalesInvoiceItem, field: string) { this.selectedItemRow = row; this.selectedItemField = field; }, - emitSetTransferAmount(amount: Money = fyo.pesa(0)) { - this.$emit('setTransferAmount', amount); - }, - selectItem(item: POSItem | Item | undefined) { - this.$emit('addItem', item); - }, - openCouponModal() { - if (this.sinvDoc?.party && this.sinvDoc?.items?.length) { - this.toggleModal('CouponCode', true); - } - }, getItem, }, }); diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index b99dc3de..0d4c7eb0 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -12,10 +12,13 @@ @@ -529,11 +541,6 @@ export default defineComponent({ }); } }, - openCouponModal() { - if (this.sinvDoc.party && this.sinvDoc.items?.length) { - this.toggleModal('CouponCode', true); - } - }, async submitSinvDoc(shouldPrint: boolean) { this.sinvDoc.once('afterSubmit', async () => { showToast({ diff --git a/src/pages/POS/POSQuickActions.vue b/src/pages/POS/POSQuickActions.vue index 092d2b49..71dfe711 100644 --- a/src/pages/POS/POSQuickActions.vue +++ b/src/pages/POS/POSQuickActions.vue @@ -88,7 +88,7 @@ }" @click=" loyaltyPoints && sinvDoc?.party && sinvDoc?.items?.length - ? toggleModal('LoyaltyProgram', true) + ? $emit('toggleModal', 'LoyaltyProgram') : null " > @@ -254,7 +254,6 @@
@@ -186,7 +197,7 @@ @@ -229,7 +240,7 @@ :border="true" :value="itemSearchTerm" @keyup.enter=" - async () => await selectItem(await getItem(itemSearchTerm)) + async () => emitEvent('addItem', await getItem(itemSearchTerm) as Item) " @change="(item: string) =>itemSearchTerm= item" /> @@ -239,22 +250,24 @@ class="w-1/3" @item-selected=" async (name: string) => { - await selectItem(await getItem(name)); + emitEvent('addItem', await getItem(name) as Item); } " /> + emitEvent('addItem', item)" /> + emitEvent('addItem', item)" /> @@ -264,9 +277,9 @@ :loyalty-points="loyaltyPoints" :loyalty-program="loyaltyProgram" :applied-coupons-count="appliedCouponsCount" - @toggle-view="toggleView" - @toggle-modal="toggleModal" - @emit-route-to-sinv-list="emitRouteToSinvList" + @toggle-view="emitEvent('toggleView')" + @emit-route-to-sinv-list="emitEvent('routeToSinvList')" + @toggle-modal="(modalName) => emitEvent('toggleModal', modalName)" /> @@ -292,10 +305,9 @@ import OpenPOSShiftModal from './OpenPOSShiftModal.vue'; import SavedInvoiceModal from './SavedInvoiceModal.vue'; import Barcode from 'src/components/Controls/Barcode.vue'; import ClosePOSShiftModal from './ClosePOSShiftModal.vue'; -import { Payment } from 'models/baseModels/Payment/Payment'; import LoyaltyProgramModal from './LoyaltyProgramModal.vue'; -import { InvoiceItem } from 'models/baseModels/InvoiceItem/InvoiceItem'; import MultiLabelLink from 'src/components/Controls/MultiLabelLink.vue'; +import { POSItem, PosEmits, ItemQtyMap } from 'src/components/POS/types'; import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; import ModernPOSItemsGrid from 'src/components/POS/Modern/ModernPOSItemsGrid.vue'; import ModernPOSItemsTable from 'src/components/POS/Modern/ModernPOSItemsTable.vue'; @@ -304,12 +316,6 @@ import { SalesInvoiceItem } from 'models/baseModels/SalesInvoiceItem/SalesInvoic import FloatingLabelCurrencyInput from 'src/components/POS/FloatingLabelCurrencyInput.vue'; import { AppliedCouponCodes } from 'models/baseModels/AppliedCouponCodes/AppliedCouponCodes'; import ModernPOSSelectedItemTable from 'src/components/POS/Modern/ModernPOSSelectedItemTable.vue'; -import { - ItemQtyMap, - ItemSerialNumbers, - ModalName, - POSItem, -} from 'src/components/POS/types'; export default defineComponent({ name: 'ModernPos', @@ -335,8 +341,10 @@ export default defineComponent({ }, props: { cashAmount: Money, + tableView: Boolean, itemDiscounts: Money, openAlertModal: Boolean, + isPosShiftOpen: Boolean, disablePayButton: Boolean, openPaymentModal: Boolean, openKeyboardModal: Boolean, @@ -345,6 +353,10 @@ export default defineComponent({ openSavedInvoiceModal: Boolean, openLoyaltyProgramModal: Boolean, openAppliedCouponsModal: Boolean, + totalQuantity: { + type: Number, + default: 0, + }, loyaltyPoints: { type: Number, default: 0, @@ -376,6 +388,7 @@ export default defineComponent({ }, emits: [ 'addItem', + 'toggleView', 'toggleModal', 'setCustomer', 'clearValues', @@ -383,79 +396,31 @@ export default defineComponent({ 'setCouponsCount', 'routeToSinvList', 'setLoyaltyPoints', + 'setTransferRefNo', 'saveInvoiceAction', 'createTransaction', 'setTransferAmount', 'selectedInvoiceName', + 'setTransferClearanceDate', ], data() { return { - tableView: true, - - totalQuantity: 0, - totalTaxedAmount: fyo.pesa(0), additionalDiscounts: fyo.pesa(0), - paymentDoc: {} as Payment, - itemSerialNumbers: {} as ItemSerialNumbers, - selectedItemField: '', selectedItemRow: {} as SalesInvoiceItem, itemSearchTerm: '', - transferRefNo: undefined as string | undefined, - transferClearanceDate: undefined as Date | undefined, }; }, - computed: { - isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen, - }, methods: { - setTransferRefNo(ref: string) { - this.transferRefNo = ref; - }, - toggleView() { - this.tableView = !this.tableView; - }, - emitSetCashAmount(amount: Money) { - this.$emit('setCashAmount', amount); - }, - setTransferClearanceDate(date: Date) { - this.transferClearanceDate = date; - }, - emitCouponsCount(value: number) { - this.$emit('setCouponsCount', value); - }, - emitRouteToSinvList() { - this.$emit('routeToSinvList'); - }, - emitSetLoyaltyPoints(value: string) { - this.$emit('setLoyaltyPoints', value); - }, - emitSelectedInvoice(doc: InvoiceItem) { - this.$emit('selectedInvoiceName', doc); - }, - toggleModal(modal: ModalName, value: boolean) { - this.$emit('toggleModal', modal, value); - }, - emitCreateTransaction(shouldPrint = false) { - this.$emit('createTransaction', shouldPrint); + emitEvent(eventName: PosEmits, ...args: (string | boolean | Item)[]) { + this.$emit(eventName, ...args); }, selectedRow(row: SalesInvoiceItem, field: string) { this.selectedItemRow = row; this.selectedItemField = field; }, - emitSetTransferAmount(amount: Money = fyo.pesa(0)) { - this.$emit('setTransferAmount', amount); - }, - selectItem(item: POSItem | Item | undefined) { - this.$emit('addItem', item); - }, - openCouponModal() { - if (this.sinvDoc?.party && this.sinvDoc?.items?.length) { - this.toggleModal('CouponCode', true); - } - }, getItem, }, }); diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index b99dc3de..0d4c7eb0 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -12,10 +12,13 @@ @@ -529,11 +541,6 @@ export default defineComponent({ }); } }, - openCouponModal() { - if (this.sinvDoc.party && this.sinvDoc.items?.length) { - this.toggleModal('CouponCode', true); - } - }, async submitSinvDoc(shouldPrint: boolean) { this.sinvDoc.once('afterSubmit', async () => { showToast({ diff --git a/src/pages/POS/POSQuickActions.vue b/src/pages/POS/POSQuickActions.vue index 092d2b49..71dfe711 100644 --- a/src/pages/POS/POSQuickActions.vue +++ b/src/pages/POS/POSQuickActions.vue @@ -88,7 +88,7 @@ }" @click=" loyaltyPoints && sinvDoc?.party && sinvDoc?.items?.length - ? toggleModal('LoyaltyProgram', true) + ? $emit('toggleModal', 'LoyaltyProgram') : null " > @@ -254,7 +254,6 @@
@@ -229,7 +240,7 @@ :border="true" :value="itemSearchTerm" @keyup.enter=" - async () => await selectItem(await getItem(itemSearchTerm)) + async () => emitEvent('addItem', await getItem(itemSearchTerm) as Item) " @change="(item: string) =>itemSearchTerm= item" /> @@ -239,22 +250,24 @@ class="w-1/3" @item-selected=" async (name: string) => { - await selectItem(await getItem(name)); + emitEvent('addItem', await getItem(name) as Item); } " /> + emitEvent('addItem', item)" /> + emitEvent('addItem', item)" /> @@ -264,9 +277,9 @@ :loyalty-points="loyaltyPoints" :loyalty-program="loyaltyProgram" :applied-coupons-count="appliedCouponsCount" - @toggle-view="toggleView" - @toggle-modal="toggleModal" - @emit-route-to-sinv-list="emitRouteToSinvList" + @toggle-view="emitEvent('toggleView')" + @emit-route-to-sinv-list="emitEvent('routeToSinvList')" + @toggle-modal="(modalName) => emitEvent('toggleModal', modalName)" /> @@ -292,10 +305,9 @@ import OpenPOSShiftModal from './OpenPOSShiftModal.vue'; import SavedInvoiceModal from './SavedInvoiceModal.vue'; import Barcode from 'src/components/Controls/Barcode.vue'; import ClosePOSShiftModal from './ClosePOSShiftModal.vue'; -import { Payment } from 'models/baseModels/Payment/Payment'; import LoyaltyProgramModal from './LoyaltyProgramModal.vue'; -import { InvoiceItem } from 'models/baseModels/InvoiceItem/InvoiceItem'; import MultiLabelLink from 'src/components/Controls/MultiLabelLink.vue'; +import { POSItem, PosEmits, ItemQtyMap } from 'src/components/POS/types'; import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; import ModernPOSItemsGrid from 'src/components/POS/Modern/ModernPOSItemsGrid.vue'; import ModernPOSItemsTable from 'src/components/POS/Modern/ModernPOSItemsTable.vue'; @@ -304,12 +316,6 @@ import { SalesInvoiceItem } from 'models/baseModels/SalesInvoiceItem/SalesInvoic import FloatingLabelCurrencyInput from 'src/components/POS/FloatingLabelCurrencyInput.vue'; import { AppliedCouponCodes } from 'models/baseModels/AppliedCouponCodes/AppliedCouponCodes'; import ModernPOSSelectedItemTable from 'src/components/POS/Modern/ModernPOSSelectedItemTable.vue'; -import { - ItemQtyMap, - ItemSerialNumbers, - ModalName, - POSItem, -} from 'src/components/POS/types'; export default defineComponent({ name: 'ModernPos', @@ -335,8 +341,10 @@ export default defineComponent({ }, props: { cashAmount: Money, + tableView: Boolean, itemDiscounts: Money, openAlertModal: Boolean, + isPosShiftOpen: Boolean, disablePayButton: Boolean, openPaymentModal: Boolean, openKeyboardModal: Boolean, @@ -345,6 +353,10 @@ export default defineComponent({ openSavedInvoiceModal: Boolean, openLoyaltyProgramModal: Boolean, openAppliedCouponsModal: Boolean, + totalQuantity: { + type: Number, + default: 0, + }, loyaltyPoints: { type: Number, default: 0, @@ -376,6 +388,7 @@ export default defineComponent({ }, emits: [ 'addItem', + 'toggleView', 'toggleModal', 'setCustomer', 'clearValues', @@ -383,79 +396,31 @@ export default defineComponent({ 'setCouponsCount', 'routeToSinvList', 'setLoyaltyPoints', + 'setTransferRefNo', 'saveInvoiceAction', 'createTransaction', 'setTransferAmount', 'selectedInvoiceName', + 'setTransferClearanceDate', ], data() { return { - tableView: true, - - totalQuantity: 0, - totalTaxedAmount: fyo.pesa(0), additionalDiscounts: fyo.pesa(0), - paymentDoc: {} as Payment, - itemSerialNumbers: {} as ItemSerialNumbers, - selectedItemField: '', selectedItemRow: {} as SalesInvoiceItem, itemSearchTerm: '', - transferRefNo: undefined as string | undefined, - transferClearanceDate: undefined as Date | undefined, }; }, - computed: { - isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen, - }, methods: { - setTransferRefNo(ref: string) { - this.transferRefNo = ref; - }, - toggleView() { - this.tableView = !this.tableView; - }, - emitSetCashAmount(amount: Money) { - this.$emit('setCashAmount', amount); - }, - setTransferClearanceDate(date: Date) { - this.transferClearanceDate = date; - }, - emitCouponsCount(value: number) { - this.$emit('setCouponsCount', value); - }, - emitRouteToSinvList() { - this.$emit('routeToSinvList'); - }, - emitSetLoyaltyPoints(value: string) { - this.$emit('setLoyaltyPoints', value); - }, - emitSelectedInvoice(doc: InvoiceItem) { - this.$emit('selectedInvoiceName', doc); - }, - toggleModal(modal: ModalName, value: boolean) { - this.$emit('toggleModal', modal, value); - }, - emitCreateTransaction(shouldPrint = false) { - this.$emit('createTransaction', shouldPrint); + emitEvent(eventName: PosEmits, ...args: (string | boolean | Item)[]) { + this.$emit(eventName, ...args); }, selectedRow(row: SalesInvoiceItem, field: string) { this.selectedItemRow = row; this.selectedItemField = field; }, - emitSetTransferAmount(amount: Money = fyo.pesa(0)) { - this.$emit('setTransferAmount', amount); - }, - selectItem(item: POSItem | Item | undefined) { - this.$emit('addItem', item); - }, - openCouponModal() { - if (this.sinvDoc?.party && this.sinvDoc?.items?.length) { - this.toggleModal('CouponCode', true); - } - }, getItem, }, }); diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index b99dc3de..0d4c7eb0 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -12,10 +12,13 @@ @@ -529,11 +541,6 @@ export default defineComponent({ }); } }, - openCouponModal() { - if (this.sinvDoc.party && this.sinvDoc.items?.length) { - this.toggleModal('CouponCode', true); - } - }, async submitSinvDoc(shouldPrint: boolean) { this.sinvDoc.once('afterSubmit', async () => { showToast({ diff --git a/src/pages/POS/POSQuickActions.vue b/src/pages/POS/POSQuickActions.vue index 092d2b49..71dfe711 100644 --- a/src/pages/POS/POSQuickActions.vue +++ b/src/pages/POS/POSQuickActions.vue @@ -88,7 +88,7 @@ }" @click=" loyaltyPoints && sinvDoc?.party && sinvDoc?.items?.length - ? toggleModal('LoyaltyProgram', true) + ? $emit('toggleModal', 'LoyaltyProgram') : null " > @@ -254,7 +254,6 @@