@things-factory/warehouse-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 (87) hide show
  1. package/package.json +8 -8
  2. package/server/constants/index.ts +0 -5
  3. package/server/constants/inventory.ts +0 -67
  4. package/server/constants/location.ts +0 -14
  5. package/server/constants/pallet.ts +0 -10
  6. package/server/constants/rule-type.ts +0 -5
  7. package/server/constants/tote.ts +0 -5
  8. package/server/controllers/ecommerce/ecommerce-controller.ts +0 -108
  9. package/server/controllers/ecommerce/index.ts +0 -2
  10. package/server/controllers/ecommerce/sellercraft-controller.ts +0 -100
  11. package/server/controllers/index.ts +0 -2
  12. package/server/controllers/warehouse-controller.ts +0 -181
  13. package/server/index.ts +0 -9
  14. package/server/middlewares/index.ts +0 -0
  15. package/server/migrations/index.ts +0 -9
  16. package/server/service/index.ts +0 -80
  17. package/server/service/inventory/index.ts +0 -6
  18. package/server/service/inventory/inventory-mutation.ts +0 -486
  19. package/server/service/inventory/inventory-query.ts +0 -1259
  20. package/server/service/inventory/inventory-types.ts +0 -355
  21. package/server/service/inventory/inventory.ts +0 -398
  22. package/server/service/inventory-change/index.ts +0 -6
  23. package/server/service/inventory-change/inventory-change-mutation.ts +0 -969
  24. package/server/service/inventory-change/inventory-change-query.ts +0 -93
  25. package/server/service/inventory-change/inventory-change-types.ts +0 -36
  26. package/server/service/inventory-change/inventory-change.ts +0 -164
  27. package/server/service/inventory-history/index.ts +0 -6
  28. package/server/service/inventory-history/inventory-history-mutation.ts +0 -116
  29. package/server/service/inventory-history/inventory-history-query.ts +0 -1845
  30. package/server/service/inventory-history/inventory-history-types.ts +0 -444
  31. package/server/service/inventory-history/inventory-history.ts +0 -203
  32. package/server/service/inventory-item/index.ts +0 -6
  33. package/server/service/inventory-item/inventory-item-mutation.ts +0 -217
  34. package/server/service/inventory-item/inventory-item-query.ts +0 -226
  35. package/server/service/inventory-item/inventory-item-type.ts +0 -74
  36. package/server/service/inventory-item/inventory-item.ts +0 -105
  37. package/server/service/inventory-item-change/index.ts +0 -6
  38. package/server/service/inventory-item-change/inventory-item-change-mutation.ts +0 -119
  39. package/server/service/inventory-item-change/inventory-item-change-query.ts +0 -47
  40. package/server/service/inventory-item-change/inventory-item-change-type.ts +0 -68
  41. package/server/service/inventory-item-change/inventory-item-change.ts +0 -92
  42. package/server/service/inventory-product/index.ts +0 -6
  43. package/server/service/inventory-product/inventory-product-mutation.ts +0 -116
  44. package/server/service/inventory-product/inventory-product-query.ts +0 -47
  45. package/server/service/inventory-product/inventory-product-type.ts +0 -59
  46. package/server/service/inventory-product/inventory-product.ts +0 -88
  47. package/server/service/location/index.ts +0 -6
  48. package/server/service/location/location-mutation.ts +0 -134
  49. package/server/service/location/location-query.ts +0 -244
  50. package/server/service/location/location-types.ts +0 -173
  51. package/server/service/location/location.ts +0 -121
  52. package/server/service/movement/index.ts +0 -6
  53. package/server/service/movement/movement-mutation.ts +0 -60
  54. package/server/service/movement/movement-query.ts +0 -263
  55. package/server/service/movement/movement-types.ts +0 -74
  56. package/server/service/movement/movement.ts +0 -81
  57. package/server/service/pallet/index.ts +0 -6
  58. package/server/service/pallet/pallet-mutation.ts +0 -242
  59. package/server/service/pallet/pallet-query.ts +0 -106
  60. package/server/service/pallet/pallet-types.ts +0 -80
  61. package/server/service/pallet/pallet.ts +0 -92
  62. package/server/service/pallet-count/index.ts +0 -6
  63. package/server/service/pallet-count/pallet-count-mutation.ts +0 -151
  64. package/server/service/pallet-count/pallet-count-query.ts +0 -45
  65. package/server/service/pallet-count/pallet-count-types.ts +0 -36
  66. package/server/service/pallet-count/pallet-count.ts +0 -70
  67. package/server/service/pallet-history/index.ts +0 -6
  68. package/server/service/pallet-history/pallet-history-mutation.ts +0 -114
  69. package/server/service/pallet-history/pallet-history-query.ts +0 -48
  70. package/server/service/pallet-history/pallet-history-types.ts +0 -36
  71. package/server/service/pallet-history/pallet-history.ts +0 -89
  72. package/server/service/reduced-inventory-history/index.ts +0 -3
  73. package/server/service/reduced-inventory-history/reduced-inventory-history.ts +0 -92
  74. package/server/service/tote/index.ts +0 -6
  75. package/server/service/tote/tote-mutation.ts +0 -201
  76. package/server/service/tote/tote-query.ts +0 -106
  77. package/server/service/tote/tote-types.ts +0 -44
  78. package/server/service/tote/tote.ts +0 -77
  79. package/server/service/warehouse/index.ts +0 -6
  80. package/server/service/warehouse/warehouse-mutation.ts +0 -117
  81. package/server/service/warehouse/warehouse-query.ts +0 -58
  82. package/server/service/warehouse/warehouse-types.ts +0 -50
  83. package/server/service/warehouse/warehouse.ts +0 -95
  84. package/server/utils/datetime-util.ts +0 -54
  85. package/server/utils/index.ts +0 -3
  86. package/server/utils/inventory-no-generator.ts +0 -15
  87. package/server/utils/inventory-util.ts +0 -490
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/warehouse-base",
3
- "version": "8.0.0-beta.1",
3
+ "version": "8.0.0-beta.4",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,12 +24,12 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
25
25
  },
