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

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.18",
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.18",
30
+ "@things-factory/code-base": "^7.0.0-alpha.18",
31
+ "@things-factory/integration-sftp": "^7.0.0-alpha.18",
32
+ "@things-factory/notification": "^7.0.0-alpha.18",
33
+ "@things-factory/product-base": "^7.0.0-alpha.18",
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.18",
37
+ "@things-factory/warehouse-base": "^7.0.0-alpha.18"
38
38
  },
39
- "gitHead": "f8d2a44c3443fc11462533da838503f25e74672b"
39
+ "gitHead": "f695ce9c0e3a8f2d715d27a2e7674c9b9c6b1ee1"
40
40
  }
@@ -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 = {