@7365admin1/module-hygiene 4.14.0 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +21 -13
- package/dist/index.js +111 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -393,6 +393,7 @@ declare function useAreaChecklistController(): {
|
|
|
393
393
|
type TSupply = {
|
|
394
394
|
_id?: ObjectId;
|
|
395
395
|
site: string | ObjectId;
|
|
396
|
+
serviceType: TServiceType;
|
|
396
397
|
name: string;
|
|
397
398
|
unitOfMeasurement: string;
|
|
398
399
|
qty: number;
|
|
@@ -401,17 +402,18 @@ type TSupply = {
|
|
|
401
402
|
updatedAt?: string;
|
|
402
403
|
deletedAt?: string;
|
|
403
404
|
};
|
|
404
|
-
type TSupplyCreate = Pick<TSupply, "site" | "name" | "unitOfMeasurement">;
|
|
405
|
+
type TSupplyCreate = Pick<TSupply, "site" | "serviceType" | "name" | "unitOfMeasurement">;
|
|
405
406
|
type TSupplyGetQuery = {
|
|
406
407
|
page?: number;
|
|
407
408
|
limit?: number;
|
|
408
409
|
search?: string;
|
|
409
|
-
} & Pick<TSupply, "site">;
|
|
410
|
+
} & Pick<TSupply, "site" | "serviceType">;
|
|
410
411
|
type TSupplyGetById = Pick<TSupply, "_id" | "name" | "unitOfMeasurement" | "qty">;
|
|
411
412
|
type TSupplyUpdate = Partial<Pick<TSupply, "name" | "unitOfMeasurement" | "qty">>;
|
|
412
413
|
declare const supplySchema: Joi.ObjectSchema<any>;
|
|
413
414
|
declare function MSupply(value: TSupplyCreate): {
|
|
414
415
|
site: string | ObjectId;
|
|
416
|
+
serviceType: ServiceType;
|
|
415
417
|
name: string;
|
|
416
418
|
unitOfMeasurement: string;
|
|
417
419
|
qty: number;
|
|
@@ -426,7 +428,7 @@ declare function useSupplyRepository(): {
|
|
|
426
428
|
createTextIndex: () => Promise<void>;
|
|
427
429
|
createUniqueIndex: () => Promise<void>;
|
|
428
430
|
createSupply: (value: TSupplyCreate, session?: ClientSession) => Promise<ObjectId>;
|
|
429
|
-
getSupplies: ({ page, limit, search, site, }: TSupplyGetQuery) => Promise<{}>;
|
|
431
|
+
getSupplies: ({ page, limit, search, site, serviceType, }: TSupplyGetQuery) => Promise<{}>;
|
|
430
432
|
getSupplyById: (_id: string | ObjectId, session?: ClientSession) => Promise<TSupplyGetById>;
|
|
431
433
|
updateSupply: (_id: string | ObjectId, value: TSupplyUpdate, session?: ClientSession) => Promise<number>;
|
|
432
434
|
deleteSupply: (_id: string | ObjectId, session?: ClientSession) => Promise<number>;
|
|
@@ -443,6 +445,7 @@ declare function useSupplyController(): {
|
|
|
443
445
|
type TStock = {
|
|
444
446
|
_id?: ObjectId;
|
|
445
447
|
site: string | ObjectId;
|
|
448
|
+
serviceType: TServiceType;
|
|
446
449
|
supply: string | ObjectId;
|
|
447
450
|
in?: number;
|
|
448
451
|
out?: number;
|
|
@@ -453,18 +456,19 @@ type TStock = {
|
|
|
453
456
|
updatedAt?: string;
|
|
454
457
|
deletedAt?: string;
|
|
455
458
|
};
|
|
456
|
-
type TStockCreate = Pick<TStock, "site" | "supply" | "in" | "out" | "balance" | "remarks">;
|
|
457
|
-
type TStockCreateService = Pick<TStock, "site" | "supply" | "remarks"> & {
|
|
459
|
+
type TStockCreate = Pick<TStock, "site" | "serviceType" | "supply" | "in" | "out" | "balance" | "remarks">;
|
|
460
|
+
type TStockCreateService = Pick<TStock, "site" | "serviceType" | "supply" | "remarks"> & {
|
|
458
461
|
qty: number;
|
|
459
462
|
};
|
|
460
463
|
type TGetStocksQuery = {
|
|
461
464
|
page?: number;
|
|
462
465
|
limit?: number;
|
|
463
466
|
search?: string;
|
|
464
|
-
} & Pick<TStock, "site" | "supply">;
|
|
467
|
+
} & Pick<TStock, "site" | "serviceType" | "supply">;
|
|
465
468
|
declare const stockSchema: Joi.ObjectSchema<any>;
|
|
466
469
|
declare function MStock(value: TStockCreate): {
|
|
467
470
|
site: string | ObjectId;
|
|
471
|
+
serviceType: ServiceType;
|
|
468
472
|
supply: string | ObjectId;
|
|
469
473
|
in: number;
|
|
470
474
|
out: number;
|
|
@@ -479,7 +483,7 @@ declare function MStock(value: TStockCreate): {
|
|
|
479
483
|
declare function useStockRepository(): {
|
|
480
484
|
createIndex: () => Promise<void>;
|
|
481
485
|
createStock: (value: TStockCreate, session?: ClientSession) => Promise<ObjectId>;
|
|
482
|
-
getStocksBySupplyId: ({ page, limit, search, site, supply, }: TGetStocksQuery) => Promise<{}>;
|
|
486
|
+
getStocksBySupplyId: ({ page, limit, search, site, serviceType, supply, }: TGetStocksQuery) => Promise<{}>;
|
|
483
487
|
};
|
|
484
488
|
|
|
485
489
|
declare function useStockService(): {
|
|
@@ -495,6 +499,7 @@ declare const allowedCheckOutItemStatus: string[];
|
|
|
495
499
|
type TCheckOutItem = {
|
|
496
500
|
_id?: ObjectId;
|
|
497
501
|
site: string | ObjectId;
|
|
502
|
+
serviceType: TServiceType;
|
|
498
503
|
supply: string | ObjectId;
|
|
499
504
|
supplyName: string;
|
|
500
505
|
qty: number;
|
|
@@ -506,22 +511,23 @@ type TCheckOutItem = {
|
|
|
506
511
|
updatedAt?: string;
|
|
507
512
|
deletedAt?: string;
|
|
508
513
|
};
|
|
509
|
-
type TCheckOutItemCreate = Pick<TCheckOutItem, "site" | "supply" | "supplyName" | "qty" | "attachment" | "createdBy" | "createdByName">;
|
|
510
|
-
type TCheckOutItemCreateService = Pick<TCheckOutItem, "site" | "supply" | "qty" | "attachment" | "createdBy">;
|
|
511
|
-
type TCheckOutItemCreateByBatchService = Pick<TCheckOutItem, "site" | "createdBy"> & {
|
|
514
|
+
type TCheckOutItemCreate = Pick<TCheckOutItem, "site" | "serviceType" | "supply" | "supplyName" | "qty" | "attachment" | "createdBy" | "createdByName">;
|
|
515
|
+
type TCheckOutItemCreateService = Pick<TCheckOutItem, "site" | "serviceType" | "supply" | "qty" | "attachment" | "createdBy">;
|
|
516
|
+
type TCheckOutItemCreateByBatchService = Pick<TCheckOutItem, "site" | "serviceType" | "createdBy"> & {
|
|
512
517
|
items: Pick<TCheckOutItem, "supply" | "qty" | "attachment">[];
|
|
513
518
|
};
|
|
514
519
|
type TCheckOutItemGetQuery = {
|
|
515
520
|
page?: number;
|
|
516
521
|
limit?: number;
|
|
517
522
|
search?: string;
|
|
518
|
-
} & Pick<TCheckOutItem, "site">;
|
|
519
|
-
type TCheckOutItemGetById = Pick<TCheckOutItem, "_id" | "site" | "supply" | "supplyName" | "qty" | "status"> & {
|
|
523
|
+
} & Pick<TCheckOutItem, "site" | "serviceType">;
|
|
524
|
+
type TCheckOutItemGetById = Pick<TCheckOutItem, "_id" | "site" | "serviceType" | "supply" | "supplyName" | "qty" | "status"> & {
|
|
520
525
|
unitOfMeasurement?: string;
|
|
521
526
|
};
|
|
522
527
|
declare const checkOutItemSchema: Joi.ObjectSchema<any>;
|
|
523
528
|
declare function MCheckOutItem(value: TCheckOutItemCreate): {
|
|
524
529
|
site: string | ObjectId;
|
|
530
|
+
serviceType: ServiceType;
|
|
525
531
|
supply: string | ObjectId;
|
|
526
532
|
supplyName: string;
|
|
527
533
|
qty: number;
|
|
@@ -538,7 +544,7 @@ declare function useCheckOutItemRepository(): {
|
|
|
538
544
|
createIndex: () => Promise<void>;
|
|
539
545
|
createTextIndex: () => Promise<void>;
|
|
540
546
|
createCheckOutItem: (value: TCheckOutItemCreate, session?: ClientSession) => Promise<ObjectId>;
|
|
541
|
-
getCheckOutItems: ({ page, limit, search, site, }: TCheckOutItemGetQuery) => Promise<{}>;
|
|
547
|
+
getCheckOutItems: ({ page, limit, search, site, serviceType, }: TCheckOutItemGetQuery) => Promise<{}>;
|
|
542
548
|
getCheckOutItemById: (_id: string | ObjectId, session?: ClientSession) => Promise<TCheckOutItemGetById>;
|
|
543
549
|
completeCheckOutItem: (_id: string | ObjectId, session?: ClientSession) => Promise<number>;
|
|
544
550
|
};
|
|
@@ -608,6 +614,7 @@ declare function useScheduleTaskRepository(): {
|
|
|
608
614
|
getAllScheduleTask: () => Promise<TScheduleTask[]>;
|
|
609
615
|
getScheduleTaskById: (_id: string | ObjectId, session?: ClientSession) => Promise<TScheduleTaskGetById>;
|
|
610
616
|
updateScheduleTask: (_id: string | ObjectId, value: TScheduleTaskUpdate, session?: ClientSession) => Promise<number>;
|
|
617
|
+
deleteScheduleTask: (_id: string | ObjectId, session?: ClientSession) => Promise<number>;
|
|
611
618
|
};
|
|
612
619
|
|
|
613
620
|
declare function useScheduleTaskService(): {
|
|
@@ -628,6 +635,7 @@ declare function useScheduleTaskController(): {
|
|
|
628
635
|
getScheduleTasks: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
629
636
|
getScheduleTaskById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
630
637
|
updateScheduleTask: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
638
|
+
deleteScheduleTask: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
631
639
|
};
|
|
632
640
|
|
|
633
641
|
declare function useQRService(): {
|
package/dist/index.js
CHANGED
|
@@ -4735,6 +4735,7 @@ var import_mongodb12 = require("mongodb");
|
|
|
4735
4735
|
var import_node_server_utils21 = require("@7365admin1/node-server-utils");
|
|
4736
4736
|
var supplySchema = import_joi10.default.object({
|
|
4737
4737
|
site: import_joi10.default.string().hex().required(),
|
|
4738
|
+
serviceType: import_joi10.default.string().valid(...Object.values(ServiceType)).required(),
|
|
4738
4739
|
name: import_joi10.default.string().required(),
|
|
4739
4740
|
unitOfMeasurement: import_joi10.default.string().required()
|
|
4740
4741
|
});
|
|
@@ -4753,6 +4754,7 @@ function MSupply(value) {
|
|
|
4753
4754
|
}
|
|
4754
4755
|
return {
|
|
4755
4756
|
site: value.site,
|
|
4757
|
+
serviceType: value.serviceType,
|
|
4756
4758
|
name: value.name,
|
|
4757
4759
|
unitOfMeasurement: value.unitOfMeasurement,
|
|
4758
4760
|
qty: 0,
|
|
@@ -4776,7 +4778,10 @@ function useSupplyRepository() {
|
|
|
4776
4778
|
const { delNamespace, setCache, getCache } = (0, import_node_server_utils22.useCache)(namespace_collection);
|
|
4777
4779
|
async function createIndex() {
|
|
4778
4780
|
try {
|
|
4779
|
-
await collection.createIndexes([
|
|
4781
|
+
await collection.createIndexes([
|
|
4782
|
+
{ key: { site: 1 } },
|
|
4783
|
+
{ key: { serviceType: 1 } }
|
|
4784
|
+
]);
|
|
4780
4785
|
} catch (error) {
|
|
4781
4786
|
throw new import_node_server_utils22.InternalServerError(
|
|
4782
4787
|
"Failed to create index on hygiene supply."
|
|
@@ -4829,15 +4834,18 @@ function useSupplyRepository() {
|
|
|
4829
4834
|
page = 1,
|
|
4830
4835
|
limit = 10,
|
|
4831
4836
|
search = "",
|
|
4832
|
-
site
|
|
4837
|
+
site,
|
|
4838
|
+
serviceType
|
|
4833
4839
|
}) {
|
|
4834
4840
|
page = page > 0 ? page - 1 : 0;
|
|
4835
4841
|
const query = {
|
|
4836
|
-
status: { $ne: "deleted" }
|
|
4842
|
+
status: { $ne: "deleted" },
|
|
4843
|
+
serviceType
|
|
4837
4844
|
};
|
|
4838
4845
|
const cacheOptions = {
|
|
4839
4846
|
page,
|
|
4840
|
-
limit
|
|
4847
|
+
limit,
|
|
4848
|
+
serviceType
|
|
4841
4849
|
};
|
|
4842
4850
|
try {
|
|
4843
4851
|
site = new import_mongodb13.ObjectId(site);
|
|
@@ -5041,7 +5049,8 @@ function useSupplyController() {
|
|
|
5041
5049
|
page: import_joi11.default.number().min(1).optional().allow("", null),
|
|
5042
5050
|
limit: import_joi11.default.number().min(1).optional().allow("", null),
|
|
5043
5051
|
search: import_joi11.default.string().optional().allow("", null),
|
|
5044
|
-
site: import_joi11.default.string().hex().required()
|
|
5052
|
+
site: import_joi11.default.string().hex().required(),
|
|
5053
|
+
serviceType: import_joi11.default.string().valid(...Object.values(ServiceType)).required()
|
|
5045
5054
|
});
|
|
5046
5055
|
const { error } = validation.validate(query);
|
|
5047
5056
|
if (error) {
|
|
@@ -5053,12 +5062,14 @@ function useSupplyController() {
|
|
|
5053
5062
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
5054
5063
|
const search = req.query.search ?? "";
|
|
5055
5064
|
const site = req.params.site ?? "";
|
|
5065
|
+
const serviceType = req.query.serviceType ?? "";
|
|
5056
5066
|
try {
|
|
5057
5067
|
const data = await _getSupplies({
|
|
5058
5068
|
page,
|
|
5059
5069
|
limit,
|
|
5060
5070
|
search,
|
|
5061
|
-
site
|
|
5071
|
+
site,
|
|
5072
|
+
serviceType
|
|
5062
5073
|
});
|
|
5063
5074
|
res.json(data);
|
|
5064
5075
|
return;
|
|
@@ -5114,10 +5125,8 @@ function useSupplyController() {
|
|
|
5114
5125
|
}
|
|
5115
5126
|
async function deleteSupply(req, res, next) {
|
|
5116
5127
|
const id = req.params.id;
|
|
5117
|
-
const validation = import_joi11.default.
|
|
5118
|
-
|
|
5119
|
-
});
|
|
5120
|
-
const { error, value } = validation.validate({ id });
|
|
5128
|
+
const validation = import_joi11.default.string().hex().required();
|
|
5129
|
+
const { error, value } = validation.validate(id);
|
|
5121
5130
|
if (error) {
|
|
5122
5131
|
import_node_server_utils23.logger.log({ level: "error", message: error.message });
|
|
5123
5132
|
next(new import_node_server_utils23.BadRequestError(error.message));
|
|
@@ -5148,6 +5157,7 @@ var import_mongodb14 = require("mongodb");
|
|
|
5148
5157
|
var import_node_server_utils24 = require("@7365admin1/node-server-utils");
|
|
5149
5158
|
var stockSchema = import_joi12.default.object({
|
|
5150
5159
|
site: import_joi12.default.string().hex().required(),
|
|
5160
|
+
serviceType: import_joi12.default.string().valid(...Object.values(ServiceType)).required(),
|
|
5151
5161
|
supply: import_joi12.default.string().hex().required(),
|
|
5152
5162
|
in: import_joi12.default.number().min(0).optional(),
|
|
5153
5163
|
out: import_joi12.default.number().min(0).optional(),
|
|
@@ -5176,6 +5186,7 @@ function MStock(value) {
|
|
|
5176
5186
|
}
|
|
5177
5187
|
return {
|
|
5178
5188
|
site: value.site,
|
|
5189
|
+
serviceType: value.serviceType,
|
|
5179
5190
|
supply: value.supply,
|
|
5180
5191
|
in: value.in ?? 0,
|
|
5181
5192
|
out: value.out ?? 0,
|
|
@@ -5205,6 +5216,7 @@ function useStockRepository() {
|
|
|
5205
5216
|
try {
|
|
5206
5217
|
await collection.createIndexes([
|
|
5207
5218
|
{ key: { site: 1 } },
|
|
5219
|
+
{ key: { serviceType: 1 } },
|
|
5208
5220
|
{ key: { supply: 1 } },
|
|
5209
5221
|
{ key: { balance: 1 } },
|
|
5210
5222
|
{ key: { status: 1 } }
|
|
@@ -5243,15 +5255,18 @@ function useStockRepository() {
|
|
|
5243
5255
|
limit = 10,
|
|
5244
5256
|
search = "",
|
|
5245
5257
|
site,
|
|
5258
|
+
serviceType,
|
|
5246
5259
|
supply
|
|
5247
5260
|
}) {
|
|
5248
5261
|
page = page > 0 ? page - 1 : 0;
|
|
5249
5262
|
const query = {
|
|
5250
|
-
status: { $ne: "deleted" }
|
|
5263
|
+
status: { $ne: "deleted" },
|
|
5264
|
+
serviceType
|
|
5251
5265
|
};
|
|
5252
5266
|
const cacheOptions = {
|
|
5253
5267
|
page,
|
|
5254
|
-
limit
|
|
5268
|
+
limit,
|
|
5269
|
+
serviceType
|
|
5255
5270
|
};
|
|
5256
5271
|
try {
|
|
5257
5272
|
site = new import_mongodb15.ObjectId(site);
|
|
@@ -5371,6 +5386,7 @@ function useStockController() {
|
|
|
5371
5386
|
const payload = { ...req.body, ...req.params };
|
|
5372
5387
|
const validation = import_joi13.default.object({
|
|
5373
5388
|
site: import_joi13.default.string().hex().required(),
|
|
5389
|
+
serviceType: import_joi13.default.string().valid(...Object.values(ServiceType)).required(),
|
|
5374
5390
|
supply: import_joi13.default.string().hex().required(),
|
|
5375
5391
|
qty: import_joi13.default.number().min(0).required(),
|
|
5376
5392
|
remarks: import_joi13.default.string().optional().allow("", null)
|
|
@@ -5398,6 +5414,7 @@ function useStockController() {
|
|
|
5398
5414
|
limit: import_joi13.default.number().min(1).optional().allow("", null),
|
|
5399
5415
|
search: import_joi13.default.string().optional().allow("", null),
|
|
5400
5416
|
site: import_joi13.default.string().hex().required(),
|
|
5417
|
+
serviceType: import_joi13.default.string().valid(...Object.values(ServiceType)).required(),
|
|
5401
5418
|
supply: import_joi13.default.string().hex().required()
|
|
5402
5419
|
});
|
|
5403
5420
|
const { error } = validation.validate(query);
|
|
@@ -5410,6 +5427,7 @@ function useStockController() {
|
|
|
5410
5427
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
5411
5428
|
const search = req.query.search ?? "";
|
|
5412
5429
|
const site = req.params.site ?? "";
|
|
5430
|
+
const serviceType = req.query.serviceType ?? "";
|
|
5413
5431
|
const supply = req.params.supply ?? "";
|
|
5414
5432
|
try {
|
|
5415
5433
|
const data = await _getStocksBySupplyId({
|
|
@@ -5417,6 +5435,7 @@ function useStockController() {
|
|
|
5417
5435
|
limit,
|
|
5418
5436
|
search,
|
|
5419
5437
|
site,
|
|
5438
|
+
serviceType,
|
|
5420
5439
|
supply
|
|
5421
5440
|
});
|
|
5422
5441
|
res.json(data);
|
|
@@ -5440,6 +5459,7 @@ var import_node_server_utils28 = require("@7365admin1/node-server-utils");
|
|
|
5440
5459
|
var allowedCheckOutItemStatus = ["pending", "completed"];
|
|
5441
5460
|
var checkOutItemSchema = import_joi14.default.object({
|
|
5442
5461
|
site: import_joi14.default.string().hex().required(),
|
|
5462
|
+
serviceType: import_joi14.default.string().valid(...Object.values(ServiceType)).required(),
|
|
5443
5463
|
supply: import_joi14.default.string().hex().required(),
|
|
5444
5464
|
supplyName: import_joi14.default.string().required(),
|
|
5445
5465
|
qty: import_joi14.default.number().min(0).required(),
|
|
@@ -5469,6 +5489,7 @@ function MCheckOutItem(value) {
|
|
|
5469
5489
|
}
|
|
5470
5490
|
return {
|
|
5471
5491
|
site: value.site,
|
|
5492
|
+
serviceType: value.serviceType,
|
|
5472
5493
|
supply: value.supply,
|
|
5473
5494
|
supplyName: value.supplyName,
|
|
5474
5495
|
qty: value.qty,
|
|
@@ -5497,6 +5518,7 @@ function useCheckOutItemRepository() {
|
|
|
5497
5518
|
try {
|
|
5498
5519
|
await collection.createIndexes([
|
|
5499
5520
|
{ key: { site: 1 } },
|
|
5521
|
+
{ key: { serviceType: 1 } },
|
|
5500
5522
|
{ key: { supply: 1 } },
|
|
5501
5523
|
{ key: { status: 1 } }
|
|
5502
5524
|
]);
|
|
@@ -5536,15 +5558,18 @@ function useCheckOutItemRepository() {
|
|
|
5536
5558
|
page = 1,
|
|
5537
5559
|
limit = 10,
|
|
5538
5560
|
search = "",
|
|
5539
|
-
site
|
|
5561
|
+
site,
|
|
5562
|
+
serviceType
|
|
5540
5563
|
}) {
|
|
5541
5564
|
page = page > 0 ? page - 1 : 0;
|
|
5542
5565
|
const query = {
|
|
5543
|
-
status: { $ne: "deleted" }
|
|
5566
|
+
status: { $ne: "deleted" },
|
|
5567
|
+
serviceType
|
|
5544
5568
|
};
|
|
5545
5569
|
const cacheOptions = {
|
|
5546
5570
|
page,
|
|
5547
|
-
limit
|
|
5571
|
+
limit,
|
|
5572
|
+
serviceType
|
|
5548
5573
|
};
|
|
5549
5574
|
try {
|
|
5550
5575
|
site = new import_mongodb17.ObjectId(site);
|
|
@@ -5658,6 +5683,7 @@ function useCheckOutItemRepository() {
|
|
|
5658
5683
|
{
|
|
5659
5684
|
$project: {
|
|
5660
5685
|
site: 1,
|
|
5686
|
+
serviceType: 1,
|
|
5661
5687
|
supply: 1,
|
|
5662
5688
|
supplyName: 1,
|
|
5663
5689
|
qty: 1,
|
|
@@ -5760,6 +5786,7 @@ function useCheckOutItemService() {
|
|
|
5760
5786
|
const createdStocks = await createStock(
|
|
5761
5787
|
{
|
|
5762
5788
|
site: checkOutItem.site.toString(),
|
|
5789
|
+
serviceType: checkOutItem.serviceType,
|
|
5763
5790
|
supply: checkOutItem.supply.toString(),
|
|
5764
5791
|
qty: checkOutItem.qty
|
|
5765
5792
|
},
|
|
@@ -5780,7 +5807,7 @@ function useCheckOutItemService() {
|
|
|
5780
5807
|
const session = import_node_server_utils30.useAtlas.getClient()?.startSession();
|
|
5781
5808
|
try {
|
|
5782
5809
|
session?.startTransaction();
|
|
5783
|
-
const { site, createdBy, items } = value;
|
|
5810
|
+
const { site, serviceType, createdBy, items } = value;
|
|
5784
5811
|
const createdByData = await getUserById(createdBy);
|
|
5785
5812
|
const createdCheckOutItemIds = [];
|
|
5786
5813
|
for (const item of items) {
|
|
@@ -5788,6 +5815,7 @@ function useCheckOutItemService() {
|
|
|
5788
5815
|
const createdId = await _createCheckOutItem(
|
|
5789
5816
|
{
|
|
5790
5817
|
site,
|
|
5818
|
+
serviceType,
|
|
5791
5819
|
supply: item.supply,
|
|
5792
5820
|
supplyName: supplyData?.name || "",
|
|
5793
5821
|
qty: item.qty,
|
|
@@ -5800,6 +5828,7 @@ function useCheckOutItemService() {
|
|
|
5800
5828
|
await createStock(
|
|
5801
5829
|
{
|
|
5802
5830
|
site,
|
|
5831
|
+
serviceType,
|
|
5803
5832
|
supply: item.supply,
|
|
5804
5833
|
qty: item.qty
|
|
5805
5834
|
},
|
|
@@ -5848,6 +5877,7 @@ function useCheckOutItemController() {
|
|
|
5848
5877
|
};
|
|
5849
5878
|
const validation = import_joi15.default.object({
|
|
5850
5879
|
site: import_joi15.default.string().hex().required(),
|
|
5880
|
+
serviceType: import_joi15.default.string().valid(...Object.values(ServiceType)).required(),
|
|
5851
5881
|
supply: import_joi15.default.string().hex().required(),
|
|
5852
5882
|
qty: import_joi15.default.number().min(0).required(),
|
|
5853
5883
|
attachment: import_joi15.default.array().items(import_joi15.default.string()).optional().allow(null),
|
|
@@ -5882,6 +5912,7 @@ function useCheckOutItemController() {
|
|
|
5882
5912
|
};
|
|
5883
5913
|
const validation = import_joi15.default.object({
|
|
5884
5914
|
site: import_joi15.default.string().hex().required(),
|
|
5915
|
+
serviceType: import_joi15.default.string().valid(...Object.values(ServiceType)).required(),
|
|
5885
5916
|
createdBy: import_joi15.default.string().hex().required(),
|
|
5886
5917
|
items: import_joi15.default.array().items(
|
|
5887
5918
|
import_joi15.default.object({
|
|
@@ -5913,7 +5944,8 @@ function useCheckOutItemController() {
|
|
|
5913
5944
|
page: import_joi15.default.number().min(1).optional().allow("", null),
|
|
5914
5945
|
limit: import_joi15.default.number().min(1).optional().allow("", null),
|
|
5915
5946
|
search: import_joi15.default.string().optional().allow("", null),
|
|
5916
|
-
site: import_joi15.default.string().hex().required()
|
|
5947
|
+
site: import_joi15.default.string().hex().required(),
|
|
5948
|
+
serviceType: import_joi15.default.string().valid(...Object.values(ServiceType)).required()
|
|
5917
5949
|
});
|
|
5918
5950
|
const { error } = validation.validate(query);
|
|
5919
5951
|
if (error) {
|
|
@@ -5925,12 +5957,14 @@ function useCheckOutItemController() {
|
|
|
5925
5957
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
5926
5958
|
const search = req.query.search ?? "";
|
|
5927
5959
|
const site = req.params.site ?? "";
|
|
5960
|
+
const serviceType = req.query.serviceType ?? "";
|
|
5928
5961
|
try {
|
|
5929
5962
|
const data = await _getCheckOutItems({
|
|
5930
5963
|
page,
|
|
5931
5964
|
limit,
|
|
5932
5965
|
search,
|
|
5933
|
-
site
|
|
5966
|
+
site,
|
|
5967
|
+
serviceType
|
|
5934
5968
|
});
|
|
5935
5969
|
res.json(data);
|
|
5936
5970
|
return;
|
|
@@ -6111,7 +6145,7 @@ function useScheduleTaskRepository() {
|
|
|
6111
6145
|
throw new import_node_server_utils33.BadRequestError("Invalid site ID format.");
|
|
6112
6146
|
}
|
|
6113
6147
|
if (search) {
|
|
6114
|
-
query.$or = [{
|
|
6148
|
+
query.$or = [{ title: { $regex: search, $options: "i" } }];
|
|
6115
6149
|
cacheOptions.search = search;
|
|
6116
6150
|
}
|
|
6117
6151
|
const cacheKey = (0, import_node_server_utils33.makeCacheKey)(namespace_collection, cacheOptions);
|
|
@@ -6250,6 +6284,39 @@ function useScheduleTaskRepository() {
|
|
|
6250
6284
|
throw error;
|
|
6251
6285
|
}
|
|
6252
6286
|
}
|
|
6287
|
+
async function deleteScheduleTask(_id, session) {
|
|
6288
|
+
try {
|
|
6289
|
+
_id = new import_mongodb19.ObjectId(_id);
|
|
6290
|
+
} catch (error) {
|
|
6291
|
+
throw new import_node_server_utils33.BadRequestError("Invalid schedule task ID format.");
|
|
6292
|
+
}
|
|
6293
|
+
try {
|
|
6294
|
+
const updateValue = {
|
|
6295
|
+
status: "deleted",
|
|
6296
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
6297
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
6298
|
+
};
|
|
6299
|
+
const res = await collection.updateOne(
|
|
6300
|
+
{ _id },
|
|
6301
|
+
{ $set: updateValue },
|
|
6302
|
+
{ session }
|
|
6303
|
+
);
|
|
6304
|
+
if (res.modifiedCount === 0) {
|
|
6305
|
+
throw new import_node_server_utils33.InternalServerError("Unable to delete schedule task.");
|
|
6306
|
+
}
|
|
6307
|
+
delNamespace().then(() => {
|
|
6308
|
+
import_node_server_utils33.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
6309
|
+
}).catch((err) => {
|
|
6310
|
+
import_node_server_utils33.logger.error(
|
|
6311
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
6312
|
+
err
|
|
6313
|
+
);
|
|
6314
|
+
});
|
|
6315
|
+
return res.modifiedCount;
|
|
6316
|
+
} catch (error) {
|
|
6317
|
+
throw error;
|
|
6318
|
+
}
|
|
6319
|
+
}
|
|
6253
6320
|
return {
|
|
6254
6321
|
createIndex,
|
|
6255
6322
|
createTextIndex,
|
|
@@ -6257,7 +6324,8 @@ function useScheduleTaskRepository() {
|
|
|
6257
6324
|
getScheduleTasks,
|
|
6258
6325
|
getAllScheduleTask,
|
|
6259
6326
|
getScheduleTaskById,
|
|
6260
|
-
updateScheduleTask
|
|
6327
|
+
updateScheduleTask,
|
|
6328
|
+
deleteScheduleTask
|
|
6261
6329
|
};
|
|
6262
6330
|
}
|
|
6263
6331
|
|
|
@@ -6560,7 +6628,8 @@ function useScheduleTaskController() {
|
|
|
6560
6628
|
createScheduleTask: _createScheduleTask,
|
|
6561
6629
|
getScheduleTasks: _getScheduleTasks,
|
|
6562
6630
|
getScheduleTaskById: _getScheduleTaskById,
|
|
6563
|
-
updateScheduleTask: _updateScheduleTask
|
|
6631
|
+
updateScheduleTask: _updateScheduleTask,
|
|
6632
|
+
deleteScheduleTask: _deleteScheduleTask
|
|
6564
6633
|
} = useScheduleTaskRepository();
|
|
6565
6634
|
async function createScheduleTask(req, res, next) {
|
|
6566
6635
|
const cookies = req.headers.cookie ? req.headers.cookie.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
@@ -6674,11 +6743,31 @@ function useScheduleTaskController() {
|
|
|
6674
6743
|
return;
|
|
6675
6744
|
}
|
|
6676
6745
|
}
|
|
6746
|
+
async function deleteScheduleTask(req, res, next) {
|
|
6747
|
+
const validation = import_joi17.default.string().hex().required();
|
|
6748
|
+
const _id = req.params.id;
|
|
6749
|
+
const { error, value } = validation.validate(_id);
|
|
6750
|
+
if (error) {
|
|
6751
|
+
import_node_server_utils35.logger.log({ level: "error", message: error.message });
|
|
6752
|
+
next(new import_node_server_utils35.BadRequestError(error.message));
|
|
6753
|
+
return;
|
|
6754
|
+
}
|
|
6755
|
+
try {
|
|
6756
|
+
const data = await _deleteScheduleTask(value);
|
|
6757
|
+
res.json(data);
|
|
6758
|
+
return;
|
|
6759
|
+
} catch (error2) {
|
|
6760
|
+
import_node_server_utils35.logger.log({ level: "error", message: error2.message });
|
|
6761
|
+
next(error2);
|
|
6762
|
+
return;
|
|
6763
|
+
}
|
|
6764
|
+
}
|
|
6677
6765
|
return {
|
|
6678
6766
|
createScheduleTask,
|
|
6679
6767
|
getScheduleTasks,
|
|
6680
6768
|
getScheduleTaskById,
|
|
6681
|
-
updateScheduleTask
|
|
6769
|
+
updateScheduleTask,
|
|
6770
|
+
deleteScheduleTask
|
|
6682
6771
|
};
|
|
6683
6772
|
}
|
|
6684
6773
|
|