@things-factory/sales-base 7.0.0-alpha.16 → 7.0.0-alpha.19

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/sales-base",
3
- "version": "7.0.0-alpha.16",
3
+ "version": "7.0.0-alpha.19",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,17 +24,17 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
25
  },
26
26
  "dependencies": {
27
- "@things-factory/attachment-base": "^7.0.0-alpha.9",
28
- "@things-factory/auth-base": "^7.0.0-alpha.9",
29
- "@things-factory/biz-base": "^7.0.0-alpha.9",
30
- "@things-factory/code-base": "^7.0.0-alpha.9",
31
- "@things-factory/integration-sftp": "^7.0.0-alpha.16",
32
- "@things-factory/notification": "^7.0.0-alpha.9",
33
- "@things-factory/product-base": "^7.0.0-alpha.9",
34
- "@things-factory/setting-base": "^7.0.0-alpha.9",
35
- "@things-factory/shell": "^7.0.0-alpha.9",
36
- "@things-factory/transport-base": "^7.0.0-alpha.9",
37
- "@things-factory/warehouse-base": "^7.0.0-alpha.16"
27
+ "@things-factory/attachment-base": "^7.0.0-alpha.18",
28
+ "@things-factory/auth-base": "^7.0.0-alpha.18",
29
+ "@things-factory/biz-base": "^7.0.0-alpha.19",
30
+ "@things-factory/code-base": "^7.0.0-alpha.18",
31
+ "@things-factory/integration-sftp": "^7.0.0-alpha.19",
32
+ "@things-factory/notification": "^7.0.0-alpha.18",
33
+ "@things-factory/product-base": "^7.0.0-alpha.19",
34
+ "@things-factory/setting-base": "^7.0.0-alpha.18",
35
+ "@things-factory/shell": "^7.0.0-alpha.18",
36
+ "@things-factory/transport-base": "^7.0.0-alpha.19",
37
+ "@things-factory/warehouse-base": "^7.0.0-alpha.19"
38
38
  },
39
- "gitHead": "f8d2a44c3443fc11462533da838503f25e74672b"
39
+ "gitHead": "3a85ee4b15d4f0e79073840537febc3c044ef8cf"
40
40
  }
