@things-factory/operato-wms 5.0.13 → 6.0.0-alpha.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.
Files changed (206) hide show
  1. package/client/pages/bulk-operation/bulk-operation.js +96 -8
  2. package/client/pages/bulk-operation/validate-gan-popup.js +37 -27
  3. package/client/pages/bulk-operation/validate-ro-popup.js +40 -0
  4. package/client/pages/components/select-inventory-popup.js +633 -0
  5. package/client/pages/constants/order.js +2 -1
  6. package/client/pages/inbound/pallet-label-popup.js +2 -0
  7. package/client/pages/inbound/select-product-batch.js +7 -1
  8. package/client/pages/inbound/undo-unload-popup.js +37 -21
  9. package/client/pages/inbound/unload-product.js +147 -59
  10. package/client/pages/inbound/worksheet-putaway.js +1 -1
  11. package/client/pages/inbound/worksheet-unloading.js +11 -7
  12. package/client/pages/inventory/inventory-adjustment.js +261 -238
  13. package/client/pages/inventory/inventory-by-product-detail.js +99 -92
  14. package/client/pages/inventory/inventory-by-product.js +170 -68
  15. package/client/pages/inventory/onhand-inventory.js +10 -12
  16. package/client/pages/inventory/serial-number-list-popup.js +36 -5
  17. package/client/pages/inventory-check/inspecting-product.js +1 -1
  18. package/client/pages/manifest/create-loading-manifest.js +47 -22
  19. package/client/pages/manifest/dispatcher-verification-popup.js +24 -13
  20. package/client/pages/manifest/loading-manifest-detail.js +311 -46
  21. package/client/pages/manifest/loading-manifest-list.js +86 -13
  22. package/client/pages/order/arrival-notice/arrival-notice-detail.js +305 -52
  23. package/client/pages/order/arrival-notice/arrival-notice-list.js +20 -1
  24. package/client/pages/order/arrival-notice/create-arrival-notice.js +2 -2
  25. package/client/pages/order/goods-received-note/received-note-detail.js +187 -15
  26. package/client/pages/order/release-order/b2b/b2b-order-list.js +76 -80
  27. package/client/pages/order/release-order/b2c/b2c-order-requests.js +148 -123
  28. package/client/pages/order/release-order/batch-picking-popup.js +11 -0
  29. package/client/pages/order/release-order/create-release-order.js +762 -250
  30. package/client/pages/order/release-order/release-extra-product-popup.js +10 -3
  31. package/client/pages/order/release-order/release-order-detail.js +897 -215
  32. package/client/pages/order/transport-order/delivery-note-popup.js +1050 -107
  33. package/client/pages/order/transport-order/print-delivery-note.js +214 -33
  34. package/client/pages/order/transport-order/upload-delivery-note.js +6 -4
  35. package/client/pages/order/transport-order/view-delivery-note.js +0 -1
  36. package/client/pages/outbound/generate-worksheet-popup.js +374 -0
  37. package/client/pages/outbound/inventory-reassign-popup.js +1097 -0
  38. package/client/pages/outbound/loading-product.js +88 -78
  39. package/client/pages/outbound/merged-outbound-worksheet.js +1 -1
  40. package/client/pages/outbound/packing-product.js +193 -82
  41. package/client/pages/outbound/packing-worksheet-list.js +10 -9
  42. package/client/pages/outbound/picking-product.js +979 -905
  43. package/client/pages/outbound/route-label-popup.js +283 -191
  44. package/client/pages/outbound/serial-number-popup.js +1 -0
  45. package/client/pages/outbound/sorting-product.js +12 -12
  46. package/client/pages/outbound/worksheet-batch-picking.js +39 -5
  47. package/client/pages/outbound/worksheet-packing.js +17 -4
  48. package/client/pages/outbound/worksheet-picking.js +45 -6
  49. package/client/pages/report/inbound-serial-number-report.js +86 -9
  50. package/client/pages/report/inventory-report.js +10 -0
  51. package/client/pages/report/inventory-summary-report.js +28 -19
  52. package/client/pages/report/outbound-order-details-report.js +204 -43
  53. package/client/pages/report/outbound-serial-number-report.js +87 -9
  54. package/client/pages/report/release-inventory-report.js +503 -0
  55. package/client/route.js +5 -0
  56. package/client/util/index.js +2 -0
  57. package/client/util/page-settings.js +43 -0
  58. package/client/util/toast.js +10 -0
  59. package/dist-server/graphql/resolvers/board-setting/board-settings.js +3 -3
  60. package/dist-server/graphql/resolvers/board-setting/board-settings.js.map +1 -1
  61. package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.js +2 -2
  62. package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.js.map +1 -1
  63. package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.js +1 -1
  64. package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.js.map +1 -1
  65. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.js +2 -2
  66. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.js.map +1 -1
  67. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js +9 -10
  68. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js.map +1 -1
  69. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.js +2 -2
  70. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.js.map +1 -1
  71. package/dist-server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.js +6 -4
  72. package/dist-server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.js.map +1 -1
  73. package/dist-server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.js +6 -4
  74. package/dist-server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.js.map +1 -1
  75. package/dist-server/graphql/resolvers/dashboard/arrival-notices-by-status.js +21 -10
  76. package/dist-server/graphql/resolvers/dashboard/arrival-notices-by-status.js.map +1 -1
  77. package/dist-server/graphql/resolvers/dashboard/collection-orders-by-status.js +1 -2
  78. package/dist-server/graphql/resolvers/dashboard/collection-orders-by-status.js.map +1 -1
  79. package/dist-server/graphql/resolvers/dashboard/delivery-orders-by-status.js +1 -2
  80. package/dist-server/graphql/resolvers/dashboard/delivery-orders-by-status.js.map +1 -1
  81. package/dist-server/graphql/resolvers/dashboard/index.js +2 -1
  82. package/dist-server/graphql/resolvers/dashboard/index.js.map +1 -1
  83. package/dist-server/graphql/resolvers/dashboard/inventory-expiry-monitor.js +17 -1
  84. package/dist-server/graphql/resolvers/dashboard/inventory-expiry-monitor.js.map +1 -1
  85. package/dist-server/graphql/resolvers/dashboard/outbound-order-by-status.js +113 -75
  86. package/dist-server/graphql/resolvers/dashboard/outbound-order-by-status.js.map +1 -1
  87. package/dist-server/graphql/resolvers/dashboard/release-goods-by-status.js +21 -10
  88. package/dist-server/graphql/resolvers/dashboard/release-goods-by-status.js.map +1 -1
  89. package/dist-server/graphql/resolvers/dashboard/unit-inbounded-outbounded.js +56 -0
  90. package/dist-server/graphql/resolvers/dashboard/unit-inbounded-outbounded.js.map +1 -0
  91. package/dist-server/graphql/resolvers/index.js +5 -4
  92. package/dist-server/graphql/resolvers/index.js.map +1 -1
  93. package/dist-server/graphql/resolvers/inventory-comparison/inventory-comparison-list.js.map +1 -1
  94. package/dist-server/graphql/resolvers/opa-menu/opa-menus.js +8 -7
  95. package/dist-server/graphql/resolvers/opa-menu/opa-menus.js.map +1 -1
  96. package/dist-server/graphql/resolvers/{extra → other}/add-release-good-products.js +59 -8
  97. package/dist-server/graphql/resolvers/other/add-release-good-products.js.map +1 -0
  98. package/dist-server/graphql/resolvers/{extra → other}/index.js +3 -1
  99. package/dist-server/graphql/resolvers/other/index.js.map +1 -0
  100. package/dist-server/graphql/resolvers/other/page-settings.js +87 -0
  101. package/dist-server/graphql/resolvers/other/page-settings.js.map +1 -0
  102. package/dist-server/graphql/resolvers/reports/costing-report.js +4 -4
  103. package/dist-server/graphql/resolvers/reports/costing-report.js.map +1 -1
  104. package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js +3 -3
  105. package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js.map +1 -1
  106. package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js +36 -7
  107. package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js.map +1 -1
  108. package/dist-server/graphql/resolvers/reports/index.js +2 -1
  109. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  110. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js +69 -30
  111. package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js.map +1 -1
  112. package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js +36 -11
  113. package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js.map +1 -1
  114. package/dist-server/graphql/resolvers/reports/product-label-report.js +3 -3
  115. package/dist-server/graphql/resolvers/reports/product-label-report.js.map +1 -1
  116. package/dist-server/graphql/resolvers/reports/release-inventory-report.js +180 -0
  117. package/dist-server/graphql/resolvers/reports/release-inventory-report.js.map +1 -0
  118. package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js +2 -2
  119. package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js.map +1 -1
  120. package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js +1 -1
  121. package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js.map +1 -1
  122. package/dist-server/graphql/types/dashboard/index.js +1 -0
  123. package/dist-server/graphql/types/dashboard/index.js.map +1 -1
  124. package/dist-server/graphql/types/index.js +7 -2
  125. package/dist-server/graphql/types/index.js.map +1 -1
  126. package/dist-server/graphql/types/other/index.js +19 -0
  127. package/dist-server/graphql/types/other/index.js.map +1 -0
  128. package/dist-server/graphql/types/other/page-setting.js +34 -0
  129. package/dist-server/graphql/types/other/page-setting.js.map +1 -0
  130. package/dist-server/graphql/types/reports/index.js +6 -1
  131. package/dist-server/graphql/types/reports/index.js.map +1 -1
  132. package/dist-server/graphql/types/reports/outbound-order-details-report.js +17 -1
  133. package/dist-server/graphql/types/reports/outbound-order-details-report.js.map +1 -1
  134. package/dist-server/graphql/types/reports/release-inventory-report-list.js +12 -0
  135. package/dist-server/graphql/types/reports/release-inventory-report-list.js.map +1 -0
  136. package/dist-server/graphql/types/reports/release-inventory-report.js +27 -0
  137. package/dist-server/graphql/types/reports/release-inventory-report.js.map +1 -0
  138. package/dist-server/migrations/1568858861188-SeedSetting.js +5 -6
  139. package/dist-server/migrations/1568858861188-SeedSetting.js.map +1 -1
  140. package/dist-server/migrations/1623308919899-SeedLocationRecommendSetting.js +1 -1
  141. package/dist-server/migrations/1623308919899-SeedLocationRecommendSetting.js.map +1 -1
  142. package/dist-server/migrations/1623381200659-SeedStoringRule.js +1 -1
  143. package/dist-server/migrations/1623381200659-SeedStoringRule.js.map +1 -1
  144. package/dist-server/tsconfig.tsbuildinfo +1 -1
  145. package/dist-server/utils/report-query-util.js +5 -2
  146. package/dist-server/utils/report-query-util.js.map +1 -1
  147. package/helps/release-note.ko.md +8 -20
  148. package/helps/release-note.md +8 -20
  149. package/helps/release-note.ms.md +8 -20
  150. package/helps/release-note.zh.md +8 -20
  151. package/package.json +42 -42
  152. package/server/graphql/resolvers/board-setting/board-settings.ts +4 -6
  153. package/server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.ts +4 -5
  154. package/server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.ts +9 -10
  155. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.ts +4 -5
  156. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.ts +17 -19
  157. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.ts +10 -8
  158. package/server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.ts +9 -9
  159. package/server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.ts +9 -9
  160. package/server/graphql/resolvers/dashboard/arrival-notices-by-status.ts +23 -14
  161. package/server/graphql/resolvers/dashboard/collection-orders-by-status.ts +4 -5
  162. package/server/graphql/resolvers/dashboard/delivery-orders-by-status.ts +4 -5
  163. package/server/graphql/resolvers/dashboard/index.ts +3 -1
  164. package/server/graphql/resolvers/dashboard/inventory-expiry-monitor.ts +18 -6
  165. package/server/graphql/resolvers/dashboard/outbound-order-by-status.ts +114 -81
  166. package/server/graphql/resolvers/dashboard/release-goods-by-status.ts +23 -14
  167. package/server/graphql/resolvers/dashboard/unit-inbounded-outbounded.ts +61 -0
  168. package/server/graphql/resolvers/index.ts +5 -4
  169. package/server/graphql/resolvers/inventory-comparison/inventory-comparison-list.ts +11 -9
  170. package/server/graphql/resolvers/opa-menu/opa-menus.ts +7 -6
  171. package/server/graphql/resolvers/{extra → other}/add-release-good-products.ts +73 -12
  172. package/server/graphql/resolvers/other/index.ts +10 -0
  173. package/server/graphql/resolvers/other/page-settings.ts +105 -0
  174. package/server/graphql/resolvers/reports/costing-report.ts +8 -10
  175. package/server/graphql/resolvers/reports/inbound-order-details-report.ts +7 -9
  176. package/server/graphql/resolvers/reports/inbound-serial-number-report.ts +41 -13
  177. package/server/graphql/resolvers/reports/index.ts +3 -1
  178. package/server/graphql/resolvers/reports/outbound-order-details-report.ts +76 -38
  179. package/server/graphql/resolvers/reports/outbound-serial-number-report.ts +42 -18
  180. package/server/graphql/resolvers/reports/product-label-report.ts +4 -6
  181. package/server/graphql/resolvers/reports/release-inventory-report.ts +201 -0
  182. package/server/graphql/resolvers/shipping-provider/shipping-providers.ts +3 -5
  183. package/server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.ts +10 -10
  184. package/server/graphql/types/dashboard/index.ts +1 -0
  185. package/server/graphql/types/index.ts +8 -2
  186. package/server/graphql/types/other/index.ts +19 -0
  187. package/server/graphql/types/other/page-setting.ts +33 -0
  188. package/server/graphql/types/reports/index.ts +6 -1
  189. package/server/graphql/types/reports/outbound-order-details-report.ts +17 -1
  190. package/server/graphql/types/reports/release-inventory-report-list.ts +8 -0
  191. package/server/graphql/types/reports/release-inventory-report.ts +23 -0
  192. package/server/migrations/1568858861188-SeedSetting.ts +4 -4
  193. package/server/migrations/1623308919899-SeedLocationRecommendSetting.ts +3 -2
  194. package/server/migrations/1623381200659-SeedStoringRule.ts +3 -2
  195. package/server/utils/report-query-util.ts +5 -2
  196. package/things-factory.config.js +4 -0
  197. package/translations/en.json +148 -27
  198. package/translations/ko.json +185 -105
  199. package/translations/ms.json +183 -98
  200. package/translations/zh.json +197 -112
  201. package/dist-server/graphql/resolvers/extra/add-release-good-products.js.map +0 -1
  202. package/dist-server/graphql/resolvers/extra/index.js.map +0 -1
  203. package/dist-server/graphql/types/extra/index.js +0 -11
  204. package/dist-server/graphql/types/extra/index.js.map +0 -1
  205. package/server/graphql/resolvers/extra/index.ts +0 -5
  206. package/server/graphql/types/extra/index.ts +0 -7
