@things-factory/marketplace-base 4.0.22 → 4.0.26

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 (28) hide show
  1. package/dist-server/entities/marketplace-product-variation.js +6 -1
  2. package/dist-server/entities/marketplace-product-variation.js.map +1 -1
  3. package/dist-server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.js +97 -5
  4. package/dist-server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.js.map +1 -1
  5. package/dist-server/graphql/resolvers/marketplace-order/sync-marketplace-order.js +105 -8
  6. package/dist-server/graphql/resolvers/marketplace-order/sync-marketplace-order.js.map +1 -1
  7. package/dist-server/graphql/resolvers/marketplace-order-shipping/marketplace-order-shippings.js +1 -1
  8. package/dist-server/graphql/resolvers/marketplace-order-shipping/marketplace-order-shippings.js.map +1 -1
  9. package/dist-server/graphql/types/marketplace-product-variation/marketplace-product-variation-patch.js +1 -0
  10. package/dist-server/graphql/types/marketplace-product-variation/marketplace-product-variation-patch.js.map +1 -1
  11. package/dist-server/graphql/types/marketplace-product-variation/marketplace-product-variation.js +1 -0
  12. package/dist-server/graphql/types/marketplace-product-variation/marketplace-product-variation.js.map +1 -1
  13. package/dist-server/graphql/types/marketplace-product-variation/new-marketplace-product-variation.js +1 -0
  14. package/dist-server/graphql/types/marketplace-product-variation/new-marketplace-product-variation.js.map +1 -1
  15. package/package.json +5 -5
  16. package/server/entities/marketplace-product-variation.ts +9 -2
  17. package/server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.ts +174 -32
  18. package/server/graphql/resolvers/marketplace-order/sync-marketplace-order.ts +178 -35
  19. package/server/graphql/resolvers/marketplace-order-shipping/marketplace-order-shippings.ts +1 -1
  20. package/server/graphql/types/marketplace-product-variation/marketplace-product-variation-patch.ts +1 -0
  21. package/server/graphql/types/marketplace-product-variation/marketplace-product-variation.ts +1 -0
  22. package/server/graphql/types/marketplace-product-variation/new-marketplace-product-variation.ts +1 -0
  23. package/dist-server/graphql/resolvers/marketplace-order/get-order-airway-bill.js +0 -34
  24. package/dist-server/graphql/resolvers/marketplace-order/get-order-airway-bill.js.map +0 -1
  25. package/dist-server/graphql/types/marketplace-order/airwaybill.js +0 -18
  26. package/dist-server/graphql/types/marketplace-order/airwaybill.js.map +0 -1
  27. package/dist-server/util/no-generator.js +0 -17
  28. package/dist-server/util/no-generator.js.map +0 -1
