@things-factory/sales-base 8.0.2 → 8.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist-server/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +12 -12
  3. package/server/constants/attachment-type.ts +0 -9
  4. package/server/constants/index.ts +0 -7
  5. package/server/constants/load-type.ts +0 -4
  6. package/server/constants/order.ts +0 -203
  7. package/server/constants/product-group-type.ts +0 -4
  8. package/server/constants/release-good.ts +0 -9
  9. package/server/constants/transfer-order-type.ts +0 -6
  10. package/server/constants/validation-error-code.ts +0 -3
  11. package/server/constants/vas-target-type.ts +0 -25
  12. package/server/controllers/ecommerce/ecommerce-controller.ts +0 -122
  13. package/server/controllers/ecommerce/index.ts +0 -2
  14. package/server/controllers/ecommerce/sellercraft-controller.ts +0 -182
  15. package/server/controllers/index.ts +0 -2
  16. package/server/controllers/order-controller.ts +0 -296
  17. package/server/errors/index.ts +0 -1
  18. package/server/errors/validation-error.ts +0 -25
  19. package/server/index.ts +0 -5
  20. package/server/migrations/index.ts +0 -9
  21. package/server/service/arrival-notice/arrival-notice-mutation.ts +0 -1152
  22. package/server/service/arrival-notice/arrival-notice-query.ts +0 -549
  23. package/server/service/arrival-notice/arrival-notice-types.ts +0 -310
  24. package/server/service/arrival-notice/arrival-notice.ts +0 -202
  25. package/server/service/arrival-notice/index.ts +0 -9
  26. package/server/service/claim/claim-mutation.ts +0 -308
  27. package/server/service/claim/claim-query.ts +0 -122
  28. package/server/service/claim/claim-types.ts +0 -130
  29. package/server/service/claim/claim.ts +0 -140
  30. package/server/service/claim/index.ts +0 -9
  31. package/server/service/claim-detail/claim-detail-mutation.ts +0 -102
  32. package/server/service/claim-detail/claim-detail-query.ts +0 -55
  33. package/server/service/claim-detail/claim-detail-types.ts +0 -47
  34. package/server/service/claim-detail/claim-detail.ts +0 -69
  35. package/server/service/claim-detail/index.ts +0 -9
  36. package/server/service/claim-order/claim-order-mutation.ts +0 -101
  37. package/server/service/claim-order/claim-order-query.ts +0 -47
  38. package/server/service/claim-order/claim-order-types.ts +0 -35
  39. package/server/service/claim-order/claim-order.ts +0 -81
  40. package/server/service/claim-order/index.ts +0 -9
  41. package/server/service/collection-order/collection-order-mutation.ts +0 -245
  42. package/server/service/collection-order/collection-order-query.ts +0 -97
  43. package/server/service/collection-order/collection-order-types.ts +0 -165
  44. package/server/service/collection-order/collection-order.ts +0 -135
  45. package/server/service/collection-order/index.ts +0 -9
  46. package/server/service/delivery-order/delivery-order-mutation.ts +0 -967
  47. package/server/service/delivery-order/delivery-order-query.ts +0 -631
  48. package/server/service/delivery-order/delivery-order-types.ts +0 -268
  49. package/server/service/delivery-order/delivery-order.ts +0 -258
  50. package/server/service/delivery-order/index.ts +0 -9
  51. package/server/service/draft-release-good/draft-release-good-mutation.ts +0 -765
  52. package/server/service/draft-release-good/draft-release-good-query.ts +0 -354
  53. package/server/service/draft-release-good/draft-release-good-type.ts +0 -261
  54. package/server/service/draft-release-good/draft-release-good.ts +0 -284
  55. package/server/service/draft-release-good/index.ts +0 -9
  56. package/server/service/goods-receival-note/goods-receival-note-mutation.ts +0 -129
  57. package/server/service/goods-receival-note/goods-receival-note-query.ts +0 -280
  58. package/server/service/goods-receival-note/goods-receival-note-types.ts +0 -105
  59. package/server/service/goods-receival-note/goods-receival-note.ts +0 -127
  60. package/server/service/goods-receival-note/index.ts +0 -9
  61. package/server/service/index.ts +0 -238
  62. package/server/service/inventory-check/index.ts +0 -9
  63. package/server/service/inventory-check/inventory-check-mutation.ts +0 -149
  64. package/server/service/inventory-check/inventory-check-query.ts +0 -48
  65. package/server/service/inventory-check/inventory-check-types.ts +0 -48
  66. package/server/service/inventory-check/inventory-check.ts +0 -90
  67. package/server/service/invoice/index.ts +0 -9
  68. package/server/service/invoice/invoice-mutation.ts +0 -95
  69. package/server/service/invoice/invoice-query.ts +0 -53
  70. package/server/service/invoice/invoice-types.ts +0 -279
  71. package/server/service/invoice/invoice.ts +0 -230
  72. package/server/service/invoice-product/index.ts +0 -9
  73. package/server/service/invoice-product/invoice-product-mutation.ts +0 -54
  74. package/server/service/invoice-product/invoice-product-query.ts +0 -54
  75. package/server/service/invoice-product/invoice-product-types.ts +0 -84
  76. package/server/service/invoice-product/invoice-product.ts +0 -92
  77. package/server/service/job-sheet/index.ts +0 -9
  78. package/server/service/job-sheet/job-sheet-mutation.ts +0 -92
  79. package/server/service/job-sheet/job-sheet-query.ts +0 -112
  80. package/server/service/job-sheet/job-sheet-types.ts +0 -78
  81. package/server/service/job-sheet/job-sheet.ts +0 -102
  82. package/server/service/manifest/index.ts +0 -6
  83. package/server/service/manifest/manifest-mutation.ts +0 -190
  84. package/server/service/manifest/manifest-query.ts +0 -149
  85. package/server/service/manifest/manifest-type.ts +0 -84
  86. package/server/service/manifest/manifest.ts +0 -114
  87. package/server/service/order-inventory/index.ts +0 -9
  88. package/server/service/order-inventory/order-inventory-mutation.ts +0 -54
  89. package/server/service/order-inventory/order-inventory-query.ts +0 -722
  90. package/server/service/order-inventory/order-inventory-types.ts +0 -238
  91. package/server/service/order-inventory/order-inventory.ts +0 -401
  92. package/server/service/order-product/index.ts +0 -9
  93. package/server/service/order-product/order-product-mutation.ts +0 -48
  94. package/server/service/order-product/order-product-query.ts +0 -89
  95. package/server/service/order-product/order-product-types.ts +0 -335
  96. package/server/service/order-product/order-product.ts +0 -362
  97. package/server/service/order-tote/index.ts +0 -9
  98. package/server/service/order-tote/order-tote-mutation.ts +0 -31
  99. package/server/service/order-tote/order-tote-query.ts +0 -112
  100. package/server/service/order-tote/order-tote-types.ts +0 -47
  101. package/server/service/order-tote/order-tote.ts +0 -73
  102. package/server/service/order-tote-item/index.ts +0 -9
  103. package/server/service/order-tote-item/order-tote-item-mutation.ts +0 -31
  104. package/server/service/order-tote-item/order-tote-item-query.ts +0 -82
  105. package/server/service/order-tote-item/order-tote-item-types.ts +0 -56
  106. package/server/service/order-tote-item/order-tote-item.ts +0 -72
  107. package/server/service/order-tote-seal/index.ts +0 -9
  108. package/server/service/order-tote-seal/order-tote-seal-mutation.ts +0 -31
  109. package/server/service/order-tote-seal/order-tote-seal-query.ts +0 -59
  110. package/server/service/order-tote-seal/order-tote-seal-types.ts +0 -41
  111. package/server/service/order-tote-seal/order-tote-seal.ts +0 -46
  112. package/server/service/order-vas/index.ts +0 -9
  113. package/server/service/order-vas/order-vas-mutation.ts +0 -20
  114. package/server/service/order-vas/order-vas-query.ts +0 -72
  115. package/server/service/order-vas/order-vas-types.ts +0 -159
  116. package/server/service/order-vas/order-vas.ts +0 -207
  117. package/server/service/others/index.ts +0 -5
  118. package/server/service/others/other-query.ts +0 -563
  119. package/server/service/others/other-types.ts +0 -115
  120. package/server/service/purchase-order/index.ts +0 -9
  121. package/server/service/purchase-order/purchase-order-mutation.ts +0 -458
  122. package/server/service/purchase-order/purchase-order-query.ts +0 -90
  123. package/server/service/purchase-order/purchase-order-types.ts +0 -154
  124. package/server/service/purchase-order/purchase-order.ts +0 -172
  125. package/server/service/purchase-order-other-charge/index.ts +0 -9
  126. package/server/service/purchase-order-other-charge/purchase-order-other-charge-mutation.ts +0 -31
  127. package/server/service/purchase-order-other-charge/purchase-order-other-charge-query.ts +0 -52
  128. package/server/service/purchase-order-other-charge/purchase-order-other-charge-types.ts +0 -44
  129. package/server/service/purchase-order-other-charge/purchase-order-other-charge.ts +0 -68
  130. package/server/service/release-good/index.ts +0 -9
  131. package/server/service/release-good/release-good-mutation.ts +0 -1686
  132. package/server/service/release-good/release-good-query.ts +0 -980
  133. package/server/service/release-good/release-good-types.ts +0 -662
  134. package/server/service/release-good/release-good.ts +0 -490
  135. package/server/service/retail-replenishment-order/index.ts +0 -9
  136. package/server/service/retail-replenishment-order/retail-replenishment-order-mutation.ts +0 -382
  137. package/server/service/retail-replenishment-order/retail-replenishment-order-query.ts +0 -54
  138. package/server/service/retail-replenishment-order/retail-replenishment-order-types.ts +0 -101
  139. package/server/service/retail-replenishment-order/retail-replenishment-order.ts +0 -115
  140. package/server/service/return-order/index.ts +0 -9
  141. package/server/service/return-order/return-order-mutation.ts +0 -516
  142. package/server/service/return-order/return-order-query.ts +0 -226
  143. package/server/service/return-order/return-order-types.ts +0 -196
  144. package/server/service/return-order/return-order.ts +0 -127
  145. package/server/service/reverse-kitting-order/index.ts +0 -9
  146. package/server/service/reverse-kitting-order/reverse-kitting-order-mutation.ts +0 -500
  147. package/server/service/reverse-kitting-order/reverse-kitting-order-query.ts +0 -197
  148. package/server/service/reverse-kitting-order/reverse-kitting-order-type.ts +0 -173
  149. package/server/service/reverse-kitting-order/reverse-kitting-order.ts +0 -121
  150. package/server/service/reverse-kitting-order-inventory/index.ts +0 -9
  151. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.ts +0 -129
  152. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-query.ts +0 -52
  153. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.ts +0 -95
  154. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +0 -143
  155. package/server/service/shipping-order/index.ts +0 -9
  156. package/server/service/shipping-order/shipping-order-mutation.ts +0 -61
  157. package/server/service/shipping-order/shipping-order-query.ts +0 -61
  158. package/server/service/shipping-order/shipping-order-types.ts +0 -89
  159. package/server/service/shipping-order/shipping-order.ts +0 -129
  160. package/server/service/transfer-order/index.ts +0 -9
  161. package/server/service/transfer-order/transfer-order-mutation.ts +0 -309
  162. package/server/service/transfer-order/transfer-order-query.ts +0 -66
  163. package/server/service/transfer-order/transfer-order-types.ts +0 -97
  164. package/server/service/transfer-order/transfer-order.ts +0 -117
  165. package/server/service/vas/index.ts +0 -9
  166. package/server/service/vas/vas-mutation.ts +0 -106
  167. package/server/service/vas/vas-query.ts +0 -60
  168. package/server/service/vas/vas-types.ts +0 -71
  169. package/server/service/vas/vas.ts +0 -77
  170. package/server/service/vas-order/index.ts +0 -9
  171. package/server/service/vas-order/vas-order-mutation.ts +0 -259
  172. package/server/service/vas-order/vas-order-query.ts +0 -119
  173. package/server/service/vas-order/vas-order-types.ts +0 -49
  174. package/server/service/vas-order/vas-order.ts +0 -81
  175. package/server/utils/datetime-util.ts +0 -54
  176. package/server/utils/index.ts +0 -3
  177. package/server/utils/inventory-util.ts +0 -1155
  178. package/server/utils/order-no-generator.ts +0 -146