@@ -80,7 +80,7 @@ export class NewOrderInventory {
80
80
  @Field({ nullable: true })
81
81
  uom: string
82
82
 
83
- @Field(type => Int, { nullable: true })
83
+ @Field(type => Float, { nullable: true })
84
84
  palletQty: number
85
85
 
86
86
  @Field({ nullable: true })
@@ -1,29 +1,11 @@
1
- import {
2
- Field,
3
- Float,
4
- ID,
5
- ObjectType
6
- } from 'type-graphql'
7
- import {
8
- Column,
9
- CreateDateColumn,
10
- Entity,
11
- Index,
12
- ManyToOne,
13
- OneToMany,
14
- PrimaryGeneratedColumn,
15
- RelationId,
16
- UpdateDateColumn
17
- } from 'typeorm'
1
+ import { Field, Float, ID, ObjectType } from 'type-graphql'
2
+ import { Column, CreateDateColumn, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'
18
3
 
19
4
  import { User } from '@things-factory/auth-base'
20
5
  import { Bizplace } from '@things-factory/biz-base'
21
6
  import { Product } from '@things-factory/product-base'
22
7
  import { Domain } from '@things-factory/shell'
23
- import {
24
- Inventory,
25
- Location
26
- } from '@things-factory/warehouse-base'
8
+ import { Inventory, Location } from '@things-factory/warehouse-base'
27
9
 
28
10
  import { ArrivalNotice } from '../arrival-notice/arrival-notice'
29
11
  import { DeliveryOrder } from '../delivery-order/delivery-order'
@@ -290,7 +272,7 @@ export class OrderInventory {
290
272
  @Field({ nullable: true })
291
273
  actualPackQty: number
292
274
 
293
- @Column({ nullable: true })
275
+ @Column('float', { nullable: true })
294
276
  @Field({ nullable: true })
295
277
  palletQty: number
296
278
 
@@ -1,15 +1,6 @@
1
- import {
2
- Field,
3
- Float,
4
- InputType,
5
- Int,
6
- ObjectType
7
- } from 'type-graphql'
8
-
9
- import {
10
- ObjectRef,
11
- ScalarDate
12
- } from '@things-factory/shell'
1
+ import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
2
+
3
+ import { ObjectRef, ScalarDate } from '@things-factory/shell'
13
4
 
14
5
  import { OrderProduct } from './order-product'
15
6
 
@@ -144,13 +135,13 @@ export class OrderProductPatch {
144
135
  @Field(type => Float, { nullable: true })
145
136
  unpackQty: number
146
137
 
147
- @Field(type => Int, { nullable: true })
138
+ @Field(type => Float, { nullable: true })
148
139
  palletQty: number
149
140
 
150
- @Field(type => Int, { nullable: true })
141
+ @Field(type => Float, { nullable: true })
151
142
  actualPalletQty: number
152
143
 
153
- @Field(type => Int, { nullable: true })
144
+ @Field(type => Float, { nullable: true })
154
145
  adjustedPalletQty: number
155
146
 
156
147
  @Field({ nullable: true })
@@ -288,13 +279,13 @@ export class NewOrderProduct {
288
279
  @Field(type => Float, { nullable: true })
289
280
  unpackQty: number
290
281
 
291
- @Field(type => Int, { nullable: true })
282
+ @Field(type => Float, { nullable: true })
292
283
  palletQty: number
293
284
 
294
- @Field(type => Int, { nullable: true })
285
+ @Field(type => Float, { nullable: true })
295
286
  actualPalletQty: number
296
287
 
297
- @Field(type => Int, { nullable: true })
288
+ @Field(type => Float, { nullable: true })
298
289
  adjustedPalletQty: number
299
290
 
300
291
  @Field({ nullable: true })
@@ -1,30 +1,20 @@
1
- import { Field, ID, ObjectType, Float } from 'type-graphql'
2
- import {
3
- Column,
4
- CreateDateColumn,
5
- Entity,
6
- Index,
7
- ManyToOne,
8
- PrimaryGeneratedColumn,
9
- RelationId,
10
- UpdateDateColumn,
11
- OneToMany
12
- } from 'typeorm'
1
+ import { Field, Float, ID, ObjectType } from 'type-graphql'
2
+ import { Column, CreateDateColumn, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'
13
3
 
14
4
  import { User } from '@things-factory/auth-base'
15
5
  import { Bizplace } from '@things-factory/biz-base'
16
- import { Product, ProductDetail, ProductBundle } from '@things-factory/product-base'
6
+ import { Product, ProductBundle, ProductDetail } from '@things-factory/product-base'
17
7
  import { Domain, ScalarDate } from '@things-factory/shell'
18
8
  import { Inventory } from '@things-factory/warehouse-base'
19
9
 
20
10
  import { ArrivalNotice } from '../arrival-notice/arrival-notice'
21
11
  import { CollectionOrder } from '../collection-order/collection-order'
22
12
  import { DeliveryOrder } from '../delivery-order/delivery-order'
13
+ import { DraftReleaseGood } from '../draft-release-good/draft-release-good'
14
+ import { OrderInventory } from '../order-inventory/order-inventory'
23
15
  import { PurchaseOrder } from '../purchase-order/purchase-order'
24
16
  import { ReleaseGood } from '../release-good/release-good'
25
- import { DraftReleaseGood } from '../draft-release-good/draft-release-good'
26
17
  import { RetailReplenishmentOrder } from '../retail-replenishment-order/retail-replenishment-order'
27
- import { OrderInventory } from '../order-inventory/order-inventory'
28
18
 
29
19
  @Entity()
30
20
  @Index('ix_order-product_0', (orderProduct: OrderProduct) => [orderProduct.domain, orderProduct.name], {
@@ -285,15 +275,15 @@ export class OrderProduct {
285
275
  @Field({ nullable: true })
286
276
  miscAmt: number
287
277
 
288
- @Column({ nullable: true })
278
+ @Column('float', { nullable: true })
289
279
  @Field({ nullable: true })
290
280
  palletQty: number
291
281
 
292
- @Column({ nullable: true })
282
+ @Column('float', { nullable: true })
293
283
  @Field({ nullable: true })
294
284
  adjustedPalletQty: number
295
285
 
296
- @Column({ nullable: true })
286
+ @Column('float', { nullable: true })
297
287
  @Field({ nullable: true })
298
288
  actualPalletQty: number
299
289
 
@@ -8,14 +8,7 @@ import { Product, ProductDetail } from '@things-factory/product-base'
8
8
  import { PartnerSetting, Setting } from '@things-factory/setting-base'
9
9
  import { Domain, ListParam } from '@things-factory/shell'
10
10
 
11
- import {
12
- InventoryProductGroup,
13
- InventoryProductGroupList,
14
- NewOrderInventory,
15
- NewOrderProduct,
16
- OrderInventory,
17
- OrderProduct
18
- } from '../'
11
+ import { InventoryProductGroup, InventoryProductGroupList, NewOrderInventory, NewOrderProduct, OrderInventory, OrderProduct } from '../'
19
12
  import { InventoryUtil } from '../../utils'
20
13
 
21
14
  @Resolver()
@@ -23,12 +16,8 @@ export class OtherQuery {
23
16
  @Directive('@privilege(category: "inventory", privilege: "query", domainOwnerGranted: true)')
24
17
  @Directive('@transaction')
25
18
  @Query(returns => InventoryProductGroupList)
26
- async allBizplaceProductInventory(
27
- @Ctx() context: ResolverContext,
28
- @Args() params: ListParam
29
- ): Promise<InventoryProductGroupList> {
30
- const { domain, user, tx, bizplace }: { domain: Domain; user: User; tx: EntityManager; bizplace?: Bizplace } =
31
- context.state
19
+ async allBizplaceProductInventory(@Ctx() context: ResolverContext, @Args() params: ListParam): Promise<InventoryProductGroupList> {
20
+ const { domain, user, tx, bizplace } = context.state
32
21
 
33
22
  let permittedBizplaces: Bizplace[] = await getPermittedBizplaces(domain, user)
34
23
 
@@ -62,12 +51,8 @@ export class OtherQuery {
62
51
  @Directive('@privilege(category: "inventory", privilege: "query", domainOwnerGranted: true)')
63
52
  @Directive('@transaction')
64
53
  @Query(returns => InventoryProductGroupList)
65
- async inventoryProductGroup(
66
- @Ctx() context: ResolverContext,
67
- @Args() params: ListParam
68
- ): Promise<InventoryProductGroupList> {
69
- const { domain, user, tx, bizplace }: { domain: Domain; user: User; tx: EntityManager; bizplace?: Bizplace } =
70
- context.state
54
+ async inventoryProductGroup(@Ctx() context: ResolverContext, @Args() params: ListParam): Promise<InventoryProductGroupList> {
55
+ const { domain, user, tx, bizplace } = context.state
71
56
 
72
57
  let permittedBizplaces: Bizplace[] = await getPermittedBizplaces(domain, user)
73
58
 
@@ -100,12 +85,8 @@ export class OtherQuery {
100
85
 
101
86
  @Directive('@transaction')
102
87
  @Query(returns => InventoryProductGroupList)
103
- async inventoryProductGroupOpenAPI(
104
- @Ctx() context: ResolverContext,
105
- @Args() params: ListParam
106
- ): Promise<InventoryProductGroupList> {
107
- const { domain, user, tx, bizplace }: { domain: Domain; user: User; tx: EntityManager; bizplace?: Bizplace } =
108
- context.state
88
+ async inventoryProductGroupOpenAPI(@Ctx() context: ResolverContext, @Args() params: ListParam): Promise<InventoryProductGroupList> {
89
+ const { domain, user, tx, bizplace } = context.state
109
90
 
110
91
  let permittedBizplaces: Bizplace[] = await getPermittedBizplaces(domain, user)
111
92
 
@@ -144,8 +125,7 @@ export class OtherQuery {
144
125
  @Arg('partnerBizplaceId') partnerBizplaceId: string,
145
126
  @Arg('orderInventories', type => [NewOrderInventory], { nullable: true }) orderInventories?: NewOrderInventory[]
146
127
  ): Promise<OrderInventory[]> {
147
- const { domain, user, tx, bizplace }: { domain: Domain; user: User; tx: EntityManager; bizplace?: Bizplace } =
148
- context.state
128
+ const { domain, user, tx, bizplace } = context.state
149
129
 
150
130
  let permittedBizplaces: Bizplace[] = await getPermittedBizplaces(domain, user)
151
131
  let foundPermittedBizplace: Bizplace
@@ -239,11 +219,7 @@ export class OtherQuery {
239
219
  batchIdRef: availableItem ? availableItem.batchIdRef : null,
240
220
  packingType: availableItem ? availableItem.packingType : orderInventory.packingType,
241
221
  packingSize: availableItem ? availableItem.packingSize : 1,
242
- releaseQty: orderInventory.releaseQty
243
- ? Number.isInteger(orderInventory.releaseQty)
244
- ? orderInventory.releaseQty
245
- : null
246
- : null,
222
+ releaseQty: orderInventory.releaseQty ? (Number.isInteger(orderInventory.releaseQty) ? orderInventory.releaseQty : null) : null,
247
223
  releaseUomValue: availableItem
248
224
  ? Number.isInteger(orderInventory.releaseQty)
249
225
  ? parseFloat((orderInventory.releaseQty * packageUomValue).toFixed(2))
@@ -259,31 +235,18 @@ export class OtherQuery {
259
235
  }
260
236
 
261
237
  try {
262
- await InventoryUtil.validateWarehousePartnersProductsQuantity(
263
- domain,
264
- partnerBizplace,
265
- newOrderInventories,
266
- context,
267
- tx
268
- )
238
+ await InventoryUtil.validateWarehousePartnersProductsQuantity(domain, partnerBizplace, newOrderInventories, context, tx)
269
239
  } catch (e) {
270
240
  const errorData = JSON.parse(e.detail.data)
271
241
 
272
242
  errorData.forEach(dt => {
273
- let idx = newOrderInventories.findIndex(
274
- x =>
275
- x.product?.id && x.product.id == dt.productId && x.batchId == dt.batchId && x.packingType == dt.packingType
276
- )
243
+ let idx = newOrderInventories.findIndex(x => x.product?.id && x.product.id == dt.productId && x.batchId == dt.batchId && x.packingType == dt.packingType)
277
244
 
278
245
  if (idx >= 0) {
279
246
  newOrderInventories[idx].remainQty = dt.availableQty
280
247
  newOrderInventories[idx].remainUomValue = dt.availableUomValue
281
- newOrderInventories[idx].isError =
282
- dt.availableQty == null
283
- ? newOrderInventories[idx].releaseQty > 0
284
- : newOrderInventories[idx].releaseQty > dt.availableQty
285
- newOrderInventories[idx].remainUomValueWithUom =
286
- dt.availableUomValue == null ? '' : `${dt.availableUomValue} ${dt.uom}`
248
+ newOrderInventories[idx].isError = dt.availableQty == null ? newOrderInventories[idx].releaseQty > 0 : newOrderInventories[idx].releaseQty > dt.availableQty
249
+ newOrderInventories[idx].remainUomValueWithUom = dt.availableUomValue == null ? '' : `${dt.availableUomValue} ${dt.uom}`
287
250
  if (newOrderInventories[idx].inventory != null) {
288
251
  newOrderInventories[idx].inventory.remainQty = dt.availableQty
289
252
  newOrderInventories[idx].inventory.remainUomValue = dt.availableUomValue
@@ -304,8 +267,7 @@ export class OtherQuery {
304
267
  @Arg('partnerBizplaceId') partnerBizplaceId: string,
305
268
  @Arg('orderProducts', type => [NewOrderProduct], { nullable: true }) orderProducts: NewOrderProduct[]
306
269
  ): Promise<OrderProduct[]> {
307
- const { domain, user, tx, bizplace }: { domain: Domain; user: User; tx: EntityManager; bizplace?: Bizplace } =
308
- context.state
270
+ const { domain, user, tx, bizplace } = context.state
309
271
 
310
272
  const productDetailRepo = tx.getRepository(ProductDetail)
311
273
 
@@ -366,14 +328,12 @@ export class OtherQuery {
366
328
  if (foundProduct) {
367
329
  let productDetail: ProductDetail
368
330
  const hasConditions: boolean = Boolean(
369
- (orderProduct?.packingType && orderProduct?.packingType.trim() != '') ||
370
- (orderProduct?.uom && orderProduct?.uom.trim() != '')
331
+ (orderProduct?.packingType && orderProduct?.packingType.trim() != '') || (orderProduct?.uom && orderProduct?.uom.trim() != '')
371
332
  )
372
333
  let productDetailCondition: any = { product: foundProduct }
373
334
 
374
335
  if (hasConditions) {
375
- if (orderProduct?.packingType && orderProduct.packingType.trim() != '')
376
- productDetailCondition.packingType = orderProduct.packingType.trim()
336
+ if (orderProduct?.packingType && orderProduct.packingType.trim() != '') productDetailCondition.packingType = orderProduct.packingType.trim()
377
337
 
378
338
  if (orderProduct?.uom && orderProduct.uom.trim() != '') productDetailCondition.uom = orderProduct.uom.trim()
379
339
  } else {
@@ -385,13 +345,7 @@ export class OtherQuery {
385
345
  })
386
346
 
387
347
  const uomValue: number =
388
- strictProduct == true
389
- ? productDetail?.uomValue
390
- ? productDetail.uomValue
391
- : null
392
- : orderProduct?.uomValue
393
- ? orderProduct.uomValue
394
- : productDetail.uomValue
348
+ strictProduct == true ? (productDetail?.uomValue ? productDetail.uomValue : null) : orderProduct?.uomValue ? orderProduct.uomValue : productDetail.uomValue
395
349
 
396
350
  newOrderProduct = {
397
351
  ...orderProduct,
@@ -411,12 +365,7 @@ export class OtherQuery {
411
365
  primaryUnit: productDetail?.uom ? productDetail.uom : null,
412
366
  primaryValue: productDetail?.uomValue ? productDetail.uomValue : null
413
367
  },
414
- totalUomValue:
415
- orderProduct.packQty > 0
416
- ? uomValue
417
- ? `${(orderProduct.packQty * uomValue).toFixed(2)} ${productDetail.uom}`
418
- : null
419
- : null
368
+ totalUomValue: orderProduct.packQty > 0 ? (uomValue ? `${(orderProduct.packQty * uomValue).toFixed(2)} ${productDetail.uom}` : null) : null
420
369
  }
421
370
  } else {
422
371
  newOrderProduct = {
@@ -439,8 +388,7 @@ export class OtherQuery {
439
388
  @Arg('partnerBizplaceId') partnerBizplaceId: string,
440
389
  @Arg('orderProducts', type => [NewOrderProduct], { nullable: true }) orderProducts: NewOrderProduct[]
441
390
  ): Promise<OrderProduct[]> {
442
- const { domain, user, tx, bizplace }: { domain: Domain; user: User; tx: EntityManager; bizplace?: Bizplace } =
443
- context.state
391
+ const { domain, user, tx, bizplace } = context.state
444
392
 
445
393
  const productDetailRepo = tx.getRepository(ProductDetail)
446
394
 
@@ -501,14 +449,12 @@ export class OtherQuery {
501
449
  if (foundProduct) {
502
450
  let productDetail: ProductDetail
503
451
  const hasConditions: boolean = Boolean(
504
- (orderProduct?.packingType && orderProduct?.packingType.trim() != '') ||
505
- (orderProduct?.uom && orderProduct?.uom.trim() != '')
452
+ (orderProduct?.packingType && orderProduct?.packingType.trim() != '') || (orderProduct?.uom && orderProduct?.uom.trim() != '')
506
453
  )
507
454
  let productDetailCondition: any = { product: foundProduct }
508
455
 
509
456
  if (hasConditions) {
510
- if (orderProduct?.packingType && orderProduct.packingType.trim() != '')
511
- productDetailCondition.packingType = orderProduct.packingType.trim()
457
+ if (orderProduct?.packingType && orderProduct.packingType.trim() != '') productDetailCondition.packingType = orderProduct.packingType.trim()
512
458
 
513
459
  if (orderProduct?.uom && orderProduct.uom.trim() != '') productDetailCondition.uom = orderProduct.uom.trim()
514
460
  } else {
@@ -520,13 +466,7 @@ export class OtherQuery {
520
466
  })
521
467
 
522
468
  const uomValue: number =
523
- strictProduct == true
524
- ? productDetail?.uomValue
525
- ? productDetail.uomValue
526
- : null
527
- : orderProduct?.uomValue
528
- ? orderProduct.uomValue
529
- : productDetail.uomValue
469
+ strictProduct == true ? (productDetail?.uomValue ? productDetail.uomValue : null) : orderProduct?.uomValue ? orderProduct.uomValue : productDetail.uomValue
530
470
 
531
471
  newOrderProduct = {
532
472
  ...orderProduct,
@@ -546,12 +486,7 @@ export class OtherQuery {
546
486
  primaryUnit: productDetail?.uom ? productDetail.uom : null,
547
487
  primaryValue: productDetail?.uomValue ? productDetail.uomValue : null
548
488
  },
549
- totalUomValue:
550
- orderProduct.packQty > 0
551
- ? uomValue
552
- ? `${(orderProduct.packQty * uomValue).toFixed(2)} ${productDetail.uom}`
553
- : null
554
- : null
489
+ totalUomValue: orderProduct.packQty > 0 ? (uomValue ? `${(orderProduct.packQty * uomValue).toFixed(2)} ${productDetail.uom}` : null) : null
555
490
  }
556
491
  } else {
557
492
  newOrderProduct = {