@things-factory/product-base 8.0.0-beta.1 → 8.0.0-beta.4

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 (51) hide show
  1. package/package.json +5 -5
  2. package/server/constants/index.ts +0 -1
  3. package/server/constants/product.ts +0 -24
  4. package/server/controllers/index.ts +0 -0
  5. package/server/index.ts +0 -2
  6. package/server/middlewares/index.ts +0 -0
  7. package/server/migrations/index.ts +0 -9
  8. package/server/service/index.ts +0 -61
  9. package/server/service/product/index.ts +0 -6
  10. package/server/service/product/product-mutation.ts +0 -407
  11. package/server/service/product/product-query.ts +0 -336
  12. package/server/service/product/product-types.ts +0 -450
  13. package/server/service/product/product.ts +0 -543
  14. package/server/service/product/validate-product.ts +0 -42
  15. package/server/service/product-bundle/index.ts +0 -6
  16. package/server/service/product-bundle/product-bundle-mutation.ts +0 -140
  17. package/server/service/product-bundle/product-bundle-query.ts +0 -104
  18. package/server/service/product-bundle/product-bundle-types.ts +0 -51
  19. package/server/service/product-bundle/product-bundle.ts +0 -102
  20. package/server/service/product-bundle-setting/index.ts +0 -6
  21. package/server/service/product-bundle-setting/product-bundle-setting-mutation.ts +0 -168
  22. package/server/service/product-bundle-setting/product-bundle-setting-query.ts +0 -139
  23. package/server/service/product-bundle-setting/product-bundle-setting-types.ts +0 -41
  24. package/server/service/product-bundle-setting/product-bundle-setting.ts +0 -45
  25. package/server/service/product-combination/index.ts +0 -6
  26. package/server/service/product-combination/product-combination-mutation.ts +0 -148
  27. package/server/service/product-combination/product-combination-query.ts +0 -48
  28. package/server/service/product-combination/product-combination-type.ts +0 -50
  29. package/server/service/product-combination/product-combination.ts +0 -116
  30. package/server/service/product-combination-setting/index.ts +0 -6
  31. package/server/service/product-combination-setting/product-combination-setting-mutation.ts +0 -248
  32. package/server/service/product-combination-setting/product-combination-setting-query.ts +0 -176
  33. package/server/service/product-combination-setting/product-combination-setting-type.ts +0 -44
  34. package/server/service/product-combination-setting/product-combination-setting.ts +0 -77
  35. package/server/service/product-detail/index.ts +0 -6
  36. package/server/service/product-detail/product-detail-mutation.ts +0 -238
  37. package/server/service/product-detail/product-detail-query.ts +0 -213
  38. package/server/service/product-detail/product-detail-types.ts +0 -280
  39. package/server/service/product-detail/product-detail.ts +0 -388
  40. package/server/service/product-detail-bizplace-setting/index.ts +0 -6
  41. package/server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.ts +0 -118
  42. package/server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.ts +0 -90
  43. package/server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.ts +0 -62
  44. package/server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.ts +0 -104
  45. package/server/service/product-set/index.ts +0 -6
  46. package/server/service/product-set/product-set-mutation.ts +0 -149
  47. package/server/service/product-set/product-set-query.ts +0 -114
  48. package/server/service/product-set/product-set-types.ts +0 -45
  49. package/server/service/product-set/product-set.ts +0 -95
  50. package/server/utils/index.ts +0 -1
  51. package/server/utils/product-util.ts +0 -11