@@ -1,5 +1,3 @@
1
- import { User } from '@things-factory/auth-base'
2
- import { Domain } from '@things-factory/shell'
3
1
  import {
4
2
  Column,
5
3
  CreateDateColumn,
@@ -10,8 +8,13 @@ import {
10
8
  PrimaryGeneratedColumn,
11
9
  UpdateDateColumn
12
10
  } from 'typeorm'
11
+
12
+ import { User } from '@things-factory/auth-base'
13
+ import { Domain } from '@things-factory/shell'
14
+
13
15
  import { MarketplaceProduct, MarketplaceProductVariationPrice } from '../entities'
14
16
  import { NoGenerator } from '../utils'
17
+
15
18
  @Entity()
16
19
  @Index(
17
20
  'ix_marketplace-product-variation_0',
@@ -33,6 +36,7 @@ export class MarketplaceProductVariation {
33
36
  this.name = productVariation.name ? productVariation.name.toString() : NoGenerator.id()
34
37
  this.description = productVariation.description
35
38
  this.qty = productVariation.qty
39
+ this.reserveQty = productVariation.reserveQty
36
40
  this.type = productVariation.type
37
41
  this.mrpPrice = productVariation.mrpPrice
38
42
  this.costPrice = productVariation.costPrice
@@ -91,6 +95,9 @@ export class MarketplaceProductVariation {
91
95
  @Column('float', { nullable: true })
92
96
  qty: number
93
97
 
98
+ @Column('float', { nullable: true })
99
+ reserveQty: number
100
+
94
101
  @Column({ nullable: true })
95
102
  type: string
96
103
 
@@ -380,43 +380,161 @@ export const syncAllMarketplaceOrder = {
380
380
  nonMatchedOrderItems.push({ ...item })
381
381
  }
382
382
  })
383
- if (nonMatchedOrderItems.length > 0 && !cancelStatuses.includes(marketplaceOrder.status))
383
+ if (nonMatchedOrderItems.length > 0 && !cancelStatuses.includes(marketplaceOrder.status)) {
384
+ await Promise.all(
385
+ nonMatchedOrderItems.map(async item => {
386
+ if (foundVariation.sku) {
387
+ let allVariations: MarketplaceProductVariation[] = await getRepository(
388
+ MarketplaceProductVariation
389
+ ).find({
390
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
391
+ relations: [
392
+ 'domain',
393
+ 'marketplaceProduct',
394
+ 'marketplaceProduct.marketplaceStore',
395
+ 'marketplaceProduct.marketplaceStore.marketplaceDistributors'
396
+ ]
397
+ })
398
+
399
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
400
+ variation =>
401
+ variation.id != foundVariation.id &&
402
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
403
+ )
404
+
405
+ variationsFromOtherStores.map(async variation => {
406
+ variation.reserveQty -= item.qty
407
+
408
+ variation = await getRepository(MarketplaceProductVariation).save(variation)
409
+ })
410
+ }
411
+
412
+ foundVariation.qty += item.qty
413
+ foundVariation = await getRepository(MarketplaceProductVariation).save(foundVariation)
414
+ })
415
+ )
416
+
384
417
  await getRepository(MarketplaceOrderItem).delete(nonMatchedOrderItems)
418
+ }
385
419
 
386
- existingOrderItems = marketplaceOrderItems.map(item => {
387
- const matchedOrderItem = existingOrderItems.find(
388
- itm =>
389
- itm.name == item.name &&
390
- itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
391
- )
392
- if (matchedOrderItem) {
393
- return {
394
- ...matchedOrderItem,
395
- ...item,
396
- updater: user
420
+ existingOrderItems = await Promise.all(
421
+ marketplaceOrderItems.map(async item => {
422
+ const matchedOrderItem = existingOrderItems.find(
423
+ itm =>
424
+ itm.name == item.name &&
425
+ itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
426
+ )
427
+ if (matchedOrderItem) {
428
+ if (foundVariation.sku) {
429
+ let allVariations: MarketplaceProductVariation[] = await getRepository(
430
+ MarketplaceProductVariation
431
+ ).find({
432
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
433
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
434
+ })
435
+
436
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
437
+ variation =>
438
+ variation.id != foundVariation.id &&
439
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
440
+ )
441
+
442
+ variationsFromOtherStores.map(async variation => {
443
+ variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
444
+ ? variation.reserveQty + matchedOrderItem.qty
445
+ : variation.reserveQty - item.qty + matchedOrderItem.qty
446
+
447
+ variation = await getRepository(MarketplaceProductVariation).save(variation)
448
+ })
449
+ }
450
+
451
+ foundVariation.qty = existingMarketplaceOrder?.releaseOrderId
452
+ ? foundVariation.qty - matchedOrderItem.qty
453
+ : foundVariation.qty + item.qty - matchedOrderItem.qty
454
+ foundVariation = await getRepository(MarketplaceProductVariation).save(foundVariation)
455
+
456
+ return {
457
+ ...matchedOrderItem,
458
+ ...item,
459
+ updater: user
460
+ }
397
461
  }
398
- }
399
- })
462
+ })
463
+ )
400
464
  } else {
401
- existingOrderItems = marketplaceOrderItems.map(item => {
402
- const matchedOrderItem = existingOrderItems.find(
403
- itm =>
404
- itm.name == item.name &&
405
- itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
406
- )
407
- if (matchedOrderItem) {
408
- return {
409
- ...matchedOrderItem,
410
- ...item,
411
- updater: user
465
+ existingOrderItems = await Promise.all(
466
+ marketplaceOrderItems.map(async item => {
467
+ const matchedOrderItem = existingOrderItems.find(
468
+ itm =>
469
+ itm.name == item.name &&
470
+ itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
471
+ )
472
+ if (matchedOrderItem) {
473
+ if (foundVariation.sku) {
474
+ let allVariations: MarketplaceProductVariation[] = await tx
475
+ .getRepository(MarketplaceProductVariation)
476
+ .find({
477
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
478
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
479
+ })
480
+
481
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
482
+ variation =>
483
+ variation.id != foundVariation.id &&
484
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
485
+ )
486
+
487
+ variationsFromOtherStores.map(async variation => {
488
+ variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
489
+ ? variation.reserveQty + matchedOrderItem.qty
490
+ : variation.reserveQty - item.qty + matchedOrderItem.qty
491
+
492
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
493
+ })
494
+ }
495
+
496
+ foundVariation.qty = existingMarketplaceOrder?.releaseOrderId
497
+ ? foundVariation.qty - matchedOrderItem.qty
498
+ : foundVariation.qty + item.qty - matchedOrderItem.qty
499
+ foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
500
+
501
+ return {
502
+ ...matchedOrderItem,
503
+ ...item,
504
+ updater: user
505
+ }
506
+ } else {
507
+ if (foundVariation.sku) {
508
+ let allVariations: MarketplaceProductVariation[] = await tx
509
+ .getRepository(MarketplaceProductVariation)
510
+ .find({
511
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
512
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
513
+ })
514
+
515
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
516
+ variation =>
517
+ variation.id != foundVariation.id &&
518
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
519
+ )
520
+
521
+ variationsFromOtherStores.map(async variation => {
522
+ variation.reserveQty += item.qty
523
+
524
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
525
+ })
526
+ }
527
+
528
+ foundVariation.qty -= item.qty
529
+ foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
530
+
531
+ return {
532
+ ...item,
533
+ updater: user
534
+ }
412
535
  }
413
- } else {
414
- return {
415
- ...item,
416
- updater: user
417
- }
418
- }
419
- })
536
+ })
537
+ )
420
538
  }
