@things-factory/sales-base 8.0.0-beta.9 → 8.0.0

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 +13 -13
  3. package/server/constants/attachment-type.ts +9 -0
  4. package/server/constants/index.ts +7 -0
  5. package/server/constants/load-type.ts +4 -0
  6. package/server/constants/order.ts +203 -0
  7. package/server/constants/product-group-type.ts +4 -0
  8. package/server/constants/release-good.ts +9 -0
  9. package/server/constants/transfer-order-type.ts +6 -0
  10. package/server/constants/validation-error-code.ts +3 -0
  11. package/server/constants/vas-target-type.ts +25 -0
  12. package/server/controllers/ecommerce/ecommerce-controller.ts +122 -0
  13. package/server/controllers/ecommerce/index.ts +2 -0
  14. package/server/controllers/ecommerce/sellercraft-controller.ts +182 -0
  15. package/server/controllers/index.ts +2 -0
  16. package/server/controllers/order-controller.ts +296 -0
  17. package/server/errors/index.ts +1 -0
  18. package/server/errors/validation-error.ts +25 -0
  19. package/server/index.ts +5 -0
  20. package/server/migrations/index.ts +9 -0
  21. package/server/service/arrival-notice/arrival-notice-mutation.ts +1152 -0
  22. package/server/service/arrival-notice/arrival-notice-query.ts +549 -0
  23. package/server/service/arrival-notice/arrival-notice-types.ts +310 -0
  24. package/server/service/arrival-notice/arrival-notice.ts +202 -0
  25. package/server/service/arrival-notice/index.ts +9 -0
  26. package/server/service/claim/claim-mutation.ts +308 -0
  27. package/server/service/claim/claim-query.ts +122 -0
  28. package/server/service/claim/claim-types.ts +130 -0
  29. package/server/service/claim/claim.ts +140 -0
  30. package/server/service/claim/index.ts +9 -0
  31. package/server/service/claim-detail/claim-detail-mutation.ts +102 -0
  32. package/server/service/claim-detail/claim-detail-query.ts +55 -0
  33. package/server/service/claim-detail/claim-detail-types.ts +47 -0
  34. package/server/service/claim-detail/claim-detail.ts +69 -0
  35. package/server/service/claim-detail/index.ts +9 -0
  36. package/server/service/claim-order/claim-order-mutation.ts +101 -0
  37. package/server/service/claim-order/claim-order-query.ts +47 -0
  38. package/server/service/claim-order/claim-order-types.ts +35 -0
  39. package/server/service/claim-order/claim-order.ts +81 -0
  40. package/server/service/claim-order/index.ts +9 -0
  41. package/server/service/collection-order/collection-order-mutation.ts +245 -0
  42. package/server/service/collection-order/collection-order-query.ts +97 -0
  43. package/server/service/collection-order/collection-order-types.ts +165 -0
  44. package/server/service/collection-order/collection-order.ts +135 -0
  45. package/server/service/collection-order/index.ts +9 -0
  46. package/server/service/delivery-order/delivery-order-mutation.ts +967 -0
  47. package/server/service/delivery-order/delivery-order-query.ts +631 -0
  48. package/server/service/delivery-order/delivery-order-types.ts +268 -0
  49. package/server/service/delivery-order/delivery-order.ts +258 -0
  50. package/server/service/delivery-order/index.ts +9 -0
  51. package/server/service/draft-release-good/draft-release-good-mutation.ts +765 -0
  52. package/server/service/draft-release-good/draft-release-good-query.ts +354 -0
  53. package/server/service/draft-release-good/draft-release-good-type.ts +261 -0
  54. package/server/service/draft-release-good/draft-release-good.ts +284 -0
  55. package/server/service/draft-release-good/index.ts +9 -0
  56. package/server/service/goods-receival-note/goods-receival-note-mutation.ts +129 -0
  57. package/server/service/goods-receival-note/goods-receival-note-query.ts +280 -0
  58. package/server/service/goods-receival-note/goods-receival-note-types.ts +105 -0
  59. package/server/service/goods-receival-note/goods-receival-note.ts +127 -0
  60. package/server/service/goods-receival-note/index.ts +9 -0
  61. package/server/service/index.ts +238 -0
  62. package/server/service/inventory-check/index.ts +9 -0
  63. package/server/service/inventory-check/inventory-check-mutation.ts +149 -0
  64. package/server/service/inventory-check/inventory-check-query.ts +48 -0
  65. package/server/service/inventory-check/inventory-check-types.ts +48 -0
  66. package/server/service/inventory-check/inventory-check.ts +90 -0
  67. package/server/service/invoice/index.ts +9 -0
  68. package/server/service/invoice/invoice-mutation.ts +95 -0
  69. package/server/service/invoice/invoice-query.ts +53 -0
  70. package/server/service/invoice/invoice-types.ts +279 -0
  71. package/server/service/invoice/invoice.ts +230 -0
  72. package/server/service/invoice-product/index.ts +9 -0
  73. package/server/service/invoice-product/invoice-product-mutation.ts +54 -0
  74. package/server/service/invoice-product/invoice-product-query.ts +54 -0
  75. package/server/service/invoice-product/invoice-product-types.ts +84 -0
  76. package/server/service/invoice-product/invoice-product.ts +92 -0
  77. package/server/service/job-sheet/index.ts +9 -0
  78. package/server/service/job-sheet/job-sheet-mutation.ts +92 -0
  79. package/server/service/job-sheet/job-sheet-query.ts +112 -0
  80. package/server/service/job-sheet/job-sheet-types.ts +78 -0
  81. package/server/service/job-sheet/job-sheet.ts +102 -0
  82. package/server/service/manifest/index.ts +6 -0
  83. package/server/service/manifest/manifest-mutation.ts +190 -0
  84. package/server/service/manifest/manifest-query.ts +149 -0
  85. package/server/service/manifest/manifest-type.ts +84 -0
  86. package/server/service/manifest/manifest.ts +114 -0
  87. package/server/service/order-inventory/index.ts +9 -0
  88. package/server/service/order-inventory/order-inventory-mutation.ts +54 -0
  89. package/server/service/order-inventory/order-inventory-query.ts +722 -0
  90. package/server/service/order-inventory/order-inventory-types.ts +238 -0
  91. package/server/service/order-inventory/order-inventory.ts +401 -0
  92. package/server/service/order-product/index.ts +9 -0
  93. package/server/service/order-product/order-product-mutation.ts +48 -0
  94. package/server/service/order-product/order-product-query.ts +89 -0
  95. package/server/service/order-product/order-product-types.ts +335 -0
  96. package/server/service/order-product/order-product.ts +362 -0
  97. package/server/service/order-tote/index.ts +9 -0
  98. package/server/service/order-tote/order-tote-mutation.ts +31 -0
  99. package/server/service/order-tote/order-tote-query.ts +112 -0
  100. package/server/service/order-tote/order-tote-types.ts +47 -0
  101. package/server/service/order-tote/order-tote.ts +73 -0
  102. package/server/service/order-tote-item/index.ts +9 -0
  103. package/server/service/order-tote-item/order-tote-item-mutation.ts +31 -0
  104. package/server/service/order-tote-item/order-tote-item-query.ts +82 -0
  105. package/server/service/order-tote-item/order-tote-item-types.ts +56 -0
  106. package/server/service/order-tote-item/order-tote-item.ts +72 -0
  107. package/server/service/order-tote-seal/index.ts +9 -0
  108. package/server/service/order-tote-seal/order-tote-seal-mutation.ts +31 -0
  109. package/server/service/order-tote-seal/order-tote-seal-query.ts +59 -0
  110. package/server/service/order-tote-seal/order-tote-seal-types.ts +41 -0
  111. package/server/service/order-tote-seal/order-tote-seal.ts +46 -0
  112. package/server/service/order-vas/index.ts +9 -0
  113. package/server/service/order-vas/order-vas-mutation.ts +20 -0
  114. package/server/service/order-vas/order-vas-query.ts +72 -0
  115. package/server/service/order-vas/order-vas-types.ts +159 -0
  116. package/server/service/order-vas/order-vas.ts +207 -0
  117. package/server/service/others/index.ts +5 -0
  118. package/server/service/others/other-query.ts +563 -0
  119. package/server/service/others/other-types.ts +115 -0
  120. package/server/service/purchase-order/index.ts +9 -0
  121. package/server/service/purchase-order/purchase-order-mutation.ts +458 -0
  122. package/server/service/purchase-order/purchase-order-query.ts +90 -0
  123. package/server/service/purchase-order/purchase-order-types.ts +154 -0
  124. package/server/service/purchase-order/purchase-order.ts +172 -0
  125. package/server/service/purchase-order-other-charge/index.ts +9 -0
  126. package/server/service/purchase-order-other-charge/purchase-order-other-charge-mutation.ts +31 -0
  127. package/server/service/purchase-order-other-charge/purchase-order-other-charge-query.ts +52 -0
  128. package/server/service/purchase-order-other-charge/purchase-order-other-charge-types.ts +44 -0
  129. package/server/service/purchase-order-other-charge/purchase-order-other-charge.ts +68 -0
  130. package/server/service/release-good/index.ts +9 -0
  131. package/server/service/release-good/release-good-mutation.ts +1686 -0
  132. package/server/service/release-good/release-good-query.ts +980 -0
  133. package/server/service/release-good/release-good-types.ts +662 -0
  134. package/server/service/release-good/release-good.ts +490 -0
  135. package/server/service/retail-replenishment-order/index.ts +9 -0
  136. package/server/service/retail-replenishment-order/retail-replenishment-order-mutation.ts +382 -0
  137. package/server/service/retail-replenishment-order/retail-replenishment-order-query.ts +54 -0
  138. package/server/service/retail-replenishment-order/retail-replenishment-order-types.ts +101 -0
  139. package/server/service/retail-replenishment-order/retail-replenishment-order.ts +115 -0
  140. package/server/service/return-order/index.ts +9 -0
  141. package/server/service/return-order/return-order-mutation.ts +516 -0
  142. package/server/service/return-order/return-order-query.ts +226 -0
  143. package/server/service/return-order/return-order-types.ts +196 -0
  144. package/server/service/return-order/return-order.ts +127 -0
  145. package/server/service/reverse-kitting-order/index.ts +9 -0
  146. package/server/service/reverse-kitting-order/reverse-kitting-order-mutation.ts +500 -0
  147. package/server/service/reverse-kitting-order/reverse-kitting-order-query.ts +197 -0
  148. package/server/service/reverse-kitting-order/reverse-kitting-order-type.ts +173 -0
  149. package/server/service/reverse-kitting-order/reverse-kitting-order.ts +121 -0
  150. package/server/service/reverse-kitting-order-inventory/index.ts +9 -0
  151. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-mutation.ts +129 -0
  152. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-query.ts +52 -0
  153. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.ts +95 -0
  154. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +143 -0
  155. package/server/service/shipping-order/index.ts +9 -0
  156. package/server/service/shipping-order/shipping-order-mutation.ts +61 -0
  157. package/server/service/shipping-order/shipping-order-query.ts +61 -0
  158. package/server/service/shipping-order/shipping-order-types.ts +89 -0
  159. package/server/service/shipping-order/shipping-order.ts +129 -0
  160. package/server/service/transfer-order/index.ts +9 -0
  161. package/server/service/transfer-order/transfer-order-mutation.ts +309 -0
  162. package/server/service/transfer-order/transfer-order-query.ts +66 -0
  163. package/server/service/transfer-order/transfer-order-types.ts +97 -0
  164. package/server/service/transfer-order/transfer-order.ts +117 -0
  165. package/server/service/vas/index.ts +9 -0
  166. package/server/service/vas/vas-mutation.ts +106 -0
  167. package/server/service/vas/vas-query.ts +60 -0
  168. package/server/service/vas/vas-types.ts +71 -0
  169. package/server/service/vas/vas.ts +77 -0
  170. package/server/service/vas-order/index.ts +9 -0
  171. package/server/service/vas-order/vas-order-mutation.ts +259 -0
  172. package/server/service/vas-order/vas-order-query.ts +119 -0
  173. package/server/service/vas-order/vas-order-types.ts +49 -0
  174. package/server/service/vas-order/vas-order.ts +81 -0
  175. package/server/utils/datetime-util.ts +54 -0
  176. package/server/utils/index.ts +3 -0
  177. package/server/utils/inventory-util.ts +1155 -0
  178. package/server/utils/order-no-generator.ts +146 -0