@@ -1,25 +1,34 @@
1
- import { getRepository, SelectQueryBuilder } from 'typeorm'
1
+ import { SelectQueryBuilder } from 'typeorm'
2
2
 
3
- import { User } from '@things-factory/auth-base'
4
3
  import { getPermittedBizplaceIds } from '@things-factory/biz-base'
5
4
  import { ArrivalNotice } from '@things-factory/sales-base'
6
- import { buildQuery, Domain, ListParam } from '@things-factory/shell'
5
+ import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
7
6
 
8
7
  export const arrivalNoticesByStatusResolver = {
9
- async arrivalNoticesByStatus(_: any, params: ListParam, context: any) {
10
- const { domain, user }: { domain: Domain; user: User } = context.state
8
+ async arrivalNoticesByStatus(_: any, params: ListParam, context: ResolverContext) {
9
+ const { domain, user } = context.state
10
+ const bizplaceId: string = params.filters.find((filter: any) => filter.name === 'bizplace')?.value || 'ALL'
11
+ params.filters = params.filters.filter(filter => filter.name !== 'bizplace')
12
+ const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i)
13
+ let bizplaceIds: string
11
14
 
12
- if (!params.filters.find((filter: any) => filter.name === 'bizplace')) {
13
- params.filters.push({
14
- name: 'bizplaceId',
15
- operator: 'in',
16
- value: await getPermittedBizplaceIds(domain, user),
17
- relation: false
18
- })
19
- }
15
+ if (bizplaceId && (bizplaceId == 'ALL' || bizplaceId.match(v4))) {
16
+ let bizplaces: string[] =
17
+ bizplaceId && bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
18
+ bizplaceIds = bizplaces
19
+ .map(bizplace => {
20
+ return "'" + bizplace?.trim() + "'"
21
+ })
22
+ .join(',')
23
+ } else throw new Error('invalid bizplaceId')
20
24
 
21
25
  const qb: SelectQueryBuilder<ArrivalNotice> = getRepository(ArrivalNotice).createQueryBuilder('an')
22
26
  buildQuery(qb, params, context)
23
- return qb.select('an.status', 'status').addSelect('COUNT(*) AS count').groupBy('an.status').getRawMany()
27
+ return qb
28
+ .select('an.status', 'status')
29
+ .addSelect('COUNT(*) AS count')
30
+ .andWhere(`an.bizplace_id IN (${bizplaceIds})`)
31
+ .groupBy('an.status')
32
+ .getRawMany()
24
33
  }
25
34
  }
