mirror of
https://github.com/frappe/books.git
synced 2025-01-05 08:02:15 +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:
commit
bea978a45c
@ -8,7 +8,6 @@ import {
|
|||||||
import { ModelNameEnum } from '../../models/types';
|
import { ModelNameEnum } from '../../models/types';
|
||||||
import DatabaseCore from './core';
|
import DatabaseCore from './core';
|
||||||
import { BespokeFunction } from './types';
|
import { BespokeFunction } from './types';
|
||||||
import { DateTime } from 'luxon';
|
|
||||||
import { DocItem, ReturnDocItem } from 'models/inventory/types';
|
import { DocItem, ReturnDocItem } from 'models/inventory/types';
|
||||||
import { safeParseFloat } from 'utils/index';
|
import { safeParseFloat } from 'utils/index';
|
||||||
import { Money } from 'pesa';
|
import { Money } from 'pesa';
|
||||||
@ -408,7 +407,7 @@ export class BespokeQueries {
|
|||||||
sinvNamesQuery.andWhere(
|
sinvNamesQuery.andWhere(
|
||||||
'created',
|
'created',
|
||||||
'>',
|
'>',
|
||||||
DateTime.fromJSDate(lastShiftClosingDate).toUTC().toString()
|
lastShiftClosingDate.toISOString()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ export class POSClosingShift extends Doc {
|
|||||||
closingAmounts?: ClosingAmounts[];
|
closingAmounts?: ClosingAmounts[];
|
||||||
closingCash?: ClosingCash[];
|
closingCash?: ClosingCash[];
|
||||||
closingDate?: Date;
|
closingDate?: Date;
|
||||||
|
openingShift?: string;
|
||||||
|
|
||||||
get closingCashAmount() {
|
get closingCashAmount() {
|
||||||
if (!this.closingCash) {
|
if (!this.closingCash) {
|
||||||
|
@ -7,6 +7,7 @@ export class POSOpeningShift extends Doc {
|
|||||||
openingAmounts?: OpeningAmounts[];
|
openingAmounts?: OpeningAmounts[];
|
||||||
openingCash?: OpeningCash[];
|
openingCash?: OpeningCash[];
|
||||||
openingDate?: Date;
|
openingDate?: Date;
|
||||||
|
closingShift?: string;
|
||||||
|
|
||||||
get openingCashAmount() {
|
get openingCashAmount() {
|
||||||
if (!this.openingCash) {
|
if (!this.openingCash) {
|
||||||
|
@ -19,6 +19,12 @@
|
|||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"label": "Closing Amounts",
|
"label": "Closing Amounts",
|
||||||
"target": "ClosingAmounts"
|
"target": "ClosingAmounts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "openingShift",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Opening Shift",
|
||||||
|
"target": "POSOpeningShift"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,12 @@
|
|||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"label": "Opening Amounts",
|
"label": "Opening Amounts",
|
||||||
"target": "OpeningAmounts"
|
"target": "OpeningAmounts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "closingShift",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Closing Shift",
|
||||||
|
"target": "POSClosingShift"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ import {
|
|||||||
getPOSOpeningShiftDoc,
|
getPOSOpeningShiftDoc,
|
||||||
} from 'src/utils/pos';
|
} from 'src/utils/pos';
|
||||||
import { POSClosingShift } from 'models/inventory/Point of Sale/POSClosingShift';
|
import { POSClosingShift } from 'models/inventory/Point of Sale/POSClosingShift';
|
||||||
|
import { ForbiddenError } from 'fyo/utils/errors';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'ClosePOSShiftModal',
|
name: 'ClosePOSShiftModal',
|
||||||
@ -100,6 +101,11 @@ export default defineComponent({
|
|||||||
transactedAmount: {} as Record<string, Money> | undefined,
|
transactedAmount: {} as Record<string, Money> | undefined,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isOnline() {
|
||||||
|
return !!navigator.onLine;
|
||||||
|
},
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
openModal: {
|
openModal: {
|
||||||
async handler() {
|
async handler() {
|
||||||
@ -190,10 +196,23 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
async handleSubmit() {
|
async handleSubmit() {
|
||||||
try {
|
try {
|
||||||
|
if (!this.isOnline) {
|
||||||
|
throw new ForbiddenError(
|
||||||
|
t`Device is offline. Please connect to a network to continue.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
validateClosingAmounts(this.posClosingShiftDoc as POSClosingShift);
|
validateClosingAmounts(this.posClosingShiftDoc as POSClosingShift);
|
||||||
await this.posClosingShiftDoc?.set('isShiftOpen', false);
|
|
||||||
await this.posClosingShiftDoc?.set('closingDate', new Date());
|
await this.posClosingShiftDoc?.set('closingDate', new Date());
|
||||||
|
await this.posClosingShiftDoc?.set(
|
||||||
|
'openingShift',
|
||||||
|
this.posOpeningShiftDoc?.name
|
||||||
|
);
|
||||||
await this.posClosingShiftDoc?.sync();
|
await this.posClosingShiftDoc?.sync();
|
||||||
|
await this.posOpeningShiftDoc?.setAndSync(
|
||||||
|
'closingShift',
|
||||||
|
this.posClosingShiftDoc?.name
|
||||||
|
);
|
||||||
await transferPOSCashAndWriteOff(
|
await transferPOSCashAndWriteOff(
|
||||||
fyo,
|
fyo,
|
||||||
this.posClosingShiftDoc as POSClosingShift
|
this.posClosingShiftDoc as POSClosingShift
|
||||||
|
Loading…
Reference in New Issue
Block a user