@@ -0,0 +1,362 @@
1
+ import { Field, Float, ID, ObjectType } from 'type-graphql'
2
+ import {
3
+ Column,
4
+ CreateDateColumn,
5
+ Entity,
6
+ Index,
7
+ ManyToOne,
8
+ OneToMany,
9
+ PrimaryGeneratedColumn,
10
+ RelationId,
11
+ UpdateDateColumn
12
+ } from 'typeorm'
13
+
14
+ import { User } from '@things-factory/auth-base'
15
+ import { Bizplace, ContactPoint } from '@things-factory/biz-base'
16
+ import { Product, ProductBundle, ProductDetail } from '@things-factory/product-base'
17
+ import { Domain, ScalarDate, roundTransformer } from '@things-factory/shell'
18
+ import { Inventory } from '@things-factory/warehouse-base'
19
+
20
+ import { ArrivalNotice } from '../arrival-notice/arrival-notice'
21
+ import { CollectionOrder } from '../collection-order/collection-order'
22
+ import { DeliveryOrder } from '../delivery-order/delivery-order'
23
+ import { DraftReleaseGood } from '../draft-release-good/draft-release-good'
24
+ import { OrderInventory } from '../order-inventory/order-inventory'
25
+ import { PurchaseOrder } from '../purchase-order/purchase-order'
26
+ import { ReleaseGood } from '../release-good/release-good'
27
+ import { RetailReplenishmentOrder } from '../retail-replenishment-order/retail-replenishment-order'
28
+
29
+ @Entity()
30
+ @Index('ix_order-product_0', (orderProduct: OrderProduct) => [orderProduct.domain, orderProduct.name], {
31
+ unique: true
32
+ })
33
+ @Index('ix_order-product_1', (orderProduct: OrderProduct) => [
34
+ orderProduct.bizplace,
35
+ orderProduct.arrivalNotice,
36
+ orderProduct.product,
37
+ orderProduct.batchId,
38
+ orderProduct.packingType
39
+ ])
40
+ @Index(
41
+ 'ix_order-product_2',
42
+ (orderProduct: OrderProduct) => [
43
+ orderProduct.bizplace,
44
+ orderProduct.retailReplenishmentOrder,
45
+ orderProduct.product,
46
+ orderProduct.batchId,
47
+ orderProduct.packingType
48
+ ],
49
+ { unique: true }
50
+ )
51
+ @Index(
52
+ 'ix_order-product_3',
53
+ (orderProduct: OrderProduct) => [
54
+ orderProduct.bizplace,
55
+ orderProduct.purchaseOrder,
56
+ orderProduct.product,
57
+ orderProduct.batchId,
58
+ orderProduct.uom
59
+ ],
60
+ { unique: true }
61
+ )
62
+ @Index('ix_order-product_4', (orderProduct: OrderProduct) => [orderProduct.draftReleaseGood], { unique: false })
63
+ @ObjectType()
64
+ export class OrderProduct {
65
+ @PrimaryGeneratedColumn('uuid')
66
+ @Field(type => ID)
67
+ id: string
68
+
69
+ @ManyToOne(type => Domain, { nullable: false })
70
+ @Field(type => Domain, { nullable: true })
71
+ domain: Domain
72
+
73
+ @RelationId((orderProduct: OrderProduct) => orderProduct.domain)
74
+ domainId: string
75
+
76
+ @ManyToOne(type => Bizplace, { nullable: false })
77
+ @Field(type => Bizplace, { nullable: true })
78
+ bizplace: Bizplace
79
+
80
+ @RelationId((orderProduct: OrderProduct) => orderProduct.bizplace)
81
+ bizplaceId: string
82
+
83
+ @Column()
84
+ @Field()
85
+ name: string
86
+
87
+ @Column({ nullable: true })
88
+ @Field({ nullable: true })
89
+ description: string
90
+
91
+ @Column({ nullable: true })
92
+ @Field({ nullable: true })
93
+ type: string
94
+
95
+ @ManyToOne(type => ArrivalNotice)
96
+ @Field(type => ArrivalNotice, { nullable: true })
97
+ arrivalNotice: ArrivalNotice
98
+
99
+ @RelationId((orderProduct: OrderProduct) => orderProduct.arrivalNotice)
100
+ arrivalNoticeId: string
101
+
102
+ @ManyToOne(type => ReleaseGood)
103
+ @Field(type => ReleaseGood, { nullable: true })
104
+ releaseGood: ReleaseGood
105
+
106
+ @RelationId((orderProduct: OrderProduct) => orderProduct.releaseGood)
107
+ releaseGoodId: string
108
+
109
+ @ManyToOne(type => DraftReleaseGood)
110
+ @Field(type => DraftReleaseGood, { nullable: true })
111
+ draftReleaseGood: DraftReleaseGood
112
+
113
+ @RelationId((orderProduct: OrderProduct) => orderProduct.draftReleaseGood)
114
+ draftReleaseGoodId: string
115
+
116
+ @ManyToOne(type => CollectionOrder)
117
+ @Field(type => CollectionOrder, { nullable: true })
118
+ collectionOrder: CollectionOrder
119
+
120
+ @RelationId((orderProduct: OrderProduct) => orderProduct.collectionOrder)
121
+ collectionOrderId: string
122
+
123
+ @ManyToOne(type => PurchaseOrder)
124
+ @Field(type => PurchaseOrder, { nullable: true })
125
+ purchaseOrder: PurchaseOrder
126
+
127
+ @RelationId((orderProduct: OrderProduct) => orderProduct.purchaseOrder)
128
+ purchaseOrderId: string
129
+
130
+ @OneToMany(type => OrderInventory, orderInventory => orderInventory.orderProduct)
131
+ @Field(type => [OrderInventory], { nullable: true })
132
+ orderInventories: OrderInventory
133
+
134
+ @ManyToOne(type => RetailReplenishmentOrder)
135
+ @Field(type => RetailReplenishmentOrder, { nullable: true })
136
+ retailReplenishmentOrder: RetailReplenishmentOrder
137
+
138
+ @RelationId((orderProduct: OrderProduct) => orderProduct.retailReplenishmentOrder)
139
+ retailReplenishmentOrderId: string
140
+
141
+ @ManyToOne(type => DeliveryOrder)
142
+ @Field(type => DeliveryOrder, { nullable: true })
143
+ deliveryOrder: DeliveryOrder
144
+
145
+ @RelationId((orderProduct: OrderProduct) => orderProduct.deliveryOrder)
146
+ deliveryOrderId: string
147
+
148
+ @ManyToOne(type => Inventory)
149
+ @Field(type => Inventory, { nullable: true })
150
+ fromInventory: Inventory
151
+
152
+ @RelationId((orderProduct: OrderProduct) => orderProduct.fromInventory)
153
+ fromInventoryId: string
154
+
155
+ @ManyToOne(type => Inventory)
156
+ @Field(type => Inventory, { nullable: true })
157
+ currentInventory: Inventory
158
+
159
+ @RelationId((orderProduct: OrderProduct) => orderProduct.currentInventory)
160
+ currentInventoryId: string
161
+
162
+ @ManyToOne(type => Inventory)
163
+ @Field(type => Inventory, { nullable: true })
164
+ toInventory: Inventory
165
+
166
+ @RelationId((orderProduct: OrderProduct) => orderProduct.toInventory)
167
+ toInventoryId: string
168
+
169
+ @ManyToOne(type => Product, { nullable: true })
170
+ @Field(type => Product)
171
+ product: Product
172
+
173
+ @RelationId((orderProduct: OrderProduct) => orderProduct.product)
174
+ productId: string
175
+
176
+ @ManyToOne(type => ProductDetail, { nullable: true })
177
+ @Field(type => ProductDetail)
178
+ productDetail: ProductDetail
179
+
180
+ @RelationId((orderProduct: OrderProduct) => orderProduct.productDetail)
181
+ productDetailId: string
182
+
183
+ @ManyToOne(type => ProductBundle, { nullable: true })
184
+ @Field(type => ProductBundle)
185
+ productBundle: ProductBundle
186
+
187
+ @RelationId((orderProduct: OrderProduct) => orderProduct.productBundle)
188
+ productBundleId: string
189
+
190
+ @ManyToOne(type => ContactPoint)
191
+ @Field(type => ContactPoint, { nullable: true })
192
+ contactPoint?: ContactPoint
193
+
194
+ @RelationId((orderProduct: OrderProduct) => orderProduct.contactPoint)
195
+ contactPointId?: string
196
+
197
+ @Column()
198
+ @Field()
199
+ batchId: string
200
+
201
+ @Column({ nullable: true })
202
+ @Field({ nullable: true })
203
+ adjustedBatchId: string
204
+
205
+ @Column({ nullable: true })
206
+ @Field({ nullable: true })
207
+ batchIdRef: string
208
+
209
+ @Column({ nullable: true })
210
+ @Field({ nullable: true })
211
+ adjustedBatchIdRef: string
212
+
213
+ @Column()
214
+ @Field()
215
+ packingType: string
216
+
217
+ @Column({ nullable: true })
218
+ @Field({ nullable: true })
219
+ adjustedPackingType: string
220
+
221
+ @Column('float', { nullable: true, default: 1, transformer: roundTransformer })
222
+ @Field({ nullable: true })
223
+ packingSize: number
224
+
225
+ @Column('int', { nullable: true })
226
+ @Field({ nullable: true })
227
+ manufactureYear: number
228
+
229
+ @Column('date', { nullable: true })
230
+ @Field(type => ScalarDate, { nullable: true })
231
+ manufactureDate: Date
232
+
233
+ @Column({ nullable: true })
234
+ @Field({ nullable: true })
235
+ uom: string
236
+
237
+ @Column({ nullable: true })
238
+ @Field({ nullable: true })
239
+ adjustedUom: string
240
+
241
+ @Column('float', { nullable: true, transformer: roundTransformer })
242
+ @Field({ nullable: true })
243
+ uomValue: number
244
+
245
+ @Column('float', { nullable: true, transformer: roundTransformer })
246
+ @Field({ nullable: true })
247
+ adjustedUomValue: number
248
+
249
+ @Column('float', { nullable: true, transformer: roundTransformer })
250
+ @Field({ nullable: true })
251
+ unpackUomValue: number
252
+
253
+ @Column('float', { transformer: roundTransformer })
254
+ @Field()
255
+ packQty: number
256
+
257
+ @Column({ nullable: true })
258
+ @Field({ nullable: true })
259
+ adjustedPackQty: number
260
+
261
+ @Column('float', { nullable: true, transformer: roundTransformer })
262
+ @Field({ nullable: true })
263
+ actualPackQty: number
264
+
265
+ @Column('float', { nullable: true, transformer: roundTransformer })
266
+ @Field({ nullable: true })
267
+ unpackQty: number
268
+
269
+ @Column('float', { nullable: true, transformer: roundTransformer })
270
+ @Field({ nullable: true })
271
+ unitPrice: number
272
+
273
+ @Column('float', { nullable: true, transformer: roundTransformer })
274
+ @Field({ nullable: true })
275
+ adjustedUnitPrice: number
276
+
277
+ @Column('float', { nullable: true, transformer: roundTransformer })
278
+ @Field({ nullable: true })
279
+ discountAmt: number
280
+
281
+ @Column('float', { nullable: true, transformer: roundTransformer })
282
+ @Field({ nullable: true })
283
+ taxRate: number
284
+
285
+ @Column('float', { nullable: true, transformer: roundTransformer })
286
+ @Field({ nullable: true })
287
+ miscAmt: number
288
+
289
+ @Column('float', { nullable: true, transformer: roundTransformer })
290
+ @Field({ nullable: true })
291
+ palletQty: number
292
+
293
+ @Column('float', { nullable: true, transformer: roundTransformer })
294
+ @Field({ nullable: true })
295
+ adjustedPalletQty: number
296
+
297
+ @Column('float', { nullable: true, transformer: roundTransformer })
298
+ @Field({ nullable: true })
299
+ actualPalletQty: number
300
+
301
+ @Column({ nullable: true })
302
+ @Field({ nullable: true })
303
+ totalUomValue: string
304
+
305
+ @Column({ nullable: true })
306
+ @Field({ nullable: true })
307
+ adjustedTotalUomValue: string
308
+
309
+ @Column({ nullable: true, type: 'float', transformer: roundTransformer })
310
+ @Field({ nullable: true })
311
+ releaseQty: number
312
+
313
+ @Column({ nullable: true, type: 'float', transformer: roundTransformer })
314
+ @Field({ nullable: true })
315
+ releaseUomValue: number
316
+
317
+ @Column({ nullable: true })
318
+ @Field({ nullable: true })
319
+ remark: string
320
+
321
+ @Column({ nullable: true })
322
+ @Field({ nullable: true })
323
+ issue: string
324
+
325
+ @Column()
326
+ @Field()
327
+ status: string
328
+
329
+ @CreateDateColumn()
330
+ @Field()
331
+ createdAt: Date
332
+
333
+ @UpdateDateColumn()
334
+ @Field()
335
+ updatedAt: Date
336
+
337
+ @ManyToOne(type => User)
338
+ @Field(type => User, { nullable: true })
339
+ creator: User
340
+
341
+ @RelationId((orderProduct: OrderProduct) => orderProduct.creator)
342
+ creatorId: string
343
+
344
+ @ManyToOne(type => User)
345
+ @Field(type => User, { nullable: true })
346
+ updater: User
347
+
348
+ @RelationId((orderProduct: OrderProduct) => orderProduct.updater)
349
+ updaterId: string
350
+
351
+ @Field(type => Float, { nullable: true })
352
+ remainQty: number
353
+
354
+ @Field(type => Float, { nullable: true })
355
+ remainUomValue: number
356
+
357
+ @Field({ nullable: true })
358
+ remainUomValueWithUom: string
359
+
360
+ @Field({ nullable: true })
361
+ groupType: string
362
+ }
@@ -0,0 +1,9 @@
1
+ import { OrderTote } from './order-tote'
2
+ import { OrderToteMutation } from './order-tote-mutation'
3
+ import { OrderToteQuery } from './order-tote-query'
4
+
5
+ export const entities = [OrderTote]
6
+ export const resolvers = [OrderToteQuery, OrderToteMutation]
7
+
8
+ export * from './order-tote-mutation'
9
+ export * from './order-tote-query'
@@ -0,0 +1,31 @@
1
+ import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
+ import { In } from 'typeorm'
3
+
4
+ import { OrderTote } from './order-tote'
5
+
6
+ @Resolver(OrderTote)
7
+ export class OrderToteMutation {
8
+ @Directive('@transaction')
9
+ @Mutation(returns => Boolean)
10
+ async deleteOrderTote(@Arg('name') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {
11
+ const { domain, tx } = context.state
12
+
13
+ await tx.getRepository(OrderTote).delete({ domain: { id: domain.id }, id })
14
+ return true
15
+ }
16
+
17
+ @Directive('@transaction')
18
+ @Mutation(returns => Boolean)
19
+ async deleteOrderTotes(
20
+ @Arg('ids', type => [String]) ids: string[],
21
+ @Ctx() context: ResolverContext
22
+ ): Promise<Boolean> {
23
+ const { domain, tx } = context.state
24
+
25
+ await tx.getRepository(OrderTote).delete({
26
+ domain: { id: domain.id },
27
+ id: In(ids)
28
+ })
29
+ return true
30
+ }
31
+ }
@@ -0,0 +1,112 @@
1
+ import { Arg, Ctx, Query, Resolver } from 'type-graphql'
2
+ import { In } from 'typeorm'
3
+
4
+ import { buildQuery, Filter, getRepository, Pagination, Sorting } from '@things-factory/shell'
5
+ import { Tote } from '@things-factory/warehouse-base'
6
+
7
+ import { OrderToteSeal } from '../order-tote-seal/order-tote-seal'
8
+ import { ReleaseGood } from '../release-good/release-good'
9
+ import { OrderTote } from './order-tote'
10
+ import { OrderToteList } from './order-tote-types'
11
+
12
+ @Resolver(OrderTote)
13
+ export class OrderToteQuery {
14
+ @Query(returns => OrderToteList)
15
+ async orderTotes(
16
+ @Ctx() context: ResolverContext,
17
+ @Arg('filters', type => [Filter], { nullable: true }) filters?: Filter[],
18
+ @Arg('pagination', type => Pagination, { nullable: true }) pagination?: Pagination,
19
+ @Arg('sortings', type => [Sorting], { nullable: true }) sortings?: Sorting[]
20
+ ): Promise<OrderToteList> {
21
+ try {
22
+ const { domain } = context.state
23
+
24
+ const releaseGoodNoParam = filters.find(item => item.name === 'releaseGoodNo')
25
+
26
+ const queryBuilder = await getRepository(OrderTote).createQueryBuilder()
27
+ buildQuery(queryBuilder, { filters, pagination, sortings }, context)
28
+
29
+ queryBuilder
30
+ .leftJoinAndSelect('OrderTote.domain', 'Domain')
31
+ .leftJoinAndSelect('OrderTote.releaseGood', 'ReleaseGood')
32
+ .leftJoinAndSelect('OrderTote.tote', 'Tote')
33
+ .leftJoinAndSelect('OrderTote.updater', 'Updater')
34
+ .where('Domain.id = :domainId', { domainId: domain.id })
35
+
36
+ if (releaseGoodNoParam) {
37
+ filters.splice(
38
+ filters.findIndex(item => item.name == 'releaseGoodNo'),
39
+ 1
40
+ )
41
+ queryBuilder.andWhere('ReleaseGood.name = :rgName', { rgName: releaseGoodNoParam.value })
42
+ }
43
+
44
+ let [items, total] = await queryBuilder.getManyAndCount()
45
+
46
+ let orderToteIds: string[] = items.map(itm => itm.id)
47
+
48
+ let orderToteSeals: OrderToteSeal[] = await getRepository(OrderToteSeal).find({
49
+ where: { orderTote: In(orderToteIds) }
50
+ })
51
+
52
+ items = items.map((itm: OrderTote) => {
53
+ return {
54
+ ...itm,
55
+ orderToteSeals: orderToteSeals.filter(seal => seal.orderToteId == itm.id)
56
+ }
57
+ })
58
+
59
+ return { items, total }
60
+ } catch (e) {
61
+ throw new Error(e)
62
+ }
63
+ }
64
+
65
+ @Query(returns => OrderTote)
66
+ async orderTote(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<OrderTote> {
67
+ const { domain } = context.state
68
+
69
+ return await getRepository(OrderTote).findOne({
70
+ where: { domain: { id: domain.id }, id },
71
+ relations: ['domain', 'releaseGood', 'tote', 'updater']
72
+ })
73
+ }
74
+
75
+ @Query(returns => Boolean)
76
+ async checkOrderTote(
77
+ @Arg('name') name: string,
78
+ @Arg('orderNo') orderNo: string,
79
+ @Ctx() context: ResolverContext
80
+ ): Promise<Boolean> {
81
+ const { domain } = context.state
82
+ let foundOrder = await getRepository(ReleaseGood).findOne({
83
+ where: { name: orderNo, domain: { id: domain.id } },
84
+ relations: ['bizplace']
85
+ })
86
+ let scannedTote = await getRepository(Tote).findOne({ where: { name, bizplace: { id: foundOrder.bizplace.id } } })
87
+
88
+ let foundOrderTote = await getRepository(OrderTote).findOne({
89
+ where: { domain: { id: domain.id }, releaseGood: { id: foundOrder.id }, name },
90
+ relations: ['domain', 'releaseGood', 'tote', 'updater']
91
+ })
92
+
93
+ if (!foundOrderTote && scannedTote) {
94
+ let executingOrderTote = await getRepository(OrderTote).find({
95
+ where: { tote: scannedTote },
96
+ relations: ['releaseGood']
97
+ })
98
+
99
+ executingOrderTote = executingOrderTote.filter(itm => itm.releaseGood.status !== 'DONE')
100
+
101
+ if (executingOrderTote && executingOrderTote.length > 0) {
102
+ throw new Error(`Current tote is used in another RO (${executingOrderTote[0].releaseGood.name})`)
103
+ }
104
+ }
105
+
106
+ if (foundOrderTote?.closedDate) {
107
+ return true
108
+ } else {
109
+ return false
110
+ }
111
+ }
112
+ }
@@ -0,0 +1,47 @@
1
+ import { Field, InputType, Int, ObjectType } from 'type-graphql'
2
+
3
+ import { ObjectRef } from '@things-factory/shell'
4
+
5
+ import { OrderTote } from './order-tote'
6
+
7
+ @ObjectType()
8
+ export class OrderToteList {
9
+ @Field(type => [OrderTote], { nullable: true })
10
+ items: OrderTote[]
11
+
12
+ @Field(type => Int, { nullable: true })
13
+ total: number
14
+ }
15
+
16
+ @InputType()
17
+ export class NewOrderTote {
18
+ @Field({ nullable: true })
19
+ name: string
20
+
21
+ @Field({ nullable: true })
22
+ description: string
23
+
24
+ @Field(type => ObjectRef, { nullable: true })
25
+ releaseGood: ObjectRef
26
+
27
+ @Field(type => ObjectRef, { nullable: true })
28
+ tote: ObjectRef
29
+ }
30
+
31
+ @InputType()
32
+ export class OrderTotePatch {
33
+ @Field({ nullable: true })
34
+ id: string
35
+
36
+ @Field({ nullable: true })
37
+ name: string
38
+
39
+ @Field({ nullable: true })
40
+ description: string
41
+
42
+ @Field(type => ObjectRef, { nullable: true })
43
+ releaseGood: ObjectRef
44
+
45
+ @Field(type => ObjectRef, { nullable: true })
46
+ tote: ObjectRef
47
+ }
@@ -0,0 +1,73 @@
1
+ import { Field, ObjectType } from 'type-graphql'
2
+ import {
3
+ Column,
4
+ Entity,
5
+ Index,
6
+ ManyToOne,
7
+ OneToMany,
8
+ PrimaryGeneratedColumn,
9
+ RelationId,
10
+ UpdateDateColumn
11
+ } from 'typeorm'
12
+
13
+ import { User } from '@things-factory/auth-base'
14
+ import { Domain } from '@things-factory/shell'
15
+ import { Tote } from '@things-factory/warehouse-base'
16
+
17
+ import { OrderToteSeal } from '../order-tote-seal/order-tote-seal'
18
+ import { ReleaseGood } from '../release-good/release-good'
19
+
20
+ @Entity()
21
+ @Index('ix_order_tote_0', (orderTote: OrderTote) => [orderTote.id], { unique: true })
22
+ @ObjectType()
23
+ export class OrderTote {
24
+ @PrimaryGeneratedColumn('uuid')
25
+ @Field()
26
+ id: string
27
+
28
+ @ManyToOne(type => Domain)
29
+ @Field(type => Domain)
30
+ domain: Domain
31
+
32
+ @RelationId((orderTote: OrderTote) => orderTote.domain)
33
+ domainId: string
34
+
35
+ @Column()
36
+ @Field()
37
+ name: string
38
+
39
+ @ManyToOne(type => ReleaseGood)
40
+ @Field(type => ReleaseGood)
41
+ releaseGood?: ReleaseGood
42
+
43
+ @RelationId((orderTote: OrderTote) => orderTote.releaseGood)
44
+ releaseGoodId: string
45
+
46
+ @ManyToOne(type => Tote)
47
+ @Field(type => Tote, { nullable: true })
48
+ tote?: Tote
49
+
50
+ @RelationId((orderTote: OrderTote) => orderTote.tote)
51
+ toteId: string
52
+
53
+ @Column({ nullable: true })
54
+ @Field({ nullable: true })
55
+ closedDate?: Date
56
+
57
+ @UpdateDateColumn()
58
+ @Field({ nullable: true })
59
+ updatedAt: Date
60
+
61
+ @ManyToOne(type => User, {
62
+ nullable: true
63
+ })
64
+ @Field(type => User, { nullable: true })
65
+ updater?: User
66
+
67
+ @RelationId((orderTote: OrderTote) => orderTote.updater)
68
+ updaterId: string
69
+
70
+ @OneToMany(type => OrderToteSeal, orderToteSeal => orderToteSeal.orderTote, { nullable: true })
71
+ @Field(type => [OrderToteSeal], { nullable: true })
72
+ orderToteSeals?: OrderToteSeal[]
73
+ }
@@ -0,0 +1,9 @@
1
+ import { OrderToteItem } from './order-tote-item'
2
+ import { OrderToteItemMutation } from './order-tote-item-mutation'
3
+ import { OrderToteItemQuery } from './order-tote-item-query'
4
+
5
+ export const entities = [OrderToteItem]
6
+ export const resolvers = [OrderToteItemQuery, OrderToteItemMutation]
7
+
8
+ export * from './order-tote-item-mutation'
9
+ export * from './order-tote-item-query'
@@ -0,0 +1,31 @@
1
+ import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
+ import { In } from 'typeorm'
3
+
4
+ import { OrderToteItem } from './order-tote-item'
5
+
6
+ @Resolver(OrderToteItem)
7
+ export class OrderToteItemMutation {
8
+ @Directive('@transaction')
9
+ @Mutation(returns => Boolean)
10
+ async deleteOrderToteItem(@Arg('name') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {
11
+ const { domain, tx } = context.state
12
+
13
+ await tx.getRepository(OrderToteItem).delete({ domain: { id: domain.id }, id })
14
+ return true
15
+ }
16
+
17
+ @Directive('@transaction')
18
+ @Mutation(returns => Boolean)
19
+ async deleteOrderToteItems(
20
+ @Arg('ids', type => [String]) ids: string[],
21
+ @Ctx() context: ResolverContext
22
+ ): Promise<Boolean> {
23
+ const { domain, tx } = context.state
24
+
25
+ await tx.getRepository(OrderToteItem).delete({
26
+ domain: { id: domain.id },
27
+ id: In(ids)
28
+ })
29
+ return true
30
+ }
31
+ }