26
26
  "dependencies": {
27
- "@things-factory/biz-base": "^8.0.0-beta.1",
28
- "@things-factory/id-rule-base": "^8.0.0-beta.1",
29
- "@things-factory/integration-sellercraft": "^8.0.0-beta.1",
30
- "@things-factory/marketplace-base": "^8.0.0-beta.1",
31
- "@things-factory/product-base": "^8.0.0-beta.1",
32
- "@things-factory/setting-base": "^8.0.0-beta.1"
27
+ "@things-factory/biz-base": "^8.0.0-beta.4",
28
+ "@things-factory/id-rule-base": "^8.0.0-beta.4",
29
+ "@things-factory/integration-sellercraft": "^8.0.0-beta.4",
30
+ "@things-factory/marketplace-base": "^8.0.0-beta.4",
31
+ "@things-factory/product-base": "^8.0.0-beta.4",
32
+ "@things-factory/setting-base": "^8.0.0-beta.4"
33
33
  },
34
- "gitHead": "36c494e587640c1490318ef7b95adab02606e0c2"
34
+ "gitHead": "d83d12ed4ba07177dff1dac26e37be347d156b43"
35
35
  }
@@ -1,5 +0,0 @@
1
- export * from './inventory'
2
- export * from './location'
3
- export * from './pallet'
4
- export * from './rule-type'
5
- export * from './tote'
@@ -1,67 +0,0 @@
1
- export const INVENTORY_STATUS = {
2
- UNLOADED: 'UNLOADED',
3
- PARTIALLY_UNLOADED: 'PARTIALLY_UNLOADED',
4
- PUTTING_AWAY: 'PUTTING_AWAY',
5
- STORED: 'STORED',
6
- LOADED: 'LOADED',
7
- INTRANSIT: 'INTRANSIT',
8
- TERMINATED: 'TERMINATED',
9
- TRANSFERED: 'TRANSFERED',
10
- DELETED: 'DELETED',
11
- CHECKED: 'CHECKED',
12
- PICKED: 'PICKED',
13
- PICKING: 'PICKING',
14
- SORTING: 'SORTING',
15
- SORTED: 'SORTED'
16
- }
17
-
18
- export const INVENTORY_TYPES = {
19
- BUFFER: 'BUFFER',
20
- SHELF: 'SHELF'
21
- }
22
-
23
- export const INVENTORY_TRANSACTION_TYPE = {
24
- NEW: 'NEW',
25
- UNLOADING: 'UNLOADING',
26
- UNDO_UNLOADING: 'UNDO_UNLOADING',
27
- PUTAWAY: 'PUTAWAY',
28
- UNDO_PUTAWAY: 'UNDO_PUTAWAY',
29
- UNDO_UNPACKING: 'UNDO_UNPACKING',
30
- ADJUSTMENT: 'ADJUSTMENT',
31
- CC_ADJUSTMENT: 'CC_ADJUSTMENT',
32
- SALES_ADJUSTMENT: 'SALES_ADJUSTMENT',
33
- RELOCATE: 'RELOCATE',
34
- PICKING: 'PICKING',
35
- PACKING: 'PACKING',
36
- LOADING: 'LOADING',
37
- SORTING: 'SORTING',
38
- UNDO_LOADING: 'UNDO_LOADING',
39
- UNDO_PICKING: 'UNDO_PICKING',
40
- CANCEL_ORDER: 'CANCEL_ORDER',
41
- RETURN: 'RETURN',
42
- EXTERNAL_RETURN: 'EXTERNAL_RETURN',
43
- TERMINATED: 'TERMINATED',
44
- TRANSFERED_IN: 'TRANSFERED_IN',
45
- TRANSFERED_OUT: 'TRANSFERED_OUT',
46
- RELABELING: 'RELABELING',
47
- REPACKAGING: 'REPACKAGING',
48
- REPACKAGING_RELABELING: 'REPACKAGING_RELABELING',
49
- REPALLETIZING: 'REPALLETIZING',
50
- UNPACKING: 'UNPACKING',
51
- UNPACKED: 'UNPACKED',
52
- REVERSE_KITTING: 'REVERSE_KITTING',
53
- UNDO_REVERSE_KITTING: 'UNDO_REVERSE_KITTING',
54
- DIRECT_DEDUCTION: 'DIRECT_DEDUCTION'
55
- }
56
-
57
- export const INVENTORY_ITEM_SOURCE = {
58
- INBOUND: 'INBOUND',
59
- OUTBOUND: 'OUTBOUND',
60
- ADJUSTMENT: 'ADJUSTMENT'
61
- }
62
-
63
- export const INVENTORY_ITEM_CHANGE_TYPE = {
64
- NEW: 'NEW',
65
- MODIFIED: 'MODIFIED',
66
- REMOVED: 'REMOVED'
67
- }
@@ -1,14 +0,0 @@
1
- export const LOCATION_STATUS = {
2
- EMPTY: 'EMPTY',
3
- OCCUPIED: 'OCCUPIED',
4
- FULL: 'FULL'
5
- }
6
-
7
- export const LOCATION_TYPE = {
8
- BUFFER: 'BUFFER',
9
- SHELF: 'SHELF',
10
- FLOOR: 'FLOOR',
11
- BIN: 'BIN',
12
- QUARANTINE: 'QUARANTINE',
13
- RESERVE: 'RESERVE'
14
- }
@@ -1,10 +0,0 @@
1
- export const PALLET_STATUS = {
2
- ACTIVE: 'ACTIVE',
3
- LOST: 'LOST',
4
- DAMAGED: 'DAMAGED'
5
- }
6
-
7
- export const PALLET_TYPES = {
8
- WOODEN_PALLET: 'WOODEN_PALLET',
9
- REUSABLE_PALLET: 'REUSABLE_PALLET'
10
- }
@@ -1,5 +0,0 @@
1
- export const RULE_TYPE = {
2
- LOT_NUMBER_ID: 'inbound_pallet_id',
3
- CARTON_NUMBER_ID: 'inbound_carton_id',
4
- LOT_ID: 'inbound_lot_id'
5
- }
@@ -1,5 +0,0 @@
1
- export const TOTE_STATUS = {
2
- ACTIVE: 'ACTIVE',
3
- DISPATCHED: 'DISPATCHED',
4
- DAMAGED: 'DAMAGED'
5
- }
@@ -1,108 +0,0 @@
1
- import { Equal, Not } from 'typeorm'
2
-
3
- import { MarketplaceSetting, MarketplaceStore, StoreAPI } from '@things-factory/integration-marketplace'
4
- import { MarketplaceProductVariation } from '@things-factory/marketplace-base'
5
- import { Product } from '@things-factory/product-base'
6
- import { Domain } from '@things-factory/shell'
7
-
8
- import { INVENTORY_STATUS, LOCATION_TYPE } from '../../constants'
9
- import { Inventory } from '../../service/inventory/inventory'
10
- import { WarehouseController } from '../warehouse-controller'
11
-
12
- export class EcommerceController extends WarehouseController {
13
- async updateProductVariationStock(
14
- marketplaceStores: MarketplaceStore[],
15
- productId: string,
16
- companyDomain: Domain
17
- ): Promise<void> {
18
- const product: Product = await this.trxMgr.getRepository(Product).findOneBy({ id: productId })
19
- let inventories: Inventory[] = await this.trxMgr.getRepository(Inventory).find({
20
- where: {
21
- domain: { id: this.domain.id },
22
- product: { id: product.id },
23
- status: Not(Equal(INVENTORY_STATUS.TERMINATED))
24
- },
25
- relations: ['location']
26
- })
27
-
28
- inventories = inventories.filter(
29
- inventory =>
30
- inventory?.location.type !== LOCATION_TYPE.QUARANTINE || inventory?.location.type !== LOCATION_TYPE.RESERVE
31
- )
32
-
33
- const inventoryQty: number = inventories.reduce((total, currentValue) => {
34
- total += currentValue.qty
35
- return total
36
- }, 0)
37
-
38
- const inventoryLockedQty: number = inventories.reduce((total, currentValue) => {
39
- total += currentValue.lockedQty
40
- return total
41
- }, 0)
42
-
43
- const inventoryProduct: any = {
44
- sku: product.sku,
45
- name: product.name,
46
- qty: inventoryQty - inventoryLockedQty
47
- }
48
-
49
- for (var i = 0; i < marketplaceStores.length; i++) {
50
- const marketplaceStore = marketplaceStores[i]
51
-
52
- // get marketplace setting based on marketplace connection
53
- const marketplaceSetting: MarketplaceSetting = await this.trxMgr.getRepository(MarketplaceSetting).findOne({
54
- where: { marketplaceStore: { id: marketplaceStore.id }, category: 'stock_allocation' }
55
- })
56
-
57
- const marketplaceProductVariations: MarketplaceProductVariation[] = await this.trxMgr
58
- .getRepository(MarketplaceProductVariation)
59
- .find({
60
- where: { domain: { id: companyDomain.id }, sku: inventoryProduct.sku },
61
- relations: ['marketplaceProduct', 'marketplaceProduct.marketplaceStore']
62
- })
63
-
64
- let marketplaceProductVariation: MarketplaceProductVariation = marketplaceProductVariations.filter(
65
- productVariation => productVariation.marketplaceProduct.marketplaceStore.id === marketplaceStore.id
66
- )[0]
67
-
68
- if (marketplaceProductVariation) {
69
- // update stock qty based on calculated inventory by product qty
70
- let percentageValue: number = 100
71
- if (marketplaceSetting) {
72
- percentageValue = parseInt(marketplaceSetting.value)
73
- }
74
-
75
- let productVariationLocationId = marketplaceProductVariation?.locationId
76
- let adjustQty: number = Math.floor(inventoryProduct.qty * (percentageValue / 100))
77
- if (marketplaceStore.platform === 'shopify') {
78
- let locationIds: any[] = JSON.parse(productVariationLocationId)
79
- adjustQty = adjustQty - marketplaceProductVariation.qty
80
- if (locationIds[0]?.location_id) productVariationLocationId = locationIds[0].location_id
81
- }
82
-
83
- let validMarketplaceDistributors: any[] = []
84
- if (marketplaceStore.marketplaceDistributors) {
85
- validMarketplaceDistributors = marketplaceStore.marketplaceDistributors.filter(
86
- distributor => distributor.status === 'ACTIVE'
87
- )
88
- }
89
-
90
- await StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
91
- {
92
- itemId: marketplaceProductVariation.marketplaceProduct.itemId,
93
- variationId: marketplaceProductVariation.variationId,
94
- variationSku: marketplaceProductVariation.variationSku,
95
- qty: adjustQty,
96
- locationId: productVariationLocationId,
97
- inventoryItemId: marketplaceProductVariation.inventoryItemId,
98
- distributors: validMarketplaceDistributors
99
- }
100
- ])
101
-
102
- marketplaceProductVariation.qty = Math.floor(inventoryProduct.qty * (percentageValue / 100))
103
- marketplaceProductVariation.updater = this.user
104
- await this.trxMgr.getRepository(MarketplaceProductVariation).save(marketplaceProductVariation)
105
- }
106
- }
107
- }
108
- }
@@ -1,2 +0,0 @@
1
- export * from './ecommerce-controller'
2
- export * from './sellercraft-controller'
@@ -1,100 +0,0 @@
1
- import { Bizplace } from '@things-factory/biz-base'
2
- import { Sellercraft, SellercraftAPI } from '@things-factory/integration-sellercraft'
3
- import { Product, ProductDetail } from '@things-factory/product-base'
4
-
5
- import { INVENTORY_STATUS, LOCATION_TYPE } from '../../constants'
6
- import { Inventory } from '../../service/inventory/inventory'
7
- import { WarehouseController } from '../warehouse-controller'
8
-
9
- export class SellercraftController extends WarehouseController {
10
- async updateSellercraftStock(sellercraft: Sellercraft, inventory: Inventory): Promise<void> {
11
- let sellercraftSetting: any = sellercraft.sellercraftSetting
12
- let disableUpdateStock: boolean =
13
- sellercraftSetting?.disableUpdateStock && sellercraftSetting?.disableUpdateStock == 1 ? true : false
14
-
15
- if (!disableUpdateStock) {
16
- const bizplace: Bizplace = await this.trxMgr.getRepository(Bizplace).findOneBy({ domain: sellercraft.domain })
17
-
18
- let product: Product = inventory.product
19
- const productDetails: ProductDetail[] = product.productDetails
20
-
21
- let qb = await this.trxMgr.getRepository(Inventory).createQueryBuilder('inv')
22
- qb.leftJoinAndSelect('inv.location', 'loc')
23
- .andWhere('"inv"."domain_id" = :domainId')
24
- .andWhere('"inv"."bizplace_id" = :bizplaceId')
25
- .andWhere('"inv"."product_id" = :productId')
26
- .andWhere('"inv"."status" = :status')
27
- .andWhere('"loc"."type" NOT IN (:...locationTypes)')
28
- .setParameters({
29
- domainId: this.domain.id,
30
- bizplaceId: bizplace.id,
31
- productId: product.id,
32
- status: INVENTORY_STATUS.STORED,
33
- locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
34
- })
35
-
36
- let inventories: Inventory[] = await qb.getMany()
37
-
38
- let defaultProductDetail: ProductDetail = product.productDetails.find(productDetail => productDetail.isDefault)
39
- let inventoryTotalQty: number = 0
40
- let inventoryTotalLockedQty: number = 0
41
-
42
- if (inventories?.length > 0) {
43
- const sellercraftInvs: any[] = await Promise.all(
44
- inventories.map(async (inventory: Inventory) => {
45
- const inventoryPackingType: string = inventory.packingType
46
-
47
- let packingSize: number = 1
48
- if (inventoryPackingType !== defaultProductDetail.packingType) {
49
- const unmatchingProductDetail: ProductDetail = product.productDetails.find(
50
- productDetail => productDetail.packingType === inventoryPackingType
51
- )
52
-
53
- packingSize = await this.getChildPackingSize(
54
- productDetails,
55
- defaultProductDetail,
56
- unmatchingProductDetail
57
- )
58
- }
59
-
60
- return { totalQty: inventory.qty * packingSize, totalLockedQty: inventory.lockedQty * packingSize }
61
- })
62
- )
63
-
64
- inventoryTotalQty = sellercraftInvs.reduce((total, currentValue) => {
65
- total += currentValue.totalQty
66
- return total
67
- }, 0)
68
-
69
- inventoryTotalLockedQty = sellercraftInvs.reduce((total, currentValue) => {
70
- total += currentValue.totalLockedQty
71
- return total
72
- }, 0)
73
- }
74
-
75
- const sellercraftInv: any[] = [
76
- {
77
- sku: product.sku,
78
- gtin: defaultProductDetail.gtin,
79
- stock: {
80
- quantity_total: inventoryTotalQty,
81
- quantity_reserved: inventoryTotalLockedQty,
82
- unit_of_measure: 'EA'
83
- },
84
- package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
85
- package_dimensions: {
86
- length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
87
- width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
88
- height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
89
- }
90
- }
91
- ]
92
-
93
- await SellercraftAPI.updateProduct(sellercraft, {
94
- context: { state: { domain: this?.domain, user: this?.user } },
95
- accountId: sellercraft.accountId,
96
- sellercraftInv
97
- })
98
- }
99
- }
100
- }
@@ -1,2 +0,0 @@
1
- export * from './ecommerce'
2
- export * from './warehouse-controller'
@@ -1,181 +0,0 @@
1
- import { EntityManager } from 'typeorm'
2
-
3
- import { Role, User } from '@things-factory/auth-base'
4
- import { Bizplace, getDomainUsers } from '@things-factory/biz-base'
5
- import { sendNotification } from '@things-factory/notification'
6
- import { ProductDetail } from '@things-factory/product-base'
7
- import { Domain } from '@things-factory/shell'
8
-
9
- export interface BasicInterface {
10
- domain: Domain
11
- user: User
12
- }
13
-
14
- export type NotificationMsgInterface = {
15
- title: string
16
- body: string
17
- url: string
18
- data: any
19
- }
20
-
21
- export class WarehouseController {
22
- public readonly ERROR_MSG = {
23
- FIND: {
24
- NO_RESULT: (condition: any) => `There's no results matched with condition ${condition}`,
25
- NO_CHILD_RESULT: (condition: any) => `There's no child result matched with condition ${condition}`,
26
- NOT_MATCH: (source: any, target: any) => `Unable to find matching ${target} using ${source}`
27
- },
28
- CREATE: {
29
- ID_EXISTS: 'Target has ID already',
30
- EMPTY_CREATOR: 'Cannot create without creator',
31
- EMPTY_UPDATER: 'Cannot create without updater'
32
- },
33
- UPDATE: {
34
- ID_NOT_EXISTS: `Target doesn't have ID`,
35
- EMPTY_UPDATER: 'Cannot update without updater'
36
- },
37
- VALIDITY: {
38
- UNEXPECTED_FIELD_VALUE: (field: string, expectedValue: any, actualValue: any) =>
39
- `Expected ${field} value is ${expectedValue} but got ${actualValue}`,
40
- DUPLICATED: (field: string, value: any) => `There is duplicated ${field} value (${value})`,
41
- CANT_PROCEED_STEP_BY: (step: string, reason: string) => `Can't proceed to ${step} it because ${reason}`
42
- }
43
- }
44
-
45
- private readonly ROLE_NAMES: Record<string, string> = {
46
- OFFICE_ADMIN: 'Office Admin'
47
- }
48
-
49
- protected trxMgr: EntityManager
50
- protected domain: Domain
51
- protected user: User
52
-
53
- constructor(trxMgr: EntityManager, domain: Domain, user: User) {
54
- this.trxMgr = trxMgr
55
- this.domain = domain
56
- this.user = user
57
- }
58
-
59
- /**
60
- * @summary Notify to passed users
61
- * @description Passed notification message will be sent to passed users
62
- */
63
- async notifyToUsers(users: User[], message: NotificationMsgInterface): Promise<void> {
64
- const receivers: any[] = users.map(user => user.id)
65
-
66
- /**
67
- * @notes Temporary off sendNotification due to suspect of causing wms down
68
- */
69
-
70
- // await sendNotification({
71
- // receivers,
72
- // message
73
- // })
74
- }
75
-
76
- /**
77
- * @summary Notify to office admin
78
- * @description Passed notification message will be sent to office admin of current domain
79
- * default role name is defiend as ROLE_NAME.OFFICE_ADMIn by default
80
- * You can change role name by passing roleName as parameter
81
- */
82
- async notifyToOfficeAdmin(message: NotificationMsgInterface, roleName?: string): Promise<void> {
83
- const users: User[] = await this.trxMgr
84
- .getRepository('users_roles')
85
- .createQueryBuilder('ur')
86
- .select('ur.users_id', 'id')
87
- .where(qb => {
88
- const subQuery = qb
89
- .subQuery()
90
- .select('role.id')
91
- .from(Role, 'role')
92
- .where('role.name = :roleName', { roleName: roleName || this.ROLE_NAMES.OFFICE_ADMIN })
93
- .andWhere('role.domain_id = :domainId', { domainId: this.domain.id })
94
- .getQuery()
95
- return 'ur.roles_id IN ' + subQuery
96
- })
97
- .getRawMany()
98
-
99
- this.notifyToUsers(users, message)
100
- }
101
-
102
- /**
103
- * @summary Notify to customer of passed bizplace
104
- * @description Passed notification message will be sent to customer of passed bizplace
105
- */
106
- async notifyToCustomer(bizplace: Bizplace, message: NotificationMsgInterface): Promise<void> {
107
- const users: any[] = await getDomainUsers(bizplace, this.trxMgr)
108
-
109
- this.notifyToUsers(users, message)
110
- }
111
-
112
- async getChildPackingSize(
113
- productDetails: ProductDetail[],
114
- defaultProductDetail: ProductDetail,
115
- unmatchingProductDetail: ProductDetail
116
- ): Promise<number> {
117
- let hasChildRelation: boolean = Boolean(unmatchingProductDetail?.childProductDetail)
118
- let hasMatchingChild: boolean
119
- let packingSize: number = 1
120
- let currentChildProductDetail: ProductDetail
121
-
122
- if (hasChildRelation) {
123
- currentChildProductDetail = productDetails.find(
124
- (productDetail: ProductDetail) => productDetail.id === unmatchingProductDetail.childProductDetail.id
125
- )
126
-
127
- if (!currentChildProductDetail) {
128
- throw new Error(this.ERROR_MSG.FIND.NOT_MATCH('packing type', `GTIN (${unmatchingProductDetail.gtin})`))
129
- }
130
-
131
- hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)
132
- if (hasMatchingChild) {
133
- packingSize = unmatchingProductDetail.packingSize
134
- } else {
135
- packingSize = unmatchingProductDetail.packingSize * packingSize
136
- }
137
- } else {
138
- throw new Error(this.ERROR_MSG.FIND.NO_CHILD_RESULT(`${unmatchingProductDetail.gtin}`))
139
- }
140
-
141
- while (hasChildRelation && !hasMatchingChild) {
142
- if (hasMatchingChild) {
143
- packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10
144
- } else if (!hasMatchingChild && hasChildRelation) {
145
- packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10
146
- currentChildProductDetail = productDetails.find(
147
- (productDetail: ProductDetail) => productDetail.id === currentChildProductDetail.childProductDetail.id
148
- )
149
-
150
- hasChildRelation = Boolean(currentChildProductDetail?.childProductDetail)
151
- hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)
152
- } else if (!hasChildRelation && !hasMatchingChild) {
153
- throw new Error(this.ERROR_MSG.FIND.NO_RESULT(unmatchingProductDetail.gtin))
154
- }
155
- }
156
-
157
- return packingSize
158
- }
159
-
160
- /**
161
- * @summary set common stamp like domain, creator, updater
162
- * @description Set common stamp to passed record
163
- * If it doesn't have id it will handle it as creating one
164
- * If it has id it will handle it as updating one
165
- */
166
- setStamp(record: Record<string, any>): Record<string, any> {
167
- if (!record.domain) record.domain = this.domain
168
- if (!record.id && !record.creator) record.creator = this.user
169
- if (!record.updater) record.updater = this.user
170
-
171
- return record
172
- }
173
-
174
- tidyConditions(record: Record<string, any>): Record<string, any> {
175
- Object.keys(record).forEach((key: string) => {
176
- if (record[key] === null || record[key] instanceof Date || Array.isArray(record[key])) delete record[key]
177
- })
178
-
179
- return record
180
- }
181
- }
package/server/index.ts DELETED
@@ -1,9 +0,0 @@
1
- export * from './constants'
2
- export { createLocation, deleteLocation, deleteLocations, updateLocation } from './service/location/location-mutation'
3
- export { createWarehouse, deleteWarehouse, deleteWarehouses, updateWarehouse } from './service/warehouse/warehouse-mutation'
4
- export * from './migrations'
5
- export * from './utils'
6
- export * from './service'
7
- export * from './service/inventory/inventory-query'
8
- export { updateMultipleInventory } from './service/inventory/inventory-mutation'
9
- export { approveInventoryChanges } from './service/inventory-change/inventory-change-mutation'
File without changes
@@ -1,9 +0,0 @@
1
- const glob = require('glob')
2
- const path = require('path')
3
-
4
- export var migrations = []
5
-
6
- glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {
7
- if (file.indexOf('index.js') !== -1) return
8
- migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
9
- })
@@ -1,80 +0,0 @@
1
- import { entities as InventoryEntities, resolvers as InventoryResolvers } from './inventory'
2
- import { entities as InventoryChangeEntities, resolvers as InventoryChangeResolvers } from './inventory-change'
3
- import { entities as InventoryHistoryEntities, resolvers as InventoryHistoryResvolers } from './inventory-history'
4
- import { entities as InventoryItemEntities, resolvers as InventoryItemResolvers } from './inventory-item'
5
- import {
6
- entities as InventoryItemChangeEntities,
7
- resolvers as InventoryItemChangeResolvers
8
- } from './inventory-item-change'
9
- import { entities as LocationEntities, resolvers as LocationResolvers } from './location'
10
- import { entities as MovementEntities, resolvers as MovementResolvers } from './movement'
11
- import { entities as PalletEntities, resolvers as PalletResolvers } from './pallet'
12
- import { entities as PalletCountEntities, resolvers as PalletCountResolvers } from './pallet-count'
13
- import { entities as PalletHistoryEntities, resolvers as PalletHistoryResolvers } from './pallet-history'
14
- import { entities as ReducedInventoryHistoryEntities } from './reduced-inventory-history'
15
- import { entities as WarehouseEntities, resolvers as WarehouseResolvers } from './warehouse'
16
- import { entities as ToteEntities, resolvers as ToteResolvers } from './tote'
17
-
18
- /* EXPORT ENTITY TYPES */
19
- export * from './inventory-item-change/inventory-item-change'
20
- export * from './inventory-item/inventory-item'
21
- export * from './inventory-item-change/inventory-item-change'
22
- export * from './inventory/inventory'
23
- export * from './inventory-change/inventory-change'
24
- export * from './inventory-history/inventory-history'
25
- export * from './location/location'
26
- export * from './movement/movement'
27
- export * from './pallet/pallet'
28
- export * from './pallet-count/pallet-count'
29
- export * from './pallet-history/pallet-history'
30
- export * from './warehouse/warehouse'
31
- export * from './reduced-inventory-history/reduced-inventory-history'
32
- export * from './tote/tote'
33
-
34
- /* EXPORT TYPES */
35
- export * from './inventory/inventory-types'
36
- export * from './inventory/inventory-types'
37
- export * from './inventory-item/inventory-item'
38
- export * from './inventory-item-change/inventory-item-change'
39
- export * from './inventory-change/inventory-change-types'
40
- export * from './inventory-history/inventory-history-types'
41
- export * from './location/location-types'
42
- export * from './movement/movement-types'
43
- export * from './pallet/pallet-types'
44
- export * from './pallet-count/pallet-count-types'
45
- export * from './pallet-history/pallet-history-types'
46
- export * from './warehouse/warehouse-types'
47
- export * from './tote/tote-types'
48
-
49
- export const entities = [
50
- ...InventoryEntities,
51
- ...InventoryChangeEntities,
52
- ...InventoryHistoryEntities,
53
- ...InventoryItemEntities,
54
- ...InventoryItemChangeEntities,
55
- ...LocationEntities,
56
- ...MovementEntities,
57
- ...PalletEntities,
58
- ...PalletCountEntities,
59
- ...PalletHistoryEntities,
60
- ...WarehouseEntities,
61
- ...ReducedInventoryHistoryEntities,
62
- ...ToteEntities
63
- ]
64
-
65
- export const schema = {
66
- resolverClasses: [
67
- ...InventoryResolvers,
68
- ...InventoryChangeResolvers,
69
- ...InventoryHistoryResvolers,
70
- ...InventoryItemResolvers,
71
- ...InventoryItemChangeResolvers,
72
- ...LocationResolvers,
73
- ...MovementResolvers,
74
- ...PalletResolvers,
75
- ...PalletCountResolvers,
76
- ...PalletHistoryResolvers,
77
- ...WarehouseResolvers,
78
- ...ToteResolvers
79
- ]
80
- }
@@ -1,6 +0,0 @@
1
- import { Inventory } from './inventory'
2
- import { InventoryMutation } from './inventory-mutation'
3
- import { InventoryQuery } from './inventory-query'
4
-
5
- export const entities = [Inventory]
6
- export const resolvers = [InventoryQuery, InventoryMutation]