@@ -1,354 +0,0 @@
1
- import { Arg, Args, Ctx, Directive, Query, Resolver } from 'type-graphql'
2
- import { EntityManager, In, OrderByCondition, SelectQueryBuilder } from 'typeorm'
3
-
4
- import { Attachment } from '@things-factory/attachment-base'
5
- import { User } from '@things-factory/auth-base'
6
- import { Bizplace, getPermittedBizplaceIds, getPermittedBizplaces } from '@things-factory/biz-base'
7
- import { buildQuery, Domain, getRepository, ListParam } from '@things-factory/shell'
8
-
9
- import { ATTACHMENT_TYPE, DRAFT_RELEASE_ORDER_STATUS } from '../../constants'
10
- import { InventoryUtil } from '../../utils'
11
- import { DraftReleaseGood } from './draft-release-good'
12
- import { DraftReleaseGoodList } from './draft-release-good-type'
13
-
14
- @Resolver(DraftReleaseGood)
15
- export class DraftReleaseGoodQuery {
16
- @Query(returns => DraftReleaseGood, { description: 'To fetch a DraftReleaseGood' })
17
- async draftReleaseGood(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<DraftReleaseGood> {
18
- const { domain } = context.state
19
-
20
- return await getRepository(DraftReleaseGood).findOne({
21
- where: { domain: { id: domain.id }, id }
22
- })
23
- }
24
-
25
- @Directive('@transaction')
26
- @Query(returns => DraftReleaseGood, { description: 'To fetch a DraftReleaseGood' })
27
- async draftReleaseGoodByName(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<DraftReleaseGood> {
28
- const { domain, tx } = context.state
29
-
30
- return getDraftReleaseGoodFunction(null, name, context, tx)
31
- }
32
-
33
- @Directive('@transaction')
34
- @Query(returns => DraftReleaseGoodList, { description: 'To fetch multiple DraftReleaseGoods' })
35
- async draftReleaseGoods(
36
- @Args(type => ListParam) params: ListParam,
37
- @Ctx() context: ResolverContext
38
- ): Promise<DraftReleaseGoodList> {
39
- try {
40
- const { domain, user, tx } = context.state
41
-
42
- const statusFilter = params.filters.find(e => e.name === 'status')
43
- const bizplaceFilter = params.filters.find(param => param.name === 'bizplaceId')
44
- const noOfItemsFilter = params.filters.find(param => param.name === 'noOfItems')
45
- const skuFilter = params.filters.find(param => param.name === 'sku')
46
- const orderRemarkFilter = params.filters.find(param => param.name === 'orderRemark')
47
-
48
- if (!bizplaceFilter) {
49
- params.filters.push({
50
- name: 'bizplaceId',
51
- operator: 'in',
52
- value: await getPermittedBizplaceIds(domain, user),
53
- relation: false
54
- })
55
- }
56
-
57
- params.filters = params.filters.filter(
58
- itm => itm.name !== 'noOfItems' && itm.name !== 'sku' && itm.name !== 'status'
59
- )
60
-
61
- if (orderRemarkFilter) {
62
- const orderRemarkIdx = params.filters.findIndex(param => param.name === 'orderRemark')
63
- if (orderRemarkFilter.value == true) {
64
- params.filters.splice(orderRemarkIdx, 1)
65
- params.filters.push({
66
- name: 'remark',
67
- operator: 'is_not_null',
68
- value: null,
69
- relation: false
70
- })
71
- } else {
72
- params.filters.splice(orderRemarkIdx, 1)
73
- params.filters.push({
74
- name: 'remark',
75
- operator: 'is_null',
76
- value: null,
77
- relation: false
78
- })
79
- }
80
- }
81
-
82
- const fromDateParamIdx = params.filters.findIndex(param => param.name === 'fromDate')
83
- if (fromDateParamIdx >= 0) {
84
- let fromDateVal = new Date(params.filters[fromDateParamIdx].value)
85
- params.filters.splice(fromDateParamIdx, 1)
86
-
87
- params.filters.push({
88
- name: 'createdAt',
89
- operator: 'gte',
90
- value: fromDateVal.toISOString(),
91
- relation: false
92
- })
93
- }
94
-
95
- const toDateParamIdx = params.filters.findIndex(param => param.name === 'toDate')
96
- if (toDateParamIdx >= 0) {
97
- let toDateVal = new Date(params.filters[toDateParamIdx].value)
98
- params.filters.splice(toDateParamIdx, 1)
99
-
100
- params.filters.push({
101
- name: 'createdAt',
102
- operator: 'lt',
103
- value: new Date(toDateVal.setDate(toDateVal.getDate() + 1)).toISOString(),
104
- relation: false
105
- })
106
- }
107
-
108
- tx.query(
109
- `
110
- create temp table temp_op_calculation on commit drop as (
111
- SELECT drg1.id from draft_release_goods drg1
112
- left join order_products op on drg1.id = op.draft_release_good_id
113
- where drg1.status ='DRAFT' AND drg1.domain_id = $1
114
- AND NOT EXISTS (
115
- SELECT * FROM warehouse_bizplace_onhand_inventories wboi
116
- where (wboi."productId" = op.product_id or wboi."productBundleId" = op.product_id)
117
- and wboi."domainId" = op.domain_id
118
- and wboi."bizplaceId" = op.bizplace_id
119
- AND wboi."remainQty" >= op.release_qty
120
- ) GROUP BY drg1.id
121
- )
122
- `,
123
- [domain.id]
124
- )
125
-
126
- const qb: SelectQueryBuilder<DraftReleaseGood> = tx.getRepository(DraftReleaseGood).createQueryBuilder('drg')
127
- buildQuery(qb, params, context)
128
- qb.addSelect('COALESCE("cc".rank, 99999)', 'rank')
129
- qb.addSelect(
130
- `CASE WHEN "drg".status = 'DRAFT' and tmp_calc.id IS NOT null then 'INSUFFICIENT' else "drg".status END`,
131
- 'computed_status'
132
- )
133
- qb.leftJoin(`temp_op_calculation`, 'tmp_calc', 'tmp_calc.id = drg.id')
134
- qb.leftJoinAndSelect('drg.domain', 'domain')
135
- qb.leftJoinAndSelect('drg.bizplace', 'bizplace')
136
- qb.leftJoinAndSelect('drg.creator', 'creator')
137
- qb.leftJoinAndSelect('drg.updater', 'updater')
138
- qb.leftJoinAndSelect('drg.deliverTo', 'deliverTo')
139
- qb.leftJoin(
140
- subQuery => {
141
- return subQuery
142
- .select(`ccd.rank`, 'rank')
143
- .addSelect(`ccd.name`, 'status')
144
- .from(`common_code_details`, 'ccd')
145
- .innerJoin(`ccd.commonCode`, 'cc')
146
- .where(`ccd.domain_id = :domainId`, { domainId: domain.id })
147
- .andWhere(`cc.name = 'ODO_REQUESTS_STATUS'`)
148
- },
149
- 'cc',
150
- 'cc.status = drg.status'
151
- )
152
-
153
- if (skuFilter) {
154
- qb.andWhere(
155
- `
156
- exists (
157
- select * from order_products op
158
- inner join products p on op.product_id = p.id
159
- where op.draft_release_good_id = drg.id
160
- and lower(p.sku) ilike :sku
161
- )
162
- `,
163
- { sku: skuFilter.value.toLowerCase() }
164
- )
165
- }
166
-
167
- if (noOfItemsFilter) {
168
- qb.andWhere(
169
- `
170
- exists (
171
- select numberFilterOp.product_id from order_products numberFilterOp
172
- where numberFilterOp.draft_release_good_id = drg.id
173
- group by numberFilterOp.product_id having count(*) ${noOfItemsFilter.value == 1 ? ' = 1' : '> 1'}
174
- )
175
- `
176
- )
177
- }
178
-
179
- if (statusFilter) {
180
- if (statusFilter.value == DRAFT_RELEASE_ORDER_STATUS.DRAFT) {
181
- qb.andWhere(
182
- `
183
- drg.status = 'DRAFT' and tmp_calc.id IS null
184
- `
185
- )
186
- } else if (statusFilter.value == DRAFT_RELEASE_ORDER_STATUS.INSUFFICIENT) {
187
- qb.andWhere(
188
- `
189
- drg.status = 'DRAFT' and tmp_calc.id IS NOT null
190
- `
191
- )
192
- } else {
193
- qb.andWhere(
194
- `
195
- drg.status = '${statusFilter.value}'
196
- `
197
- )
198
- }
199
- }
200
-
201
- const arrChildSortData = ['bizplace', 'creator']
202
- const sort: OrderByCondition = (params.sortings || []).reduce(
203
- (acc, sort) => ({
204
- ...acc,
205
- [arrChildSortData.indexOf(sort.name) >= 0 ? sort.name + '.name' : 'drg.' + sort.name]: sort.desc
206
- ? 'DESC'
207
- : 'ASC'
208
- }),
209
- params.sortings.length < 1 ? { rank: 'ASC', 'drg.createdAt': 'DESC' } : {}
210
- )
211
-
212
- qb.orderBy(sort)
213
- qb.offset((params.pagination.page - 1) * params.pagination.limit)
214
- qb.limit(params.pagination.limit)
215
-
216
- let [items, total] = await Promise.all([qb.getRawMany(), qb.getCount()])
217
-
218
- items = items.map(itm => {
219
- return {
220
- id: itm.drg_id,
221
- name: itm.drg_name,
222
- description: itm.drg_description,
223
- type: itm.drg_type,
224
- releaseDate: itm.drg_release_date,
225
- exportOption: itm.drg_export_option,
226
- ownTransport: itm.drg_own_transport,
227
- bizplace: { id: itm.bizplace_id, name: itm.bizplace_name, description: itm.bizplace_description },
228
- refNo: itm.drg_ref_no,
229
- refNo2: itm.drg_ref_no_2,
230
- refNo3: itm.drg_ref_no_3,
231
- status: itm.computed_status,
232
- createdAt: itm.drg_created_at,
233
- creator: { id: itm.creator_id, name: itm.creator_name, description: itm.creator_description },
234
- updatedAt: itm.drg_updated_at,
235
- updater: { id: itm.updater_id, name: itm.updater_name, description: itm.updater_description }
236
- }
237
- })
238
-
239
- return { items, total }
240
- } catch (error) {
241
- throw error
242
- }
243
- }
244
- }
245
-
246
- export async function getDraftReleaseGoodFunction(_: any, name: any, context: any, tx?: EntityManager) {
247
- try {
248
- const { domain, user, bizplace }: { domain: Domain; user: User; bizplace: Bizplace } = context.state
249
-
250
- let permittedBizplaces = await getPermittedBizplaces(domain, user)
251
- let result: any = await tx.getRepository(DraftReleaseGood).findOne({
252
- where: { domain: { id: domain.id }, name, bizplace: { id: In(permittedBizplaces.map(biz => biz.id)) } },
253
- relations: [
254
- 'releaseGood',
255
- 'orderProducts',
256
- 'orderProducts.product',
257
- 'orderProducts.productBundle',
258
- 'shippingOrder',
259
- 'bizplace',
260
- 'domain',
261
- 'creator',
262
- 'updater'
263
- ]
264
- })
265
-
266
- if (!result?.id) throw new Error(`Failed to find draft release good ${name}`)
267
-
268
- let foundPermittedBizplace: Bizplace
269
- let companyBizplace: Bizplace
270
-
271
- if (result.bizplace.id) {
272
- foundPermittedBizplace = permittedBizplaces.find(biz => biz.id == result.bizplace.id)
273
-
274
- if (foundPermittedBizplace) {
275
- if (!foundPermittedBizplace.company?.id) {
276
- foundPermittedBizplace = await tx.getRepository(Bizplace).findOne({
277
- where: { id: foundPermittedBizplace.id },
278
- relations: ['company', 'company.domain']
279
- })
280
- }
281
- const companyDomain: Domain = foundPermittedBizplace.company.domain
282
- companyBizplace = await tx.getRepository(Bizplace).findOne({ where: { domain: { id: companyDomain.id } } })
283
- }
284
- }
285
-
286
- const bizplaces: Bizplace[] = [foundPermittedBizplace, companyBizplace]
287
-
288
- let productInventory
289
- if (result.orderProducts.length > 0)
290
- productInventory = await InventoryUtil.bizplaceProductInventory(
291
- bizplaces,
292
- {
293
- filters: [
294
- { name: 'bizplaceId', operator: 'eq', value: result.bizplace.id },
295
- {
296
- name: 'productId',
297
- operator: 'in',
298
- value: [
299
- ...result.orderProducts
300
- .filter(itm => itm?.product)
301
- .map(itm => {
302
- return itm.product.id
303
- }),
304
- ...result.orderProducts
305
- .filter(itm => itm?.productBundle)
306
- .map(itm => {
307
- return itm.productBundle.id
308
- })
309
- ]
310
- }
311
- ]
312
- },
313
- context,
314
- tx
315
- )
316
-
317
- result.orderProducts = result.orderProducts.map(itm => {
318
- let foundProductInv = productInventory?.items.find(
319
- i =>
320
- (i.productId == itm?.product?.id || i.productId == itm?.productBundle?.id) &&
321
- i.packingType == itm.packingType &&
322
- i.packingSize == itm.packingSize &&
323
- i.uom == itm.uom
324
- )
325
- return {
326
- ...itm,
327
- product: itm.product || {
328
- id: foundProductInv.productId,
329
- name: foundProductInv.productName,
330
- brand: foundProductInv.productBrand,
331
- sku: foundProductInv.productSKU
332
- },
333
- groupType: foundProductInv ? foundProductInv.groupType : 'SINGLE',
334
- remainQty: foundProductInv ? foundProductInv.remainQty : 0,
335
- remainUomValue: foundProductInv ? foundProductInv.remainUomValue : 0,
336
- remainUomValueWithUom: foundProductInv ? foundProductInv.remainUomValueWithUom : 0
337
- }
338
- })
339
- const foundAttachments: Attachment[] = await tx.getRepository(Attachment).find({
340
- where: {
341
- domain: { id: domain.id },
342
- refBy: result.id,
343
- category: ATTACHMENT_TYPE.DGRN
344
- }
345
- })
346
-
347
- return {
348
- ...result,
349
- attachment: foundAttachments
350
- }
351
- } catch (error) {
352
- console.error(error)
353
- }
354
- }
@@ -1,261 +0,0 @@
1
- import { Field, InputType, Int, ObjectType } from 'type-graphql'
2
-
3
- import { ObjectRef } from '@things-factory/shell'
4
-
5
- import { OrderProductPatch } from '../order-product/order-product-types'
6
- import { DraftReleaseGood } from './draft-release-good'
7
-
8
- @InputType()
9
- export class NewDraftReleaseGood {
10
- @Field({ nullable: true })
11
- name: string
12
-
13
- @Field({ nullable: true })
14
- releaseDate: string
15
-
16
- @Field({ nullable: true })
17
- type: string
18
-
19
- @Field({ nullable: true })
20
- collectionOrderNo: string
21
-
22
- @Field({ nullable: true })
23
- ownTransport: Boolean
24
-
25
- @Field({ nullable: true })
26
- courierOption: Boolean
27
-
28
- @Field({ nullable: true })
29
- packingOption: Boolean
30
-
31
- @Field({ nullable: true })
32
- packageId: string
33
-
34
- @Field({ nullable: true })
35
- truckNo: string
36
-
37
- @Field({ nullable: true })
38
- refNo: string
39
-
40
- @Field({ nullable: true })
41
- refNo2: string
42
-
43
- @Field({ nullable: true })
44
- refNo3: string
45
-
46
- @Field({ nullable: true })
47
- pickupAddress: string
48
-
49
- @Field({ nullable: true })
50
- pickupTime: string
51
-
52
- @Field({ nullable: true })
53
- handoverType: string
54
-
55
- @Field({ nullable: true })
56
- dropoffAddress: string
57
-
58
- @Field({ nullable: true })
59
- marketplaceOrderStatus: string
60
-
61
- @Field({ nullable: true })
62
- billingAddress: string
63
-
64
- @Field({ nullable: true })
65
- deliveryAddress1: string
66
-
67
- @Field({ nullable: true })
68
- deliveryAddress2: string
69
-
70
- @Field({ nullable: true })
71
- deliveryAddress3: string
72
-
73
- @Field({ nullable: true })
74
- deliveryAddress4: string
75
-
76
- @Field({ nullable: true })
77
- deliveryAddress5: string
78
-
79
- @Field({ nullable: true })
80
- attentionTo: string
81
-
82
- @Field({ nullable: true })
83
- attentionCompany: string
84
-
85
- @Field({ nullable: true })
86
- city: string
87
-
88
- @Field({ nullable: true })
89
- state: string
90
-
91
- @Field({ nullable: true })
92
- postalCode: string
93
-
94
- @Field({ nullable: true })
95
- country: string
96
-
97
- @Field({ nullable: true })
98
- phone1: string
99
-
100
- @Field({ nullable: true })
101
- phone2: string
102
-
103
- @Field({ nullable: true })
104
- email: string
105
-
106
- @Field()
107
- exportOption: Boolean
108
-
109
- @Field({ nullable: true })
110
- status: string
111
-
112
- @Field({ nullable: true })
113
- description: string
114
-
115
- @Field({ nullable: true })
116
- deliverTo: string
117
-
118
- @Field(type => ObjectRef, { nullable: true })
119
- bizplace: ObjectRef
120
-
121
- @Field({ nullable: true })
122
- remark: string
123
-
124
- @Field(type => [ObjectRef], { nullable: true })
125
- orderProducts: ObjectRef[]
126
- }
127
-
128
- @InputType()
129
- export class DraftReleaseGoodPatch {
130
- @Field({ nullable: true })
131
- id: string
132
-
133
- @Field({ nullable: true })
134
- name: string
135
-
136
- @Field(type => ObjectRef, { nullable: true })
137
- bizplace: ObjectRef
138
-
139
- @Field({ nullable: true })
140
- releaseDate: string
141
-
142
- @Field({ nullable: true })
143
- collectionOrderNo: string
144
-
145
- @Field({ nullable: true })
146
- ownTransport: Boolean
147
-
148
- @Field({ nullable: true })
149
- type: string
150
-
151
- @Field({ nullable: true })
152
- truckNo: string
153
-
154
- @Field({ nullable: true })
155
- packageId: string
156
-
157
- @Field({ nullable: true })
158
- refNo: string
159
-
160
- @Field({ nullable: true })
161
- refNo2: string
162
-
163
- @Field({ nullable: true })
164
- refNo3: string
165
-
166
- @Field({ nullable: true })
167
- exportOption: Boolean
168
-
169
- @Field({ nullable: true })
170
- packingOption: Boolean
171
-
172
- @Field(type => ObjectRef, { nullable: true })
173
- shippingOrder: ObjectRef
174
-
175
- @Field({ nullable: true })
176
- status: string
177
-
178
- @Field({ nullable: true })
179
- remark: string
180
-
181
- @Field({ nullable: true })
182
- billingAddress: string
183
-
184
- @Field({ nullable: true })
185
- deliveryAddress1: string
186
-
187
- @Field({ nullable: true })
188
- deliveryAddress2: string
189
-
190
- @Field({ nullable: true })
191
- deliveryAddress3: string
192
-
193
- @Field({ nullable: true })
194
- deliveryAddress4: string
195
-
196
- @Field({ nullable: true })
197
- deliveryAddress5: string
198
-
199
- @Field({ nullable: true })
200
- attentionTo: string
201
-
202
- @Field({ nullable: true })
203
- attentionCompany: string
204
-
205
- @Field({ nullable: true })
206
- city: string
207
-
208
- @Field({ nullable: true })
209
- state: string
210
-
211
- @Field({ nullable: true })
212
- postalCode: string
213
-
214
- @Field({ nullable: true })
215
- country: string
216
-
217
- @Field({ nullable: true })
218
- phone1: string
219
-
220
- @Field({ nullable: true })
221
- phone2: string
222
-
223
- @Field({ nullable: true })
224
- email: string
225
-
226
- @Field({ nullable: true })
227
- description: string
228
-
229
- @Field({ nullable: true })
230
- courierOption: Boolean
231
-
232
- @Field({ nullable: true })
233
- pickupAddress: string
234
-
235
- @Field({ nullable: true })
236
- pickupTime: string
237
-
238
- @Field({ nullable: true })
239
- handoverType: string
240
-
241
- @Field({ nullable: true })
242
- dropoffAddress: string
243
-
244
- @Field({ nullable: true })
245
- marketplaceOrderStatus: string
246
-
247
- @Field({ nullable: true })
248
- deliverTo: string
249
-
250
- @Field(type => [OrderProductPatch], { nullable: true })
251
- orderProducts: OrderProductPatch[]
252
- }
253
-
254
- @ObjectType()
255
- export class DraftReleaseGoodList {
256
- @Field(type => [DraftReleaseGood])
257
- items: DraftReleaseGood[]
258
-
259
- @Field(type => Int)
260
- total: number
261
- }