@things-factory/worksheet-base 4.3.89 → 4.3.94-alpha.1
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/dist-server/controllers/ecommerce/ecommerce-controller.js +1 -1
- package/dist-server/controllers/ecommerce/ecommerce-controller.js.map +1 -1
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +87 -71
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js +2 -4
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/loading-worksheet-controller.js +10 -4
- package/dist-server/controllers/outbound/loading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +47 -33
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +78 -48
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js +12 -14
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/vas/vas-worksheet-controller.js +1 -2
- package/dist-server/controllers/vas/vas-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +3 -8
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/entities/index.js +3 -2
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +29 -62
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js +6 -0
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js +1 -2
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js +6 -6
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js +67 -28
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js +23 -8
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js +30 -7
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js +23 -8
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js +25 -8
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +60 -12
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js +51 -25
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +37 -29
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +132 -118
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +3 -2
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js +6 -4
- package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js +39 -14
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/transfer.js +9 -9
- package/dist-server/graphql/resolvers/worksheet/transfer.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js +17 -17
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js +4 -4
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/index.js +1 -0
- package/dist-server/graphql/types/worksheet-detail/index.js.map +1 -1
- package/dist-server/utils/inventory-util.js +1 -98
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +17 -17
- package/server/controllers/ecommerce/ecommerce-controller.ts +1 -1
- package/server/controllers/inbound/unloading-worksheet-controller.ts +102 -84
- package/server/controllers/inspect/cycle-count-worksheet-controller.ts +2 -4
- package/server/controllers/outbound/loading-worksheet-controller.ts +9 -3
- package/server/controllers/outbound/packing-worksheet-controller.ts +56 -45
- package/server/controllers/outbound/picking-worksheet-controller.ts +98 -66
- package/server/controllers/outbound/sorting-worksheet-controller.ts +12 -12
- package/server/controllers/vas/vas-worksheet-controller.ts +2 -2
- package/server/controllers/worksheet-controller.ts +18 -23
- package/server/entities/index.ts +2 -2
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +29 -63
- package/server/graphql/resolvers/worksheet/batch-picking-worksheet.ts +6 -0
- package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +1 -2
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +2 -2
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +3 -1
- package/server/graphql/resolvers/worksheet/loading/complete-loading.ts +77 -33
- package/server/graphql/resolvers/worksheet/packing/activate-packing.ts +26 -9
- package/server/graphql/resolvers/worksheet/packing/complete-packing.ts +34 -9
- package/server/graphql/resolvers/worksheet/packing/packing.ts +26 -9
- package/server/graphql/resolvers/worksheet/packing/scan-product-packing.ts +28 -9
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +69 -13
- package/server/graphql/resolvers/worksheet/picking/activate-picking.ts +60 -30
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +46 -40
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +142 -131
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +3 -2
- package/server/graphql/resolvers/worksheet/proceed-extra-products.ts +5 -4
- package/server/graphql/resolvers/worksheet/putaway/complete-putaway.ts +45 -15
- package/server/graphql/resolvers/worksheet/transfer.ts +18 -16
- package/server/graphql/resolvers/worksheet/vas-transactions/common-utils.ts +3 -2
- package/server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.ts +4 -1
- package/server/graphql/types/worksheet-detail/index.ts +1 -0
- package/server/utils/inventory-util.ts +1 -126
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntityManager } from 'typeorm'
|
|
2
2
|
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
3
|
+
import { ApplicationType, User } from '@things-factory/auth-base'
|
|
4
4
|
import { Bizplace, getMyBizplace } from '@things-factory/biz-base'
|
|
5
5
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
6
6
|
import { OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
@@ -46,48 +46,54 @@ export async function completeBatchPicking(
|
|
|
46
46
|
.filter(wsd => wsd.status != 'MISSING')
|
|
47
47
|
.map((wsd: WorksheetDetail) => wsd.targetInventory)
|
|
48
48
|
|
|
49
|
-
const
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const map = new Map()
|
|
59
|
-
for (const releaseGood of releaseGoods) {
|
|
60
|
-
if (!map.has(releaseGood.id)) {
|
|
61
|
-
map.set(releaseGood.id, true)
|
|
62
|
-
uniqueReleaseGoods.push({ ...releaseGood })
|
|
63
|
-
}
|
|
49
|
+
const releaseGoods: ReleaseGood[] = worksheetDetails.map(
|
|
50
|
+
worksheetDetail => worksheetDetail.targetInventory && worksheetDetail.targetInventory.releaseGood
|
|
51
|
+
)
|
|
52
|
+
const uniqueReleaseGoods: ReleaseGood[] = []
|
|
53
|
+
const map = new Map()
|
|
54
|
+
for (const releaseGood of releaseGoods) {
|
|
55
|
+
if (!map.has(releaseGood.id)) {
|
|
56
|
+
map.set(releaseGood.id, true)
|
|
57
|
+
uniqueReleaseGoods.push({ ...releaseGood })
|
|
64
58
|
}
|
|
59
|
+
}
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
61
|
+
await Promise.all(
|
|
62
|
+
uniqueReleaseGoods.map(async releaseGood => {
|
|
63
|
+
let foundReleaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
64
|
+
where: { id: releaseGood.id },
|
|
65
|
+
relations: ['orderProducts', 'orderProducts.product']
|
|
66
|
+
})
|
|
67
|
+
const orderSource: string = foundReleaseGood.source
|
|
68
|
+
switch (orderSource) {
|
|
69
|
+
case ApplicationType.SELLERCRAFT:
|
|
70
|
+
const sellercraft: Sellercraft = await tx
|
|
71
|
+
.getRepository(Sellercraft)
|
|
72
|
+
.findOne({ domain: worksheet.bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
73
|
+
|
|
74
|
+
if (sellercraft) {
|
|
75
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
76
|
+
if (!foundReleaseGood?.packageId) {
|
|
77
|
+
foundReleaseGood = await sellercraftCtrl.packOrder(sellercraft, foundReleaseGood)
|
|
78
|
+
if (foundReleaseGood?.packageId) {
|
|
79
|
+
await tx
|
|
80
|
+
.getRepository(ReleaseGood)
|
|
81
|
+
.update(
|
|
82
|
+
{ id: foundReleaseGood.id },
|
|
83
|
+
{ packageId: foundReleaseGood.packageId, updater: foundReleaseGood.updater }
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
sellercraftCtrl.initiateOrderShipment(sellercraft, foundReleaseGood)
|
|
84
89
|
}
|
|
85
|
-
|
|
90
|
+
break
|
|
86
91
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
default:
|
|
93
|
+
break
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
)
|
|
91
97
|
|
|
92
98
|
const pickPackTargetInventories: OrderInventory[] = targetInventories
|
|
93
99
|
.filter(targetInventory => targetInventory.releaseGood.packingOption)
|
|
@@ -112,7 +118,7 @@ export async function completeBatchPicking(
|
|
|
112
118
|
})
|
|
113
119
|
|
|
114
120
|
// loop to generate packing worksheet
|
|
115
|
-
for (
|
|
121
|
+
for (let i: number = 0; i < uniqueRoNo.length; i++) {
|
|
116
122
|
const releaseGoodNo: string = uniqueRoNo[i]
|
|
117
123
|
const packingWSCtrl: PackingWorksheetController = new PackingWorksheetController(tx, domain, user)
|
|
118
124
|
await packingWSCtrl.generatePackingWorksheet(releaseGoodNo)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntityManager, getManager } from 'typeorm'
|
|
2
2
|
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
3
|
+
import { ApplicationType, User } from '@things-factory/auth-base'
|
|
4
4
|
import { Bizplace, ContactPoint, getMyBizplace } from '@things-factory/biz-base'
|
|
5
5
|
import { LastMileAPI, LastMileDelivery } from '@things-factory/integration-lmd'
|
|
6
6
|
import { MarketplaceStore, MarketplaceTransporter } from '@things-factory/integration-marketplace'
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
OrderProduct,
|
|
19
19
|
ReleaseGood
|
|
20
20
|
} from '@things-factory/sales-base'
|
|
21
|
-
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
22
21
|
import { Domain } from '@things-factory/shell'
|
|
23
22
|
|
|
24
23
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../../constants'
|
|
@@ -81,147 +80,159 @@ export async function completePicking(
|
|
|
81
80
|
|
|
82
81
|
await pickingWSCtrl.completePicking(releaseGoodNo)
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
83
|
+
const orderSource: string = releaseGood.source
|
|
84
|
+
switch (orderSource) {
|
|
85
|
+
case ApplicationType.SELLERCRAFT:
|
|
86
|
+
const sellercraft: Sellercraft = await tx
|
|
87
|
+
.getRepository(Sellercraft)
|
|
88
|
+
.findOne({ domain: releaseGood.bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
89
|
+
const initSCOrderShipment = async sellercraft => {
|
|
90
|
+
if (sellercraft) {
|
|
91
|
+
await getManager().transaction(async txMgr => {
|
|
92
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(txMgr, domain, user)
|
|
93
|
+
|
|
94
|
+
if (!releaseGood?.packageId) {
|
|
95
|
+
const orderProducts: OrderProduct[] = await tx.getRepository(OrderProduct).find({
|
|
96
|
+
where: { releaseGood },
|
|
97
|
+
relations: ['product', 'product.productDetails']
|
|
98
|
+
})
|
|
99
|
+
releaseGood = await sellercraftCtrl.packOrder(sellercraft, { ...releaseGood, orderProducts })
|
|
100
|
+
|
|
101
|
+
if (releaseGood?.packageId) {
|
|
102
|
+
await txMgr
|
|
103
|
+
.getRepository(ReleaseGood)
|
|
104
|
+
.update({ id: releaseGood.id }, { packageId: releaseGood.packageId, updater: releaseGood.updater })
|
|
105
|
+
}
|
|
102
106
|
}
|
|
103
|
-
}
|
|
104
107
|
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
await sellercraftCtrl.initiateOrderShipment(sellercraft, releaseGood)
|
|
109
|
+
})
|
|
110
|
+
}
|
|
107
111
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// asynchronouly call to initiate sellercraft order shipment/ RTS
|
|
111
|
-
initSCOrderShipment(sellercraft)
|
|
112
|
-
|
|
113
|
-
const companyDomain: Domain = releaseGood.bizplace.company.domain
|
|
114
|
-
let marketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
115
|
-
where: { orderNo: releaseGood.refNo, domain: companyDomain },
|
|
116
|
-
relations: [
|
|
117
|
-
'marketplaceStore',
|
|
118
|
-
'marketplaceOrderItems',
|
|
119
|
-
'marketplaceOrderItems.marketplaceOrderShippingItems',
|
|
120
|
-
'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping'
|
|
121
|
-
]
|
|
122
|
-
})
|
|
123
112
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
// asynchronouly call to initiate sellercraft order shipment/ RTS
|
|
114
|
+
initSCOrderShipment(sellercraft)
|
|
115
|
+
break
|
|
116
|
+
|
|
117
|
+
case ApplicationType.MMS:
|
|
118
|
+
const companyDomain: Domain = releaseGood.bizplace.company.domain
|
|
119
|
+
let marketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
120
|
+
where: { orderNo: releaseGood.refNo, domain: companyDomain },
|
|
121
|
+
relations: [
|
|
122
|
+
'marketplaceStore',
|
|
123
|
+
'marketplaceOrderItems',
|
|
124
|
+
'marketplaceOrderItems.marketplaceOrderShippingItems',
|
|
125
|
+
'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping'
|
|
126
|
+
]
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
if (marketplaceOrder) {
|
|
130
|
+
const marketplaceStore: MarketplaceStore = marketplaceOrder.marketplaceStore
|
|
131
|
+
let eTraxOption: boolean
|
|
132
|
+
|
|
133
|
+
if (marketplaceStore.isAutoUpdateShipment) {
|
|
134
|
+
const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
135
|
+
await ecommerceCtrl.createOrderComment(marketplaceStore, marketplaceOrder, ORDER_STATUS.PACKING)
|
|
136
|
+
}
|
|
127
137
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
if (!marketplaceOrder)
|
|
139
|
+
throw new Error('Failed to find ecommerce order, kindly contact our support team regarding this issue')
|
|
140
|
+
eTraxOption = marketplaceOrder?.marketplaceStore.eTrax
|
|
141
|
+
|
|
142
|
+
// if eTrax option is true
|
|
143
|
+
if (eTraxOption) {
|
|
144
|
+
const marketplaceOrderItems: MarketplaceOrderItem[] = marketplaceOrder.marketplaceOrderItems
|
|
145
|
+
|
|
146
|
+
// access every marketplaceOrderItems for shipping information you need
|
|
147
|
+
// trigger the controller from integration-lmd that trigger the API, build the parameters needed
|
|
148
|
+
// for etrax didn't support multi awb per order
|
|
149
|
+
const marketplaceOrderShippingItems: MarketplaceOrderShippingItem[] =
|
|
150
|
+
marketplaceOrderItems[0].marketplaceOrderShippingItems
|
|
151
|
+
const marketplaceOrderShipping: MarketplaceOrderShipping =
|
|
152
|
+
marketplaceOrderShippingItems[0].marketplaceOrderShipping
|
|
153
|
+
const lmd: LastMileDelivery = await tx.getRepository(LastMileDelivery).findOne({
|
|
154
|
+
where: {
|
|
155
|
+
domain,
|
|
156
|
+
platform: 'eTrax'
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
//Get which transporter to use
|
|
161
|
+
const marketplaceTransporter: MarketplaceTransporter = await tx
|
|
162
|
+
.getRepository(MarketplaceTransporter)
|
|
163
|
+
.findOne({
|
|
164
|
+
where: { marketplaceStore: marketplaceOrder.marketplaceStore },
|
|
165
|
+
relations: ['pickupTransporter', 'deliveryTransporter']
|
|
166
|
+
})
|
|
132
167
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
168
|
+
const resp = await LastMileAPI.createShipmentRequest(lmd, {
|
|
169
|
+
orderNo: marketplaceOrder.orderNo,
|
|
170
|
+
clientId: lmd.clientId,
|
|
171
|
+
clientType: lmd.clientType,
|
|
172
|
+
clientName: lmd.clientName,
|
|
173
|
+
transporterId: marketplaceTransporter.pickupTransporter.transporterId,
|
|
174
|
+
pickupName: warehouseContactPoint.name,
|
|
175
|
+
pickupAddress1: warehouseContactPoint.address,
|
|
176
|
+
pickupAddress2: warehouseContactPoint.address2,
|
|
177
|
+
pickupPostcode: warehouseContactPoint.postCode,
|
|
178
|
+
pickupState: warehouseContactPoint.state,
|
|
179
|
+
pickupCity: warehouseContactPoint.city,
|
|
180
|
+
pickupPhone: warehouseContactPoint.phone,
|
|
181
|
+
pickupEmail: warehouseContactPoint.email,
|
|
182
|
+
name: marketplaceOrderShipping?.attentionTo ? marketplaceOrderShipping.attentionTo.trim() : '',
|
|
183
|
+
address1: marketplaceOrderShipping?.address1 ? marketplaceOrderShipping?.address1.trim() : '-',
|
|
184
|
+
address2: marketplaceOrderShipping?.address2 ? marketplaceOrderShipping?.address2.trim() : '-',
|
|
185
|
+
postCode: marketplaceOrderShipping?.postCode ? marketplaceOrderShipping?.postCode.trim() : '',
|
|
186
|
+
city: marketplaceOrderShipping?.city ? marketplaceOrderShipping?.city.trim() : '',
|
|
187
|
+
state: marketplaceOrderShipping?.state ? marketplaceOrderShipping?.state.trim() : '',
|
|
188
|
+
phone: marketplaceOrderShipping.phone1 || '',
|
|
189
|
+
email: marketplaceOrderShipping.email || '',
|
|
190
|
+
attentionTo: marketplaceOrderShipping.attentionTo,
|
|
191
|
+
quantity: marketplaceOrderItems.length
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
const delay = (ms: number) => {
|
|
195
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
|
152
196
|
}
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
//Get which transporter to use
|
|
156
|
-
const marketplaceTransporter: MarketplaceTransporter = await tx.getRepository(MarketplaceTransporter).findOne({
|
|
157
|
-
where: { marketplaceStore: marketplaceOrder.marketplaceStore },
|
|
158
|
-
relations: ['pickupTransporter', 'deliveryTransporter']
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
const resp = await LastMileAPI.createShipmentRequest(lmd, {
|
|
162
|
-
orderNo: marketplaceOrder.orderNo,
|
|
163
|
-
clientId: lmd.clientId,
|
|
164
|
-
clientType: lmd.clientType,
|
|
165
|
-
clientName: lmd.clientName,
|
|
166
|
-
transporterId: marketplaceTransporter.pickupTransporter.transporterId,
|
|
167
|
-
pickupName: warehouseContactPoint.name,
|
|
168
|
-
pickupAddress1: warehouseContactPoint.address,
|
|
169
|
-
pickupAddress2: warehouseContactPoint.address2,
|
|
170
|
-
pickupPostcode: warehouseContactPoint.postCode,
|
|
171
|
-
pickupState: warehouseContactPoint.state,
|
|
172
|
-
pickupCity: warehouseContactPoint.city,
|
|
173
|
-
pickupPhone: warehouseContactPoint.phone,
|
|
174
|
-
pickupEmail: warehouseContactPoint.email,
|
|
175
|
-
name: marketplaceOrderShipping?.attentionTo ? marketplaceOrderShipping.attentionTo.trim() : '',
|
|
176
|
-
address1: marketplaceOrderShipping?.address1 ? marketplaceOrderShipping?.address1.trim() : '-',
|
|
177
|
-
address2: marketplaceOrderShipping?.address2 ? marketplaceOrderShipping?.address2.trim() : '-',
|
|
178
|
-
postCode: marketplaceOrderShipping?.postCode ? marketplaceOrderShipping?.postCode.trim() : '',
|
|
179
|
-
city: marketplaceOrderShipping?.city ? marketplaceOrderShipping?.city.trim() : '',
|
|
180
|
-
state: marketplaceOrderShipping?.state ? marketplaceOrderShipping?.state.trim() : '',
|
|
181
|
-
phone: marketplaceOrderShipping.phone1 || '',
|
|
182
|
-
email: marketplaceOrderShipping.email || '',
|
|
183
|
-
attentionTo: marketplaceOrderShipping.attentionTo,
|
|
184
|
-
quantity: marketplaceOrderItems.length
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
const delay = (ms: number) => {
|
|
188
|
-
return new Promise(resolve => setTimeout(resolve, ms))
|
|
189
|
-
}
|
|
190
197
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
198
|
+
if (resp.Status === 'SUCCESS') {
|
|
199
|
+
//Success
|
|
200
|
+
let awbObtained = false
|
|
201
|
+
let retry = 0
|
|
202
|
+
while (!awbObtained) {
|
|
203
|
+
const marketplaceOrder2: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
|
|
204
|
+
where: { releaseOrderId: releaseGood.id },
|
|
205
|
+
relations: [
|
|
206
|
+
'marketplaceStore',
|
|
207
|
+
'marketplaceOrderItems',
|
|
208
|
+
'marketplaceOrderItems.marketplaceOrderShippingItems',
|
|
209
|
+
'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping'
|
|
210
|
+
]
|
|
211
|
+
})
|
|
212
|
+
const orderShipping =
|
|
213
|
+
marketplaceOrder2.marketplaceOrderItems[0].marketplaceOrderShippingItems[0].marketplaceOrderShipping
|
|
214
|
+
if (orderShipping?.airwayBill) {
|
|
215
|
+
awbObtained = true
|
|
216
|
+
}
|
|
217
|
+
await delay(5000)
|
|
218
|
+
//Timeout after 15sec
|
|
219
|
+
if (++retry > 3) {
|
|
220
|
+
break
|
|
221
|
+
}
|
|
214
222
|
}
|
|
223
|
+
} else {
|
|
224
|
+
if (resp?.AWBurl && resp?.TrackingNo)
|
|
225
|
+
await tx
|
|
226
|
+
.getRepository(MarketplaceOrderShipping)
|
|
227
|
+
.update({ id: marketplaceOrderShipping.id }, { airwayBill: resp.AWBurl, trackingNo: resp.TrackingNo })
|
|
228
|
+
else throw resp
|
|
215
229
|
}
|
|
216
|
-
} else {
|
|
217
|
-
if (resp?.AWBurl && resp?.TrackingNo)
|
|
218
|
-
await tx
|
|
219
|
-
.getRepository(MarketplaceOrderShipping)
|
|
220
|
-
.update({ id: marketplaceOrderShipping.id }, { airwayBill: resp.AWBurl, trackingNo: resp.TrackingNo })
|
|
221
|
-
else throw resp
|
|
222
230
|
}
|
|
223
231
|
}
|
|
224
|
-
|
|
232
|
+
break
|
|
233
|
+
|
|
234
|
+
default:
|
|
235
|
+
break
|
|
225
236
|
}
|
|
226
237
|
|
|
227
238
|
if (releaseGood.packingOption) {
|
|
@@ -76,6 +76,7 @@ export async function pickingWorksheet(
|
|
|
76
76
|
.leftJoinAndSelect('T_INV.binLocation', 'BIN_LOC')
|
|
77
77
|
.leftJoinAndSelect('T_INV.inventory', 'INV')
|
|
78
78
|
.leftJoinAndSelect('T_INV.product', 'PROD')
|
|
79
|
+
.leftJoinAndSelect('T_INV.productDetail', 'PROD_DET')
|
|
79
80
|
.leftJoinAndSelect('INV.location', 'LOC')
|
|
80
81
|
|
|
81
82
|
if (locationSortingRules?.length > 0) {
|
|
@@ -114,8 +115,8 @@ export async function pickingWorksheet(
|
|
|
114
115
|
const inventoryChangesCount: number = await tx.getRepository(InventoryChange).count({
|
|
115
116
|
where: {
|
|
116
117
|
inventory: inventory.id,
|
|
117
|
-
status:
|
|
118
|
-
transactionType:
|
|
118
|
+
status: 'PENDING',
|
|
119
|
+
transactionType: 'MISSING'
|
|
119
120
|
},
|
|
120
121
|
relations: ['inventory', 'product']
|
|
121
122
|
})
|
|
@@ -73,7 +73,7 @@ export const proceedExtraProductsResolver = {
|
|
|
73
73
|
if (editedApprovedProducts?.length > 0) {
|
|
74
74
|
editedApprovedProducts.map((editedApprovedProd: OrderProduct) => {
|
|
75
75
|
const selectedOrderProduct: OrderProduct = storedOrderProducts.find(
|
|
76
|
-
(op: OrderProduct) => op.id === editedApprovedProd.
|
|
76
|
+
(op: OrderProduct) => op.productDetail.id === editedApprovedProd.productDetailId
|
|
77
77
|
)
|
|
78
78
|
|
|
79
79
|
updatedOrderProducts.push({
|
|
@@ -115,7 +115,7 @@ export const proceedExtraProductsResolver = {
|
|
|
115
115
|
if (addedApprovedProducts?.length > 0) {
|
|
116
116
|
addedApprovedProducts.map((addedApprovedProd: OrderProduct) => {
|
|
117
117
|
const selectedOrderProduct: OrderProduct = storedOrderProducts.find(
|
|
118
|
-
(op: OrderProduct) => op.
|
|
118
|
+
(op: OrderProduct) => op.productDetailId === addedApprovedProd.productDetailId
|
|
119
119
|
)
|
|
120
120
|
updatedOrderProducts.push({
|
|
121
121
|
...selectedOrderProduct,
|
|
@@ -173,7 +173,7 @@ export const proceedExtraProductsResolver = {
|
|
|
173
173
|
if (editedRejectedProducts?.length > 0) {
|
|
174
174
|
editedRejectedProducts = editedRejectedProducts.map((editedRejectProduct: OrderProduct) => {
|
|
175
175
|
const selectedOrderProduct: OrderProduct = storedOrderProducts.find(
|
|
176
|
-
(op: OrderProduct) => op.id === editedRejectProduct.
|
|
176
|
+
(op: OrderProduct) => op.productDetail.id === editedRejectProduct.productDetailId
|
|
177
177
|
)
|
|
178
178
|
|
|
179
179
|
return {
|
|
@@ -194,7 +194,8 @@ export const proceedExtraProductsResolver = {
|
|
|
194
194
|
let deleteOrderProducts: OrderProduct[] = []
|
|
195
195
|
addedRejectedProducts.map(rejectedOp => {
|
|
196
196
|
const selectedOrderProduct: OrderProduct[] = storedOrderProducts.find(
|
|
197
|
-
(op: OrderProduct) => op.id === rejectedOp.id
|
|
197
|
+
//(op: OrderProduct) => op.id === rejectedOp.id
|
|
198
|
+
(op: OrderProduct) => op.productDetailId === rejectedOp.productDetailId
|
|
198
199
|
)
|
|
199
200
|
deleteOrderProducts.push(selectedOrderProduct)
|
|
200
201
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntityManager } from 'typeorm'
|
|
2
2
|
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
3
|
+
import { ApplicationType, User } from '@things-factory/auth-base'
|
|
4
4
|
import { MarketplaceStore } from '@things-factory/integration-marketplace'
|
|
5
5
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
6
6
|
import { ArrivalNotice } from '@things-factory/sales-base'
|
|
@@ -33,24 +33,54 @@ export const completePutawayResolver = {
|
|
|
33
33
|
// search for any active marketplace connection
|
|
34
34
|
const companyDomain: Domain = arrivalNotice.bizplace.company.domain
|
|
35
35
|
const customerDomain: Domain = arrivalNotice.bizplace.domain
|
|
36
|
-
const marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
|
|
37
|
-
where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
|
|
38
|
-
relations: ['marketplaceDistributors']
|
|
39
|
-
})
|
|
40
36
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
.
|
|
37
|
+
const orderSource: string = arrivalNotice.source
|
|
38
|
+
switch (orderSource) {
|
|
39
|
+
case ApplicationType.SELLERCRAFT:
|
|
40
|
+
const sellercraft: Sellercraft = await tx
|
|
41
|
+
.getRepository(Sellercraft)
|
|
42
|
+
.findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
if (sellercraft) {
|
|
45
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
46
|
+
await sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
|
|
47
|
+
}
|
|
48
|
+
break
|
|
49
|
+
|
|
50
|
+
case ApplicationType.MMS:
|
|
51
|
+
const marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
|
|
52
|
+
where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
|
|
53
|
+
relations: ['marketplaceDistributors']
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
|
|
57
|
+
const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
58
|
+
await ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
|
|
59
|
+
}
|
|
60
|
+
break
|
|
49
61
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
await ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
|
|
62
|
+
default:
|
|
63
|
+
break
|
|
53
64
|
}
|
|
65
|
+
|
|
66
|
+
// const marketplaceStores: MarketplaceStore[] = await tx.getRepository(MarketplaceStore).find({
|
|
67
|
+
// where: { domain: companyDomain, status: 'ACTIVE', isAutoUpdateStockQty: true },
|
|
68
|
+
// relations: ['marketplaceDistributors']
|
|
69
|
+
// })
|
|
70
|
+
|
|
71
|
+
// const sellercraft: Sellercraft = await tx
|
|
72
|
+
// .getRepository(Sellercraft)
|
|
73
|
+
// .findOne({ domain: customerDomain, status: SellercraftStatus.ACTIVE })
|
|
74
|
+
|
|
75
|
+
// if (sellercraft) {
|
|
76
|
+
// const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
77
|
+
// await sellercraftCtrl.registerProductInbound(sellercraft, arrivalNotice)
|
|
78
|
+
// }
|
|
79
|
+
|
|
80
|
+
// if (marketplaceStores?.length && marketplaceStores.some(store => store.isAutoUpdateStockQty)) {
|
|
81
|
+
// const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
|
|
82
|
+
// await ecommerceCtrl.updateProductVariationStock(marketplaceStores, arrivalNotice.orderProducts, companyDomain)
|
|
83
|
+
// }
|
|
54
84
|
}
|
|
55
85
|
}
|
|
56
86
|
|
|
@@ -1,38 +1,36 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { User } from '@things-factory/auth-base'
|
|
2
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
+
import { ORDER_PRODUCT_STATUS, OrderInventory } from '@things-factory/sales-base'
|
|
3
6
|
import { Domain } from '@things-factory/shell'
|
|
4
|
-
import { OrderInventory, ORDER_PRODUCT_STATUS } from '@things-factory/sales-base'
|
|
5
7
|
import {
|
|
6
8
|
Inventory,
|
|
7
|
-
InventoryHistory,
|
|
8
|
-
InventoryNoGenerator,
|
|
9
9
|
INVENTORY_STATUS,
|
|
10
|
-
INVENTORY_TRANSACTION_TYPE
|
|
10
|
+
INVENTORY_TRANSACTION_TYPE,
|
|
11
|
+
InventoryHistory,
|
|
12
|
+
InventoryNoGenerator
|
|
11
13
|
} from '@things-factory/warehouse-base'
|
|
12
|
-
|
|
14
|
+
|
|
13
15
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
14
16
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
15
17
|
|
|
16
18
|
export const transfer = {
|
|
17
19
|
async transfer(_: any, { palletId, toPalletId, qty }, context: any) {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
domain,
|
|
21
|
-
bizplace,
|
|
22
|
-
user
|
|
23
|
-
}: { tx: EntityManager; domain: Domain; bizplace: Bizplace; user: User } = context.state
|
|
20
|
+
const { tx, domain, bizplace, user }: { tx: EntityManager; domain: Domain; bizplace: Bizplace; user: User } =
|
|
21
|
+
context.state
|
|
24
22
|
|
|
25
23
|
// 1. get to inventory
|
|
26
24
|
let toInventory: Inventory = await tx.getRepository(Inventory).findOne({
|
|
27
25
|
where: { domain: domain, palletId: toPalletId },
|
|
28
|
-
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
26
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
29
27
|
})
|
|
30
28
|
if (!toInventory) throw new Error(`to pallet doesn't exists`)
|
|
31
29
|
|
|
32
30
|
// 2. get from inventory
|
|
33
31
|
let fromInventory: Inventory = await tx.getRepository(Inventory).findOne({
|
|
34
32
|
where: { domain: domain, palletId },
|
|
35
|
-
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
33
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
36
34
|
})
|
|
37
35
|
if (!fromInventory) throw new Error(`from pallet doesn't exists`)
|
|
38
36
|
if (toInventory.batchId !== fromInventory.batchId) throw new Error(`Can't transfer to different batch`)
|
|
@@ -74,6 +72,7 @@ export const transfer = {
|
|
|
74
72
|
domain: domain,
|
|
75
73
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
76
74
|
product: toInventory.product,
|
|
75
|
+
productDetail: toInventory.productDetail,
|
|
77
76
|
warehouse: toInventory.warehouse,
|
|
78
77
|
location: toInventory.location,
|
|
79
78
|
seq: toInventory.lastSeq,
|
|
@@ -97,7 +96,7 @@ export const transfer = {
|
|
|
97
96
|
|
|
98
97
|
fromInventory = await tx.getRepository(Inventory).findOne({
|
|
99
98
|
where: { id: fromInventory.id },
|
|
100
|
-
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
99
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
101
100
|
})
|
|
102
101
|
|
|
103
102
|
// - add inventory history
|
|
@@ -105,6 +104,7 @@ export const transfer = {
|
|
|
105
104
|
...fromInventory,
|
|
106
105
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
107
106
|
product: fromInventory.product,
|
|
107
|
+
productDetail: fromInventory.productDetail,
|
|
108
108
|
warehouse: fromInventory.warehouse,
|
|
109
109
|
location: fromInventory.location,
|
|
110
110
|
seq: fromInventory.lastSeq,
|
|
@@ -131,7 +131,7 @@ export const transfer = {
|
|
|
131
131
|
|
|
132
132
|
toInventory = await tx.getRepository(Inventory).findOne({
|
|
133
133
|
where: { id: toInventory.id },
|
|
134
|
-
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
134
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
135
135
|
})
|
|
136
136
|
// - add inventory history
|
|
137
137
|
delete toInventory.id
|
|
@@ -140,6 +140,7 @@ export const transfer = {
|
|
|
140
140
|
domain,
|
|
141
141
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
142
142
|
product: toInventory.product,
|
|
143
|
+
productDetail: toInventory.productDetail,
|
|
143
144
|
warehouse: toInventory.warehouse,
|
|
144
145
|
location: toInventory.location,
|
|
145
146
|
seq: toInventory.lastSeq,
|
|
@@ -157,7 +158,7 @@ export const transfer = {
|
|
|
157
158
|
|
|
158
159
|
fromInventory = await tx.getRepository(Inventory).findOne({
|
|
159
160
|
where: { id: fromInventory.id },
|
|
160
|
-
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
161
|
+
relations: ['bizplace', 'product', 'productDetail', 'warehouse', 'location']
|
|
161
162
|
})
|
|
162
163
|
|
|
163
164
|
// - add inventory history
|
|
@@ -165,6 +166,7 @@ export const transfer = {
|
|
|
165
166
|
...fromInventory,
|
|
166
167
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
167
168
|
product: fromInventory.product,
|
|
169
|
+
productDetail: fromInventory.productDetail,
|
|
168
170
|
warehouse: fromInventory.warehouse,
|
|
169
171
|
location: fromInventory.location,
|
|
170
172
|
seq: fromInventory.lastSeq,
|