@@ -1,543 +0,0 @@
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 } from '@things-factory/biz-base'
16
- import { config } from '@things-factory/env'
17
- import { Routing } from '@things-factory/routing-base'
18
- import { Domain, roundTransformer } from '@things-factory/shell'
19
-
20
- import { ProductDetail } from '../product-detail/product-detail'
21
- import { ProductSet } from '../product-set/product-set'
22
-
23
- const ORMCONFIG = config.get('ormconfig', {})
24
- const DATABASE_TYPE = ORMCONFIG.type
25
-
26
- export enum pickStrategy {
27
- FIFO = 'FIFO',
28
- FEFO = 'FEFO',
29
- FMFO = 'FMFO',
30
- LIFO = 'LIFO',
31
- LOCATION = 'LOCATION'
32
- }
33
-
34
- @Entity()
35
- @Index(
36
- 'ix_product_0',
37
- (product: Product) => [product.domain, product.bizplace, product.name, product.description, product.weight],
38
- { unique: true }
39
- )
40
- @Index('ix_product_1', (product: Product) => [product.bizplace])
41
- @ObjectType()
42
- export class Product {
43
- @PrimaryGeneratedColumn('uuid')
44
- @Field(type => ID, { nullable: true })
45
- id: string
46
-
47
- @ManyToOne(type => Domain)
48
- @Field(type => Domain)
49
- domain: Domain
50
-
51
- @RelationId((product: Product) => product.domain)
52
- domainId: string
53
-
54
- @RelationId((product: Product) => product.bizplace)
55
- bizplaceId: string
56
-
57
- @RelationId((product: Product) => product.productRef)
58
- productRefId: string
59
-
60
- @RelationId((product: Product) => product.parentProductRef)
61
- parentProductRefId: string
62
-
63
- @ManyToOne(type => Bizplace)
64
- @Field()
65
- bizplace: Bizplace
66
-
67
- @Column({ default: false })
68
- @Field()
69
- isCompany: boolean
70
-
71
- @Column()
72
- @Field({ nullable: true })
73
- sku: string
74
-
75
- @Column({ nullable: true })
76
- @Field({ nullable: true })
77
- brandSku: string
78
-
79
- @Column({ nullable: true })
80
- @Field({ nullable: true })
81
- brand: string
82
-
83
- @Column({ nullable: true })
84
- @Field({ nullable: true })
85
- subBrand: string
86
-
87
- // 입고 단위
88
- @Column({ nullable: true })
89
- @Field({ nullable: true })
90
- inboundUnit?: string
91
-
92
- // 변환 kg
93
- @Column('float', { nullable: true, default: 1, transformer: roundTransformer })
94
- @Field({ nullable: true })
95
- convertWeight?: number
96
-
97
- // 박스입수
98
- @Column('float', { nullable: true, default: 0, transformer: roundTransformer })
99
- @Field({ nullable: true })
100
- boxInQty?: number
101
-
102
- // 제품군
103
- @Column({ nullable: true })
104
- @Field({ nullable: true })
105
- category?: string
106
-
107
- // 경매입고
108
- @Column({ nullable: true, default: false })
109
- @Field({ nullable: true })
110
- isAuction?: boolean
111
-
112
- //// To be removed ////
113
- @Column({ nullable: true })
114
- @Field({ nullable: true })
115
- gtin: string
116
-
117
- //// To be removed ////
118
- @Column({ nullable: true })
119
- @Field({ nullable: true })
120
- caseGtin: string
121
-
122
- @Column({ nullable: true })
123
- @Field({ nullable: true })
124
- name: string
125
-
126
- @Column()
127
- @Field()
128
- type: string
129
-
130
- //// To be removed ////
131
- @Column({ nullable: true })
132
- @Field({ nullable: true })
133
- packingType: string
134
-
135
- @Column({ nullable: true })
136
- @Field({ nullable: true })
137
- description: string
138
-
139
- @OneToMany(type => ProductDetail, productDetails => productDetails.product, { nullable: true })
140
- @Field(type => [ProductDetail], { nullable: true })
141
- productDetails: ProductDetail[]
142
-
143
- @ManyToOne(type => Product, { nullable: true })
144
- @Field({ nullable: true })
145
- productRef: Product
146
-
147
- //// To be removed ////
148
- @ManyToOne(type => Product, { nullable: true })
149
- @Field({ nullable: true })
150
- parentProductRef: Product
151
-
152
- //// To be removed ////
153
- @OneToMany(type => Product, product => product.parentProductRef, { nullable: true })
154
- @Field(type => [Product], { nullable: true })
155
- childProducts: Product[]
156
-
157
- //// To be removed ////
158
- @Column('float', { nullable: true, transformer: roundTransformer })
159
- @Field({ nullable: true })
160
- bundleQty: number
161
-
162
- //// To be removed ////
163
- @Column({ nullable: true })
164
- @Field({ nullable: true })
165
- expirationPeriod: number
166
-
167
- //// To be removed ////
168
- @Column({ nullable: true })
169
- @Field({ nullable: true })
170
- weightUnit: string
171
-
172
- //// To be removed ////
173
- @Column('float', { nullable: true, transformer: roundTransformer })
174
- @Field({ nullable: true })
175
- weight: number
176
-
177
- //// To be removed ////
178
- @Column('float', { nullable: true, transformer: roundTransformer })
179
- @Field({ nullable: true })
180
- grossWeight: number
181
-
182
- //// To be removed ////
183
- @Column('float', { nullable: true, transformer: roundTransformer })
184
- @Field({ nullable: true })
185
- caseWeight: number
186
-
187
- //// To be removed ////
188
- @Column('float', { nullable: true, transformer: roundTransformer })
189
- @Field({ nullable: true })
190
- caseGrossWeight: number
191
-
192
- //// To be removed ////
193
- @Column('float', { nullable: true, transformer: roundTransformer })
194
- @Field({ nullable: true })
195
- density: number
196
-
197
- //// To be removed ////
198
- @Column({ nullable: true })
199
- @Field({ nullable: true })
200
- lengthUnit: string
201
-
202
- //// To be removed ////
203
- @Column('float', { nullable: true, transformer: roundTransformer })
204
- @Field({ nullable: true })
205
- costPrice: number
206
-
207
- //// To be removed ////
208
- @Column('float', { nullable: true, transformer: roundTransformer })
209
- @Field({ nullable: true })
210
- mrpPrice: number
211
-
212
- //// To be removed ////
213
- @Column('float', { nullable: true, transformer: roundTransformer })
214
- @Field({ nullable: true })
215
- sellPrice: number
216
-
217
- //// To be removed ////
218
- @Column('float', { nullable: true, transformer: roundTransformer })
219
- @Field({ nullable: true })
220
- afterTaxCostPrice: number
221
-
222
- //// To be removed ////
223
- @Column('float', { nullable: true, transformer: roundTransformer })
224
- @Field({ nullable: true })
225
- afterTaxSalesPrice: number
226
-
227
- //// To be removed ////
228
- @Column('float', { nullable: true, transformer: roundTransformer })
229
- @Field({ nullable: true })
230
- width: number
231
-
232
- //// To be removed ////
233
- @Column('float', { nullable: true, transformer: roundTransformer })
234
- @Field({ nullable: true })
235
- depth: number
236
-
237
- //// To be removed ////
238
- @Column('float', { nullable: true, transformer: roundTransformer })
239
- @Field({ nullable: true })
240
- height: number
241
-
242
- //// To be removed ////
243
- @Column('float', { nullable: true, transformer: roundTransformer })
244
- @Field({ nullable: true })
245
- volume: number
246
-
247
- //// To be removed ////
248
- @Column('float', { nullable: true, transformer: roundTransformer })
249
- @Field({ nullable: true })
250
- caseWidth: number
251
-
252
- //// To be removed ////
253
- @Column('float', { nullable: true, transformer: roundTransformer })
254
- @Field({ nullable: true })
255
- caseDepth: number
256
-
257
- //// To be removed ////
258
- @Column('float', { nullable: true, transformer: roundTransformer })
259
- @Field({ nullable: true })
260
- caseHeight: number
261
-
262
- //// To be removed ////
263
- @Column('float', { nullable: true, transformer: roundTransformer })
264
- @Field({ nullable: true })
265
- caseVolume: number
266
-
267
- //// To be removed ////
268
- @Column({ nullable: true })
269
- @Field({ nullable: true })
270
- volumeSize: string
271
-
272
- //// To be removed ////
273
- @Column({ nullable: true })
274
- @Field({ nullable: true })
275
- primaryUnit: string
276
-
277
- //// To be removed ////
278
- @Column('float', { nullable: true, transformer: roundTransformer })
279
- @Field({ nullable: true })
280
- primaryValue: number
281
-
282
- //// To be removed ////
283
- @Column({ nullable: true })
284
- @Field({ nullable: true })
285
- auxUnit1: string
286
-
287
- //// To be removed ////
288
- @Column({ nullable: true })
289
- @Field({ nullable: true })
290
- auxValue1: string
291
-
292
- //// To be removed ////
293
- @Column({ nullable: true })
294
- @Field({ nullable: true })
295
- auxUnit2: string
296
-
297
- //// To be removed ////
298
- @Column({ nullable: true })
299
- @Field({ nullable: true })
300
- auxValue2: string
301
-
302
- //// To be removed ////
303
- @Column({ nullable: true })
304
- @Field({ nullable: true })
305
- auxUnit3: string
306
-
307
- //// To be removed ////
308
- @Column({ nullable: true })
309
- @Field({ nullable: true })
310
- auxValue3: string
311
-
312
- //// To be removed ////
313
- @Column({ nullable: true })
314
- @Field({ nullable: true })
315
- inventoryAccountCode: string
316
-
317
- //// To be removed ////
318
- @Column({ nullable: true })
319
- @Field({ nullable: true })
320
- cogsAccountCode: string
321
-
322
- //// To be removed ////
323
- @ManyToOne(type => ProductSet, productSet => productSet.product, { nullable: true })
324
- @Field({ nullable: true })
325
- productSet: ProductSet
326
-
327
- //// To be removed ////
328
- @Column({ nullable: true })
329
- @Field({ nullable: true })
330
- movement: string
331
-
332
- //// To be removed ////
333
- @Column({ nullable: true })
334
- @Field({ nullable: true })
335
- bufferQty: number
336
-
337
- //// To be removed ////
338
- @Column('float', { nullable: true, transformer: roundTransformer })
339
- @Field({ nullable: true })
340
- minQty: number
341
-
342
- //// To be removed ////
343
- @Column('float', { nullable: true, transformer: roundTransformer })
344
- @Field({ nullable: true })
345
- maxQty: number
346
-
347
- //// To be removed ////
348
- @Column({ nullable: true })
349
- @Field({ nullable: true })
350
- discountId: number
351
-
352
- //// To be removed ////
353
- @Column({ nullable: true })
354
- @Field({ nullable: true })
355
- status: string
356
-
357
- //// To be removed ////
358
- @Column({ nullable: true })
359
- @Field({ nullable: true })
360
- isTrackedAsInventory: boolean
361
-
362
- @Column({ default: false })
363
- @Field({ nullable: true })
364
- isRequiredCheckExpiry: boolean
365
-
366
- @Column({ default: false })
367
- @Field({ nullable: true })
368
- isRequireSerialNumberScanning: boolean
369
-
370
- @Column({ default: false })
371
- @Field({ nullable: true })
372
- isRequireSerialNumberScanningInbound: boolean
373
-
374
- @Column({ default: false })
375
- @Field({ nullable: true })
376
- isRequireSerialNumberScanningOutbound: boolean
377
-
378
- @Column({ nullable: true })
379
- @Field({ nullable: true })
380
- deletedAt: Date
381
-
382
- @Column({
383
- nullable: false,
384
- type:
385
- DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
386
- ? 'enum'
387
- : DATABASE_TYPE == 'oracle'
388
- ? 'varchar2'
389
- : DATABASE_TYPE == 'mssql'
390
- ? 'nvarchar'
391
- : 'varchar',
392
- enum:
393
- DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? pickStrategy : undefined,
394
- length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,
395
- default: pickStrategy.FIFO
396
- })
397
- @Field()
398
- pickingStrategy: pickStrategy
399
-
400
- @Column({ nullable: true })
401
- @Field({ nullable: true })
402
- releaseType?: string
403
-
404
- @Field({ nullable: true })
405
- refCode: string
406
-
407
- @Field(type => Float, { nullable: true })
408
- nettWeight: number
409
-
410
- @Field({ nullable: true })
411
- uom: string
412
-
413
- @Field(type => Float, { nullable: true })
414
- uomValue: number
415
-
416
- @Field({ nullable: true })
417
- auxUnit4: string
418
-
419
- @Field({ nullable: true })
420
- auxValue4: string
421
-
422
- @Field({ nullable: true })
423
- auxUnit5: string
424
-
425
- @Field({ nullable: true })
426
- auxValue5: string
427
-
428
- @ManyToOne(type => User, { nullable: true })
429
- @Field({ nullable: true })
430
- creator: User
431
-
432
- @RelationId((product: Product) => product.creator)
433
- creatorId: string
434
-
435
- @ManyToOne(type => User, { nullable: true })
436
- @Field({ nullable: true })
437
- updater: User
438
-
439
- @RelationId((product: Product) => product.updater)
440
- updaterId: string
441
-
442
- @CreateDateColumn()
443
- @Field({ nullable: true })
444
- createdAt: Date
445
-
446
- @UpdateDateColumn()
447
- @Field({ nullable: true })
448
- updatedAt: Date
449
-
450
- @ManyToOne(type => Routing, { nullable: true })
451
- @Field({ nullable: true })
452
- routing?: Routing
453
-
454
- @RelationId((product: Product) => product.routing)
455
- routingId?: string
456
-
457
- @Column({ nullable: true })
458
- @Field(type => String, { nullable: true })
459
- warehouseName?: string
460
-
461
- @Field(type => String, { nullable: true })
462
- thumbnail?: string
463
-
464
- @Field({ nullable: true })
465
- productInformation: string
466
-
467
- @Field({ nullable: true })
468
- batchNo?: string
469
-
470
- @Field({ nullable: true })
471
- loadedQty: number
472
-
473
- constructor(obj?) {
474
- if (obj) {
475
- this.id = obj.product_id
476
- this.sku = obj.product_sku
477
- this.name = obj.product_name
478
- this.description = obj.product_description
479
- this.bundleQty = obj.product_bundle_qty
480
- this.type = obj.product_type
481
- this.packingType = obj.product_packing_type
482
- this.expirationPeriod = obj.product_expiration_period
483
- this.weightUnit = obj.product_weight_unit
484
- this.weight = obj.product_weight
485
- this.density = obj.product_density
486
- this.lengthUnit = obj.product_length_unit
487
- this.costPrice = obj.product_cost_price
488
- this.sellPrice = obj.product_sell_price
489
- this.width = obj.product_width
490
- this.depth = obj.product_depth
491
- this.height = obj.product_height
492
- this.primaryUnit = obj.product_primary_unit
493
- this.primaryValue = obj.product_primary_value
494
- this.auxUnit1 = obj.product_aux_unit_1
495
- this.auxValue1 = obj.product_aux_value_1
496
- this.auxUnit2 = obj.product_aux_unit_2
497
- this.auxValue2 = obj.product_aux_value_2
498
- this.auxUnit3 = obj.product_aux_unit_3
499
- this.auxValue3 = obj.product_aux_value_3
500
- this.createdAt = obj.product_created_at
501
- this.updatedAt = obj.product_updated_at
502
- this.movement = obj.product_movement
503
- this.inventoryAccountCode = obj.product_inventory_account_code
504
- this.cogsAccountCode = obj.product_cogs_account_code
505
- this.isTrackedAsInventory = obj.product_is_tracked_as_inventory
506
- this.mrpPrice = obj.product_mrp_price
507
- this.afterTaxCostPrice = obj.product_after_tax_cost_price
508
- this.afterTaxSalesPrice = obj.product_after_tax_sales_price
509
- this.bufferQty = obj.product_buffer_qty
510
- this.discountId = obj.product_discount_id
511
- this.status = obj.product_status
512
- this.brandSku = obj.product_brand_sku
513
- this.brand = obj.product_brand
514
- this.subBrand = obj.product_sub_brand
515
- this.gtin = obj.product_gtin
516
- this.caseGtin = obj.product_case_gtin
517
- this.grossWeight = obj.product_gross_weight
518
- this.caseWeight = obj.product_case_weight
519
- this.caseGrossWeight = obj.product_case_gross_weight
520
- this.volume = obj.product_volume
521
- this.caseWidth = obj.product_case_width
522
- this.caseDepth = obj.product_case_depth
523
- this.caseHeight = obj.product_case_height
524
- this.caseVolume = obj.product_case_volume
525
- this.volumeSize = obj.product_volume_size
526
- this.minQty = obj.product_min_qty
527
- this.maxQty = obj.product_max_qty
528
- this.isCompany = obj.product_is_company
529
- this.deletedAt = obj.product_deleted_at
530
- this.isRequiredCheckExpiry = obj.product_is_required_check_expiry
531
- this.isRequireSerialNumberScanning = obj.product_is_require_serial_number_scanning
532
- this.isRequireSerialNumberScanningInbound = obj.product_is_require_serial_number_scanning_inbound
533
- this.isRequireSerialNumberScanningOutbound = obj.product_is_require_serial_number_scanning_outbound
534
- this.bizplace = { id: obj.product_bizplace_id } as any
535
- this.domain = { id: obj.product_domain_id } as any
536
- this.inboundUnit = obj.product_inbound_unit
537
- this.convertWeight = obj.product_convert_weight
538
- this.category = obj.product_category
539
- this.boxInQty = obj.product_box_in_qty
540
- this.isAuction = obj.product_is_auction
541
- }
542
- }
543
- }
@@ -1,42 +0,0 @@
1
- import _ from 'lodash'
2
- import { EntityManager, IsNull, Not } from 'typeorm'
3
-
4
- import { User } from '@things-factory/auth-base'
5
- import { Domain } from '@things-factory/shell'
6
-
7
- import { Product } from './product'
8
-
9
- export async function validateProduct(product: Product, context: ResolverContext) {
10
- const { tx } = context.state
11
-
12
- let errors = []
13
-
14
- if (_.isEmpty(product.sku) || '') {
15
- errors.push('Product SKU is required')
16
- }
17
- if (_.isEmpty(product.name) || '') {
18
- errors.push('Product name is required')
19
- }
20
- if (_.isEmpty(product.type) || '') {
21
- errors.push('Product type is required')
22
- }
23
-
24
- if (
25
- (await tx.getRepository(Product).count({
26
- where: {
27
- sku: product.sku,
28
- bizplace: { id: product.bizplace.id },
29
- domain: { id: product.domain.id },
30
- id: product?.id == null ? Not(IsNull()) : Not(product.id)
31
- }
32
- })) > 0
33
- ) {
34
- errors.push('Duplicated SKU found.')
35
- }
36
-
37
- if (errors.length > 0) {
38
- throw new Error(errors.join(', '))
39
- }
40
-
41
- return true
42
- }
@@ -1,6 +0,0 @@
1
- import { ProductBundle } from './product-bundle'
2
- import { ProductBundleMutation } from './product-bundle-mutation'
3
- import { ProductBundleQuery } from './product-bundle-query'
4
-
5
- export const entities = [ProductBundle]
6
- export const resolvers = [ProductBundleQuery, ProductBundleMutation]