421
539
 
422
540
  marketplaceOrderItems = existingOrderItems
@@ -429,6 +547,30 @@ export const syncAllMarketplaceOrder = {
429
547
  }
430
548
  }
431
549
  } else {
550
+ if (foundVariation.sku) {
551
+ let allVariations: MarketplaceProductVariation[] = await tx
552
+ .getRepository(MarketplaceProductVariation)
553
+ .find({
554
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
555
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
556
+ })
557
+
558
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
559
+ variation =>
560
+ variation.id != foundVariation.id &&
561
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
562
+ )
563
+
564
+ variationsFromOtherStores.map(async variation => {
565
+ variation.reserveQty += item.qty
566
+
567
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
568
+ })
569
+ }
570
+
571
+ foundVariation.qty -= item.qty
572
+ foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
573
+
432
574
  if (order?.orderShipping) {
433
575
  savedMarketplaceOrderShipping.totalWeight = orderTotalWeight
434
576
  savedMarketplaceOrderShipping = await getRepository(MarketplaceOrderShipping).save(
@@ -285,9 +285,10 @@ export const syncMarketplaceOrder = {
285
285
  let foundVariation
286
286
  for (var j = 0; j < order.orderItems.length; j++) {
287
287
  var item = order.orderItems[j]
288
- foundVariation = await tx
289
- .getRepository(MarketplaceProductVariation)
290
- .findOne({ where: { domain: marketplaceStore.domain, variationId: item.variationId } })
288
+ foundVariation = await tx.getRepository(MarketplaceProductVariation).findOne({
289
+ where: { domain: marketplaceStore.domain, variationId: item.variationId },
290
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
291
+ })
291
292
 
292
293
  if (!foundVariation) {
293
294
  let newVariation: any = {
@@ -373,43 +374,161 @@ export const syncMarketplaceOrder = {
373
374
  nonMatchedOrderItems.push({ ...item })
374
375
  }
375
376
  })
376
- if (nonMatchedOrderItems.length > 0 && !cancelStatuses.includes(marketplaceOrder.status))
377
+ if (nonMatchedOrderItems.length > 0 && !cancelStatuses.includes(marketplaceOrder.status)) {
378
+ await Promise.all(
379
+ nonMatchedOrderItems.map(async item => {
380
+ if (foundVariation.sku) {
381
+ let allVariations: MarketplaceProductVariation[] = await tx
382
+ .getRepository(MarketplaceProductVariation)
383
+ .find({
384
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
385
+ relations: [
386
+ 'domain',
387
+ 'marketplaceProduct',
388
+ 'marketplaceProduct.marketplaceStore',
389
+ 'marketplaceProduct.marketplaceStore.marketplaceDistributors'
390
+ ]
391
+ })
392
+
393
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
394
+ variation =>
395
+ variation.id != foundVariation.id &&
396
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
397
+ )
398
+
399
+ variationsFromOtherStores.map(async variation => {
400
+ variation.reserveQty -= item.qty
401
+
402
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
403
+ })
404
+ }
405
+
406
+ foundVariation.qty += item.qty
407
+ foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
408
+ })
409
+ )
410
+
377
411
  await tx.getRepository(MarketplaceOrderItem).delete(nonMatchedOrderItems)
412
+ }
378
413
 
379
- existingOrderItems = marketplaceOrderItems.map(item => {
380
- const matchedOrderItem = existingOrderItems.find(
381
- itm =>
382
- itm.name == item.name &&
383
- itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
384
- )
385
- if (matchedOrderItem) {
386
- return {
387
- ...matchedOrderItem,
388
- ...item,
389
- updater: user
414
+ existingOrderItems = await Promise.all(
415
+ marketplaceOrderItems.map(async item => {
416
+ const matchedOrderItem = existingOrderItems.find(
417
+ itm =>
418
+ itm.name == item.name &&
419
+ itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
420
+ )
421
+ if (matchedOrderItem) {
422
+ if (foundVariation.sku) {
423
+ let allVariations: MarketplaceProductVariation[] = await tx
424
+ .getRepository(MarketplaceProductVariation)
425
+ .find({
426
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
427
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
428
+ })
429
+
430
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
431
+ variation =>
432
+ variation.id != foundVariation.id &&
433
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
434
+ )
435
+
436
+ variationsFromOtherStores.map(async variation => {
437
+ variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
438
+ ? variation.reserveQty + matchedOrderItem.qty
439
+ : variation.reserveQty - item.qty + matchedOrderItem.qty
440
+
441
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
442
+ })
443
+ }
444
+
445
+ foundVariation.qty = existingMarketplaceOrder?.releaseOrderId
446
+ ? foundVariation.qty - matchedOrderItem.qty
447
+ : foundVariation.qty + item.qty - matchedOrderItem.qty
448
+ foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
449
+
450
+ return {
451
+ ...matchedOrderItem,
452
+ ...item,
453
+ updater: user
454
+ }
390
455
  }
391
- }
392
- })
456
+ })
457
+ )
393
458
  } else {
394
- existingOrderItems = marketplaceOrderItems.map(item => {
395
- const matchedOrderItem = existingOrderItems.find(
396
- itm =>
397
- itm.name == item.name &&
398
- itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
399
- )
400
- if (matchedOrderItem) {
401
- return {
402
- ...matchedOrderItem,
403
- ...item,
404
- updater: user
459
+ existingOrderItems = await Promise.all(
460
+ marketplaceOrderItems.map(async item => {
461
+ const matchedOrderItem = existingOrderItems.find(
462
+ itm =>
463
+ itm.name == item.name &&
464
+ itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
465
+ )
466
+ if (matchedOrderItem) {
467
+ if (foundVariation.sku) {
468
+ let allVariations: MarketplaceProductVariation[] = await tx
469
+ .getRepository(MarketplaceProductVariation)
470
+ .find({
471
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
472
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
473
+ })
474
+
475
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
476
+ variation =>
477
+ variation.id != foundVariation.id &&
478
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
479
+ )
480
+
481
+ variationsFromOtherStores.map(async variation => {
482
+ variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
483
+ ? variation.reserveQty + matchedOrderItem.qty
484
+ : variation.reserveQty - item.qty + matchedOrderItem.qty
485
+
486
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
487
+ })
488
+ }
489
+
490
+ foundVariation.qty = existingMarketplaceOrder?.releaseOrderId
491
+ ? foundVariation.qty - matchedOrderItem.qty
492
+ : foundVariation.qty + item.qty - matchedOrderItem.qty
493
+ foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
494
+
495
+ return {
496
+ ...matchedOrderItem,
497
+ ...item,
498
+ updater: user
499
+ }
500
+ } else {
501
+ if (foundVariation.sku) {
502
+ let allVariations: MarketplaceProductVariation[] = await tx
503
+ .getRepository(MarketplaceProductVariation)
504
+ .find({
505
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
506
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
507
+ })
508
+
509
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
510
+ variation =>
511
+ variation.id != foundVariation.id &&
512
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
513
+ )
514
+
515
+ variationsFromOtherStores.map(async variation => {
516
+ variation.reserveQty += item.qty
517
+
518
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
519
+ })
520
+ }
521
+
522
+ foundVariation.qty -= item.qty
523
+ foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
524
+
525
+ return {
526
+ ...item,
527
+ updater: user
528
+ }
405
529
  }
406
- } else {
407
- return {
408
- ...item,
409
- updater: user
410
- }
411
- }
412
- })
530
+ })
531
+ )
413
532
  }
414
533
 
415
534
  marketplaceOrderItems = existingOrderItems
@@ -422,6 +541,30 @@ export const syncMarketplaceOrder = {
422
541
  }
423
542
  }
