2
0
mirror of https://github.com/frappe/books.git synced 2025-01-02 22:50:14 +00:00

Merge pull request #1073 from frappe/link-pos-shifts

feat: mention pos shift closing and opening in each documents
This commit is contained in:
Akshay 2024-12-30 11:15:55 +05:30 committed by GitHub
commit bea978a45c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 35 additions and 3 deletions

View File

@ -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';
@ -408,7 +407,7 @@ export class BespokeQueries {
sinvNamesQuery.andWhere(
'created',
'>',
DateTime.fromJSDate(lastShiftClosingDate).toUTC().toString()
lastShiftClosingDate.toISOString()
);
}

View File

@ -7,6 +7,7 @@ export class POSClosingShift extends Doc {
closingAmounts?: ClosingAmounts[];
closingCash?: ClosingCash[];
closingDate?: Date;
openingShift?: string;
get closingCashAmount() {
if (!this.closingCash) {

View File

@ -7,6 +7,7 @@ export class POSOpeningShift extends Doc {
openingAmounts?: OpeningAmounts[];
openingCash?: OpeningCash[];
openingDate?: Date;
closingShift?: string;
get openingCashAmount() {
if (!this.openingCash) {

View File

@ -19,6 +19,12 @@
"fieldtype": "Table",
"label": "Closing Amounts",
"target": "ClosingAmounts"
},
{
"fieldname": "openingShift",
"fieldtype": "Link",
"label": "Opening Shift",
"target": "POSOpeningShift"
}
]
}

View File

@ -19,6 +19,12 @@
"fieldtype": "Table",
"label": "Opening Amounts",
"target": "OpeningAmounts"
},
{
"fieldname": "closingShift",
"fieldtype": "Link",
"label": "Closing Shift",
"target": "POSClosingShift"
}
]
}

View File

@ -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',
@ -100,6 +101,11 @@ export default defineComponent({
transactedAmount: {} as Record<string, Money> | undefined,
};
},
computed: {
isOnline() {
return !!navigator.onLine;
},
},
watch: {
openModal: {
async handler() {
@ -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