storemw-core-api 1.0.32 → 1.0.34

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.
@@ -12,8 +12,8 @@ const lib_1 = require("../../lib");
12
12
  const lib_2 = require("../../lib");
13
13
  const documentTypeKey = "DELIVERY";
14
14
  exports.deliveryOrderDataTypes = {
15
- deliveryOrderInjectionFields: "delivery_order_injection_fields",
16
- deliveryOrderItemInjectionFields: "delivery_order_item_injection_fields",
15
+ deliveryOrderInjectionFields: "delivery_injection_fields",
16
+ deliveryOrderItemInjectionFields: "delivery_item_injection_fields",
17
17
  // branch: "branch",
18
18
  // branchCount: "branch_count",
19
19
  // shippingAddress: "shipping_address",
@@ -1 +1 @@
1
- {"version":3,"file":"DeliveryOrderService.js","sourceRoot":"","sources":["../../../src/services/document/DeliveryOrderService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,qCAIkB;AAElB,yCAAmD;AAMnD,uEAAoE;AACpE,+DAA0E;AAC1E,iEAA6E;AAC7E,qEAAmF;AAEnF,+BAA0J;AAE1J,+BAUe;AAIf,MAAM,eAAe,GAAG,UAAU,CAAA;AAErB,QAAA,sBAAsB,GAAG;IAClC,4BAA4B,EAAE,iCAAiC;IAC/D,gCAAgC,EAAE,sCAAsC;IACxE,oBAAoB;IACpB,+BAA+B;IAC/B,uCAAuC;IACvC,kDAAkD;IAClD,wCAAwC;CAC3C,CAAA;AAyCD,IAAI,aAAa,GAAG,IAAA,gCAA0B,GAAE,CAAA;AAEhD,IAAI,oBAAoB,GAAG,IAAA,mCAA6B,EAAC,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAA;AACxI,IAAI,wBAAwB,GAAG,IAAA,mCAA6B,EAAC,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAA;AAC7I,IAAI,uBAAuB,GAAG,IAAA,mCAA6B,EAAC,W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GAAG,MAAM,uBAAuB,CAAC,uBAAuB,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAC;QAC3G,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,mBAAmB,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAA;QAClG,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC,sBAAsB,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAA;QACxG,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,oBAAoB,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAA;QAEpG,OAAO,SAAS,CAAA;IACpB,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,EAAE;QACtB,OAAO,MAAM,CAAC,MAAM,CAAC,8BAAsB,CAAC,CAAC;IACjD,CAAC,CAAA;IAED,OAAO;QACH,mBAAmB;QACnB,mBAAmB;QACnB,gBAAgB;QAChB,kBAAkB;QAClB,oBAAoB;QACpB,YAAY;KACf,CAAA;AAEL,CAAC,CAAA;AA5VY,QAAA,oBAAoB,wBA4VhC","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n DocumentModel,\n ModelDocumentFields,\n ModelDocumentPropFields,\n} from \"@/models\";\n\nimport { InjectionFieldService } from \"@/services\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { DocumentDocumentService } from \"./DocumentDocumentService\";\nimport { DocumentItemService, DocumentItem } from \"./DocumentItemService\";\nimport { DocumentTotalService, DocumentTotal } from \"./DocumentTotalService\";\nimport { DocumentProfileService, DocumentProfile } from \"./DocumentProfileService\";\n\nimport { getDocumentSqlRelationMaps, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect, getListWithCount } from \"@/lib\";\n\nimport {\n buildDocumentProfileSqlSelect,\n // buildDocumentAmountSqlSelect,\n // buildDocumentLocationSqlSelect,\n // buildDocumentPaymentSqlSelect,\n buildDocumentTotalSqlSelect,\n buildDocumentItemSqlSelect,\n buildDocumentItemSqlSelectAgg,\n buildDocumentMainSqlSelect,\n buildDocumentDefaultSqlSelect\n} from \"@/lib\";\n\nexport type DocumentType = \"delivery\"\n\nconst documentTypeKey = \"DELIVERY\"\n\nexport const deliveryOrderDataTypes = {\n deliveryOrderInjectionFields: \"delivery_order_injection_fields\",\n deliveryOrderItemInjectionFields: \"delivery_order_item_injection_fields\",\n // branch: \"branch\",\n // branchCount: \"branch_count\",\n // shippingAddress: \"shipping_address\",\n // shippingAddressCount: \"shipping_address_count\",\n // branchUserCount: \"branch_user_count\",\n}\n\nexport type DeliveryOrderDataType = keyof typeof deliveryOrderDataTypes;\n\nexport type DeliveryOrderServiceProps = DefaultServiceProps & {};\n\nexport type DeliveryOrderGetProps = QueryGet & {\n id: number,\n datatypes: DeliveryOrderDataType[]\n};\n\nexport type DeliveryOrderListProps = QueryList & {\n datatypes: DeliveryOrderDataType[]\n};\n\nexport type DeliveryOrderRemoveProps = {\n deliveryOrderIds: BigInt[]\n};\n\nexport type DeliveryOrderCreateProps = {\n documentId: number,\n data: {\n profile: Pick<DocumentProfile, \"userId\">,\n shipping: Omit<DocumentProfile, \"userId\" | \"profileType\">,\n billing: Omit<DocumentProfile, \"userId\" | \"profileType\">,\n items?: Omit<DocumentItem, \"documentId\">[]\n totals?: Omit<DocumentTotal, \"documentId\">[]\n }\n}\n\nexport type DeliveryOrderUpdateProps = {\n documentId: number,\n data: {\n profile: Pick<DocumentProfile, \"userId\">,\n shipping: Omit<DocumentProfile, \"userId\" | \"profileType\">,\n billing: Omit<DocumentProfile, \"userId\" | \"profileType\">,\n items?: Omit<DocumentItem, \"documentId\">[]\n totals?: Omit<DocumentTotal, \"documentId\">[]\n }\n}\n\nlet mainSqlSelect = buildDocumentMainSqlSelect()\n\nlet profileSqlMainSelect = buildDocumentProfileSqlSelect(\"docpromain\", \"docprostatemain\", \"docprocoumain\", \"docproareamain\", \"profile_\")\nlet profileSqlShippingSelect = buildDocumentProfileSqlSelect(\"docproship\", \"docprostateship\", \"docprocouship\", \"docproareaship\", \"shipping_\")\nlet profileSqlBillingSelect = buildDocumentProfileSqlSelect(\"docprobil\", \"docprostatebil\", \"docprocoubil\", \"docproareabil\", \"billing_\")\n\n// let amountSqlSelect = buildDocumentAmountSqlSelect()\n// let locationSqlSelect = buildDocumentLocationSqlSelect()\n// let paymentSqlSelect = buildDocumentPaymentSqlSelect()\nlet totalSqlSelect = buildDocumentTotalSqlSelect()\n\n// let propSqlSelect = {\n// [`docprop.${ModelDocumentPropFields.document_prop_id}`]: \"document_prop_id\",\n// [`docprop.${ModelDocumentPropFields.document_status}`]: \"document_status\"\n// }\n\nlet defaultSqlSelect = buildDocumentDefaultSqlSelect()\n\nconst { relationKeys, sqlRelationMaps } = getDocumentSqlRelationMaps(documentTypeKey)\n\nexport const DeliveryOrderService = (props: DeliveryOrderServiceProps) => {\n\n const {\n prisma,\n accountId = 0,\n actionUserId = 0\n } = props\n\n const documentModel = DocumentModel({ prisma, accountId, actionUserId })\n\n const documentDocumentService = DocumentDocumentService({ prisma, accountId, actionUserId, documentType: documentTypeKey as DocumentType })\n const documentProfileService = DocumentProfileService({ prisma, accountId, actionUserId, documentType: documentTypeKey as DocumentType })\n const documentItemService = DocumentItemService({ prisma, accountId, actionUserId, documentType: documentTypeKey as DocumentType })\n const documentTotalService = DocumentTotalService({ prisma, accountId, actionUserId, documentType: documentTypeKey as DocumentType })\n\n const injectionFieldService = InjectionFieldService({ prisma, accountId, actionUserId, injectionFieldType: \"document\" })\n\n const createDeliveryOrder = async ({ data, documentId }: DeliveryOrderCreateProps) => {\n\n // replace profile - main\n let resProfile = await documentProfileService.replaceDocumentProfileHQ({\n documentId,\n data: {\n ...data.profile,\n }\n })\n\n // replace profile - billing\n let resBilling = await documentProfileService.replaceDocumentProfileOther({\n documentId,\n documentProfileType: \"billing\",\n data: {\n ...data.billing\n }\n })\n\n // replace profile - shipping\n let resShipping = await documentProfileService.replaceDocumentProfileOther({\n documentId,\n documentProfileType: \"shipping\",\n data: {\n ...data.shipping\n }\n })\n\n // console.log('data', data, resProfile)\n // console.log('data', data, resBilling)\n // console.log('data', data, resShipping)\n\n let resItems: any = []\n\n // replace items\n if (data?.items && data.items?.length > 0) {\n resItems = await documentItemService.replaceDocumentItems({\n data: data.items?.map(i => ({\n documentId,\n ...i\n }))\n })\n }\n\n let resTotals: any = []\n\n // replace totals\n if (data?.totals && data.totals?.length > 0) {\n resTotals = await documentTotalService.replaceDocumentTotals({\n documentType: documentTypeKey.toLowerCase() as DocumentType,\n data: data.totals?.map(i => ({\n ...i,\n documentId,\n }))\n })\n }\n\n // calculate and replace all the document amounts\n const documentAmounts = documentDocumentService.calculateDocumentAmount({\n items: resItems.length > 0 ? resItems[0] : [],\n totals: resTotals.length > 0 ? resTotals[0] : []\n })\n\n await documentDocumentService.replaceDocumentAmount({\n documentId,\n data: documentAmounts\n })\n\n return await getDeliveryOrder({ id: documentId, datatypes: [] })\n\n }\n\n const updateDeliveryOrder = async ({ documentId, data }: DeliveryOrderUpdateProps) => {\n\n // replace profile - main\n let resProfile = await documentProfileService.replaceDocumentProfileHQ({\n documentId,\n data: {\n ...data.profile,\n }\n })\n\n // replace profile - billing\n let resBilling = await documentProfileService.replaceDocumentProfileOther({\n documentId,\n documentProfileType: \"billing\",\n data: {\n ...data.billing\n }\n })\n\n // replace profile - shipping\n let resShipping = await documentProfileService.replaceDocumentProfileOther({\n documentId,\n documentProfileType: \"shipping\",\n data: {\n ...data.shipping\n }\n })\n\n // console.log('data', data, resProfile)\n // console.log('data', data, resBilling)\n // console.log('data', data, resShipping)\n\n let resItems: any = []\n\n // replace items\n if (data?.items && data.items?.length > 0) {\n resItems = await documentItemService.replaceDocumentItems({\n data: data.items?.map(i => ({\n documentId,\n ...i\n }))\n })\n }\n\n let resTotals: any = []\n\n // replace totals\n if (data?.totals && data.totals?.length > 0) {\n resTotals = await documentTotalService.replaceDocumentTotals({\n documentType: documentTypeKey as DocumentType,\n data: data.totals?.map(i => ({\n ...i,\n documentId,\n }))\n })\n }\n\n // calculate and replace all the document amounts\n const documentAmounts = documentDocumentService.calculateDocumentAmount({\n items: resItems.length > 0 ? resItems[0] : [],\n totals: resTotals.length > 0 ? resTotals[0] : []\n })\n\n await documentDocumentService.replaceDocumentAmount({\n documentId,\n data: documentAmounts\n })\n\n return await getDeliveryOrder({ id: documentId, datatypes: [] })\n }\n\n const getDeliveryOrder = async ({ id, datatypes = [] }: DeliveryOrderGetProps) => {\n\n let { data } = await listDeliveryOrders({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelDocumentFields.document_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelDocumentFields.document_id}`,\n sortorder: \"ASC\",\n datatypes\n })\n\n return data[0] ?? null;\n\n };\n\n const listDeliveryOrders = async ({\n limit,\n offset,\n filters,\n sortfield,\n sortorder,\n datatypes = []\n }: DeliveryOrderListProps) => {\n\n let sqlSelect: string[] = []\n let sqlRelation: string[] = []\n let sqlGroupBy: string[] = []\n\n let sqlSelectAgg: string[] = []\n let sqlRelationAgg: string[] = []\n\n sqlSelect = [\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, profileSqlMainSelect),\n buildSqlSelect(``, profileSqlShippingSelect),\n buildSqlSelect(``, profileSqlBillingSelect),\n // buildSqlSelect(``, amountSqlSelect),\n // buildSqlSelect(``, locationSqlSelect),\n // buildSqlSelect(``, paymentSqlSelect),\n buildSqlSelect(``, totalSqlSelect),\n // buildSqlSelect(``, propSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n sqlRelation = [\n sqlRelationMaps.docpromain,\n sqlRelationMaps.docproship,\n sqlRelationMaps.docprobil,\n sqlRelationMaps.docproareamain,\n sqlRelationMaps.docproareaship,\n sqlRelationMaps.docproareabil,\n sqlRelationMaps.docprostatemain,\n sqlRelationMaps.docprostateship,\n sqlRelationMaps.docprostatebil,\n sqlRelationMaps.docprocoumain,\n sqlRelationMaps.docprocouship,\n sqlRelationMaps.docprocoubil,\n sqlRelationMaps.docttl,\n sqlRelationMaps.maindocloc,\n sqlRelationMaps.creator,\n sqlRelationMaps.updater\n ]\n\n sqlRelationAgg = [\n sqlRelationMaps.docitm,\n ]\n\n sqlGroupBy = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(profileSqlMainSelect),\n ...Object.keys(profileSqlShippingSelect),\n ...Object.keys(profileSqlBillingSelect),\n // ...Object.keys(amountSqlSelect),\n // ...Object.keys(locationSqlSelect),\n // ...Object.keys(propSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...profileSqlMainSelect,\n ...profileSqlShippingSelect,\n ...profileSqlBillingSelect,\n // ...amountSqlSelect,\n // ...locationSqlSelect,\n // ...propSqlSelect,\n ...defaultSqlSelect\n }\n\n if (datatypes.includes(deliveryOrderDataTypes.deliveryOrderInjectionFields)) {\n\n let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"document\", documentTypeKey.toLowerCase() as any)\n\n const deliveryOrderInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"dif\", activeInjectionFields)\n\n filterColumns = { ...filterColumns, ...deliveryOrderInjectionFieldSqlSelect }\n\n sqlSelect = [...sqlSelect, ...(activeInjectionFields.length > 0 ? [buildSqlSelect(``, deliveryOrderInjectionFieldSqlSelect)] : [])]\n sqlRelation = [...sqlRelation, sqlRelationMaps.dif]\n sqlGroupBy = [...sqlGroupBy, ...Object.keys(deliveryOrderInjectionFieldSqlSelect)]\n }\n\n let itemSqlSelectAgg = buildDocumentItemSqlSelectAgg()\n\n if (datatypes.includes(deliveryOrderDataTypes.deliveryOrderItemInjectionFields)) {\n\n let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"document_item\", documentTypeKey.toLowerCase() as any)\n\n const deliveryOrderItemInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"difi\", activeInjectionFields)\n\n if (Object.entries(deliveryOrderItemInjectionFieldSqlSelect).length > 0) {\n Object.entries(deliveryOrderItemInjectionFieldSqlSelect).map(([col, alias]) => {\n itemSqlSelectAgg.push(`'${alias}', ${col}`)\n })\n }\n\n sqlRelationAgg = [...sqlRelationAgg, sqlRelationMaps.difi]\n\n }\n\n let itemSqlSelect = buildDocumentItemSqlSelect(itemSqlSelectAgg)\n\n sqlSelectAgg = [...sqlSelectAgg, ...[buildSqlSelect(``, itemSqlSelect)]]\n\n let sqlWhere = [\n `maindoc.isdelete = false`,\n `maindoc.istrash = false`,\n `LOWER(maindoc.doc_type) = LOWER('${documentTypeKey}')`\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n // get the listing data & count\n const { data, total } = await getListWithCount({\n model: documentModel,\n tableName: \"documents\",\n mainAlias: \"maindoc\",\n countKey: `${ModelDocumentFields.document_id}`,\n accountId,\n sqlRelationMaps,\n filters,\n filterColumns,\n sqlSelect,\n sqlSelectAgg,\n sqlRelation,\n sqlRelationAgg,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n const response = {\n data,\n total\n }\n\n return response\n\n };\n\n const removeDeliveryOrders = async ({ deliveryOrderIds }: DeliveryOrderRemoveProps) => {\n\n if (!deliveryOrderIds.length) throwError('deliveryOrderIds is required');\n\n // remove documents\n const response1 = await documentDocumentService.removeDocumentDocuments({ documentIds: deliveryOrderIds });\n const response2 = await documentItemService.removeDocumentItems({ documentIds: deliveryOrderIds })\n const response3 = await documentProfileService.removeDocumentProfiles({ documentIds: deliveryOrderIds })\n const response4 = await documentTotalService.removeDocumentTotals({ documentIds: deliveryOrderIds })\n\n return response1\n };\n\n const getDataTypes = () => {\n return Object.values(deliveryOrderDataTypes);\n }\n\n return {\n createDeliveryOrder,\n updateDeliveryOrder,\n getDeliveryOrder,\n listDeliveryOrders,\n removeDeliveryOrders,\n getDataTypes\n }\n\n}\n\n"]}
1
+ {"version":3,"file":"DeliveryOrderService.js","sourceRoot":"","sources":["../../../src/services/document/DeliveryOrderService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,qCAIkB;AAElB,yCAAmD;AAMnD,uEAAoE;AACpE,+DAA0E;AAC1E,iEAA6E;AAC7E,qEAAmF;AAEnF,+BAA0J;AAE1J,+BAUe;AAIf,MAAM,eAAe,GAAG,UAAU,CAAA;AAErB,QAAA,sBAAsB,GAAG;IAClC,4BAA4B,EAAE,2BAA2B;IACzD,gCAAgC,EAAE,gCAAgC;IAClE,oBAAoB;IACpB,+BAA+B;IAC/B,uCAAuC;IACvC,kDAAkD;IAClD,wCAAwC;CAC3C,CAAA;AAyCD,IAAI,aAAa,GAAG,IAAA,gCAA0B,GAAE,CAAA;AAEhD,IAAI,oBAAoB,GAAG,IAAA,mCAA6B,EAAC,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAA;AACxI,IAAI,wBAAwB,GAAG,IAAA,mCAA6B,EAAC,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAA;AAC7I,IAAI,uBAAuB,GAAG,IAAA,mCAA6B,EAAC,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,CAAC,CAAA;AAEvI,uDAAuD;AACvD,2DAA2D;AAC3D,yDAAyD;AACzD,IAAI,cAAc,GAAG,IAAA,iCAA2B,GAAE,CAAA;AAElD,wBAAwB;AACxB,mFAAmF;AACnF,gFAAgF;AAChF,IAAI;AAEJ,IAAI,gBAAgB,GAAG,IAAA,mCAA6B,GAAE,CAAA;AAEtD,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,IAAA,gCAA0B,EAAC,eAAe,CAAC,CAAA;AAE9E,MAAM,oBAAoB,GAAG,CAAC,KAAgC,EAAE,EAAE;IAErE,MAAM,EACF,MAAM,EACN,SA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F,MAAM,YAAY,GAAG,GAAG,EAAE;QACtB,OAAO,MAAM,CAAC,MAAM,CAAC,8BAAsB,CAAC,CAAC;IACjD,CAAC,CAAA;IAED,OAAO;QACH,mBAAmB;QACnB,mBAAmB;QACnB,gBAAgB;QAChB,kBAAkB;QAClB,oBAAoB;QACpB,YAAY;KACf,CAAA;AAEL,CAAC,CAAA;AA5VY,QAAA,oBAAoB,wBA4VhC","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n DocumentModel,\n ModelDocumentFields,\n ModelDocumentPropFields,\n} from \"@/models\";\n\nimport { InjectionFieldService } from \"@/services\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { DocumentDocumentService } from \"./DocumentDocumentService\";\nimport { DocumentItemService, DocumentItem } from \"./DocumentItemService\";\nimport { DocumentTotalService, DocumentTotal } from \"./DocumentTotalService\";\nimport { DocumentProfileService, DocumentProfile } from \"./DocumentProfileService\";\n\nimport { getDocumentSqlRelationMaps, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect, getListWithCount } from \"@/lib\";\n\nimport {\n buildDocumentProfileSqlSelect,\n // buildDocumentAmountSqlSelect,\n // buildDocumentLocationSqlSelect,\n // buildDocumentPaymentSqlSelect,\n buildDocumentTotalSqlSelect,\n buildDocumentItemSqlSelect,\n buildDocumentItemSqlSelectAgg,\n buildDocumentMainSqlSelect,\n buildDocumentDefaultSqlSelect\n} from \"@/lib\";\n\nexport type DocumentType = \"delivery\"\n\nconst documentTypeKey = \"DELIVERY\"\n\nexport const deliveryOrderDataTypes = {\n deliveryOrderInjectionFields: \"delivery_injection_fields\",\n deliveryOrderItemInjectionFields: \"delivery_item_injection_fields\",\n // branch: \"branch\",\n // branchCount: \"branch_count\",\n // shippingAddress: \"shipping_address\",\n // shippingAddressCount: \"shipping_address_count\",\n // branchUserCount: \"branch_user_count\",\n}\n\nexport type DeliveryOrderDataType = keyof typeof deliveryOrderDataTypes;\n\nexport type DeliveryOrderServiceProps = DefaultServiceProps & {};\n\nexport type DeliveryOrderGetProps = QueryGet & {\n id: number,\n datatypes: DeliveryOrderDataType[]\n};\n\nexport type DeliveryOrderListProps = QueryList & {\n datatypes: DeliveryOrderDataType[]\n};\n\nexport type DeliveryOrderRemoveProps = {\n deliveryOrderIds: BigInt[]\n};\n\nexport type DeliveryOrderCreateProps = {\n documentId: number,\n data: {\n profile: Pick<DocumentProfile, \"userId\">,\n shipping: Omit<DocumentProfile, \"userId\" | \"profileType\">,\n billing: Omit<DocumentProfile, \"userId\" | \"profileType\">,\n items?: Omit<DocumentItem, \"documentId\">[]\n totals?: Omit<DocumentTotal, \"documentId\">[]\n }\n}\n\nexport type DeliveryOrderUpdateProps = {\n documentId: number,\n data: {\n profile: Pick<DocumentProfile, \"userId\">,\n shipping: Omit<DocumentProfile, \"userId\" | \"profileType\">,\n billing: Omit<DocumentProfile, \"userId\" | \"profileType\">,\n items?: Omit<DocumentItem, \"documentId\">[]\n totals?: Omit<DocumentTotal, \"documentId\">[]\n }\n}\n\nlet mainSqlSelect = buildDocumentMainSqlSelect()\n\nlet profileSqlMainSelect = buildDocumentProfileSqlSelect(\"docpromain\", \"docprostatemain\", \"docprocoumain\", \"docproareamain\", \"profile_\")\nlet profileSqlShippingSelect = buildDocumentProfileSqlSelect(\"docproship\", \"docprostateship\", \"docprocouship\", \"docproareaship\", \"shipping_\")\nlet profileSqlBillingSelect = buildDocumentProfileSqlSelect(\"docprobil\", \"docprostatebil\", \"docprocoubil\", \"docproareabil\", \"billing_\")\n\n// let amountSqlSelect = buildDocumentAmountSqlSelect()\n// let locationSqlSelect = buildDocumentLocationSqlSelect()\n// let paymentSqlSelect = buildDocumentPaymentSqlSelect()\nlet totalSqlSelect = buildDocumentTotalSqlSelect()\n\n// let propSqlSelect = {\n// [`docprop.${ModelDocumentPropFields.document_prop_id}`]: \"document_prop_id\",\n// [`docprop.${ModelDocumentPropFields.document_status}`]: \"document_status\"\n// }\n\nlet defaultSqlSelect = buildDocumentDefaultSqlSelect()\n\nconst { relationKeys, sqlRelationMaps } = getDocumentSqlRelationMaps(documentTypeKey)\n\nexport const DeliveryOrderService = (props: DeliveryOrderServiceProps) => {\n\n const {\n prisma,\n accountId = 0,\n actionUserId = 0\n } = props\n\n const documentModel = DocumentModel({ prisma, accountId, actionUserId })\n\n const documentDocumentService = DocumentDocumentService({ prisma, accountId, actionUserId, documentType: documentTypeKey as DocumentType })\n const documentProfileService = DocumentProfileService({ prisma, accountId, actionUserId, documentType: documentTypeKey as DocumentType })\n const documentItemService = DocumentItemService({ prisma, accountId, actionUserId, documentType: documentTypeKey as DocumentType })\n const documentTotalService = DocumentTotalService({ prisma, accountId, actionUserId, documentType: documentTypeKey as DocumentType })\n\n const injectionFieldService = InjectionFieldService({ prisma, accountId, actionUserId, injectionFieldType: \"document\" })\n\n const createDeliveryOrder = async ({ data, documentId }: DeliveryOrderCreateProps) => {\n\n // replace profile - main\n let resProfile = await documentProfileService.replaceDocumentProfileHQ({\n documentId,\n data: {\n ...data.profile,\n }\n })\n\n // replace profile - billing\n let resBilling = await documentProfileService.replaceDocumentProfileOther({\n documentId,\n documentProfileType: \"billing\",\n data: {\n ...data.billing\n }\n })\n\n // replace profile - shipping\n let resShipping = await documentProfileService.replaceDocumentProfileOther({\n documentId,\n documentProfileType: \"shipping\",\n data: {\n ...data.shipping\n }\n })\n\n // console.log('data', data, resProfile)\n // console.log('data', data, resBilling)\n // console.log('data', data, resShipping)\n\n let resItems: any = []\n\n // replace items\n if (data?.items && data.items?.length > 0) {\n resItems = await documentItemService.replaceDocumentItems({\n data: data.items?.map(i => ({\n documentId,\n ...i\n }))\n })\n }\n\n let resTotals: any = []\n\n // replace totals\n if (data?.totals && data.totals?.length > 0) {\n resTotals = await documentTotalService.replaceDocumentTotals({\n documentType: documentTypeKey.toLowerCase() as DocumentType,\n data: data.totals?.map(i => ({\n ...i,\n documentId,\n }))\n })\n }\n\n // calculate and replace all the document amounts\n const documentAmounts = documentDocumentService.calculateDocumentAmount({\n items: resItems.length > 0 ? resItems[0] : [],\n totals: resTotals.length > 0 ? resTotals[0] : []\n })\n\n await documentDocumentService.replaceDocumentAmount({\n documentId,\n data: documentAmounts\n })\n\n return await getDeliveryOrder({ id: documentId, datatypes: [] })\n\n }\n\n const updateDeliveryOrder = async ({ documentId, data }: DeliveryOrderUpdateProps) => {\n\n // replace profile - main\n let resProfile = await documentProfileService.replaceDocumentProfileHQ({\n documentId,\n data: {\n ...data.profile,\n }\n })\n\n // replace profile - billing\n let resBilling = await documentProfileService.replaceDocumentProfileOther({\n documentId,\n documentProfileType: \"billing\",\n data: {\n ...data.billing\n }\n })\n\n // replace profile - shipping\n let resShipping = await documentProfileService.replaceDocumentProfileOther({\n documentId,\n documentProfileType: \"shipping\",\n data: {\n ...data.shipping\n }\n })\n\n // console.log('data', data, resProfile)\n // console.log('data', data, resBilling)\n // console.log('data', data, resShipping)\n\n let resItems: any = []\n\n // replace items\n if (data?.items && data.items?.length > 0) {\n resItems = await documentItemService.replaceDocumentItems({\n data: data.items?.map(i => ({\n documentId,\n ...i\n }))\n })\n }\n\n let resTotals: any = []\n\n // replace totals\n if (data?.totals && data.totals?.length > 0) {\n resTotals = await documentTotalService.replaceDocumentTotals({\n documentType: documentTypeKey as DocumentType,\n data: data.totals?.map(i => ({\n ...i,\n documentId,\n }))\n })\n }\n\n // calculate and replace all the document amounts\n const documentAmounts = documentDocumentService.calculateDocumentAmount({\n items: resItems.length > 0 ? resItems[0] : [],\n totals: resTotals.length > 0 ? resTotals[0] : []\n })\n\n await documentDocumentService.replaceDocumentAmount({\n documentId,\n data: documentAmounts\n })\n\n return await getDeliveryOrder({ id: documentId, datatypes: [] })\n }\n\n const getDeliveryOrder = async ({ id, datatypes = [] }: DeliveryOrderGetProps) => {\n\n let { data } = await listDeliveryOrders({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelDocumentFields.document_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelDocumentFields.document_id}`,\n sortorder: \"ASC\",\n datatypes\n })\n\n return data[0] ?? null;\n\n };\n\n const listDeliveryOrders = async ({\n limit,\n offset,\n filters,\n sortfield,\n sortorder,\n datatypes = []\n }: DeliveryOrderListProps) => {\n\n let sqlSelect: string[] = []\n let sqlRelation: string[] = []\n let sqlGroupBy: string[] = []\n\n let sqlSelectAgg: string[] = []\n let sqlRelationAgg: string[] = []\n\n sqlSelect = [\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, profileSqlMainSelect),\n buildSqlSelect(``, profileSqlShippingSelect),\n buildSqlSelect(``, profileSqlBillingSelect),\n // buildSqlSelect(``, amountSqlSelect),\n // buildSqlSelect(``, locationSqlSelect),\n // buildSqlSelect(``, paymentSqlSelect),\n buildSqlSelect(``, totalSqlSelect),\n // buildSqlSelect(``, propSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n sqlRelation = [\n sqlRelationMaps.docpromain,\n sqlRelationMaps.docproship,\n sqlRelationMaps.docprobil,\n sqlRelationMaps.docproareamain,\n sqlRelationMaps.docproareaship,\n sqlRelationMaps.docproareabil,\n sqlRelationMaps.docprostatemain,\n sqlRelationMaps.docprostateship,\n sqlRelationMaps.docprostatebil,\n sqlRelationMaps.docprocoumain,\n sqlRelationMaps.docprocouship,\n sqlRelationMaps.docprocoubil,\n sqlRelationMaps.docttl,\n sqlRelationMaps.maindocloc,\n sqlRelationMaps.creator,\n sqlRelationMaps.updater\n ]\n\n sqlRelationAgg = [\n sqlRelationMaps.docitm,\n ]\n\n sqlGroupBy = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(profileSqlMainSelect),\n ...Object.keys(profileSqlShippingSelect),\n ...Object.keys(profileSqlBillingSelect),\n // ...Object.keys(amountSqlSelect),\n // ...Object.keys(locationSqlSelect),\n // ...Object.keys(propSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...profileSqlMainSelect,\n ...profileSqlShippingSelect,\n ...profileSqlBillingSelect,\n // ...amountSqlSelect,\n // ...locationSqlSelect,\n // ...propSqlSelect,\n ...defaultSqlSelect\n }\n\n if (datatypes.includes(deliveryOrderDataTypes.deliveryOrderInjectionFields)) {\n\n let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"document\", documentTypeKey.toLowerCase() as any)\n\n const deliveryOrderInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"dif\", activeInjectionFields)\n\n filterColumns = { ...filterColumns, ...deliveryOrderInjectionFieldSqlSelect }\n\n sqlSelect = [...sqlSelect, ...(activeInjectionFields.length > 0 ? [buildSqlSelect(``, deliveryOrderInjectionFieldSqlSelect)] : [])]\n sqlRelation = [...sqlRelation, sqlRelationMaps.dif]\n sqlGroupBy = [...sqlGroupBy, ...Object.keys(deliveryOrderInjectionFieldSqlSelect)]\n }\n\n let itemSqlSelectAgg = buildDocumentItemSqlSelectAgg()\n\n if (datatypes.includes(deliveryOrderDataTypes.deliveryOrderItemInjectionFields)) {\n\n let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"document_item\", documentTypeKey.toLowerCase() as any)\n\n const deliveryOrderItemInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"difi\", activeInjectionFields)\n\n if (Object.entries(deliveryOrderItemInjectionFieldSqlSelect).length > 0) {\n Object.entries(deliveryOrderItemInjectionFieldSqlSelect).map(([col, alias]) => {\n itemSqlSelectAgg.push(`'${alias}', ${col}`)\n })\n }\n\n sqlRelationAgg = [...sqlRelationAgg, sqlRelationMaps.difi]\n\n }\n\n let itemSqlSelect = buildDocumentItemSqlSelect(itemSqlSelectAgg)\n\n sqlSelectAgg = [...sqlSelectAgg, ...[buildSqlSelect(``, itemSqlSelect)]]\n\n let sqlWhere = [\n `maindoc.isdelete = false`,\n `maindoc.istrash = false`,\n `LOWER(maindoc.doc_type) = LOWER('${documentTypeKey}')`\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n // get the listing data & count\n const { data, total } = await getListWithCount({\n model: documentModel,\n tableName: \"documents\",\n mainAlias: \"maindoc\",\n countKey: `${ModelDocumentFields.document_id}`,\n accountId,\n sqlRelationMaps,\n filters,\n filterColumns,\n sqlSelect,\n sqlSelectAgg,\n sqlRelation,\n sqlRelationAgg,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n const response = {\n data,\n total\n }\n\n return response\n\n };\n\n const removeDeliveryOrders = async ({ deliveryOrderIds }: DeliveryOrderRemoveProps) => {\n\n if (!deliveryOrderIds.length) throwError('deliveryOrderIds is required');\n\n // remove documents\n const response1 = await documentDocumentService.removeDocumentDocuments({ documentIds: deliveryOrderIds });\n const response2 = await documentItemService.removeDocumentItems({ documentIds: deliveryOrderIds })\n const response3 = await documentProfileService.removeDocumentProfiles({ documentIds: deliveryOrderIds })\n const response4 = await documentTotalService.removeDocumentTotals({ documentIds: deliveryOrderIds })\n\n return response1\n };\n\n const getDataTypes = () => {\n return Object.values(deliveryOrderDataTypes);\n }\n\n return {\n createDeliveryOrder,\n updateDeliveryOrder,\n getDeliveryOrder,\n listDeliveryOrders,\n removeDeliveryOrders,\n getDataTypes\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.32",
3
+ "version": "1.0.34",
4
4
  "description": "STOREMW Core API",
5
5
  "main": "dist/app.js",
6
6
  "types": "dist/app.d.ts",