storemw-core-api 1.0.38 → 1.0.39

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.
@@ -103,6 +103,12 @@ const replaceInjectionFields = async (req, res, next) => {
103
103
  uom: "uomId",
104
104
  });
105
105
  }
106
+ if (requestInjectionFieldType === "document") {
107
+ groupInjectionFields = (0, utils_2.groupPayloadInjectionFields)(request.payload.injection_fields, {}, {
108
+ document: "documentId",
109
+ documentItem: "documentItemId"
110
+ });
111
+ }
106
112
  const responseAll = await Promise.all(groupInjectionFields.map(async (i) => {
107
113
  const payload = {
108
114
  injectionFieldType: requestInjectionFieldType,
@@ -1 +1 @@
1
- {"version":3,"file":"injectionFieldController.js","sourceRoot":"","sources":["../../../src/controllers/injection_field/injectionFieldController.ts"],"names":[],"mappings":";;;AAEA,mCAAqF;AACrF,mCAAqD;AAErD,yCAA8J;AAC9J,8CAA4I;AAG5I,MAAM,WAAW,GAAG,CAAC,yBAA2E,EAAE,UAAmB,EAAE,EAAE;IAErH,IAAI,QAAQ,GAAQ,EAAE,CAAA;IAEtB,QAAQ,yBAAyB,EAAE,CAAC;QAChC,KAAK,MAAM;YAAE,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CAAC;YAAC,MAAM;QACnF,KAAK,MAAM;YAAE,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CAAC;YAAC,MAAM;QACnF,KAAK,UAAU;YAAE,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CAAC;YAAC,MAAM;QACvF,KAAK,YAAY;YAAE,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CAAC;YAAC,MAAM;QACzF,KAAK,UAAU;YAAE,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC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iceProps, sendSuccess, sendError, HTTP_STATUS } from \"@/utils\"\nimport { groupPayloadInjectionFields } from '@/utils'\n\nimport { InjectionFieldService, InjectionFieldListProps, InjectionFieldServiceProps, InjectionFieldCreateProps, InjectionFieldReplaceProps } from \"@/services\"\nimport { schemaInjectionFieldReplacePayload, schemaInjectionFieldCreatePayload, schemaInjectionFieldDeletePayload } from \"@/schema/payload\";\nimport { QueryList } from \"@/schema/middleware/route\";\n\nconst getRootName = (requestInjectionFieldType: InjectionFieldServiceProps[\"injectionFieldType\"], toSingular: boolean) => {\n\n let rootName: any = ``\n\n switch (requestInjectionFieldType) {\n case \"user\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n case \"item\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n case \"document\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n case \"repository\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n case \"logistic\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n }\n\n return rootName\n}\n\n/** injection_field : create injection field */\nexport const createInjectionField = async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n try {\n\n // const requestUserType = req.body.scope.target as InjectionFieldServiceProps[\"injectionFieldType\"]\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: \"user\"\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaInjectionFieldCreatePayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action\n },\n payload: {\n injection_fields: reqPayload?.injection_fields.map((i: any) => ({\n field_module: `${i.field_module}`,\n field_ref: `${i.field_ref}`,\n field_key: `${i.field_key}`,\n field_type: `${i.field_type}`,\n }))\n }\n })\n\n response = await Promise.all(\n request.payload.injection_fields.map(i => {\n const payload: InjectionFieldCreateProps = {\n data: {\n ...i,\n is_multiple: false,\n merge_multiple_inline: false,\n multiple_count: false,\n },\n };\n\n return injectionFieldService.createInjectionField(payload);\n })\n );\n\n sendSuccess(res, response, `Injection Fields created successfully`, `injection_field`)\n\n } catch (error: any) {\n next(error);\n }\n};\n\n/** injection_fields : replace injection fields */\nexport const replaceInjectionFields = async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n try {\n\n const requestInjectionFieldType = req.body.scope.target as InjectionFieldServiceProps[\"injectionFieldType\"]\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: requestInjectionFieldType\n })\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let response: any = {}\n\n let request = schemaInjectionFieldReplacePayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action,\n },\n payload: reqPayload\n })\n\n let groupInjectionFields: any = []\n\n if (requestInjectionFieldType === \"user\") {\n\n groupInjectionFields = groupPayloadInjectionFields(request.payload.injection_fields, {\n user: \"userId\",\n branch: \"branchId\",\n });\n\n }\n\n if (requestInjectionFieldType === \"item\") {\n\n groupInjectionFields = groupPayloadInjectionFields(request.payload.injection_fields, {}, {\n item: \"itemId\",\n product: \"productId\",\n category: \"categoryId\",\n brand: \"brandId\",\n uom: \"uomId\",\n });\n\n }\n\n const responseAll = await Promise.all(\n groupInjectionFields.map(async (i: any) => {\n const payload = {\n injectionFieldType: requestInjectionFieldType,\n data: i as InjectionFieldReplaceProps[\"data\"],\n };\n\n try {\n return injectionFieldService.replaceInjectionField(payload);\n } catch (error) {\n // console.log('err', error)\n return error\n }\n\n })\n );\n\n // console.log('responseAll', JSON.stringify(responseAll))\n\n response = {\n [`${getRootName(requestInjectionFieldType, false)}`]: responseAll\n }\n\n sendSuccess(res, response, `Injection Fields(${requestInjectionFieldType}) replaced successfully`)\n\n } catch (err: any) {\n next(err);\n }\n};\n\n/** injection_field/definition/:id : get injection field (registered) */\nexport const getInjectionField = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const { id } = req.params;\n const requestQuery = req.query as unknown as QueryList;\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: \"user\" // any\n })\n\n const data = await injectionFieldService.getInjectionField({ id: Number(id), datatypes: requestQuery.datatypes })\n\n return sendSuccess(res, data, \"Retrieved successfully\", `injection_field`);\n\n } catch (error: any) {\n next(error);\n }\n}\n\n/** injection_fields/injection_field : list injection fields registered */\nexport const listInjectionFields = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n\n try {\n\n const requestQuery = req.query as unknown as QueryList;\n // const requestInjectionFieldType = req.params.locationType as InjectionFieldServiceProps[\"injectionFieldType\"];\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: \"document\" // any\n })\n\n let payload: InjectionFieldListProps = requestQuery\n\n payload = {\n ...requestQuery\n }\n\n\n const { data, total } = await injectionFieldService.listInjectionFields(payload);\n\n let response = {\n [`injection_fields`]: data,\n total,\n }\n\n return sendSuccess(res, response, \"Retrieved successfully\");\n\n } catch (error: any) {\n next(error);\n }\n};\n\n/** injection_fields/delete : delete injection fields */\nexport const deleteInjectionFields = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n\n try {\n\n const requestInjectionFieldType = req.body.scope.target as InjectionFieldServiceProps[\"injectionFieldType\"]\n // const requestQuery = req.query as unknown as QueryList;\n // const requestFileId = Number(req.params.fileId)\n\n const request = schemaInjectionFieldDeletePayload.parse(req.body)\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: requestInjectionFieldType\n })\n\n const payload = {\n injectionFieldIds: request.payload.ids.map(i => BigInt(i))\n }\n\n const data = await injectionFieldService.removeInjectionFields(payload);\n\n return sendSuccess(res, data, \"Deleted\", `injection_fields`);\n\n } catch (error: any) {\n next(error);\n }\n};"]}
1
+ {"version":3,"file":"injectionFieldController.js","sourceRoot":"","sources":["../../../src/controllers/injection_field/injectionFieldController.ts"],"names":[],"mappings":";;;AAEA,mCAAqF;AACrF,mCAAqD;AAErD,yCAA8J;AAC9J,8CAA4I;AAG5I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AgB,EAAE;IAEzG,IAAI,CAAC;QAED,MAAM,yBAAyB,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAA0D,CAAA;QAC3G,0DAA0D;QAC1D,kDAAkD;QAElD,MAAM,OAAO,GAAG,2CAAiC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEjE,MAAM,qBAAqB,GAAG,IAAA,gCAAqB,EAAC;YAChD,GAAG,IAAA,8BAAsB,EAAC,GAAG,CAAC;YAC9B,kBAAkB,EAAE,yBAAyB;SAChD,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG;YACZ,iBAAiB,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SAC7D,CAAA;QAED,MAAM,IAAI,GAAG,MAAM,qBAAqB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAExE,OAAO,IAAA,mBAAW,EAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAEjE,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,CAAC;IAChB,CAAC;AACL,CAAC,CAAC;AA1BW,QAAA,qBAAqB,yBA0BhC","sourcesContent":["import { Request, Response, NextFunction } from \"express\";\n\nimport { getDefaultServiceProps, sendSuccess, sendError, HTTP_STATUS } from \"@/utils\"\nimport { groupPayloadInjectionFields } from '@/utils'\n\nimport { InjectionFieldService, InjectionFieldListProps, InjectionFieldServiceProps, InjectionFieldCreateProps, InjectionFieldReplaceProps } from \"@/services\"\nimport { schemaInjectionFieldReplacePayload, schemaInjectionFieldCreatePayload, schemaInjectionFieldDeletePayload } from \"@/schema/payload\";\nimport { QueryList } from \"@/schema/middleware/route\";\n\nconst getRootName = (requestInjectionFieldType: InjectionFieldServiceProps[\"injectionFieldType\"], toSingular: boolean) => {\n\n let rootName: any = ``\n\n switch (requestInjectionFieldType) {\n case \"user\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n case \"item\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n case \"document\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n case \"repository\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n case \"logistic\": rootName = toSingular ? \"injection_field\" : \"injection_fields\"; break;\n }\n\n return rootName\n}\n\n/** injection_field : create injection field */\nexport const createInjectionField = async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n try {\n\n // const requestUserType = req.body.scope.target as InjectionFieldServiceProps[\"injectionFieldType\"]\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: \"user\"\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaInjectionFieldCreatePayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action\n },\n payload: {\n injection_fields: reqPayload?.injection_fields.map((i: any) => ({\n field_module: `${i.field_module}`,\n field_ref: `${i.field_ref}`,\n field_key: `${i.field_key}`,\n field_type: `${i.field_type}`,\n }))\n }\n })\n\n response = await Promise.all(\n request.payload.injection_fields.map(i => {\n const payload: InjectionFieldCreateProps = {\n data: {\n ...i,\n is_multiple: false,\n merge_multiple_inline: false,\n multiple_count: false,\n },\n };\n\n return injectionFieldService.createInjectionField(payload);\n })\n );\n\n sendSuccess(res, response, `Injection Fields created successfully`, `injection_field`)\n\n } catch (error: any) {\n next(error);\n }\n};\n\n/** injection_fields : replace injection fields */\nexport const replaceInjectionFields = async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n try {\n\n const requestInjectionFieldType = req.body.scope.target as InjectionFieldServiceProps[\"injectionFieldType\"]\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: requestInjectionFieldType\n })\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let response: any = {}\n\n let request = schemaInjectionFieldReplacePayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action,\n },\n payload: reqPayload\n })\n\n let groupInjectionFields: any = []\n\n if (requestInjectionFieldType === \"user\") {\n\n groupInjectionFields = groupPayloadInjectionFields(request.payload.injection_fields, {\n user: \"userId\",\n branch: \"branchId\",\n });\n\n }\n\n if (requestInjectionFieldType === \"item\") {\n\n groupInjectionFields = groupPayloadInjectionFields(request.payload.injection_fields, {}, {\n item: \"itemId\",\n product: \"productId\",\n category: \"categoryId\",\n brand: \"brandId\",\n uom: \"uomId\",\n });\n\n }\n\n if (requestInjectionFieldType === \"document\") {\n\n groupInjectionFields = groupPayloadInjectionFields(request.payload.injection_fields, {}, {\n document: \"documentId\",\n documentItem: \"documentItemId\"\n });\n\n }\n\n const responseAll = await Promise.all(\n groupInjectionFields.map(async (i: any) => {\n const payload = {\n injectionFieldType: requestInjectionFieldType,\n data: i as InjectionFieldReplaceProps[\"data\"],\n };\n\n try {\n return injectionFieldService.replaceInjectionField(payload);\n } catch (error) {\n // console.log('err', error)\n return error\n }\n\n })\n );\n\n // console.log('responseAll', JSON.stringify(responseAll))\n\n response = {\n [`${getRootName(requestInjectionFieldType, false)}`]: responseAll\n }\n\n sendSuccess(res, response, `Injection Fields(${requestInjectionFieldType}) replaced successfully`)\n\n } catch (err: any) {\n next(err);\n }\n};\n\n/** injection_field/definition/:id : get injection field (registered) */\nexport const getInjectionField = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const { id } = req.params;\n const requestQuery = req.query as unknown as QueryList;\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: \"user\" // any\n })\n\n const data = await injectionFieldService.getInjectionField({ id: Number(id), datatypes: requestQuery.datatypes })\n\n return sendSuccess(res, data, \"Retrieved successfully\", `injection_field`);\n\n } catch (error: any) {\n next(error);\n }\n}\n\n/** injection_fields/injection_field : list injection fields registered */\nexport const listInjectionFields = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n\n try {\n\n const requestQuery = req.query as unknown as QueryList;\n // const requestInjectionFieldType = req.params.locationType as InjectionFieldServiceProps[\"injectionFieldType\"];\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: \"document\" // any\n })\n\n let payload: InjectionFieldListProps = requestQuery\n\n payload = {\n ...requestQuery\n }\n\n\n const { data, total } = await injectionFieldService.listInjectionFields(payload);\n\n let response = {\n [`injection_fields`]: data,\n total,\n }\n\n return sendSuccess(res, response, \"Retrieved successfully\");\n\n } catch (error: any) {\n next(error);\n }\n};\n\n/** injection_fields/delete : delete injection fields */\nexport const deleteInjectionFields = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n\n try {\n\n const requestInjectionFieldType = req.body.scope.target as InjectionFieldServiceProps[\"injectionFieldType\"]\n // const requestQuery = req.query as unknown as QueryList;\n // const requestFileId = Number(req.params.fileId)\n\n const request = schemaInjectionFieldDeletePayload.parse(req.body)\n\n const injectionFieldService = InjectionFieldService({\n ...getDefaultServiceProps(req),\n injectionFieldType: requestInjectionFieldType\n })\n\n const payload = {\n injectionFieldIds: request.payload.ids.map(i => BigInt(i))\n }\n\n const data = await injectionFieldService.removeInjectionFields(payload);\n\n return sendSuccess(res, data, \"Deleted\", `injection_fields`);\n\n } catch (error: any) {\n next(error);\n }\n};"]}
@@ -8,13 +8,13 @@ export declare const ModelDocumentInjectionFieldFields: {
8
8
  updateuserid: "updateuserid";
9
9
  isdelete: "isdelete";
10
10
  istrash: "istrash";
11
+ accountid: "accountid";
11
12
  document_id: "document_id";
12
13
  document_item_id: "document_item_id";
13
14
  document_doc_id: "document_doc_id";
14
15
  field_module: "field_module";
15
16
  field_ref: "field_ref";
16
17
  document_injection_field_id: "document_injection_field_id";
17
- ax_accountid: "ax_accountid";
18
18
  doc_do_pack_qty2_bk_39: "doc_do_pack_qty2_bk_39";
19
19
  doc_do_pack_qty2: "doc_do_pack_qty2";
20
20
  doci_do_pack_item_qty: "doci_do_pack_item_qty";
@@ -91,7 +91,7 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
91
91
  accountId: number;
92
92
  actionUserId: number;
93
93
  }) => {
94
- primaryKey: "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "document_id" | "document_item_id" | "document_doc_id" | "field_module" | "field_ref" | "document_injection_field_id" | "ax_accountid" | "doc_do_pack_qty2_bk_39" | "doc_do_pack_qty2" | "doci_do_pack_item_qty" | "doc_do_pack_item_qty" | "doc_so_test" | "doci_so_testitem" | "doc_so_pack_qty2" | "doc_do_aaaa" | "doc_do_remark_ids" | "doc_do_remark_id" | "doci_ir_batch_no" | "doci_ir_expiry_date" | "doci_ir_production_date" | "doc_scn_is_adhoc" | "doc_scn_shipment_address" | "doci_scn_existing_mp_quantity" | "doci_scn_is_bulk" | "doc_do_is_adhoc" | "doc_do_shipment_address" | "doci_do_existing_mp_quantity" | "doci_do_is_bulk" | "doc_cs_is_adhoc" | "doc_cs_shipment_address" | "doci_cs_existing_mp_quantity" | "doci_cs_is_bulk" | "doc_rdo_is_adhoc" | "doc_rdo_shipment_address" | "doci_rdo_existing_mp_quantity" | "doci_rdo_is_bulk" | "doc_pr_is_adhoc" | "doc_pr_shipment_address" | "doci_pr_existing_mp_quantity" | "doci_pr_is_bulk" | "doc_sdn_is_adhoc" | "doc_sdn_shipment_address" | "doci_sdn_existing_mp_quantity" | "doci_sdn_is_bulk" | "removed_doci_do_4sdfsdfd7s" | "doc_trp_samepltrip_date" | "doc_trp_sampletrip_no" | "doci_trp_sampletrip_item_no" | "doci_trp_samepltrip_item_date";
94
+ primaryKey: "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "document_id" | "document_item_id" | "document_doc_id" | "field_module" | "field_ref" | "document_injection_field_id" | "doc_do_pack_qty2_bk_39" | "doc_do_pack_qty2" | "doci_do_pack_item_qty" | "doc_do_pack_item_qty" | "doc_so_test" | "doci_so_testitem" | "doc_so_pack_qty2" | "doc_do_aaaa" | "doc_do_remark_ids" | "doc_do_remark_id" | "doci_ir_batch_no" | "doci_ir_expiry_date" | "doci_ir_production_date" | "doc_scn_is_adhoc" | "doc_scn_shipment_address" | "doci_scn_existing_mp_quantity" | "doci_scn_is_bulk" | "doc_do_is_adhoc" | "doc_do_shipment_address" | "doci_do_existing_mp_quantity" | "doci_do_is_bulk" | "doc_cs_is_adhoc" | "doc_cs_shipment_address" | "doci_cs_existing_mp_quantity" | "doci_cs_is_bulk" | "doc_rdo_is_adhoc" | "doc_rdo_shipment_address" | "doci_rdo_existing_mp_quantity" | "doci_rdo_is_bulk" | "doc_pr_is_adhoc" | "doc_pr_shipment_address" | "doci_pr_existing_mp_quantity" | "doci_pr_is_bulk" | "doc_sdn_is_adhoc" | "doc_sdn_shipment_address" | "doci_sdn_existing_mp_quantity" | "doci_sdn_is_bulk" | "removed_doci_do_4sdfsdfd7s" | "doc_trp_samepltrip_date" | "doc_trp_sampletrip_no" | "doci_trp_sampletrip_item_no" | "doci_trp_samepltrip_item_date";
95
95
  getFields: (prefix?: string, excludeKeywords?: string[]) => Promise<{
96
96
  name: string;
97
97
  type: string;
@@ -105,13 +105,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
105
105
  updateuserid: bigint;
106
106
  isdelete: boolean | null;
107
107
  istrash: boolean | null;
108
+ accountid: bigint;
108
109
  document_id: bigint;
109
110
  document_item_id: bigint;
110
111
  document_doc_id: bigint;
111
112
  field_module: string | null;
112
113
  field_ref: string | null;
113
114
  document_injection_field_id: bigint;
114
- ax_accountid: bigint;
115
115
  doc_do_pack_qty2_bk_39: bigint;
116
116
  doc_do_pack_qty2: bigint | null;
117
117
  doci_do_pack_item_qty: bigint | null;
@@ -165,13 +165,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
165
165
  updateuserid: bigint;
166
166
  isdelete: boolean | null;
167
167
  istrash: boolean | null;
168
+ accountid: bigint;
168
169
  document_id: bigint;
169
170
  document_item_id: bigint;
170
171
  document_doc_id: bigint;
171
172
  field_module: string | null;
172
173
  field_ref: string | null;
173
174
  document_injection_field_id: bigint;
174
- ax_accountid: bigint;
175
175
  doc_do_pack_qty2_bk_39: bigint;
176
176
  doc_do_pack_qty2: bigint | null;
177
177
  doci_do_pack_item_qty: bigint | null;
@@ -226,13 +226,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
226
226
  updateuserid: bigint;
227
227
  isdelete: boolean | null;
228
228
  istrash: boolean | null;
229
+ accountid: bigint;
229
230
  document_id: bigint;
230
231
  document_item_id: bigint;
231
232
  document_doc_id: bigint;
232
233
  field_module: string | null;
233
234
  field_ref: string | null;
234
235
  document_injection_field_id: bigint;
235
- ax_accountid: bigint;
236
236
  doc_do_pack_qty2_bk_39: bigint;
237
237
  doc_do_pack_qty2: bigint | null;
238
238
  doci_do_pack_item_qty: bigint | null;
@@ -283,13 +283,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
283
283
  updateuserid: bigint;
284
284
  isdelete: boolean | null;
285
285
  istrash: boolean | null;
286
+ accountid: bigint;
286
287
  document_id: bigint;
287
288
  document_item_id: bigint;
288
289
  document_doc_id: bigint;
289
290
  field_module: string | null;
290
291
  field_ref: string | null;
291
292
  document_injection_field_id: bigint;
292
- ax_accountid: bigint;
293
293
  doc_do_pack_qty2_bk_39: bigint;
294
294
  doc_do_pack_qty2: bigint | null;
295
295
  doci_do_pack_item_qty: bigint | null;
@@ -337,7 +337,7 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
337
337
  where?: Record<string, any>;
338
338
  }) => Promise<number>;
339
339
  aggregate: ({ field, operation, where, }: {
340
- field: "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "document_id" | "document_item_id" | "document_doc_id" | "field_module" | "field_ref" | "document_injection_field_id" | "ax_accountid" | "doc_do_pack_qty2_bk_39" | "doc_do_pack_qty2" | "doci_do_pack_item_qty" | "doc_do_pack_item_qty" | "doc_so_test" | "doci_so_testitem" | "doc_so_pack_qty2" | "doc_do_aaaa" | "doc_do_remark_ids" | "doc_do_remark_id" | "doci_ir_batch_no" | "doci_ir_expiry_date" | "doci_ir_production_date" | "doc_scn_is_adhoc" | "doc_scn_shipment_address" | "doci_scn_existing_mp_quantity" | "doci_scn_is_bulk" | "doc_do_is_adhoc" | "doc_do_shipment_address" | "doci_do_existing_mp_quantity" | "doci_do_is_bulk" | "doc_cs_is_adhoc" | "doc_cs_shipment_address" | "doci_cs_existing_mp_quantity" | "doci_cs_is_bulk" | "doc_rdo_is_adhoc" | "doc_rdo_shipment_address" | "doci_rdo_existing_mp_quantity" | "doci_rdo_is_bulk" | "doc_pr_is_adhoc" | "doc_pr_shipment_address" | "doci_pr_existing_mp_quantity" | "doci_pr_is_bulk" | "doc_sdn_is_adhoc" | "doc_sdn_shipment_address" | "doci_sdn_existing_mp_quantity" | "doci_sdn_is_bulk" | "removed_doci_do_4sdfsdfd7s" | "doc_trp_samepltrip_date" | "doc_trp_sampletrip_no" | "doci_trp_sampletrip_item_no" | "doci_trp_samepltrip_item_date";
340
+ field: "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "document_id" | "document_item_id" | "document_doc_id" | "field_module" | "field_ref" | "document_injection_field_id" | "doc_do_pack_qty2_bk_39" | "doc_do_pack_qty2" | "doci_do_pack_item_qty" | "doc_do_pack_item_qty" | "doc_so_test" | "doci_so_testitem" | "doc_so_pack_qty2" | "doc_do_aaaa" | "doc_do_remark_ids" | "doc_do_remark_id" | "doci_ir_batch_no" | "doci_ir_expiry_date" | "doci_ir_production_date" | "doc_scn_is_adhoc" | "doc_scn_shipment_address" | "doci_scn_existing_mp_quantity" | "doci_scn_is_bulk" | "doc_do_is_adhoc" | "doc_do_shipment_address" | "doci_do_existing_mp_quantity" | "doci_do_is_bulk" | "doc_cs_is_adhoc" | "doc_cs_shipment_address" | "doci_cs_existing_mp_quantity" | "doci_cs_is_bulk" | "doc_rdo_is_adhoc" | "doc_rdo_shipment_address" | "doci_rdo_existing_mp_quantity" | "doci_rdo_is_bulk" | "doc_pr_is_adhoc" | "doc_pr_shipment_address" | "doci_pr_existing_mp_quantity" | "doci_pr_is_bulk" | "doc_sdn_is_adhoc" | "doc_sdn_shipment_address" | "doci_sdn_existing_mp_quantity" | "doci_sdn_is_bulk" | "removed_doci_do_4sdfsdfd7s" | "doc_trp_samepltrip_date" | "doc_trp_sampletrip_no" | "doci_trp_sampletrip_item_no" | "doci_trp_samepltrip_item_date";
341
341
  operation?: "sum" | "avg" | "min" | "max" | "count";
342
342
  where?: Record<string, any>;
343
343
  }) => Promise<number>;
@@ -351,13 +351,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
351
351
  updateuserid: bigint;
352
352
  isdelete: boolean | null;
353
353
  istrash: boolean | null;
354
+ accountid: bigint;
354
355
  document_id: bigint;
355
356
  document_item_id: bigint;
356
357
  document_doc_id: bigint;
357
358
  field_module: string | null;
358
359
  field_ref: string | null;
359
360
  document_injection_field_id: bigint;
360
- ax_accountid: bigint;
361
361
  doc_do_pack_qty2_bk_39: bigint;
362
362
  doc_do_pack_qty2: bigint | null;
363
363
  doci_do_pack_item_qty: bigint | null;
@@ -409,13 +409,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
409
409
  updateuserid: bigint;
410
410
  isdelete: boolean | null;
411
411
  istrash: boolean | null;
412
+ accountid: bigint;
412
413
  document_id: bigint;
413
414
  document_item_id: bigint;
414
415
  document_doc_id: bigint;
415
416
  field_module: string | null;
416
417
  field_ref: string | null;
417
418
  document_injection_field_id: bigint;
418
- ax_accountid: bigint;
419
419
  doc_do_pack_qty2_bk_39: bigint;
420
420
  doc_do_pack_qty2: bigint | null;
421
421
  doci_do_pack_item_qty: bigint | null;
@@ -469,13 +469,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
469
469
  updateuserid: bigint;
470
470
  isdelete: boolean | null;
471
471
  istrash: boolean | null;
472
+ accountid: bigint;
472
473
  document_id: bigint;
473
474
  document_item_id: bigint;
474
475
  document_doc_id: bigint;
475
476
  field_module: string | null;
476
477
  field_ref: string | null;
477
478
  document_injection_field_id: bigint;
478
- ax_accountid: bigint;
479
479
  doc_do_pack_qty2_bk_39: bigint;
480
480
  doc_do_pack_qty2: bigint | null;
481
481
  doci_do_pack_item_qty: bigint | null;
@@ -528,13 +528,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
528
528
  updateuserid: bigint;
529
529
  isdelete: boolean | null;
530
530
  istrash: boolean | null;
531
+ accountid: bigint;
531
532
  document_id: bigint;
532
533
  document_item_id: bigint;
533
534
  document_doc_id: bigint;
534
535
  field_module: string | null;
535
536
  field_ref: string | null;
536
537
  document_injection_field_id: bigint;
537
- ax_accountid: bigint;
538
538
  doc_do_pack_qty2_bk_39: bigint;
539
539
  doc_do_pack_qty2: bigint | null;
540
540
  doci_do_pack_item_qty: bigint | null;
@@ -587,13 +587,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
587
587
  updateuserid: bigint;
588
588
  isdelete: boolean | null;
589
589
  istrash: boolean | null;
590
+ accountid: bigint;
590
591
  document_id: bigint;
591
592
  document_item_id: bigint;
592
593
  document_doc_id: bigint;
593
594
  field_module: string | null;
594
595
  field_ref: string | null;
595
596
  document_injection_field_id: bigint;
596
- ax_accountid: bigint;
597
597
  doc_do_pack_qty2_bk_39: bigint;
598
598
  doc_do_pack_qty2: bigint | null;
599
599
  doci_do_pack_item_qty: bigint | null;
@@ -647,13 +647,13 @@ export declare const DocumentInjectionFieldModel: ({ prisma, accountId, actionUs
647
647
  updateuserid: bigint;
648
648
  isdelete: boolean | null;
649
649
  istrash: boolean | null;
650
+ accountid: bigint;
650
651
  document_id: bigint;
651
652
  document_item_id: bigint;
652
653
  document_doc_id: bigint;
653
654
  field_module: string | null;
654
655
  field_ref: string | null;
655
656
  document_injection_field_id: bigint;
656
- ax_accountid: bigint;
657
657
  doc_do_pack_qty2_bk_39: bigint;
658
658
  doc_do_pack_qty2: bigint | null;
659
659
  doci_do_pack_item_qty: bigint | null;
@@ -5,7 +5,7 @@ type DocumentInjectionFieldMap = {
5
5
  documentId: any;
6
6
  };
7
7
  document_item: {
8
- documentId: any;
8
+ documentItemId: any;
9
9
  };
10
10
  };
11
11
  cash_sales: {
@@ -13,7 +13,7 @@ type DocumentInjectionFieldMap = {
13
13
  documentId: any;
14
14
  };
15
15
  document_item: {
16
- documentId: any;
16
+ documentItemId: any;
17
17
  };
18
18
  };
19
19
  sales: {
@@ -21,7 +21,7 @@ type DocumentInjectionFieldMap = {
21
21
  documentId: any;
22
22
  };
23
23
  document_item: {
24
- documentId: any;
24
+ documentItemId: any;
25
25
  };
26
26
  };
27
27
  proforma_sales: {
@@ -29,7 +29,7 @@ type DocumentInjectionFieldMap = {
29
29
  documentId: any;
30
30
  };
31
31
  document_item: {
32
- documentId: any;
32
+ documentItemId: any;
33
33
  };
34
34
  };
35
35
  retail_cash_sales: {
@@ -37,7 +37,7 @@ type DocumentInjectionFieldMap = {
37
37
  documentId: any;
38
38
  };
39
39
  document_item: {
40
- documentId: any;
40
+ documentItemId: any;
41
41
  };
42
42
  };
43
43
  replacement_delivery_order: {
@@ -45,7 +45,7 @@ type DocumentInjectionFieldMap = {
45
45
  documentId: any;
46
46
  };
47
47
  document_item: {
48
- documentId: any;
48
+ documentItemId: any;
49
49
  };
50
50
  };
51
51
  trip: {
@@ -53,7 +53,7 @@ type DocumentInjectionFieldMap = {
53
53
  documentId: any;
54
54
  };
55
55
  document_item: {
56
- documentId: any;
56
+ documentDocId: any;
57
57
  };
58
58
  };
59
59
  };
@@ -18,7 +18,7 @@ exports.documentRefPrefixMap = {
18
18
  document_item: "doci",
19
19
  };
20
20
  const getReplacePayload = (data) => {
21
- let { module, ref, documentId } = data;
21
+ let { module, ref } = data;
22
22
  let payload = {};
23
23
  payload = {
24
24
  ...payload,
@@ -28,16 +28,14 @@ const getReplacePayload = (data) => {
28
28
  }
29
29
  };
30
30
  if ("documentId" in data) {
31
- payload = { ...payload, ...(data?.documentId ? { [`${models_1.ModelDocumentInjectionFieldFields.document_id}`]: documentId } : {}) };
31
+ payload = { ...payload, ...(data?.documentId ? { [`${models_1.ModelDocumentInjectionFieldFields.document_id}`]: data.documentId } : {}) };
32
+ }
33
+ if ("documentItemId" in data) {
34
+ payload = { ...payload, ...(data?.documentItemId ? { [`${models_1.ModelDocumentInjectionFieldFields.document_item_id}`]: data.documentItemId } : {}) };
35
+ }
36
+ if ("documentDocId" in data) {
37
+ payload = { ...payload, ...(data?.documentDocId ? { [`${models_1.ModelDocumentInjectionFieldFields.document_doc_id}`]: data.documentDocId } : {}) };
32
38
  }
33
- // if ("branchId" in data) {
34
- // const branchId = data.branchId
35
- // payload = { ...payload, ...(data?.branchId ? { [`${ModelDocumentInjectionFieldFields.branch_id}`]: branchId } : {}) }
36
- // }
37
- // if ("memberId" in data) {
38
- // const memberId = data.memberId
39
- // payload = { ...payload, ...(data?.memberId ? { [`${ModelDocumentInjectionFieldFields.member_id}`]: memberId } : {}) }
40
- // }
41
39
  const rest = data.fields;
42
40
  // apply dynamic prefix: refPrefix_modulePrefix_fieldKey
43
41
  const refPrefix = exports.documentRefPrefixMap[ref] ?? ref;
@@ -58,7 +56,9 @@ const DocumentInjectionFieldService = (props) => {
58
56
  const where = {
59
57
  [models_1.ModelDocumentInjectionFieldFields.field_module]: data.module,
60
58
  [models_1.ModelDocumentInjectionFieldFields.field_ref]: data.ref,
61
- ...(data?.documentId ? { [models_1.ModelDocumentInjectionFieldFields.document_id]: data.documentId } : {}),
59
+ ...(("documentId" in data) ? { [models_1.ModelDocumentInjectionFieldFields.document_id]: data.documentId } : {}),
60
+ ...(("documentItemId" in data) ? { [models_1.ModelDocumentInjectionFieldFields.document_item_id]: data.documentItemId } : {}),
61
+ ...(("documentDocId" in data) ? { [models_1.ModelDocumentInjectionFieldFields.document_doc_id]: data.documentDocId } : {}),
62
62
  };
63
63
  // Narrow: only include branchId if data.ref === "branch"
64
64
  // if (data.ref === "branch") {
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentInjectionFieldService.js","sourceRoot":"","sources":["../../../src/services/injection_field/DocumentInjectionFieldService.ts"],"names":[],"mappings":";;;AAAA,qCAGkB;AAIlB,mCAAmF;AAkCnF,+GAA+G;AAElG,QAAA,uBAAuB,GAAiD;IACjF,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,KAAK;IACrB,KAAK,EAAE,IAAI;IACX,iBAAiB,EAAE,KAAK;IACxB,0BAA0B,EAAE,KAAK;IACjC,IAAI,EAAE,KAAK;CACd,CAAC;AAEW,QAAA,oBAAoB,GAAiD;IAC9E,QAAQ,EAAE,KAAK;IACf,aAAa,EAAE,MAAM;CACxB,CAAC;AAuBF,MAAM,iBAAiB,GAAG,CAAC,IAAgD,EAAE,EAAE;IAE3E,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAEtC,IAAI,OAAO,GAAwB,EAAE,CAAC;IAEtC,OAAO,GAAG;QACN,GAAG,OAAO;QACV,GAAG;YACC,CAAC,GAAG,0CAAiC,CAAC,YAAY,EAAE,CAAC,EAAE,MAAM;YAC7D,CAAC,GAAG,0CAAiC,CAAC,SAAS,EAAE,CAAC,EAAE,GAAG;SAC1D;KACJ,CAAA;IAED,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,0CAAiC,CAAC,WAAW,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/H,CAAC;IAED,4BAA4B;IAC5B,qCAAqC;IACrC,4HAA4H;IAC5H,IAAI;I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E,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;QAC5E,CAAC;QAED,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAA;IAED,OAAO;QACH,6BAA6B;KAChC,CAAA;AAEL,CAAC,CAAA;AArEY,QAAA,6BAA6B,iCAqEzC","sourcesContent":["import {\n DocumentInjectionFieldModel,\n ModelDocumentInjectionFieldFields,\n} from \"@/models\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { convertPayloadByTableSchema, validateModelFieldsWithData } from \"@/utils\";\n\ntype DocumentInjectionFieldMap = {\n delivery: {\n document: { documentId: any };\n document_item: { documentId: any; };\n };\n cash_sales: {\n document: { documentId: any };\n document_item: { documentId: any; };\n };\n sales: {\n document: { documentId: any };\n document_item: { documentId: any; };\n };\n proforma_sales: {\n document: { documentId: any };\n document_item: { documentId: any; };\n };\n retail_cash_sales: {\n document: { documentId: any };\n document_item: { documentId: any; };\n };\n replacement_delivery_order: {\n document: { documentId: any };\n document_item: { documentId: any; };\n },\n trip: {\n document: { documentId: any };\n document_item: { documentId: any; };\n }\n};\n\ntype DocumentInjectionFieldModule = keyof DocumentInjectionFieldMap;\n// type DocumentInjectionFieldRef<M extends DocumentInjectionFieldModule> = keyof DocumentInjectionFieldMap[M];\n\nexport const documentModulePrefixMap: Record<DocumentInjectionFieldModule, string> = {\n delivery: \"do\",\n cash_sales: \"cs\",\n proforma_sales: \"pso\",\n sales: \"so\",\n retail_cash_sales: \"rcs\",\n replacement_delivery_order: \"rdo\",\n trip: \"trp\"\n};\n\nexport const documentRefPrefixMap: Record<\"document\" | \"document_item\", string> = {\n document: \"doc\",\n document_item: \"doci\",\n};\n\nexport type DocumentInjectionFieldModuleRef = {\n [M in DocumentInjectionFieldModule]: {\n [R in keyof DocumentInjectionFieldMap[M]]: {\n module: M;\n ref: R;\n } & DocumentInjectionFieldMap[M][R];\n }[keyof DocumentInjectionFieldMap[M]];\n}[DocumentInjectionFieldModule];\n\nexport type DocumentInjectionFieldServiceProps = DefaultServiceProps & {};\n\nexport type DocumentInjectionFieldRemoveProps = {\n ids: number[]\n};\n\nexport type DocumentInjectionFieldReplaceProps = {\n data: DocumentInjectionFieldModuleRef & {\n fields: any\n }\n}\n\nconst getReplacePayload = (data: DocumentInjectionFieldReplaceProps[\"data\"]) => {\n\n let { module, ref, documentId } = data\n\n let payload: Record<string, any> = {};\n\n payload = {\n ...payload,\n ...{\n [`${ModelDocumentInjectionFieldFields.field_module}`]: module,\n [`${ModelDocumentInjectionFieldFields.field_ref}`]: ref,\n }\n }\n\n if (\"documentId\" in data) {\n payload = { ...payload, ...(data?.documentId ? { [`${ModelDocumentInjectionFieldFields.document_id}`]: documentId } : {}) }\n }\n\n // if (\"branchId\" in data) {\n // const branchId = data.branchId\n // payload = { ...payload, ...(data?.branchId ? { [`${ModelDocumentInjectionFieldFields.branch_id}`]: branchId } : {}) }\n // }\n\n // if (\"memberId\" in data) {\n // const memberId = data.memberId\n // payload = { ...payload, ...(data?.memberId ? { [`${ModelDocumentInjectionFieldFields.member_id}`]: memberId } : {}) }\n // }\n\n const rest = data.fields\n\n // apply dynamic prefix: refPrefix_modulePrefix_fieldKey\n const refPrefix = documentRefPrefixMap[ref as keyof typeof documentRefPrefixMap] ?? ref;\n const modulePrefix = documentModulePrefixMap[module as DocumentInjectionFieldModule] ?? module;\n\n for (const [key, value] of Object.entries(rest)) {\n payload[`${refPrefix}_${modulePrefix}_${key}`] = value;\n }\n\n return payload\n\n}\n\nexport const DocumentInjectionFieldService = (props: DocumentInjectionFieldServiceProps) => {\n\n const {\n prisma,\n accountId = 0,\n actionUserId = 0\n } = props\n\n const documentInjectionFieldModel = DocumentInjectionFieldModel({ prisma, accountId, actionUserId })\n\n const replaceDocumentInjectionField = async ({ data }: DocumentInjectionFieldReplaceProps) => {\n\n const _data = getReplacePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create payload: ${JSON.stringify(_data)}`);\n }\n\n const where: Record<string, any> = {\n [ModelDocumentInjectionFieldFields.field_module]: data.module,\n [ModelDocumentInjectionFieldFields.field_ref]: data.ref,\n ...(data?.documentId ? { [ModelDocumentInjectionFieldFields.document_id]: data.documentId } : {}),\n };\n\n // Narrow: only include branchId if data.ref === \"branch\"\n // if (data.ref === \"branch\") {\n // where[ModelDocumentInjectionFieldFields.branch_id] = (data as Extract<DocumentInjectionFieldModuleRef, { ref: \"branch\" }>).branchId;\n // }\n\n let modelFields = await documentInjectionFieldModel.getFields()\n\n let finalData = convertPayloadByTableSchema(_data, modelFields)\n\n // console.log('modelFields', modelFields)\n // console.log('finalData', finalData)\n\n\n // check the request fields are in the exactly schema\n const resultInvalidFields = validateModelFieldsWithData(modelFields, finalData)\n\n if (resultInvalidFields.length > 0) {\n throw Error(`Invalid injection fields: ${resultInvalidFields.join(\", \")} (Request: ${Object.keys(finalData).join(\", \")})`)\n }\n\n // check the record exists\n let exists = await documentInjectionFieldModel.get({ where })\n\n let response: any = {}\n\n if (exists) { // update existing\n\n // remove unwanted to override\n delete finalData.field_module;\n delete finalData.field_ref;\n delete finalData.document_id;\n delete finalData.document_item_id;\n\n response = await documentInjectionFieldModel.update({ data: finalData, where, disableRollback: true })\n } else { // create new\n response = await documentInjectionFieldModel.create({ data: finalData })\n }\n\n return response\n }\n\n return {\n replaceDocumentInjectionField\n }\n\n}\n\n\n"]}
1
+ {"version":3,"file":"DocumentInjectionFieldService.js","sourceRoot":"","sources":["../../../src/services/injection_field/DocumentInjectionFieldService.ts"],"names":[],"mappings":";;;AAAA,qCAGkB;AAIlB,mCAAmF;AAkCnF,+GAA+G;AAElG,QAAA,uBAAuB,GAAiD;IACjF,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,KAAK;IACrB,KAAK,EAAE,IAAI;IACX,iBAAiB,EAAE,KAAK;IACxB,0BAA0B,EAAE,KAAK;IACjC,IAAI,EAAE,KAAK;CACd,CAAC;AAEW,QAAA,oBAAoB,GAAiD;IAC9E,QAAQ,EAAE,KAAK;IACf,a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AAgB,CAAC;YAElC,QAAQ,GAAG,MAAM,2BAA2B,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAA;QAC1G,CAAC;aAAM,CAAC,CAAC,aAAa;YAClB,QAAQ,GAAG,MAAM,2BAA2B,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;QAC5E,CAAC;QAED,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAA;IAED,OAAO;QACH,6BAA6B;KAChC,CAAA;AAEL,CAAC,CAAA;AAvEY,QAAA,6BAA6B,iCAuEzC","sourcesContent":["import {\n DocumentInjectionFieldModel,\n ModelDocumentInjectionFieldFields,\n} from \"@/models\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { convertPayloadByTableSchema, validateModelFieldsWithData } from \"@/utils\";\n\ntype DocumentInjectionFieldMap = {\n delivery: {\n document: { documentId: any };\n document_item: { documentItemId: any; };\n };\n cash_sales: {\n document: { documentId: any };\n document_item: { documentItemId: any; };\n };\n sales: {\n document: { documentId: any };\n document_item: { documentItemId: any; };\n };\n proforma_sales: {\n document: { documentId: any };\n document_item: { documentItemId: any; };\n };\n retail_cash_sales: {\n document: { documentId: any };\n document_item: { documentItemId: any; };\n };\n replacement_delivery_order: {\n document: { documentId: any };\n document_item: { documentItemId: any; };\n },\n trip: {\n document: { documentId: any };\n document_item: { documentDocId: any; };\n }\n};\n\ntype DocumentInjectionFieldModule = keyof DocumentInjectionFieldMap;\n// type DocumentInjectionFieldRef<M extends DocumentInjectionFieldModule> = keyof DocumentInjectionFieldMap[M];\n\nexport const documentModulePrefixMap: Record<DocumentInjectionFieldModule, string> = {\n delivery: \"do\",\n cash_sales: \"cs\",\n proforma_sales: \"pso\",\n sales: \"so\",\n retail_cash_sales: \"rcs\",\n replacement_delivery_order: \"rdo\",\n trip: \"trp\"\n};\n\nexport const documentRefPrefixMap: Record<\"document\" | \"document_item\", string> = {\n document: \"doc\",\n document_item: \"doci\",\n};\n\nexport type DocumentInjectionFieldModuleRef = {\n [M in DocumentInjectionFieldModule]: {\n [R in keyof DocumentInjectionFieldMap[M]]: {\n module: M;\n ref: R;\n } & DocumentInjectionFieldMap[M][R];\n }[keyof DocumentInjectionFieldMap[M]];\n}[DocumentInjectionFieldModule];\n\nexport type DocumentInjectionFieldServiceProps = DefaultServiceProps & {};\n\nexport type DocumentInjectionFieldRemoveProps = {\n ids: number[]\n};\n\nexport type DocumentInjectionFieldReplaceProps = {\n data: DocumentInjectionFieldModuleRef & {\n fields: any\n }\n}\n\nconst getReplacePayload = (data: DocumentInjectionFieldReplaceProps[\"data\"]) => {\n\n let { module, ref } = data\n\n let payload: Record<string, any> = {};\n\n payload = {\n ...payload,\n ...{\n [`${ModelDocumentInjectionFieldFields.field_module}`]: module,\n [`${ModelDocumentInjectionFieldFields.field_ref}`]: ref,\n }\n }\n\n if (\"documentId\" in data) {\n payload = { ...payload, ...(data?.documentId ? { [`${ModelDocumentInjectionFieldFields.document_id}`]: data.documentId } : {}) }\n }\n\n if (\"documentItemId\" in data) {\n payload = { ...payload, ...(data?.documentItemId ? { [`${ModelDocumentInjectionFieldFields.document_item_id}`]: data.documentItemId } : {}) }\n }\n\n if (\"documentDocId\" in data) {\n payload = { ...payload, ...(data?.documentDocId ? { [`${ModelDocumentInjectionFieldFields.document_doc_id}`]: data.documentDocId } : {}) }\n }\n\n const rest = data.fields\n\n // apply dynamic prefix: refPrefix_modulePrefix_fieldKey\n const refPrefix = documentRefPrefixMap[ref as keyof typeof documentRefPrefixMap] ?? ref;\n const modulePrefix = documentModulePrefixMap[module as DocumentInjectionFieldModule] ?? module;\n\n for (const [key, value] of Object.entries(rest)) {\n payload[`${refPrefix}_${modulePrefix}_${key}`] = value;\n }\n\n return payload\n\n}\n\nexport const DocumentInjectionFieldService = (props: DocumentInjectionFieldServiceProps) => {\n\n const {\n prisma,\n accountId = 0,\n actionUserId = 0\n } = props\n\n const documentInjectionFieldModel = DocumentInjectionFieldModel({ prisma, accountId, actionUserId })\n\n const replaceDocumentInjectionField = async ({ data }: DocumentInjectionFieldReplaceProps) => {\n\n const _data = getReplacePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create payload: ${JSON.stringify(_data)}`);\n }\n\n const where: Record<string, any> = {\n [ModelDocumentInjectionFieldFields.field_module]: data.module,\n [ModelDocumentInjectionFieldFields.field_ref]: data.ref,\n ...((\"documentId\" in data) ? { [ModelDocumentInjectionFieldFields.document_id]: data.documentId } : {}),\n ...((\"documentItemId\" in data) ? { [ModelDocumentInjectionFieldFields.document_item_id]: data.documentItemId } : {}),\n ...((\"documentDocId\" in data) ? { [ModelDocumentInjectionFieldFields.document_doc_id]: data.documentDocId } : {}),\n };\n\n // Narrow: only include branchId if data.ref === \"branch\"\n // if (data.ref === \"branch\") {\n // where[ModelDocumentInjectionFieldFields.branch_id] = (data as Extract<DocumentInjectionFieldModuleRef, { ref: \"branch\" }>).branchId;\n // }\n\n let modelFields = await documentInjectionFieldModel.getFields()\n\n let finalData = convertPayloadByTableSchema(_data, modelFields)\n\n // console.log('modelFields', modelFields)\n // console.log('finalData', finalData)\n\n\n // check the request fields are in the exactly schema\n const resultInvalidFields = validateModelFieldsWithData(modelFields, finalData)\n\n if (resultInvalidFields.length > 0) {\n throw Error(`Invalid injection fields: ${resultInvalidFields.join(\", \")} (Request: ${Object.keys(finalData).join(\", \")})`)\n }\n\n // check the record exists\n let exists = await documentInjectionFieldModel.get({ where })\n\n let response: any = {}\n\n if (exists) { // update existing\n\n // remove unwanted to override\n delete finalData.field_module;\n delete finalData.field_ref;\n delete finalData.document_id;\n delete finalData.document_item_id;\n\n response = await documentInjectionFieldModel.update({ data: finalData, where, disableRollback: true })\n } else { // create new\n response = await documentInjectionFieldModel.create({ data: finalData })\n }\n\n return response\n }\n\n return {\n replaceDocumentInjectionField\n }\n\n}\n\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storemw-core-api",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "STOREMW Core API",
5
5
  "main": "dist/app.js",
6
6
  "types": "dist/app.d.ts",
@@ -2017,7 +2017,7 @@ model document_injection_fields {
2017
2017
  updateuserid BigInt @default(0)
2018
2018
  isdelete Boolean? @default(false)
2019
2019
  istrash Boolean? @default(false)
2020
- ax_accountid BigInt @default(0)
2020
+ accountid BigInt @default(0)
2021
2021
  doc_do_pack_qty2_bk_39 BigInt @default(0)
2022
2022
  doc_do_pack_qty2 BigInt? @default(0)
2023
2023
  doci_do_pack_item_qty BigInt? @default(0)