av6-core 1.9.0 → 1.9.1
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/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +96 -3
- package/dist/index.mjs +96 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -821,7 +821,7 @@ declare class ApprovalService {
|
|
|
821
821
|
getApprovalActDetailsBySubjectId(subjectId: number, subjectType: string, service: string): Promise<ApprovalAction[]>;
|
|
822
822
|
}
|
|
823
823
|
|
|
824
|
-
declare const approvalRepository: (
|
|
824
|
+
declare const approvalRepository: (deps: ApprovalDeps) => {
|
|
825
825
|
findMatchingFlow(tx: PrismaClient | Prisma.TransactionClient, type: string, service: string, ccId: number, netTotal: number, level?: number): Promise<RawFlowWithSelectedStepResponse | null>;
|
|
826
826
|
getAllApprovalFlow(tx: PrismaClient | Prisma.TransactionClient, { staffId, ccId, pageNo, pageSize, service, sortDir, startDate, endDate, searchText, status, flowType, }: GetMyApprovalFlow): Promise<PaginatedResponse<ApprovalInstanceByUser>>;
|
|
827
827
|
getApprovalActDetailsBySubjectId(tx: PrismaClient | Prisma.TransactionClient, { subjectId, subjectType, service }: {
|
|
@@ -829,6 +829,10 @@ declare const approvalRepository: (helpers: Helpers) => {
|
|
|
829
829
|
subjectType: string;
|
|
830
830
|
service: string;
|
|
831
831
|
}): Promise<any>;
|
|
832
|
+
commonStatusUpdate(config: IParentConfigJSON, data: ICommonApprovalUpdate): Promise<void>;
|
|
833
|
+
commonParentChildUpdate(config: IParentConfigJSON, childConfig: IChildConfigJSON | null, inst: EventInstance): Promise<void>;
|
|
834
|
+
getChildCommonDetailsByParentId(tx: PrismaClient | Prisma.TransactionClient, parentId: number, subjectType: string, service: string): Promise<any>;
|
|
835
|
+
getParentCommonDetailsByParentId(tx: PrismaClient | Prisma.TransactionClient, parentId: number, subjectType: string, service: string): Promise<any>;
|
|
832
836
|
};
|
|
833
837
|
|
|
834
838
|
declare function customOmit<T extends object, K extends keyof T>(obj: T, keys: K[]): {
|
package/dist/index.d.ts
CHANGED
|
@@ -821,7 +821,7 @@ declare class ApprovalService {
|
|
|
821
821
|
getApprovalActDetailsBySubjectId(subjectId: number, subjectType: string, service: string): Promise<ApprovalAction[]>;
|
|
822
822
|
}
|
|
823
823
|
|
|
824
|
-
declare const approvalRepository: (
|
|
824
|
+
declare const approvalRepository: (deps: ApprovalDeps) => {
|
|
825
825
|
findMatchingFlow(tx: PrismaClient | Prisma.TransactionClient, type: string, service: string, ccId: number, netTotal: number, level?: number): Promise<RawFlowWithSelectedStepResponse | null>;
|
|
826
826
|
getAllApprovalFlow(tx: PrismaClient | Prisma.TransactionClient, { staffId, ccId, pageNo, pageSize, service, sortDir, startDate, endDate, searchText, status, flowType, }: GetMyApprovalFlow): Promise<PaginatedResponse<ApprovalInstanceByUser>>;
|
|
827
827
|
getApprovalActDetailsBySubjectId(tx: PrismaClient | Prisma.TransactionClient, { subjectId, subjectType, service }: {
|
|
@@ -829,6 +829,10 @@ declare const approvalRepository: (helpers: Helpers) => {
|
|
|
829
829
|
subjectType: string;
|
|
830
830
|
service: string;
|
|
831
831
|
}): Promise<any>;
|
|
832
|
+
commonStatusUpdate(config: IParentConfigJSON, data: ICommonApprovalUpdate): Promise<void>;
|
|
833
|
+
commonParentChildUpdate(config: IParentConfigJSON, childConfig: IChildConfigJSON | null, inst: EventInstance): Promise<void>;
|
|
834
|
+
getChildCommonDetailsByParentId(tx: PrismaClient | Prisma.TransactionClient, parentId: number, subjectType: string, service: string): Promise<any>;
|
|
835
|
+
getParentCommonDetailsByParentId(tx: PrismaClient | Prisma.TransactionClient, parentId: number, subjectType: string, service: string): Promise<any>;
|
|
832
836
|
};
|
|
833
837
|
|
|
834
838
|
declare function customOmit<T extends object, K extends keyof T>(obj: T, keys: K[]): {
|
package/dist/index.js
CHANGED
|
@@ -2344,7 +2344,7 @@ var ActionMode = /* @__PURE__ */ ((ActionMode2) => {
|
|
|
2344
2344
|
|
|
2345
2345
|
// src/repository/approval.repository.ts
|
|
2346
2346
|
var import_client = require("@prisma/client");
|
|
2347
|
-
var approvalRepository = (
|
|
2347
|
+
var approvalRepository = (deps) => {
|
|
2348
2348
|
return {
|
|
2349
2349
|
async findMatchingFlow(tx, type, service, ccId, netTotal, level = 1) {
|
|
2350
2350
|
const result = await tx.$queryRaw`
|
|
@@ -2371,7 +2371,7 @@ var approvalRepository = (helpers) => {
|
|
|
2371
2371
|
LIMIT 1;
|
|
2372
2372
|
`;
|
|
2373
2373
|
if (result.length === 0) {
|
|
2374
|
-
throw new helpers.ErrorHandler(400, "No matching flow found.");
|
|
2374
|
+
throw new deps.helpers.ErrorHandler(400, "No matching flow found.");
|
|
2375
2375
|
}
|
|
2376
2376
|
return result[0];
|
|
2377
2377
|
},
|
|
@@ -2480,6 +2480,99 @@ var approvalRepository = (helpers) => {
|
|
|
2480
2480
|
isActive: true
|
|
2481
2481
|
}
|
|
2482
2482
|
});
|
|
2483
|
+
},
|
|
2484
|
+
async commonStatusUpdate(config, data) {
|
|
2485
|
+
const { tableName, ...columnMap } = config;
|
|
2486
|
+
const setFragments = Object.keys(columnMap).map((key) => {
|
|
2487
|
+
const columnName = columnMap[key] ?? "";
|
|
2488
|
+
const value = data[key] ?? null;
|
|
2489
|
+
return import_client.Prisma.sql`${import_client.Prisma.raw(columnName)} = ${value}`;
|
|
2490
|
+
});
|
|
2491
|
+
const query = import_client.Prisma.sql`
|
|
2492
|
+
UPDATE ${import_client.Prisma.raw(tableName)}
|
|
2493
|
+
SET ${import_client.Prisma.join(setFragments, ", ")}
|
|
2494
|
+
WHERE id = ${data.id};
|
|
2495
|
+
`;
|
|
2496
|
+
await deps.prisma.$queryRaw(query);
|
|
2497
|
+
},
|
|
2498
|
+
async commonParentChildUpdate(config, childConfig, inst) {
|
|
2499
|
+
deps.logger.info("entering::commonRefundUpdate::repository");
|
|
2500
|
+
const { tableName: parentTableName, ...parentTableConfig } = config;
|
|
2501
|
+
const { tableName: childTableName, ...childTableConfig } = childConfig ?? {};
|
|
2502
|
+
const parentId = inst.subjectId;
|
|
2503
|
+
await deps.prisma.$transaction(async (tx) => {
|
|
2504
|
+
const commonDetails = await this.getChildCommonDetailsByParentId(tx, parentId, inst.subjectType, inst.service);
|
|
2505
|
+
const parentDetails = await this.getParentCommonDetailsByParentId(tx, parentId, inst.subjectType, inst.service);
|
|
2506
|
+
if (!parentDetails) {
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
const parentData = {
|
|
2510
|
+
...parentDetails,
|
|
2511
|
+
approvalNote: inst.comment || null,
|
|
2512
|
+
approvedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2513
|
+
approvedBy: JSON.stringify(inst.approverId),
|
|
2514
|
+
refundAmount: parentDetails.refundAmount ? parentDetails.refundAmount.toNumber() : null,
|
|
2515
|
+
discountValue: parentDetails.discountValue ? parentDetails.discountValue.toNumber() : null,
|
|
2516
|
+
discountAmount: parentDetails.discountAmount ? parentDetails.discountAmount.toNumber() : null,
|
|
2517
|
+
totalCopaymentAmount: parentDetails.totalCopaymentAmount ? parentDetails.totalCopaymentAmount.toNumber() : null
|
|
2518
|
+
};
|
|
2519
|
+
if (childTableName) {
|
|
2520
|
+
for (const child of commonDetails) {
|
|
2521
|
+
const setFragments2 = Object.keys(childTableConfig).map((key) => {
|
|
2522
|
+
const columnName = childTableConfig[key] ?? "";
|
|
2523
|
+
const value = child[key] ?? null;
|
|
2524
|
+
return import_client.Prisma.sql`${import_client.Prisma.raw(columnName)} = ${value}`;
|
|
2525
|
+
});
|
|
2526
|
+
const query2 = import_client.Prisma.sql`
|
|
2527
|
+
UPDATE ${import_client.Prisma.raw(childTableName)}
|
|
2528
|
+
SET ${import_client.Prisma.join(setFragments2, ", ")}
|
|
2529
|
+
WHERE id = ${child.childId};
|
|
2530
|
+
`;
|
|
2531
|
+
await tx.$queryRaw(query2);
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
const setFragments = Object.keys(parentTableConfig).map((key) => {
|
|
2535
|
+
const columnName = parentTableConfig[key] ?? "";
|
|
2536
|
+
const value = parentData[key] ?? null;
|
|
2537
|
+
return import_client.Prisma.sql`${import_client.Prisma.raw(columnName)} = ${value}`;
|
|
2538
|
+
});
|
|
2539
|
+
const query = import_client.Prisma.sql`
|
|
2540
|
+
UPDATE ${import_client.Prisma.raw(parentTableName)}
|
|
2541
|
+
SET ${import_client.Prisma.join(setFragments, ", ")}
|
|
2542
|
+
WHERE id = ${parentId};
|
|
2543
|
+
`;
|
|
2544
|
+
await tx.$queryRaw(query);
|
|
2545
|
+
await tx.childCommonDetails.updateMany({
|
|
2546
|
+
where: {
|
|
2547
|
+
parentId,
|
|
2548
|
+
subjectType: inst.subjectType
|
|
2549
|
+
},
|
|
2550
|
+
data: {
|
|
2551
|
+
isActive: false
|
|
2552
|
+
}
|
|
2553
|
+
});
|
|
2554
|
+
});
|
|
2555
|
+
deps.logger.info("exiting::commonRefundUpdate::repository");
|
|
2556
|
+
},
|
|
2557
|
+
async getChildCommonDetailsByParentId(tx, parentId, subjectType, service) {
|
|
2558
|
+
return tx.childCommonDetails.findMany({
|
|
2559
|
+
where: {
|
|
2560
|
+
parentId,
|
|
2561
|
+
subjectType,
|
|
2562
|
+
service,
|
|
2563
|
+
isActive: true
|
|
2564
|
+
}
|
|
2565
|
+
});
|
|
2566
|
+
},
|
|
2567
|
+
async getParentCommonDetailsByParentId(tx, parentId, subjectType, service) {
|
|
2568
|
+
return tx.parentCommonDetails.findFirst({
|
|
2569
|
+
where: {
|
|
2570
|
+
parentId,
|
|
2571
|
+
subjectType,
|
|
2572
|
+
service,
|
|
2573
|
+
isActive: true
|
|
2574
|
+
}
|
|
2575
|
+
});
|
|
2483
2576
|
}
|
|
2484
2577
|
};
|
|
2485
2578
|
};
|
|
@@ -2503,7 +2596,7 @@ var externalInterceptor = () => {
|
|
|
2503
2596
|
var ApprovalService = class {
|
|
2504
2597
|
constructor(deps) {
|
|
2505
2598
|
this.deps = deps;
|
|
2506
|
-
this.approvalRepo = approvalRepository(deps
|
|
2599
|
+
this.approvalRepo = approvalRepository(deps);
|
|
2507
2600
|
}
|
|
2508
2601
|
deps;
|
|
2509
2602
|
approvalRepo;
|
package/dist/index.mjs
CHANGED
|
@@ -2281,7 +2281,7 @@ var ActionMode = /* @__PURE__ */ ((ActionMode2) => {
|
|
|
2281
2281
|
|
|
2282
2282
|
// src/repository/approval.repository.ts
|
|
2283
2283
|
import { Prisma } from "@prisma/client";
|
|
2284
|
-
var approvalRepository = (
|
|
2284
|
+
var approvalRepository = (deps) => {
|
|
2285
2285
|
return {
|
|
2286
2286
|
async findMatchingFlow(tx, type, service, ccId, netTotal, level = 1) {
|
|
2287
2287
|
const result = await tx.$queryRaw`
|
|
@@ -2308,7 +2308,7 @@ var approvalRepository = (helpers) => {
|
|
|
2308
2308
|
LIMIT 1;
|
|
2309
2309
|
`;
|
|
2310
2310
|
if (result.length === 0) {
|
|
2311
|
-
throw new helpers.ErrorHandler(400, "No matching flow found.");
|
|
2311
|
+
throw new deps.helpers.ErrorHandler(400, "No matching flow found.");
|
|
2312
2312
|
}
|
|
2313
2313
|
return result[0];
|
|
2314
2314
|
},
|
|
@@ -2417,6 +2417,99 @@ var approvalRepository = (helpers) => {
|
|
|
2417
2417
|
isActive: true
|
|
2418
2418
|
}
|
|
2419
2419
|
});
|
|
2420
|
+
},
|
|
2421
|
+
async commonStatusUpdate(config, data) {
|
|
2422
|
+
const { tableName, ...columnMap } = config;
|
|
2423
|
+
const setFragments = Object.keys(columnMap).map((key) => {
|
|
2424
|
+
const columnName = columnMap[key] ?? "";
|
|
2425
|
+
const value = data[key] ?? null;
|
|
2426
|
+
return Prisma.sql`${Prisma.raw(columnName)} = ${value}`;
|
|
2427
|
+
});
|
|
2428
|
+
const query = Prisma.sql`
|
|
2429
|
+
UPDATE ${Prisma.raw(tableName)}
|
|
2430
|
+
SET ${Prisma.join(setFragments, ", ")}
|
|
2431
|
+
WHERE id = ${data.id};
|
|
2432
|
+
`;
|
|
2433
|
+
await deps.prisma.$queryRaw(query);
|
|
2434
|
+
},
|
|
2435
|
+
async commonParentChildUpdate(config, childConfig, inst) {
|
|
2436
|
+
deps.logger.info("entering::commonRefundUpdate::repository");
|
|
2437
|
+
const { tableName: parentTableName, ...parentTableConfig } = config;
|
|
2438
|
+
const { tableName: childTableName, ...childTableConfig } = childConfig ?? {};
|
|
2439
|
+
const parentId = inst.subjectId;
|
|
2440
|
+
await deps.prisma.$transaction(async (tx) => {
|
|
2441
|
+
const commonDetails = await this.getChildCommonDetailsByParentId(tx, parentId, inst.subjectType, inst.service);
|
|
2442
|
+
const parentDetails = await this.getParentCommonDetailsByParentId(tx, parentId, inst.subjectType, inst.service);
|
|
2443
|
+
if (!parentDetails) {
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
const parentData = {
|
|
2447
|
+
...parentDetails,
|
|
2448
|
+
approvalNote: inst.comment || null,
|
|
2449
|
+
approvedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2450
|
+
approvedBy: JSON.stringify(inst.approverId),
|
|
2451
|
+
refundAmount: parentDetails.refundAmount ? parentDetails.refundAmount.toNumber() : null,
|
|
2452
|
+
discountValue: parentDetails.discountValue ? parentDetails.discountValue.toNumber() : null,
|
|
2453
|
+
discountAmount: parentDetails.discountAmount ? parentDetails.discountAmount.toNumber() : null,
|
|
2454
|
+
totalCopaymentAmount: parentDetails.totalCopaymentAmount ? parentDetails.totalCopaymentAmount.toNumber() : null
|
|
2455
|
+
};
|
|
2456
|
+
if (childTableName) {
|
|
2457
|
+
for (const child of commonDetails) {
|
|
2458
|
+
const setFragments2 = Object.keys(childTableConfig).map((key) => {
|
|
2459
|
+
const columnName = childTableConfig[key] ?? "";
|
|
2460
|
+
const value = child[key] ?? null;
|
|
2461
|
+
return Prisma.sql`${Prisma.raw(columnName)} = ${value}`;
|
|
2462
|
+
});
|
|
2463
|
+
const query2 = Prisma.sql`
|
|
2464
|
+
UPDATE ${Prisma.raw(childTableName)}
|
|
2465
|
+
SET ${Prisma.join(setFragments2, ", ")}
|
|
2466
|
+
WHERE id = ${child.childId};
|
|
2467
|
+
`;
|
|
2468
|
+
await tx.$queryRaw(query2);
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
const setFragments = Object.keys(parentTableConfig).map((key) => {
|
|
2472
|
+
const columnName = parentTableConfig[key] ?? "";
|
|
2473
|
+
const value = parentData[key] ?? null;
|
|
2474
|
+
return Prisma.sql`${Prisma.raw(columnName)} = ${value}`;
|
|
2475
|
+
});
|
|
2476
|
+
const query = Prisma.sql`
|
|
2477
|
+
UPDATE ${Prisma.raw(parentTableName)}
|
|
2478
|
+
SET ${Prisma.join(setFragments, ", ")}
|
|
2479
|
+
WHERE id = ${parentId};
|
|
2480
|
+
`;
|
|
2481
|
+
await tx.$queryRaw(query);
|
|
2482
|
+
await tx.childCommonDetails.updateMany({
|
|
2483
|
+
where: {
|
|
2484
|
+
parentId,
|
|
2485
|
+
subjectType: inst.subjectType
|
|
2486
|
+
},
|
|
2487
|
+
data: {
|
|
2488
|
+
isActive: false
|
|
2489
|
+
}
|
|
2490
|
+
});
|
|
2491
|
+
});
|
|
2492
|
+
deps.logger.info("exiting::commonRefundUpdate::repository");
|
|
2493
|
+
},
|
|
2494
|
+
async getChildCommonDetailsByParentId(tx, parentId, subjectType, service) {
|
|
2495
|
+
return tx.childCommonDetails.findMany({
|
|
2496
|
+
where: {
|
|
2497
|
+
parentId,
|
|
2498
|
+
subjectType,
|
|
2499
|
+
service,
|
|
2500
|
+
isActive: true
|
|
2501
|
+
}
|
|
2502
|
+
});
|
|
2503
|
+
},
|
|
2504
|
+
async getParentCommonDetailsByParentId(tx, parentId, subjectType, service) {
|
|
2505
|
+
return tx.parentCommonDetails.findFirst({
|
|
2506
|
+
where: {
|
|
2507
|
+
parentId,
|
|
2508
|
+
subjectType,
|
|
2509
|
+
service,
|
|
2510
|
+
isActive: true
|
|
2511
|
+
}
|
|
2512
|
+
});
|
|
2420
2513
|
}
|
|
2421
2514
|
};
|
|
2422
2515
|
};
|
|
@@ -2440,7 +2533,7 @@ var externalInterceptor = () => {
|
|
|
2440
2533
|
var ApprovalService = class {
|
|
2441
2534
|
constructor(deps) {
|
|
2442
2535
|
this.deps = deps;
|
|
2443
|
-
this.approvalRepo = approvalRepository(deps
|
|
2536
|
+
this.approvalRepo = approvalRepository(deps);
|
|
2444
2537
|
}
|
|
2445
2538
|
deps;
|
|
2446
2539
|
approvalRepo;
|