diff --git a/backend/database/bespoke.ts b/backend/database/bespoke.ts index 6aaed0e6..35ff903e 100644 --- a/backend/database/bespoke.ts +++ b/backend/database/bespoke.ts @@ -394,7 +394,8 @@ export class BespokeQueries { static async getPOSTransactedAmount( db: DatabaseCore, - fromDate: Date + fromDate: Date, + toDate: Date ): Promise | undefined> { const sinvNames = ( await db.knex!(ModelNameEnum.SalesInvoice) @@ -403,7 +404,9 @@ export class BespokeQueries { .andWhereRaw('datetime(date) > datetime(?)', [ new Date(fromDate.setHours(0, 0, 0)).toISOString(), ]) - .andWhereRaw('datetime(date) < datetime(?)', [new Date().toISOString()]) + .andWhereRaw('datetime(date) < datetime(?)', [ + new Date(toDate.setHours(0, 0, 0)).toISOString(), + ]) ).map((row: { name: string }) => row.name); if (!sinvNames.length) { diff --git a/fyo/core/dbHandler.ts b/fyo/core/dbHandler.ts index 6a2c7d49..509f350d 100644 --- a/fyo/core/dbHandler.ts +++ b/fyo/core/dbHandler.ts @@ -344,11 +344,13 @@ export class DatabaseHandler extends DatabaseBase { } async getPOSTransactedAmount( - fromDate: Date + fromDate: Date, + toDate: Date ): Promise | undefined> { return (await this.#demux.callBespoke( 'getPOSTransactedAmount', - fromDate + fromDate, + toDate )) as Promise | undefined>; } diff --git a/models/inventory/Point of Sale/tests/testPointOfSales.spec.ts b/models/inventory/Point of Sale/tests/testPointOfSales.spec.ts index d5552283..36a6f3e0 100644 --- a/models/inventory/Point of Sale/tests/testPointOfSales.spec.ts +++ b/models/inventory/Point of Sale/tests/testPointOfSales.spec.ts @@ -31,14 +31,15 @@ let sinvDocOne: SalesInvoice | undefined; test('check pos transacted amount', async (t) => { const transactedAmountBeforeTxn = await fyo.db.getPOSTransactedAmount( - new Date('2022-01-01') + new Date('2023-01-01'), + new Date('2023-01-02') ); t.equals(transactedAmountBeforeTxn, undefined); sinvDocOne = fyo.doc.getNewDoc(ModelNameEnum.SalesInvoice, { isPOS: true, - date: new Date('2022-01-02'), + date: new Date('2023-01-01'), account: 'Debtors', party: customer.name, }) as SalesInvoice; @@ -56,7 +57,7 @@ test('check pos transacted amount', async (t) => { const sinvDocTwo = fyo.doc.getNewDoc(ModelNameEnum.SalesInvoice, { isPOS: true, - date: new Date('2022-01-02'), + date: new Date('2023-01-01'), account: 'Debtors', party: customer.name, }) as SalesInvoice; @@ -72,14 +73,17 @@ test('check pos transacted amount', async (t) => { await paymentDocTwo.setMultiple({ paymentMethod: 'Transfer', - clearanceDate: new Date(), + clearanceDate: new Date('2023-01-01'), referenceId: 'xxxxxxxx', }); await paymentDocTwo.sync(); const transactedAmountAfterTxn: Record | undefined = - await fyo.db.getPOSTransactedAmount(new Date('2022-01-02')); + await fyo.db.getPOSTransactedAmount( + new Date('2023-01-01'), + new Date('2023-01-02') + ); t.true(transactedAmountAfterTxn); diff --git a/src/components/POS/SelectedItemRow.vue b/src/components/POS/SelectedItemRow.vue index d4e8b4c9..dcdecccd 100644 --- a/src/components/POS/SelectedItemRow.vue +++ b/src/components/POS/SelectedItemRow.vue @@ -194,7 +194,7 @@
- this.sinvDoc), cashAmount: computed(() => this.cashAmount), + doc: computed(() => this.sinvDoc), isDiscountingEnabled: computed(() => this.isDiscountingEnabled), itemDiscounts: computed(() => this.itemDiscounts), itemQtyMap: computed(() => this.itemQtyMap), @@ -221,6 +219,7 @@ export default defineComponent({ sinvDoc: computed(() => this.sinvDoc), totalTaxedAmount: computed(() => this.totalTaxedAmount), transferAmount: computed(() => this.transferAmount), + transferClearanceDate: computed(() => this.transferClearanceDate), transferRefNo: computed(() => this.transferRefNo), }; }, diff --git a/src/pages/POS/PaymentModal.vue b/src/pages/POS/PaymentModal.vue index 1334020e..aa5c4940 100644 --- a/src/pages/POS/PaymentModal.vue +++ b/src/pages/POS/PaymentModal.vue @@ -1,13 +1,9 @@