@things-factory/warehouse-base 4.3.76 → 4.3.78
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/service/inventory/inventory-query.js +65 -166
- package/dist-server/service/inventory/inventory-query.js.map +1 -1
- package/dist-server/service/inventory/inventory.js +35 -35
- package/dist-server/service/inventory-change/inventory-change-mutation.js +209 -203
- package/dist-server/service/inventory-change/inventory-change-mutation.js.map +1 -1
- package/dist-server/service/location/location-query.js +1 -1
- package/dist-server/service/location/location-query.js.map +1 -1
- package/dist-server/service/location/location.js +10 -10
- package/dist-server/service/warehouse/warehouse.js +7 -7
- package/package.json +8 -8
- package/server/service/inventory/inventory-query.ts +72 -219
- package/server/service/inventory/inventory.ts +35 -35
- package/server/service/inventory-change/inventory-change-mutation.ts +237 -231
- package/server/service/location/location-query.ts +1 -1
- package/server/service/location/location.ts +10 -10
- package/server/service/warehouse/warehouse.ts +7 -7
|
@@ -137,285 +137,291 @@ export class InventoryChangeMutation {
|
|
|
137
137
|
@Ctx() context: any
|
|
138
138
|
) {
|
|
139
139
|
const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
|
|
140
|
+
try {
|
|
140
141
|
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
const _createRecords = []
|
|
143
|
+
const _updateRecords = []
|
|
143
144
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
for (let i = 0; i < patches.length; i++) {
|
|
146
|
+
let foundExistingPallet = await tx.getRepository(Inventory).createQueryBuilder('iv')
|
|
147
|
+
.where('iv.domain_id = :domain_id', { domain_id: domain.id })
|
|
148
|
+
.andWhere('(iv.pallet_id = :pallet_id or iv.id = :id)', { pallet_id: patches[i]?.palletId, id: patches[i]?.id })
|
|
149
|
+
.getOne()
|
|
148
150
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
//remove any unchanged records
|
|
152
|
+
for (const [key, value] of Object.entries(patches[i])) {
|
|
153
|
+
if (foundExistingPallet && key != 'id' && key != 'cuFlag' && value == foundExistingPallet[key]) {
|
|
154
|
+
delete patches[i][key]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// skip process when no processable data found
|
|
159
|
+
if (Object.keys(patches[i]).filter(x => x != 'id' && x != 'cuFlag').length == 0) {
|
|
160
|
+
continue
|
|
161
|
+
}
|
|
154
162
|
|
|
155
|
-
|
|
163
|
+
const invLockedQty: number = foundExistingPallet?.lockedQty == null ? 0 : foundExistingPallet?.lockedQty
|
|
156
164
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
165
|
+
if (patches[i]?.qty < invLockedQty) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
'Adjusted qty value should not be lower than released qty, kindly contact our support for assistance'
|
|
168
|
+
)
|
|
169
|
+
}
|
|
162
170
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
171
|
+
if (foundExistingPallet) {
|
|
172
|
+
delete patches[i].serialNumbers
|
|
173
|
+
_updateRecords.push(patches[i])
|
|
174
|
+
} else {
|
|
175
|
+
_createRecords.push(patches[i])
|
|
176
|
+
}
|
|
168
177
|
}
|
|
169
|
-
}
|
|
170
178
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
const inventoryChangeRepo = tx.getRepository(InventoryChange)
|
|
180
|
+
const inventoryItemChangeRepo = tx.getRepository(InventoryItemChange)
|
|
181
|
+
if (_createRecords.length > 0) {
|
|
182
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
183
|
+
const newRecord = _createRecords[i]
|
|
176
184
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
var location = await tx.getRepository(Location).findOne({
|
|
186
|
+
where: { id: newRecord.location.id },
|
|
187
|
+
relations: ['warehouse']
|
|
188
|
+
})
|
|
189
|
+
newRecord.location = location
|
|
190
|
+
newRecord.zone = location.zone
|
|
191
|
+
newRecord.warehouse = location.warehouse
|
|
184
192
|
|
|
185
|
-
|
|
193
|
+
newRecord.bizplace = await tx.getRepository(Bizplace).findOne(newRecord.bizplace.id)
|
|
186
194
|
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
var product: Product = await tx.getRepository(Product).findOne(newRecord.product.id)
|
|
196
|
+
newRecord.product = product
|
|
189
197
|
|
|
190
|
-
|
|
191
|
-
|
|
198
|
+
newRecord.status = 'PENDING'
|
|
199
|
+
newRecord.transactionType = 'NEW'
|
|
192
200
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
201
|
+
newRecord.expirationDate =
|
|
202
|
+
((newRecord?.expirationDate && new Date(newRecord.expirationDate).getFullYear()) || 0) < 2000
|
|
203
|
+
? null
|
|
204
|
+
: newRecord.expirationDate
|
|
197
205
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
const newInventoryChange: InventoryChange = await inventoryChangeRepo.save({
|
|
207
|
+
...newRecord,
|
|
208
|
+
id: undefined,
|
|
209
|
+
name: InventoryNoGenerator.inventoryName(),
|
|
210
|
+
domain: domain,
|
|
211
|
+
creator: user,
|
|
212
|
+
updater: user
|
|
213
|
+
})
|
|
206
214
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
215
|
+
if (newRecord?.serialNumbers) {
|
|
216
|
+
let serialNumbers: string = newRecord.serialNumbers
|
|
217
|
+
let newSerialNumbers: any = serialNumbers.split(',')
|
|
218
|
+
let inventoryItemChanges: InventoryItemChange[] = []
|
|
211
219
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
for (let i = 0; i < newSerialNumbers.length; i++) {
|
|
221
|
+
let newSerialNumber: string = newSerialNumbers[i]
|
|
222
|
+
let inventoryItemChange: any = {
|
|
223
|
+
serialNumber: newSerialNumber,
|
|
224
|
+
type: INVENTORY_ITEM_CHANGE_TYPE.NEW
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
inventoryItemChanges.push(inventoryItemChange)
|
|
217
228
|
}
|
|
218
229
|
|
|
219
|
-
|
|
230
|
+
newRecord.inventoryItemChangesJson = JSON.stringify(inventoryItemChanges)
|
|
220
231
|
}
|
|
221
232
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (inventoryItemChanges?.length != newRecord?.qty) {
|
|
230
|
-
throw new Error('Serial Numbers not tally with quantity')
|
|
233
|
+
// create new inventory items
|
|
234
|
+
if (newRecord?.inventoryItemChangesJson) {
|
|
235
|
+
const inventoryItemChanges: InventoryItemChange[] = JSON.parse(newRecord.inventoryItemChangesJson)
|
|
236
|
+
if (product?.isRequireSerialNumberScanningInbound) {
|
|
237
|
+
if (inventoryItemChanges?.length != newRecord?.qty) {
|
|
238
|
+
throw new Error('Serial Numbers not tally with quantity')
|
|
239
|
+
}
|
|
231
240
|
}
|
|
232
|
-
}
|
|
233
241
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
242
|
+
let newInventoryItemChanges: InventoryItemChange[] = []
|
|
243
|
+
|
|
244
|
+
inventoryItemChanges.map(inventoryItemChange => {
|
|
245
|
+
let newInventoryItemChange: InventoryItemChange = new InventoryItemChange()
|
|
246
|
+
newInventoryItemChange.name = InventoryNoGenerator.inventoryName()
|
|
247
|
+
newInventoryItemChange.serialNumber = inventoryItemChange.serialNumber
|
|
248
|
+
newInventoryItemChange.type = inventoryItemChange.type
|
|
249
|
+
newInventoryItemChange.status = newInventoryChange.status
|
|
250
|
+
newInventoryItemChange.inventoryItem =
|
|
251
|
+
newInventoryItemChange?.type == INVENTORY_ITEM_CHANGE_TYPE.NEW
|
|
252
|
+
? null
|
|
253
|
+
: newInventoryItemChange.inventoryItem
|
|
254
|
+
newInventoryItemChange.inventoryChange = newInventoryChange
|
|
255
|
+
newInventoryItemChange.domain = domain
|
|
256
|
+
newInventoryItemChange.creator = user
|
|
257
|
+
newInventoryItemChange.updater = user
|
|
258
|
+
|
|
259
|
+
newInventoryItemChanges.push(newInventoryItemChange)
|
|
260
|
+
})
|
|
253
261
|
|
|
254
|
-
|
|
262
|
+
await inventoryItemChangeRepo.save(newInventoryItemChanges)
|
|
263
|
+
}
|
|
255
264
|
}
|
|
256
265
|
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (_updateRecords.length > 0) {
|
|
260
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
261
|
-
const updateRecord = _updateRecords[i]
|
|
262
266
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
})
|
|
267
|
+
if (_updateRecords.length > 0) {
|
|
268
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
269
|
+
const updateRecord = _updateRecords[i]
|
|
267
270
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
where: { domain, id: updateRecord?.id },
|
|
271
|
+
let existingRecord = await tx.getRepository(Inventory).findOne({
|
|
272
|
+
where: { domain, palletId: updateRecord?.palletId },
|
|
271
273
|
relations: ['location', 'warehouse', 'product', 'bizplace']
|
|
272
274
|
})
|
|
273
|
-
}
|
|
274
275
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
updateRecord.zone = location.zone
|
|
282
|
-
updateRecord.warehouse = location.warehouse
|
|
283
|
-
}
|
|
276
|
+
if (!existingRecord) {
|
|
277
|
+
existingRecord = await tx.getRepository(Inventory).findOne({
|
|
278
|
+
where: { domain, id: updateRecord?.id },
|
|
279
|
+
relations: ['location', 'warehouse', 'product', 'bizplace']
|
|
280
|
+
})
|
|
281
|
+
}
|
|
284
282
|
|
|
285
|
-
|
|
286
|
-
|
|
283
|
+
if (!!updateRecord?.location?.id) {
|
|
284
|
+
var location = await tx.getRepository(Location).findOne({
|
|
285
|
+
where: { id: updateRecord.location.id },
|
|
286
|
+
relations: ['warehouse']
|
|
287
|
+
})
|
|
288
|
+
updateRecord.location = location
|
|
289
|
+
updateRecord.zone = location.zone
|
|
290
|
+
updateRecord.warehouse = location.warehouse
|
|
291
|
+
}
|
|
287
292
|
|
|
288
|
-
|
|
293
|
+
if (!!updateRecord?.bizplace?.id)
|
|
294
|
+
updateRecord.bizplace = await tx.getRepository(Bizplace).findOne(updateRecord.bizplace.id)
|
|
289
295
|
|
|
290
|
-
|
|
291
|
-
product = await tx.getRepository(Product).findOne(updateRecord.product.id)
|
|
292
|
-
updateRecord.product = product
|
|
293
|
-
} else {
|
|
294
|
-
product = existingRecord.product
|
|
295
|
-
}
|
|
296
|
+
let product: Product
|
|
296
297
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
if (!!updateRecord?.product?.id) {
|
|
299
|
+
product = await tx.getRepository(Product).findOne(updateRecord.product.id)
|
|
300
|
+
updateRecord.product = product
|
|
301
|
+
} else {
|
|
302
|
+
product = existingRecord.product
|
|
303
|
+
}
|
|
300
304
|
|
|
301
|
-
|
|
305
|
+
updateRecord.transactionType == 'MISSING'
|
|
306
|
+
? (updateRecord.transactionType = 'MISSING')
|
|
307
|
+
: (updateRecord.transactionType = 'CHANGES')
|
|
302
308
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
palletId: existingRecord.palletId,
|
|
310
|
-
...updateRecord,
|
|
311
|
-
id: undefined,
|
|
312
|
-
name: InventoryNoGenerator.inventoryName(),
|
|
313
|
-
inventory: existingRecord,
|
|
314
|
-
domain: domain,
|
|
315
|
-
creator: user,
|
|
316
|
-
updater: user
|
|
317
|
-
})
|
|
309
|
+
updateRecord.status = 'PENDING'
|
|
310
|
+
|
|
311
|
+
updateRecord.expirationDate =
|
|
312
|
+
((updateRecord?.expirationDate && new Date(updateRecord.expirationDate).getFullYear()) || 0) < 2000
|
|
313
|
+
? null
|
|
314
|
+
: updateRecord.expirationDate
|
|
318
315
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
316
|
+
const updatedInventoryChange: InventoryChange = await inventoryChangeRepo.save({
|
|
317
|
+
palletId: existingRecord.palletId,
|
|
318
|
+
...updateRecord,
|
|
319
|
+
id: undefined,
|
|
320
|
+
name: InventoryNoGenerator.inventoryName(),
|
|
321
|
+
inventory: existingRecord,
|
|
322
|
+
domain: domain,
|
|
323
|
+
creator: user,
|
|
324
|
+
updater: user
|
|
323
325
|
})
|
|
324
|
-
const inventoryItemChanges: InventoryItemChange[] = JSON.parse(updateRecord.inventoryItemChangesJson)
|
|
325
|
-
if (product?.isRequireSerialNumberScanningInbound) {
|
|
326
|
-
const combinedInventoryItems: any[] = [...originalInventoryItems, ...inventoryItemChanges]
|
|
327
|
-
let qty: number = updateRecord?.qty ? updateRecord.qty : existingRecord.qty
|
|
328
326
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
327
|
+
// create new inventory items
|
|
328
|
+
if (updateRecord?.inventoryItemChangesJson) {
|
|
329
|
+
const originalInventoryItems: InventoryItem[] = await tx.getRepository(InventoryItem).find({
|
|
330
|
+
where: { domain, inventory: existingRecord, status: Not('DELETED') }
|
|
331
|
+
})
|
|
332
|
+
const inventoryItemChanges: InventoryItemChange[] = JSON.parse(updateRecord.inventoryItemChangesJson)
|
|
333
|
+
if (product?.isRequireSerialNumberScanningInbound) {
|
|
334
|
+
// const combinedInventoryItems: any[] = [...originalInventoryItems, ...inventoryItemChanges]
|
|
335
|
+
let qty: number = updateRecord?.qty ? updateRecord.qty : existingRecord.qty
|
|
336
|
+
|
|
337
|
+
if (originalInventoryItems.length == 0) {
|
|
338
|
+
if (inventoryItemChanges.length !== qty) {
|
|
339
|
+
throw new Error('Serial Numbers not tally with quantity')
|
|
340
|
+
}
|
|
341
|
+
} else {
|
|
342
|
+
if (originalInventoryItems?.length - inventoryItemChanges.length !== qty) {
|
|
343
|
+
throw new Error('Serial Numbers not tally with quantity')
|
|
344
|
+
}
|
|
336
345
|
}
|
|
337
346
|
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
let newInventoryItemChanges: InventoryItemChange[] = []
|
|
341
|
-
|
|
342
|
-
inventoryItemChanges.map(inventoryItemChange => {
|
|
343
|
-
let newInventoryItemChange: InventoryItemChange = new InventoryItemChange()
|
|
344
|
-
newInventoryItemChange.name = InventoryNoGenerator.inventoryName()
|
|
345
|
-
newInventoryItemChange.serialNumber = inventoryItemChange.serialNumber
|
|
346
|
-
newInventoryItemChange.type = inventoryItemChange.type
|
|
347
|
-
newInventoryItemChange.status = updatedInventoryChange.status
|
|
348
|
-
newInventoryItemChange.inventory = updatedInventoryChange.inventory
|
|
349
|
-
newInventoryItemChange.inventoryItem =
|
|
350
|
-
newInventoryItemChange?.type == INVENTORY_ITEM_CHANGE_TYPE.NEW ? null : inventoryItemChange.inventoryItem
|
|
351
|
-
newInventoryItemChange.inventoryChange = updatedInventoryChange
|
|
352
|
-
newInventoryItemChange.domain = domain
|
|
353
|
-
newInventoryItemChange.creator = user
|
|
354
|
-
newInventoryItemChange.updater = user
|
|
355
|
-
|
|
356
|
-
newInventoryItemChanges.push(newInventoryItemChange)
|
|
357
|
-
})
|
|
358
347
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
348
|
+
let newInventoryItemChanges: InventoryItemChange[] = []
|
|
349
|
+
|
|
350
|
+
inventoryItemChanges.map(inventoryItemChange => {
|
|
351
|
+
let newInventoryItemChange: InventoryItemChange = new InventoryItemChange()
|
|
352
|
+
newInventoryItemChange.name = InventoryNoGenerator.inventoryName()
|
|
353
|
+
newInventoryItemChange.serialNumber = inventoryItemChange.serialNumber
|
|
354
|
+
newInventoryItemChange.type = inventoryItemChange.type
|
|
355
|
+
newInventoryItemChange.status = updatedInventoryChange.status
|
|
356
|
+
newInventoryItemChange.inventory = updatedInventoryChange.inventory
|
|
357
|
+
newInventoryItemChange.inventoryItem =
|
|
358
|
+
newInventoryItemChange?.type == INVENTORY_ITEM_CHANGE_TYPE.NEW ? null : inventoryItemChange.inventoryItem
|
|
359
|
+
newInventoryItemChange.inventoryChange = updatedInventoryChange
|
|
360
|
+
newInventoryItemChange.domain = domain
|
|
361
|
+
newInventoryItemChange.creator = user
|
|
362
|
+
newInventoryItemChange.updater = user
|
|
363
|
+
|
|
364
|
+
newInventoryItemChanges.push(newInventoryItemChange)
|
|
365
|
+
})
|
|
363
366
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
.createQueryBuilder('p')
|
|
367
|
-
.select('u.*')
|
|
368
|
-
.addSelect('r.*')
|
|
369
|
-
.innerJoin('p.roles', 'r')
|
|
370
|
-
.innerJoin('r.users', 'u')
|
|
371
|
-
.where('p.name = :name', { name: 'mutation' })
|
|
372
|
-
.andWhere('p.category = :category', { category: 'inventory' })
|
|
373
|
-
.andWhere('r.domain_id = :domainId', { domainId: domain.id })
|
|
374
|
-
.groupBy('u.id')
|
|
375
|
-
.addGroupBy('r.id')
|
|
376
|
-
.getRawMany()
|
|
377
|
-
|
|
378
|
-
if (_updateRecords.some(res => res.transactionType == 'MISSING')) {
|
|
379
|
-
if (notificationApprover?.length && context.header?.referer) {
|
|
380
|
-
const receivers: any[] = notificationApprover.map(user => user.id)
|
|
381
|
-
const msg = {
|
|
382
|
-
title: `Missing stock identified. Review this transaction in Inventory Adjustment Approval.`,
|
|
383
|
-
body: ``,
|
|
384
|
-
url: context.header.referer,
|
|
385
|
-
data: { url: context.header.referer }
|
|
367
|
+
await inventoryItemChangeRepo.save(newInventoryItemChanges)
|
|
368
|
+
}
|
|
386
369
|
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
390
|
-
*/
|
|
391
|
-
|
|
392
|
-
// await sendNotification({
|
|
393
|
-
// receivers,
|
|
394
|
-
// message: { ...msg }
|
|
395
|
-
// })
|
|
396
370
|
}
|
|
397
|
-
} else {
|
|
398
|
-
if (notificationApprover?.length && context.header?.referer) {
|
|
399
|
-
const receivers: any[] = notificationApprover.map(user => user.id)
|
|
400
|
-
const msg = {
|
|
401
|
-
title: `There is an inventory adjustment pending for approval, kindly review within 1 hour to avoid any operation conflict.`,
|
|
402
|
-
body: ``,
|
|
403
|
-
url: context.header.referer,
|
|
404
|
-
data: { url: context.header.referer }
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
409
|
-
*/
|
|
410
371
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
372
|
+
/**
|
|
373
|
+
* @notes Temporary off sendNotification due to suspect of causing wms down
|
|
374
|
+
*/
|
|
375
|
+
// const notificationApprover: any = await tx
|
|
376
|
+
// .getRepository(Privilege)
|
|
377
|
+
// .createQueryBuilder('p')
|
|
378
|
+
// .select('u.*')
|
|
379
|
+
// .addSelect('r.*')
|
|
380
|
+
// .innerJoin('p.roles', 'r')
|
|
381
|
+
// .innerJoin('r.users', 'u')
|
|
382
|
+
// .where('p.name = :name', { name: 'mutation' })
|
|
383
|
+
// .andWhere('p.category = :category', { category: 'inventory' })
|
|
384
|
+
// .andWhere('r.domain_id = :domainId', { domainId: domain.id })
|
|
385
|
+
// .groupBy('u.id')
|
|
386
|
+
// .addGroupBy('r.id')
|
|
387
|
+
// .getRawMany()
|
|
388
|
+
|
|
389
|
+
// if (_updateRecords.some(res => res.transactionType == 'MISSING')) {
|
|
390
|
+
// if (notificationApprover?.length && context.header?.referer) {
|
|
391
|
+
// const receivers: any[] = notificationApprover.map(user => user.id)
|
|
392
|
+
// const msg = {
|
|
393
|
+
// title: `Missing stock identified. Review this transaction in Inventory Adjustment Approval.`,
|
|
394
|
+
// body: ``,
|
|
395
|
+
// url: context.header.referer,
|
|
396
|
+
// data: { url: context.header.referer }
|
|
397
|
+
// }
|
|
398
|
+
// await sendNotification({
|
|
399
|
+
// receivers,
|
|
400
|
+
// message: { ...msg }
|
|
401
|
+
// })
|
|
402
|
+
// }
|
|
403
|
+
// } else {
|
|
404
|
+
// if (notificationApprover?.length && context.header?.referer) {
|
|
405
|
+
// const receivers: any[] = notificationApprover.map(user => user.id)
|
|
406
|
+
// const msg = {
|
|
407
|
+
// title: `There is an inventory adjustment pending for approval, kindly review within 1 hour to avoid any operation conflict.`,
|
|
408
|
+
// body: ``,
|
|
409
|
+
// url: context.header.referer,
|
|
410
|
+
// data: { url: context.header.referer }
|
|
411
|
+
// }
|
|
412
|
+
// await sendNotification({
|
|
413
|
+
// receivers,
|
|
414
|
+
// message: { ...msg }
|
|
415
|
+
// })
|
|
416
|
+
// }
|
|
417
|
+
// }
|
|
418
|
+
|
|
419
|
+
return true
|
|
420
|
+
|
|
421
|
+
} catch (error) {
|
|
422
|
+
throw error
|
|
416
423
|
}
|
|
417
424
|
|
|
418
|
-
return true
|
|
419
425
|
}
|
|
420
426
|
|
|
421
427
|
@Directive('@privilege(category: "inventory_adjustment_approval", privilege: "mutation")')
|
|
@@ -31,7 +31,7 @@ export class LocationQuery {
|
|
|
31
31
|
@Directive('@privilege(category: "warehouse", privilege: "query")')
|
|
32
32
|
@Query(returns => LocationList)
|
|
33
33
|
async pureLocations(@Args() params: ListParam, @Ctx() context: any): Promise<LocationList> {
|
|
34
|
-
const queryBuilder = getRepository(Location).createQueryBuilder()
|
|
34
|
+
const queryBuilder = getRepository(Location).createQueryBuilder('location')
|
|
35
35
|
buildQuery(queryBuilder, params, context)
|
|
36
36
|
const items = await queryBuilder.getRawMany()
|
|
37
37
|
const total = await queryBuilder.getCount()
|
|
@@ -105,16 +105,16 @@ export class Location {
|
|
|
105
105
|
|
|
106
106
|
constructor(obj?) {
|
|
107
107
|
if (obj) {
|
|
108
|
-
this.id = obj.
|
|
109
|
-
this.name = obj.
|
|
110
|
-
this.description = obj.
|
|
111
|
-
this.type = obj.
|
|
112
|
-
this.zone = obj.
|
|
113
|
-
this.row = obj.
|
|
114
|
-
this.column = obj.
|
|
115
|
-
this.shelf = obj.
|
|
116
|
-
this.status = obj.
|
|
117
|
-
this.updatedAt = obj.
|
|
108
|
+
this.id = obj.location_id
|
|
109
|
+
this.name = obj.location_name
|
|
110
|
+
this.description = obj.location_description
|
|
111
|
+
this.type = obj.location_type
|
|
112
|
+
this.zone = obj.location_zone
|
|
113
|
+
this.row = obj.location_row
|
|
114
|
+
this.column = obj.location_column
|
|
115
|
+
this.shelf = obj.location_shelf
|
|
116
|
+
this.status = obj.location_status
|
|
117
|
+
this.updatedAt = obj.location_updated_at
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -83,13 +83,13 @@ export class Warehouse {
|
|
|
83
83
|
|
|
84
84
|
constructor(obj?) {
|
|
85
85
|
if (obj) {
|
|
86
|
-
this.id = obj.
|
|
87
|
-
this.name = obj.
|
|
88
|
-
this.locations = obj.
|
|
89
|
-
this.type = obj.
|
|
90
|
-
this.description = obj.
|
|
91
|
-
this.createdAt = obj.
|
|
92
|
-
this.updatedAt = obj.
|
|
86
|
+
this.id = obj.warehouse_id
|
|
87
|
+
this.name = obj.warehouse_name
|
|
88
|
+
this.locations = obj.warehouse_locations
|
|
89
|
+
this.type = obj.warehouse_type
|
|
90
|
+
this.description = obj.warehouse_description
|
|
91
|
+
this.createdAt = obj.warehouse_created_at
|
|
92
|
+
this.updatedAt = obj.warehouse_updated_at
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|