@@ -1,13 +1,12 @@
1
- import { getRepository, SelectQueryBuilder } from 'typeorm'
1
+ import { SelectQueryBuilder } from 'typeorm'
2
2
 
3
- import { User } from '@things-factory/auth-base'
4
3
  import { getPermittedBizplaceIds } from '@things-factory/biz-base'
5
4
  import { CollectionOrder } from '@things-factory/sales-base'
6
- import { buildQuery, Domain, ListParam } from '@things-factory/shell'
5
+ import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
7
6
 
8
7
  export const collectionOrdersByStatusResolver = {
9
- async collectionOrdersByStatus(_: any, params: ListParam, context: any) {
10
- const { domain, user }: { domain: Domain; user: User } = context.state
8
+ async collectionOrdersByStatus(_: any, params: ListParam, context: ResolverContext) {
9
+ const { domain, user } = context.state
11
10
 
12
11
  if (!params.filters.find((filter: any) => filter.name === 'bizplace')) {
13
12
  params.filters.push({
@@ -1,13 +1,12 @@
1
- import { getRepository, SelectQueryBuilder } from 'typeorm'
1
+ import { SelectQueryBuilder } from 'typeorm'
2
2
 
3
- import { User } from '@things-factory/auth-base'
4
3
  import { getPermittedBizplaceIds } from '@things-factory/biz-base'
5
4
  import { DeliveryOrder } from '@things-factory/sales-base'
6
- import { buildQuery, Domain, ListParam } from '@things-factory/shell'
5
+ import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
7
6
 
8
7
  export const deliveryOrdersByStatusResolver = {
9
- async deliveryOrdersByStatus(_: any, params: ListParam, context: any) {
10
- const { domain, user }: { domain: Domain; user: User } = context.state
8
+ async deliveryOrdersByStatus(_: any, params: ListParam, context: ResolverContext) {
9
+ const { domain, user } = context.state
11
10
 
12
11
  if (!params.filters.find((filter: any) => filter.name === 'bizplace')) {
13
12
  params.filters.push({
@@ -4,6 +4,7 @@ import { deliveryOrdersByStatusResolver } from './delivery-orders-by-status'
4
4
  import { inventoryExpiryMonitorResolver } from './inventory-expiry-monitor'
5
5
  import { outboundOrderByStatusResolver } from './outbound-order-by-status'
6
6
  import { releaseGoodsByStatusResolver } from './release-goods-by-status'
7
+ import { unitInboundedOutboundedResolver } from './unit-inbounded-outbounded'
7
8
 
8
9
  export const Query = {
9
10
  ...arrivalNoticesByStatusResolver,
@@ -11,5 +12,6 @@ export const Query = {
11
12
  ...deliveryOrdersByStatusResolver,
12
13
  ...releaseGoodsByStatusResolver,
13
14
  ...outboundOrderByStatusResolver,
14
- ...inventoryExpiryMonitorResolver
15
+ ...inventoryExpiryMonitorResolver,
16
+ ...unitInboundedOutboundedResolver
15
17
  }
@@ -1,11 +1,22 @@
1
- import { EntityManager } from 'typeorm'
2
-
3
- import { User } from '@things-factory/auth-base'
4
- import { Domain, ListParam } from '@things-factory/shell'
1
+ import { getPermittedBizplaceIds } from '@things-factory/biz-base'
2
+ import { ListParam } from '@things-factory/shell'
5
3
 
6
4
  export const inventoryExpiryMonitorResolver = {
7
- async inventoryExpiryMonitor(_: any, params: ListParam, context: any) {
8
- const { domain, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
5
+ async inventoryExpiryMonitor(_: any, params: ListParam, context: ResolverContext) {
6
+ const { domain, user, tx } = context.state
7
+ const bizplaceId: string = params.filters.find((filter: any) => filter.name === 'bizplace')?.value || 'ALL'
8
+ const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i)
9
+ let bizplaceIds: string
10
+
11
+ if (bizplaceId && (bizplaceId == 'ALL' || bizplaceId.match(v4))) {
12
+ let bizplaces: string[] =
13
+ bizplaceId && bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
14
+ bizplaceIds = bizplaces
15
+ .map(bizplace => {
16
+ return "'" + bizplace?.trim() + "'"
17
+ })
18
+ .join(',')
19
+ } else throw new Error('invalid bizplaceId')
9
20
 
10
21
  const expInventories: {
11
22
  location: string
@@ -27,6 +38,7 @@ export const inventoryExpiryMonitorResolver = {
27
38
  AND i.expiration_date NOTNULL
28
39
  AND i.status = 'STORED'
29
40
  AND i.domain_id = $1
41
+ AND i.bizplace_id IN (${bizplaceIds})
30
42
  ) AS foo
31
43
  GROUP BY "location"
32
44
  `,
@@ -1,93 +1,126 @@
1
- import { EntityManager } from 'typeorm'
2
-
3
- import { User } from '@things-factory/auth-base'
4
- import { Domain, ListParam } from '@things-factory/shell'
1
+ import { getPermittedBizplaceIds } from '@things-factory/biz-base'
2
+ import { ListParam } from '@things-factory/shell'
5
3
 
6
4
  export const outboundOrderByStatusResolver = {
7
- async outboundOrderByStatus(_: any, params: ListParam, context: any) {
8
- const { domain, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
5
+ async outboundOrderByStatus(_: any, params: ListParam, context: ResolverContext) {
6
+ const { domain, user, tx } = context.state
7
+ const bizplaceId: string = params.filters.find((filter: any) => filter.name === 'bizplace')?.value || 'ALL'
8
+ const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i)
9
+ let bizplaceIds: string
10
+
11
+ if (bizplaceId && (bizplaceId == 'ALL' || bizplaceId.match(v4))) {
12
+ let bizplaces: string[] =
13
+ bizplaceId && bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
14
+ bizplaceIds = bizplaces
15
+ .map(bizplace => {
16
+ return "'" + bizplace?.trim() + "'"
17
+ })
18
+ .join(',')
19
+ } else throw new Error('invalid bizplaceId')
9
20
 
10
21
  const orderStatus: { status: string; count: number }[] = await tx.query(
11
22
  `
12
- WITH cte_list ("status", "count") as (
13
- select 'DONE' as status, 0 as "count"
14
- union
15
- select 'CANCELLED' as status, 0 as "count"
16
- union
17
- select 'PICKING UNASSIGNED' as status, 0 as "count"
18
- union
19
- select 'PACKING' as status, 0 as "count"
20
- union
21
- select 'AWAITING DISPATCH' as status, 0 as "count"
22
- union
23
- select 'OUT FROM WAREHOUSE' as status, 0 as "count"
24
- union
25
- select 'PICKING ASSIGNED' as status, 0 as "count"
26
- union
27
- select 'OTHERS' as status, 0 as "count"
28
- ) select l."status", coalesce(src."count", l."count") as "count"
29
- from cte_list l
30
- left join (
31
- SELECT "status", COUNT(*) AS "count" FROM (
32
- SELECT
33
- CASE WHEN "status" = 'DONE' and rg.updated_at::date = CURRENT_DATE THEN 'DONE'
34
- WHEN "status" = 'CANCELLED' THEN 'CANCELLED'
35
- WHEN "status" IN('PENDING_RECEIVE', 'PENDING_WORKSHEET') THEN 'PICKING UNASSIGNED'
36
- END AS "status"
37
- FROM release_goods rg
38
- WHERE "domain_id" = $1
39
- AND rg."status" IN ('CANCELLED','PENDING', 'PENDING_RECEIVE', 'PENDING_WORKSHEET', 'READY_TO_PICK', 'PICKING', 'READY_TO_PACK', 'PACKING', 'DONE')
40
- ) AS foo
23
+ WITH cte_list ("status", "count") AS (
24
+ SELECT 'PICKING UNASSIGNED' AS status, 0 AS "count"
25
+ UNION
26
+ SELECT 'PICKING ASSIGNED' AS status, 0 AS "count"
27
+ UNION
28
+ SELECT 'BATCH PICKING ASSIGNED' AS status, 0 AS "count"
29
+ UNION
30
+ SELECT 'PACKING' AS status, 0 AS "count"
31
+ UNION
32
+ SELECT 'AWAITING DISPATCH' AS status, 0 AS "count"
33
+ UNION
34
+ SELECT 'OUT FROM WAREHOUSE' AS status, 0 AS "count"
35
+ UNION
36
+ SELECT 'PENDING MANIFEST CREATION' AS status, 0 AS "count"
37
+ UNION
38
+ SELECT 'DONE' AS status, 0 AS "count"
39
+ UNION
40
+ SELECT 'PENDING CANCEL' AS status, 0 AS "count"
41
+ UNION
42
+ SELECT 'CANCELLED' AS status, 0 AS "count"
43
+ UNION
44
+ SELECT 'OTHERS' AS status, 0 AS "count"
45
+ UNION
46
+ SELECT 'DRAFT' AS status, 0 AS "count"
47
+ ) SELECT l."status", coalesce(src."count", l."count") AS "count"
48
+ FROM cte_list l
49
+ LEFT JOIN (
50
+ SELECT "status", SUM("count") AS count FROM (
51
+ SELECT "status", COUNT(*) AS "count" FROM (
52
+ SELECT
53
+ CASE WHEN "status" = 'DONE' AND rg.updated_at::date = CURRENT_DATE THEN 'DONE'
54
+ WHEN "status" = 'PENDING_CANCEL' THEN 'PENDING CANCEL'
55
+ WHEN "status" = 'CANCELLED' AND rg.updated_at::date = CURRENT_DATE THEN 'CANCELLED'
56
+ WHEN "status" IN('PENDING_RECEIVE','PENDING_WORKSHEET') THEN 'PICKING UNASSIGNED'
57
+ END AS "status"
58
+ FROM release_goods rg
59
+ WHERE "domain_id" = $1
60
+ AND rg."bizplace_id" IN (${bizplaceIds})
61
+ AND rg."status" IN ('PENDING','PENDING_RECEIVE','PENDING_WORKSHEET','READY_TO_PICK','PICKING','READY_TO_PACK','PACKING','PENDING_CANCEL','CANCELLED','DONE')
62
+ ) AS foo
63
+ GROUP BY "status"
64
+ UNION ALL
65
+ SELECT "status", COUNT(*) AS "count" FROM (
66
+ SELECT
67
+ CASE WHEN "dispatchment_status" = 'DISPATCHED' AND rg.updated_at::date = CURRENT_DATE THEN 'OUT FROM WAREHOUSE'
68
+ END AS "status"
69
+ FROM release_goods rg
70
+ WHERE "domain_id" = $1
71
+ AND rg."bizplace_id" IN (${bizplaceIds})
72
+ AND rg."dispatchment_status" IN ('READY_TO_DISPATCH', 'DISPATCHED')
73
+ AND rg."tracking_no" NOTNULL
74
+ AND rg."type" = 'b2c'
75
+ ) AS foo
76
+ GROUP BY "status"
77
+ UNION ALL
78
+ SELECT 'AWAITING DISPATCH' AS "status", count(*) FROM manifests m
79
+ INNER JOIN release_goods rg ON rg.manifest_id = m.id
80
+ WHERE m."status" in ('OPEN', 'IN_QUEUE')
81
+ AND m."domain_id" = $1
82
+ AND rg."bizplace_id" IN (${bizplaceIds})
83
+ UNION ALL
84
+ SELECT 'PICKING ASSIGNED' AS "status", count(*) FROM worksheets w
85
+ WHERE w."domain_id" = $1
86
+ AND w."bizplace_id" IN (${bizplaceIds})
87
+ AND w."type" = 'PICKING'
88
+ AND w."status" IN ('DEACTIVATED','EXECUTING')
89
+ GROUP BY w."status"
90
+ UNION ALL
91
+ SELECT 'BATCH PICKING ASSIGNED' AS "status", count(*) FROM worksheets w
92
+ WHERE w."domain_id" = $1
93
+ AND w."bizplace_id" IN (${bizplaceIds})
94
+ AND w."type" = 'BATCH_PICKING'
95
+ AND w."status" IN ('DEACTIVATED','EXECUTING')
96
+ GROUP BY w."status"
97
+ UNION ALL
98
+ SELECT 'PACKING' AS "status", count(*) FROM worksheets w
99
+ WHERE w."domain_id" = $1 AND w."type" = 'PACKING'
100
+ AND w."bizplace_id" IN (${bizplaceIds})
101
+ AND w."status" IN ('DEACTIVATED','EXECUTING')
102
+ GROUP BY w."status"
103
+ UNION ALL
104
+ SELECT 'PENDING MANIFEST CREATION' AS "status", count(*) FROM release_goods rg
105
+ WHERE rg."domain_id" = $1
106
+ AND rg."bizplace_id" IN (${bizplaceIds})
107
+ AND rg."status" = 'DONE'
108
+ AND rg."manifest_id" ISNULL
109
+ AND rg."type" = 'b2c'
110
+ AND rg."updated_at" >= (CURRENT_DATE - 30)
111
+ UNION ALL
112
+ SELECT 'DRAFT' AS "status", count(*) FROM draft_release_goods drg
113
+ WHERE drg."domain_id" = $1
114
+ AND drg."bizplace_id" IN (${bizplaceIds})
115
+ AND drg."status" = 'DRAFT'
116
+ AND drg."type" = 'b2c'
117
+ ) AS src
41
118
  GROUP BY "status"
42
- UNION ALL
43
- SELECT "status", COUNT(*) AS "count" FROM (
44
- SELECT
45
- CASE WHEN "dispatchment_status" = 'DISPATCHED' THEN 'OUT FROM WAREHOUSE'
46
- END AS "status"
47
- FROM release_goods rg
48
- WHERE "domain_id" = $1
49
- AND rg."dispatchment_status" IN ('READY_TO_DISPATCH', 'DISPATCHED')
50
- AND rg."status" NOT IN ('CANCELLED', 'PENDING_CANCEL')
51
- AND rg."tracking_no" NOTNULL
52
- ) AS foo
53
- GROUP BY "status"
54
- union all
55
- select 'AWAITING DISPATCH' as "status", count(*) from manifests m
56
- inner join release_goods rg ON rg.manifest_id = m.id
57
- where m."status" = 'OPEN' and m."domain_id" = $1
58
- union all
59
- select 'PICKING ASSIGNED' as "status", count(*) from worksheets w
60
- where w."domain_id" = $1 and w."type" ='PICKING'
61
- and w."status" in ('DEACTIVATED','EXECUTING','PENDING_CANCEL')
62
- group by w."status"
63
- union all
64
- select 'PACKING' as "status", count(*) from worksheets w
65
- where w."domain_id" = $1 and w."type" ='PACKING'
66
- and w."status" in ('DEACTIVATED','EXECUTING','PENDING_CANCEL')
67
- group by w."status"
68
- ) src on src."status" = l."status"
119
+ ) src ON src."status" = l."status"
69
120
  `,
70
121
  [domain.id]
71
122
  )
72
123
 
73
- const statusList: string[] = [
74
- 'PICKING UNASSIGNED',
75
- 'PICKING ASSIGNED',
76
- 'PACKING',
77
- 'AWAITING DISPATCH',
78
- 'OUT FROM WAREHOUSE',
79
- 'CANCELLED',
80
- 'DONE',
81
- 'OUT OF STOCK'
82
- ]
83
-
84
- return statusList.reduce((statusCounts: { status: string; count: number }[], status: string) => {
85
- let foundItem = orderStatus.find(order => order.status == status)
86
-
87
- if (foundItem) statusCounts.push({ status, count: foundItem.count })
88
- else statusCounts.push({ status, count: 0 })
89
-
90
- return statusCounts
91
- }, [])
124
+ return orderStatus
92
125
  }
93
126
  }
@@ -1,25 +1,34 @@
1
- import { getRepository, SelectQueryBuilder } from 'typeorm'
1
+ import { SelectQueryBuilder } from 'typeorm'
2
2
 
3
- import { User } from '@things-factory/auth-base'
4
3
  import { getPermittedBizplaceIds } from '@things-factory/biz-base'
5
4
  import { ReleaseGood } from '@things-factory/sales-base'
6
- import { buildQuery, Domain, ListParam } from '@things-factory/shell'
5
+ import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
7
6
 
8
7
  export const releaseGoodsByStatusResolver = {
9
- async releaseGoodsByStatus(_: any, params: ListParam, context: any) {
10
- const { domain, user }: { domain: Domain; user: User } = context.state
8
+ async releaseGoodsByStatus(_: any, params: ListParam, context: ResolverContext) {
9
+ const { domain, user } = context.state
10
+ const bizplaceId: string = params.filters.find((filter: any) => filter.name === 'bizplace')?.value || 'ALL'
11
+ params.filters = params.filters.filter(filter => filter.name !== 'bizplace')
12
+ const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i)
13
+ let bizplaceIds: string
11
14
 
12
- if (!params.filters.find((filter: any) => filter.name === 'bizplace')) {
13
- params.filters.push({
14
- name: 'bizplaceId',
15
- operator: 'in',
16
- value: await getPermittedBizplaceIds(domain, user),
17
- relation: false
18
- })
19
- }
15
+ if (bizplaceId && (bizplaceId == 'ALL' || bizplaceId.match(v4))) {
16
+ let bizplaces: string[] =
17
+ bizplaceId && bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
18
+ bizplaceIds = bizplaces
19
+ .map(bizplace => {
20
+ return "'" + bizplace?.trim() + "'"
21
+ })
22
+ .join(',')
23
+ } else throw new Error('invalid bizplaceId')
20
24
 
21
25
  const qb: SelectQueryBuilder<ReleaseGood> = getRepository(ReleaseGood).createQueryBuilder('rg')
22
26
  buildQuery(qb, params, context)
23
- return qb.select('rg.status', 'status').addSelect('COUNT(*) AS count').groupBy('rg.status').getRawMany()
27
+ return qb
28
+ .select('rg.status', 'status')
29
+ .addSelect('COUNT(*) AS count')
30
+ .andWhere(`rg.bizplace_id IN (${bizplaceIds})`)
31
+ .groupBy('rg.status')
32
+ .getRawMany()
24
33
  }
25
34
  }
@@ -0,0 +1,61 @@
1
+ import { getRepository, SelectQueryBuilder, EntityManager } from 'typeorm'
2
+
3
+ import { User } from '@things-factory/auth-base'
4
+ import { getPermittedBizplaceIds } from '@things-factory/biz-base'
5
+ import { buildQuery, Domain, ListParam } from '@things-factory/shell'
6
+
7
+ export const unitInboundedOutboundedResolver = {
8
+ async unitInboundedOutbounded(_: any, params: ListParam, context: any) {
9
+ const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
10
+ const bizplaceId: string = params.filters.find((filter: any) => filter.name === 'bizplace')?.value || 'ALL'
11
+ const fromDate: string = params.filters.find((filter: any) => filter.name === 'createdAt1')?.value
12
+ const toDate: string = params.filters.find((filter: any) => filter.name === 'createdAt2')?.value
13
+ const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i)
14
+ let bizplaceIds: string
15
+
16
+ if (bizplaceId && (bizplaceId == 'ALL' || bizplaceId.match(v4))) {
17
+ let bizplaces: string[] =
18
+ bizplaceId && bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
19
+ bizplaceIds = bizplaces
20
+ .map(bizplace => {
21
+ return "'" + bizplace?.trim() + "'"
22
+ })
23
+ .join(',')
24
+ } else throw new Error('invalid bizplaceId')
25
+
26
+ const orderStatus: { status: string; count: number }[] = await tx.query(
27
+ `
28
+ WITH cte_unit ("status", "count", "type") AS (
29
+ SELECT 'INBOUNDED' AS status, 0 AS "count", 'inbound' AS "type"
30
+ UNION
31
+ SELECT 'OUTBOUNDED' AS status, 0 AS "count", 'outbound' AS "type"
32
+ ) SELECT u."status", coalesce(src."count", u."count") AS "count", u."type"
33
+ FROM cte_unit u
34
+ LEFT JOIN (
35
+ SELECT "status", SUM("count") AS count, "type" FROM (
36
+ SELECT 'INBOUNDED' AS "status", SUM(coalesce(op.actual_pack_qty, op.pack_qty)) as "count", 'inbound' as "type" FROM order_products op
37
+ INNER JOIN arrival_notices an ON an.id = op.arrival_notice_id
38
+ WHERE an."status" in ('PUTTING_AWAY','DONE')
39
+ AND an."domain_id" = $1
40
+ AND an."bizplace_id" IN (${bizplaceIds})
41
+ AND an.created_at BETWEEN '${fromDate}' AND '${toDate}'
42
+ GROUP BY an."status"
43
+ UNION ALL
44
+ SELECT 'OUTBOUNDED' AS "status", SUM(coalesce(oi.release_qty , oi.picked_qty)) as "count", 'outbound' as "type" FROM order_inventories oi
45
+ INNER JOIN release_goods rg on rg.id = oi.release_good_id
46
+ WHERE rg."status" in ('DONE')
47
+ AND rg."domain_id" = $1
48
+ AND rg."bizplace_id" IN (${bizplaceIds})
49
+ AND rg.created_at BETWEEN '${fromDate}' AND '${toDate}'
50
+ GROUP BY rg."status"
51
+ ) AS src
52
+ GROUP BY "status", "type"
53
+ ) src ON src."status" = u."status"
54
+ order by "type", "status"
55
+ `,
56
+ [domain.id]
57
+ )
58
+
59
+ return orderStatus
60
+ }
61
+ }
@@ -2,7 +2,7 @@ import * as BoardSetting from './board-setting'
2
2
  import * as CustomElccl from './custom/elccl'
3
3
  import * as CustomKimeda from './custom/kimeda'
4
4
  import * as Dashboard from './dashboard'
5
- import * as Extra from './extra'
5
+ import * as Other from './other'
6
6
  import * as OpaMenu from './opa-menu'
7
7
  import * as Reports from './reports'
8
8
  import * as InventoryComparison from './inventory-comparison'
@@ -14,10 +14,11 @@ export const queries = [
14
14
  CustomElccl.Query,
15
15
  CustomKimeda.Query,
16
16
  Dashboard.Query,
17
+ InventoryComparison.Query,
17
18
  OpaMenu.Query,
19
+ Other.Query,
18
20
  Reports.Query,
19
- InventoryComparison.Query,
20
- ShippingProviders.Query,
21
+ ShippingProviders.Query
21
22
  ]
22
23
 
23
- export const mutations = [Extra.Mutation,WarehouseInventoryAdjustment.Mutation]
24
+ export const mutations = [Other.Mutation, WarehouseInventoryAdjustment.Mutation]
@@ -1,12 +1,12 @@
1
- import { onhandInventories } from '@things-factory/warehouse-base'
2
1
  import { ListParam } from '@things-factory/shell'
3
- import { EntityManager } from 'typeorm'
2
+ import { onhandInventories } from '@things-factory/warehouse-base'
3
+
4
4
  import { inventoryHistorySummaryReportQuery } from '../custom/elccl/elccl-inventory-history-summary-report'
5
5
 
6
6
  export const inventoryComparisonList = {
7
- async inventoryComparisonList(_: any, params: ListParam, context: any) {
7
+ async inventoryComparisonList(_: any, params: ListParam, context: ResolverContext) {
8
8
  try {
9
- const { tx }: { tx: EntityManager } = context.state
9
+ const { tx } = context.state
10
10
 
11
11
  let bizplaceFilter = params.filters.find(data => data.name === 'bizplace')
12
12
 
@@ -58,7 +58,7 @@ export const inventoryComparisonList = {
58
58
  inventoryHistorySummaryReportQuery(_, params, context),
59
59
  onhandInventories(params.filters, params.pagination, params.sortings, [], context, false)
60
60
  ])
61
-
61
+
62
62
  await tx.query(`
63
63
  create temp table tmp_inv_comp on commit drop as (
64
64
  select summ."batch_id", summ.product_id, summ.product_name, summ.product_sku, summ.packing_type, summ.closing_qty, coalesce(oh.qty, 0) as "onhand_qty" from temp_inventory_summary summ
@@ -70,13 +70,16 @@ export const inventoryComparisonList = {
70
70
  );
71
71
  `)
72
72
 
73
- let sumData = await tx.query(`
73
+ let sumData = await tx.query(
74
+ `
74
75
  select * from tmp_inv_comp
75
76
  offset $1 limit $2
76
- `, [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit])
77
+ `,
78
+ [(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
79
+ )
77
80
 
78
81
  const totalQuery: number = await tx.query(`select count(*) from tmp_inv_comp `)
79
-
82
+
80
83
  const total = parseInt(totalQuery[0].count)
81
84
 
82
85
  const items: any[] = sumData.map(item => {
@@ -91,7 +94,6 @@ export const inventoryComparisonList = {
91
94
  })
92
95
 
93
96
  return { items, total }
94
-
95
97
  } catch (error) {
96
98
  throw error
97
99
  }
@@ -1,10 +1,11 @@
1
+ import { In, SelectQueryBuilder } from 'typeorm'
2
+
1
3
  import { Role, User } from '@things-factory/auth-base'
2
- import { Domain } from '@things-factory/shell'
3
4
  import { Menu } from '@things-factory/menu-base'
4
- import { getRepository, SelectQueryBuilder, In } from 'typeorm'
5
+ import { Domain, getRepository } from '@things-factory/shell'
5
6
 
6
7
  export const opaMenusResolver = {
7
- async opaMenus(_: any, _params: any, context: any) {
8
+ async opaMenus(_: any, _params: any, context: ResolverContext) {
8
9
  let menus: Menu[] = []
9
10
  if (context?.state?.domain?.id && context?.state?.user?.id) {
10
11
  try {
@@ -44,7 +45,7 @@ export const opaMenusResolver = {
44
45
 
45
46
  async function getNonRestrictedMenus(domain: Domain): Promise<Menu[]> {
46
47
  const menus: Menu[] = await getRepository(Menu).find({
47
- where: { domain, hiddenFlag: false, menuType: 'MENU' },
48
+ where: { domain: { id: domain.id }, hiddenFlag: false, menuType: 'MENU' },
48
49
  relations: ['parent', 'children', 'children.roles'],
49
50
  order: { rank: 'ASC' }
50
51
  })
@@ -58,11 +59,11 @@ async function getNonRestrictedMenus(domain: Domain): Promise<Menu[]> {
58
59
 
59
60
  async function getRestrictedMenus(roleIds: string[], domain: Domain): Promise<Menu[]> {
60
61
  const menus: Menu[] = await getRepository(Menu).find({
61
- where: { domain, hiddenFlag: false, menuType: 'MENU' },
62
+ where: { domain: { id: domain.id }, hiddenFlag: false, menuType: 'MENU' },
62
63
  relations: ['parent', 'children', 'children.roles'],
63
64
  order: { rank: 'ASC' }
64
65
  })
65
- const userRoles: Role[] = await getRepository(Role).find({ where: { domain, id: In(roleIds) } })
66
+ const userRoles: Role[] = await getRepository(Role).find({ where: { domain: { id: domain.id }, id: In(roleIds) } })
66
67
 
67
68
  menus.forEach(menu => {
68
69
  menu.children = menu.children.filter(child => {