424
543
  } else {
544
+ if (foundVariation.sku) {
545
+ let allVariations: MarketplaceProductVariation[] = await tx
546
+ .getRepository(MarketplaceProductVariation)
547
+ .find({
548
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
549
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
550
+ })
551
+
552
+ let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
553
+ variation =>
554
+ variation.id != foundVariation.id &&
555
+ variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
556
+ )
557
+
558
+ variationsFromOtherStores.map(async variation => {
559
+ variation.reserveQty += item.qty
560
+
561
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
562
+ })
563
+ }
564
+
565
+ foundVariation.qty -= item.qty
566
+ foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
567
+
425
568
  if (order?.orderShipping) {
426
569
  savedMarketplaceOrderShipping.totalWeight = orderTotalWeight
427
570
  savedMarketplaceOrderShipping = await tx
@@ -17,7 +17,7 @@ export const marketplaceOrderShippingsResolver = {
17
17
  .innerJoinAndSelect('MOI.marketplaceProductVariation', 'MPV')
18
18
  .innerJoinAndSelect('MOS.marketplaceStore', 'MS')
19
19
  .innerJoinAndSelect('MOS.domain', 'domain')
20
- .innerJoinAndSelect('MOS.creator', 'creator')
20
+ .leftJoinAndSelect('MOS.creator', 'creator')
21
21
  .leftJoinAndSelect('MOS.updater', 'updater')
22
22
 
23
23
  buildQuery(qb, params, context, false)
@@ -14,6 +14,7 @@ export const MarketplaceProductVariationPatch = gql`
14
14
  type: String
15
15
  description: String
16
16
  qty: Float
17
+ reserveQty: Float
17
18
  bufferQty: Float
18
19
  thresholdQty: Float
19
20
  costPrice: Float
@@ -11,6 +11,7 @@ export const MarketplaceProductVariation = gql`
11
11
  variationSku: String
12
12
  channelSku: String
13
13
  qty: Float
14
+ reserveQty: Float
14
15
  bufferQty: Float
15
16
  thresholdQty: Float
16
17
  name: String
@@ -10,6 +10,7 @@ export const NewMarketplaceProductVariation = gql`
10
10
  variationSku: String
11
11
  channelSku: String
12
12
  qty: Float
13
+ reserveQty: Float
13
14
  bufferQty: Float
14
15
  thresholdQty: Float
15
16
  costPrice: Float
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrderAirwayBillResolver = void 0;
4
- const integration_marketplace_1 = require("@things-factory/integration-marketplace");
5
- const typeorm_1 = require("typeorm");
6
- const entities_1 = require("../../../entities");
7
- exports.getOrderAirwayBillResolver = {
8
- async getOrderAirwayBill(_, { orderNo }, context) {
9
- const { tx } = context.state;
10
- const foundMarketplaceOrders = await tx.getRepository(entities_1.MarketplaceOrder).find({
11
- where: { orderNo: typeorm_1.In(orderNo) },
12
- relations: ['marketplaceStore', 'marketplaceOrderItems']
13
- });
14
- if ((foundMarketplaceOrders === null || foundMarketplaceOrders === void 0 ? void 0 : foundMarketplaceOrders.length) === 0)
15
- throw new Error('No order is found');
16
- const marketplaceOrderItems = foundMarketplaceOrders.map((order) => order.marketplaceOrderItems);
17
- let docRefNo = [];
18
- marketplaceOrderItems.map((item) => {
19
- let orderDocNo = [];
20
- orderDocNo = item.map(oi => oi.docRefNo);
21
- if (orderDocNo[0].indexOf(',') > -1) {
22
- orderDocNo = orderDocNo[0].split(',');
23
- }
24
- Array.prototype.push.apply(docRefNo, orderDocNo);
25
- });
26
- // remove repeated docRefNo
27
- docRefNo = docRefNo.filter((value, index) => docRefNo.indexOf(value) === index);
28
- const storeId = foundMarketplaceOrders.map((order) => order.marketplaceStore.id);
29
- const marketplaceStore = await integration_marketplace_1.StoreAPI.getMarketplaceStore(storeId[0]);
30
- const airwayBill = await integration_marketplace_1.StoreAPI.getStoreOrderDocument(marketplaceStore, { docRefNo });
31
- return airwayBill;
32
- }
33
- };
34
- //# sourceMappingURL=get-order-airway-bill.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-order-airway-bill.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/marketplace-order/get-order-airway-bill.ts"],"names":[],"mappings":";;;AAAA,qFAAoF;AACpF,qCAA2C;AAC3C,gDAA0E;AAE7D,QAAA,0BAA0B,GAAG;IACxC,KAAK,CAAC,kBAAkB,CAAC,CAAM,EAAE,EAAE,OAAO,EAAE,EAAE,OAAY;QACxD,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK,CAAA;QACnD,MAAM,sBAAsB,GAAuB,MAAM,EAAE,CAAC,aAAa,CAAC,2BAAgB,CAAC,CAAC,IAAI,CAAC;YAC/F,KAAK,EAAE,EAAE,OAAO,EAAE,YAAE,CAAC,OAAO,CAAC,EAAE;YAC/B,SAAS,EAAE,CAAC,kBAAkB,EAAE,uBAAuB,CAAC;SACzD,CAAC,CAAA;QACF,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,MAAM,MAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;QAE9E,MAAM,qBAAqB,GAA2B,sBAAsB,CAAC,GAAG,CAC9E,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAC5C,CAAA;QAED,IAAI,QAAQ,GAAU,EAAE,CAAA;QACxB,qBAAqB,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE;YACtC,IAAI,UAAU,GAAU,EAAE,CAAA;YAC1B,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAA;YACxC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;gBACnC,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACtC;YACD,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;QAEF,2BAA2B;QAC3B,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,CAAA;QAE/E,MAAM,OAAO,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAA;QAClG,MAAM,gBAAgB,GAAqB,MAAM,kCAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QAEzF,MAAM,UAAU,GAAU,MAAM,kCAAQ,CAAC,qBAAqB,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QAE9F,OAAO,UAAU,CAAA;IACnB,CAAC;CACF,CAAA"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AirwayBill = void 0;
7
- const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
- exports.AirwayBill = graphql_tag_1.default `
9
- type AirwayBill {
10
- orderNo: String
11
- mimeType: String
12
- file: String
13
- airwayBill: String
14
- documentType: String
15
- itemCount: Int
16
- }
17
- `;
18
- //# sourceMappingURL=airwaybill.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"airwaybill.js","sourceRoot":"","sources":["../../../../server/graphql/types/marketplace-order/airwaybill.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,UAAU,GAAG,qBAAG,CAAA;;;;;;;;;CAS5B,CAAA"}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NoGenerator = void 0;
7
- const v4_1 = __importDefault(require("uuid/v4"));
8
- class NoGenerator {
9
- static id() {
10
- return `${v4_1.default()}`;
11
- }
12
- static sku() {
13
- return `SKU-${v4_1.default()}`;
14
- }
15
- }
16
- exports.NoGenerator = NoGenerator;
17
- //# sourceMappingURL=no-generator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"no-generator.js","sourceRoot":"","sources":["../../server/util/no-generator.ts"],"names":[],"mappings":";;;;;;AAAA,iDAA0B;AAE1B,MAAa,WAAW;IACtB,MAAM,CAAC,EAAE;QACP,OAAO,GAAG,YAAI,EAAE,EAAE,CAAA;IACpB,CAAC;IAED,MAAM,CAAC,GAAG;QACR,OAAO,OAAO,YAAI,EAAE,EAAE,CAAA;IACxB,CAAC;CACF;AARD,kCAQC"}