Skip to content

Commit

Permalink
Merge pull request #1073 from frappe/link-pos-shifts
Browse files Browse the repository at this point in the history
feat: mention pos shift closing and opening in each documents
  • Loading branch information
akshayitzme authored Dec 30, 2024
2 parents a37bee8 + f8a5b28 commit bea978a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 3 deletions.
3 changes: 1 addition & 2 deletions backend/database/bespoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { ModelNameEnum } from '../../models/types';
import DatabaseCore from './core';
import { BespokeFunction } from './types';
import { DateTime } from 'luxon';
import { DocItem, ReturnDocItem } from 'models/inventory/types';
import { safeParseFloat } from 'utils/index';
import { Money } from 'pesa';
Expand Down Expand Up @@ -408,7 +407,7 @@ export class BespokeQueries {
sinvNamesQuery.andWhere(
'created',
'>',
DateTime.fromJSDate(lastShiftClosingDate).toUTC().toString()
lastShiftClosingDate.toISOString()
);
}

Expand Down
1 change: 1 addition & 0 deletions models/inventory/Point of Sale/POSClosingShift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class POSClosingShift extends Doc {
closingAmounts?: ClosingAmounts[];
closingCash?: ClosingCash[];
closingDate?: Date;
openingShift?: string;

get closingCashAmount() {
if (!this.closingCash) {
Expand Down
1 change: 1 addition & 0 deletions models/inventory/Point of Sale/POSOpeningShift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class POSOpeningShift extends Doc {
openingAmounts?: OpeningAmounts[];
openingCash?: OpeningCash[];
openingDate?: Date;
closingShift?: string;

get openingCashAmount() {
if (!this.openingCash) {
Expand Down
6 changes: 6 additions & 0 deletions schemas/app/inventory/Point of Sale/POSClosingShift.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"fieldtype": "Table",
"label": "Closing Amounts",
"target": "ClosingAmounts"
},
{
"fieldname": "openingShift",
"fieldtype": "Link",
"label": "Opening Shift",
"target": "POSOpeningShift"
}
]
}
6 changes: 6 additions & 0 deletions schemas/app/inventory/Point of Sale/POSOpeningShift.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"fieldtype": "Table",
"label": "Opening Amounts",
"target": "OpeningAmounts"
},
{
"fieldname": "closingShift",
"fieldtype": "Link",
"label": "Closing Shift",
"target": "POSClosingShift"
}
]
}
21 changes: 20 additions & 1 deletion src/pages/POS/ClosePOSShiftModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
getPOSOpeningShiftDoc,
} from 'src/utils/pos';
import { POSClosingShift } from 'models/inventory/Point of Sale/POSClosingShift';
import { ForbiddenError } from 'fyo/utils/errors';
export default defineComponent({
name: 'ClosePOSShiftModal',
Expand All @@ -100,6 +101,11 @@ export default defineComponent({
transactedAmount: {} as Record<string, Money> | undefined,
};
},
computed: {
isOnline() {
return !!navigator.onLine;
},
},
watch: {
openModal: {
async handler() {
Expand Down Expand Up @@ -190,10 +196,23 @@ export default defineComponent({
},
async handleSubmit() {
try {
if (!this.isOnline) {
throw new ForbiddenError(
t`Device is offline. Please connect to a network to continue.`
);
}
validateClosingAmounts(this.posClosingShiftDoc as POSClosingShift);
await this.posClosingShiftDoc?.set('isShiftOpen', false);
await this.posClosingShiftDoc?.set('closingDate', new Date());
await this.posClosingShiftDoc?.set(
'openingShift',
this.posOpeningShiftDoc?.name
);
await this.posClosingShiftDoc?.sync();
await this.posOpeningShiftDoc?.setAndSync(
'closingShift',
this.posClosingShiftDoc?.name
);
await transferPOSCashAndWriteOff(
fyo,
this.posClosingShiftDoc as POSClosingShift
Expand Down

0 comments on commit bea978a

Please sign in to comment.