av6-core 2.0.3 → 2.0.5

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 CHANGED
@@ -692,6 +692,7 @@ interface StartFlowReq {
692
692
  ccId: number;
693
693
  refNo: string;
694
694
  level?: number;
695
+ createdBy: number;
695
696
  extra?: Record<string, string | number | boolean | null>;
696
697
  }
697
698
  interface NotificationEvent {
@@ -829,7 +830,7 @@ declare class ApprovalService {
829
830
  private approvalRepo;
830
831
  private prisma;
831
832
  constructor(deps: ApprovalDeps);
832
- startFlow(tx: PrismaClient | PrismaTransactionClient, { service, subjectType, subjectId, netTotal, ccId, refNo, level, extra }: StartFlowReq): Promise<void>;
833
+ startFlow(tx: PrismaClient | PrismaTransactionClient, { service, subjectType, subjectId, netTotal, ccId, refNo, level, extra, createdBy }: StartFlowReq): Promise<void>;
833
834
  lastLevel(steps: ApprovalStep[]): Promise<number>;
834
835
  /** Approver clicks “Approve” or “Reject”. */
835
836
  act({ instanceId, approverId, action, ccId, comment }: ActInput): Promise<any>;
package/dist/index.d.ts CHANGED
@@ -692,6 +692,7 @@ interface StartFlowReq {
692
692
  ccId: number;
693
693
  refNo: string;
694
694
  level?: number;
695
+ createdBy: number;
695
696
  extra?: Record<string, string | number | boolean | null>;
696
697
  }
697
698
  interface NotificationEvent {
@@ -829,7 +830,7 @@ declare class ApprovalService {
829
830
  private approvalRepo;
830
831
  private prisma;
831
832
  constructor(deps: ApprovalDeps);
832
- startFlow(tx: PrismaClient | PrismaTransactionClient, { service, subjectType, subjectId, netTotal, ccId, refNo, level, extra }: StartFlowReq): Promise<void>;
833
+ startFlow(tx: PrismaClient | PrismaTransactionClient, { service, subjectType, subjectId, netTotal, ccId, refNo, level, extra, createdBy }: StartFlowReq): Promise<void>;
833
834
  lastLevel(steps: ApprovalStep[]): Promise<number>;
834
835
  /** Approver clicks “Approve” or “Reject”. */
835
836
  act({ instanceId, approverId, action, ccId, comment }: ActInput): Promise<any>;
package/dist/index.js CHANGED
@@ -2486,7 +2486,7 @@ var approvalRepository = (deps) => {
2486
2486
  ( cam.staff_id = ${staffId} or scc.staff_id = ${staffId} )
2487
2487
  and cai.status in (${import_client.Prisma.join(status)})
2488
2488
  and LOWER(cai.service) like LOWER(${serviceLike})
2489
- and LOWER(cai.ref_no) like LOWER(${pattern})
2489
+ and (LOWER(cai.ref_no) like LOWER(${pattern}) or LOWER(cai.extra) like LOWER(${pattern}) )
2490
2490
  and cam.cc_id = ${ccId}
2491
2491
  and cai.is_active = 1
2492
2492
  and cas.is_active = 1
@@ -2680,9 +2680,9 @@ var ApprovalService = class {
2680
2680
  deps;
2681
2681
  approvalRepo;
2682
2682
  prisma;
2683
- async startFlow(tx, { service, subjectType, subjectId, netTotal, ccId, refNo, level = 1, extra }) {
2683
+ async startFlow(tx, { service, subjectType, subjectId, netTotal, ccId, refNo, level = 1, extra, createdBy }) {
2684
2684
  const store = this.deps.requestStorage.getStore();
2685
- const currentUser = store?.user?.id;
2685
+ const currentUser = createdBy ?? store?.user?.id;
2686
2686
  const flow = await this.approvalRepo.findMatchingFlow(tx, subjectType, service, ccId, netTotal, level);
2687
2687
  if (!flow) throw new Error("No approval flow configured");
2688
2688
  await tx.approvalInstance.updateMany({
package/dist/index.mjs CHANGED
@@ -2423,7 +2423,7 @@ var approvalRepository = (deps) => {
2423
2423
  ( cam.staff_id = ${staffId} or scc.staff_id = ${staffId} )
2424
2424
  and cai.status in (${Prisma.join(status)})
2425
2425
  and LOWER(cai.service) like LOWER(${serviceLike})
2426
- and LOWER(cai.ref_no) like LOWER(${pattern})
2426
+ and (LOWER(cai.ref_no) like LOWER(${pattern}) or LOWER(cai.extra) like LOWER(${pattern}) )
2427
2427
  and cam.cc_id = ${ccId}
2428
2428
  and cai.is_active = 1
2429
2429
  and cas.is_active = 1
@@ -2617,9 +2617,9 @@ var ApprovalService = class {
2617
2617
  deps;
2618
2618
  approvalRepo;
2619
2619
  prisma;
2620
- async startFlow(tx, { service, subjectType, subjectId, netTotal, ccId, refNo, level = 1, extra }) {
2620
+ async startFlow(tx, { service, subjectType, subjectId, netTotal, ccId, refNo, level = 1, extra, createdBy }) {
2621
2621
  const store = this.deps.requestStorage.getStore();
2622
- const currentUser = store?.user?.id;
2622
+ const currentUser = createdBy ?? store?.user?.id;
2623
2623
  const flow = await this.approvalRepo.findMatchingFlow(tx, subjectType, service, ccId, netTotal, level);
2624
2624
  if (!flow) throw new Error("No approval flow configured");
2625
2625
  await tx.approvalInstance.updateMany({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "av6-core",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",