Skip to content

Commit

Permalink
feat: multiple payment methods in pos
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayitzme committed Dec 26, 2024
1 parent d37287d commit 7cbe5c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 31 deletions.
5 changes: 1 addition & 4 deletions backend/database/bespoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,7 @@ export class BespokeQueries {
const sinvNamesQuery = db.knex!(ModelNameEnum.SalesInvoice)
.select('name')
.where('isPOS', true)
.andWhereBetween('date', [
DateTime.fromJSDate(fromDate).toSQLDate(),
DateTime.fromJSDate(toDate).toSQLDate(),
]);
.andWhereBetween('date', [fromDate.toISOString(), toDate.toISOString()]);

if (lastShiftClosingDate) {
sinvNamesQuery.andWhere(
Expand Down
24 changes: 7 additions & 17 deletions src/pages/POS/ClosePOSShiftModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,16 @@ export default defineComponent({
},
methods: {
async setTransactedAmount() {
if (!fyo.singles.POSShift?.openingDate) {
this.posOpeningShiftDoc = await getPOSOpeningShiftDoc(fyo);
const fromDate = this.posOpeningShiftDoc?.openingDate as Date;
if (!fromDate) {
return;
}
const fromDate = this.posOpeningShiftDoc?.openingDate as Date;
this.transactedAmount = await fyo.db.getPOSTransactedAmount(
fromDate,
new Date(),
fyo.singles.POSShift.closingDate as Date
new Date()
);
},
seedClosingCash() {
Expand Down Expand Up @@ -160,19 +162,7 @@ export default defineComponent({
return;
}
let expectedAmount = fyo.pesa(0);
if (row.paymentMethod === 'Cash') {
expectedAmount = expectedAmount.add(
this.posOpeningShiftDoc?.openingCashAmount as Money
);
}
if (row.paymentMethod === 'Transfer') {
expectedAmount = expectedAmount.add(
this.posOpeningShiftDoc?.openingTransferAmount as Money
);
}
let expectedAmount = row.amount ?? fyo.pesa(0);
if (this.transactedAmount) {
expectedAmount = expectedAmount.add(
Expand Down
17 changes: 7 additions & 10 deletions src/pages/POS/OpenPOSShiftModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,13 @@ export default defineComponent({
this.posShiftDoc.openingAmounts = [];
await this.posShiftDoc.set('openingAmounts', [
{
paymentMethod: 'Cash',
amount: fyo.pesa(0),
},
{
paymentMethod: 'Transfer',
amount: fyo.pesa(0),
},
]);
const paymentMethods = (
(await this.fyo.db.getAll(ModelNameEnum.PaymentMethod, {
fields: ['name'],
})) as { name: string }[]
).map((doc) => ({ paymentMethod: doc.name, amount: fyo.pesa(0) }));
await this.posShiftDoc.set('openingAmounts', paymentMethods);
},
async seedDefaults() {
if (!!this.posShiftDoc?.isShiftOpen) {
Expand Down

0 comments on commit 7cbe5c6

Please sign in to comment.