@things-factory/warehouse-base 4.3.156 → 4.3.157
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/constants/index.js +0 -1
- package/dist-server/constants/index.js.map +1 -1
- package/dist-server/constants/inventory.js +1 -2
- package/dist-server/constants/inventory.js.map +1 -1
- package/dist-server/service/inventory/inventory-query.js +0 -2
- package/dist-server/service/inventory/inventory-query.js.map +1 -1
- package/dist-server/service/inventory/inventory-types.js +0 -16
- package/dist-server/service/inventory/inventory-types.js.map +1 -1
- package/dist-server/service/inventory/inventory.js +0 -18
- package/dist-server/service/inventory/inventory.js.map +1 -1
- package/dist-server/service/inventory-change/inventory-change-mutation.js +2 -35
- package/dist-server/service/inventory-change/inventory-change-mutation.js.map +1 -1
- package/dist-server/service/inventory-change/inventory-change-query.js +0 -28
- package/dist-server/service/inventory-change/inventory-change-query.js.map +1 -1
- package/dist-server/service/inventory-change/inventory-change-types.js +0 -8
- package/dist-server/service/inventory-change/inventory-change-types.js.map +1 -1
- package/dist-server/service/inventory-change/inventory-change.js +0 -15
- package/dist-server/service/inventory-change/inventory-change.js.map +1 -1
- package/dist-server/utils/inventory-util.js +1 -4
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +9 -9
- package/server/constants/index.ts +0 -1
- package/server/constants/inventory.ts +1 -2
- package/server/service/inventory/inventory-query.ts +0 -4
- package/server/service/inventory/inventory-types.ts +0 -12
- package/server/service/inventory/inventory.ts +15 -18
- package/server/service/inventory-change/inventory-change-mutation.ts +18 -89
- package/server/service/inventory-change/inventory-change-query.ts +0 -30
- package/server/service/inventory-change/inventory-change-types.ts +0 -6
- package/server/service/inventory-change/inventory-change.ts +0 -12
- package/server/utils/inventory-util.ts +1 -4
- package/dist-server/constants/adjustment-code.js +0 -13
- package/dist-server/constants/adjustment-code.js.map +0 -1
- package/server/constants/adjustment-code.ts +0 -9
|
@@ -1,34 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Ctx,
|
|
4
|
-
Directive,
|
|
5
|
-
Mutation,
|
|
6
|
-
Resolver
|
|
7
|
-
} from 'type-graphql'
|
|
8
|
-
import {
|
|
9
|
-
EntityManager,
|
|
10
|
-
In,
|
|
11
|
-
MoreThan,
|
|
12
|
-
Not
|
|
13
|
-
} from 'typeorm'
|
|
1
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
+
import { EntityManager, In, MoreThan, Not } from 'typeorm'
|
|
14
3
|
|
|
15
4
|
import { User } from '@things-factory/auth-base'
|
|
16
5
|
import { Bizplace } from '@things-factory/biz-base'
|
|
17
6
|
import { generateId } from '@things-factory/id-rule-base'
|
|
18
7
|
import { Account } from '@things-factory/integration-accounting'
|
|
19
8
|
import { MarketplaceStore } from '@things-factory/integration-marketplace'
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} from '@things-factory/integration-sellercraft'
|
|
24
|
-
import {
|
|
25
|
-
Product,
|
|
26
|
-
ProductDetail
|
|
27
|
-
} from '@things-factory/product-base'
|
|
28
|
-
import {
|
|
29
|
-
PartnerSetting,
|
|
30
|
-
Setting
|
|
31
|
-
} from '@things-factory/setting-base'
|
|
9
|
+
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
10
|
+
import { Product, ProductDetail } from '@things-factory/product-base'
|
|
11
|
+
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
32
12
|
import { Domain } from '@things-factory/shell'
|
|
33
13
|
|
|
34
14
|
import {
|
|
@@ -38,11 +18,7 @@ import {
|
|
|
38
18
|
LOCATION_STATUS,
|
|
39
19
|
LOCATION_TYPE
|
|
40
20
|
} from '../../constants'
|
|
41
|
-
import {
|
|
42
|
-
EcommerceController,
|
|
43
|
-
PosController,
|
|
44
|
-
SellercraftController
|
|
45
|
-
} from '../../controllers'
|
|
21
|
+
import { EcommerceController, PosController, SellercraftController } from '../../controllers'
|
|
46
22
|
import { InventoryNoGenerator } from '../../utils'
|
|
47
23
|
import { InventoryHistory } from '../inventory-history/inventory-history'
|
|
48
24
|
import { InventoryItemChange } from '../inventory-item-change/inventory-item-change'
|
|
@@ -52,11 +28,7 @@ import { Inventory } from '../inventory/inventory'
|
|
|
52
28
|
import { InventoryPatch } from '../inventory/inventory-types'
|
|
53
29
|
import { Location } from '../location/location'
|
|
54
30
|
import { InventoryChange } from './inventory-change'
|
|
55
|
-
import {
|
|
56
|
-
InventoryChangeList,
|
|
57
|
-
InventoryChangePatch,
|
|
58
|
-
NewInventoryChange
|
|
59
|
-
} from './inventory-change-types'
|
|
31
|
+
import { InventoryChangeList, InventoryChangePatch, NewInventoryChange } from './inventory-change-types'
|
|
60
32
|
|
|
61
33
|
@Resolver(InventoryChange)
|
|
62
34
|
export class InventoryChangeMutation {
|
|
@@ -244,26 +216,22 @@ export class InventoryChangeMutation {
|
|
|
244
216
|
|
|
245
217
|
var product: Product = await tx.getRepository(Product).findOne(newRecord.product.id)
|
|
246
218
|
var productDetail: ProductDetail = await tx.getRepository(ProductDetail).findOne({
|
|
247
|
-
where: [
|
|
248
|
-
{
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
{
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
],
|
|
219
|
+
where: [{
|
|
220
|
+
product: { id: newRecord.product.id },
|
|
221
|
+
packingType: newRecord.packingType,
|
|
222
|
+
packingSize: newRecord.packingSize,
|
|
223
|
+
uom: newRecord.uom
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
product: { id: newRecord.product.id },
|
|
227
|
+
isDefault: true
|
|
228
|
+
}],
|
|
259
229
|
order: { isDefault: 'DESC' }
|
|
260
230
|
})
|
|
261
231
|
|
|
262
232
|
newRecord.product = product
|
|
263
233
|
newRecord.productDetail = productDetail
|
|
264
|
-
|
|
265
|
-
newRecord.unitCost = product.unitCost
|
|
266
|
-
}
|
|
234
|
+
|
|
267
235
|
newRecord.status = 'PENDING'
|
|
268
236
|
newRecord.transactionType = 'NEW'
|
|
269
237
|
|
|
@@ -356,8 +324,6 @@ export class InventoryChangeMutation {
|
|
|
356
324
|
|
|
357
325
|
const adjustQty: number = updateRecord?.qty | 0
|
|
358
326
|
let qtyDiff: number = 0
|
|
359
|
-
|
|
360
|
-
//if updateRecord.unitcost then ...
|
|
361
327
|
|
|
362
328
|
let existingRecord = await tx.getRepository(Inventory).findOne({
|
|
363
329
|
where: { domain, palletId: updateRecord?.palletId },
|
|
@@ -376,15 +342,6 @@ export class InventoryChangeMutation {
|
|
|
376
342
|
qtyDiff = existingQty == adjustQty ? existingQty - adjustQty : adjustQty - existingQty
|
|
377
343
|
}
|
|
378
344
|
|
|
379
|
-
if (!updateRecord.unitCost){
|
|
380
|
-
if(existingRecord.unitCost != null){
|
|
381
|
-
updateRecord.unitCost = existingRecord.unitCost
|
|
382
|
-
}
|
|
383
|
-
if (!existingRecord.unitCost){
|
|
384
|
-
updateRecord.unitCost = existingRecord.product.costPrice
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
345
|
if (!!updateRecord?.location?.id) {
|
|
389
346
|
var location = await tx.getRepository(Location).findOne({
|
|
390
347
|
where: { id: updateRecord.location.id },
|
|
@@ -432,7 +389,6 @@ export class InventoryChangeMutation {
|
|
|
432
389
|
domain: domain,
|
|
433
390
|
creator: user,
|
|
434
391
|
updater: user
|
|
435
|
-
//here?
|
|
436
392
|
})
|
|
437
393
|
|
|
438
394
|
const prevBizAccount: Account = await tx
|
|
@@ -914,20 +870,6 @@ export async function approveInventoryChanges(patches: any, context: any) {
|
|
|
914
870
|
statusFilter = (newRecord.qty != null ? newRecord.qty : inventory.qty) > 0 ? 'STORED' : 'TERMINATED'
|
|
915
871
|
}
|
|
916
872
|
|
|
917
|
-
let { expirationDate } = inventory
|
|
918
|
-
const { shelfLife } = inventory.product
|
|
919
|
-
|
|
920
|
-
if (shelfLife && expirationDate) {
|
|
921
|
-
let date: Date = new Date()
|
|
922
|
-
expirationDate = new Date(expirationDate)
|
|
923
|
-
|
|
924
|
-
const releaseBefore: Date = new Date(expirationDate.setDate(expirationDate.getDate() - shelfLife))
|
|
925
|
-
|
|
926
|
-
if (date > releaseBefore) {
|
|
927
|
-
inventory.obsolete = true
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
|
|
931
873
|
delete newRecord.createdAt
|
|
932
874
|
await tx.getRepository(Inventory).save({
|
|
933
875
|
...inventory,
|
|
@@ -1086,19 +1028,6 @@ export async function approveInventoryChanges(patches: any, context: any) {
|
|
|
1086
1028
|
? null
|
|
1087
1029
|
: newRecord.expirationDate
|
|
1088
1030
|
|
|
1089
|
-
const { shelfLife } = newRecord.product
|
|
1090
|
-
|
|
1091
|
-
if (shelfLife && expirationDate) {
|
|
1092
|
-
let date: Date = new Date()
|
|
1093
|
-
expirationDate = new Date(expirationDate)
|
|
1094
|
-
|
|
1095
|
-
const releaseBefore: Date = new Date(expirationDate.setDate(expirationDate.getDate() - shelfLife))
|
|
1096
|
-
|
|
1097
|
-
if (date > releaseBefore) {
|
|
1098
|
-
newRecord.obsolete = true
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
1031
|
let savedInventory = await tx.getRepository(Inventory).save({
|
|
1103
1032
|
...newRecord,
|
|
1104
1033
|
expirationDate,
|
|
@@ -32,36 +32,6 @@ export class InventoryChangeQuery {
|
|
|
32
32
|
params.filters = [...params.filters.filter(filter => filter.name != 'bizplace')]
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const fromDateParamIdx = params.filters.findIndex(param => param.name === 'fromDate')
|
|
36
|
-
if (fromDateParamIdx >= 0) {
|
|
37
|
-
let fromDateVal = new Date(params.filters[fromDateParamIdx].value)
|
|
38
|
-
params.filters.splice(fromDateParamIdx, 1)
|
|
39
|
-
|
|
40
|
-
params.filters.push({
|
|
41
|
-
name: 'createdAt',
|
|
42
|
-
operator: 'gte',
|
|
43
|
-
value: fromDateVal.toISOString(),
|
|
44
|
-
relation: false
|
|
45
|
-
})
|
|
46
|
-
} else {
|
|
47
|
-
throw new Error(`Error: Date range not provided correctly.`)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const toDateParamIdx = params.filters.findIndex(param => param.name === 'toDate')
|
|
51
|
-
if (toDateParamIdx >= 0) {
|
|
52
|
-
let toDateVal = new Date(params.filters[toDateParamIdx].value)
|
|
53
|
-
params.filters.splice(toDateParamIdx, 1)
|
|
54
|
-
|
|
55
|
-
params.filters.push({
|
|
56
|
-
name: 'createdAt',
|
|
57
|
-
operator: 'lt',
|
|
58
|
-
value: new Date(toDateVal.setDate(toDateVal.getDate() + 1)).toISOString(),
|
|
59
|
-
relation: false
|
|
60
|
-
})
|
|
61
|
-
} else {
|
|
62
|
-
throw new Error(`Error: Date range not provided correctly.`)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
35
|
const qb: SelectQueryBuilder<InventoryChange> = getRepository(InventoryChange).createQueryBuilder('ic')
|
|
66
36
|
buildQuery(qb, params, context)
|
|
67
37
|
|
|
@@ -104,10 +104,6 @@ export class InventoryChange {
|
|
|
104
104
|
@Field({ nullable: true })
|
|
105
105
|
uom: string
|
|
106
106
|
|
|
107
|
-
@Column({ nullable: true })
|
|
108
|
-
@Field({ nullable: true })
|
|
109
|
-
sku: string
|
|
110
|
-
|
|
111
107
|
@Column('float', { nullable: true })
|
|
112
108
|
@Field({ nullable: true })
|
|
113
109
|
weight: number
|
|
@@ -124,14 +120,6 @@ export class InventoryChange {
|
|
|
124
120
|
@Field({ nullable: true })
|
|
125
121
|
unitCost: number
|
|
126
122
|
|
|
127
|
-
@Column({ nullable: true })
|
|
128
|
-
@Field({ nullable: true })
|
|
129
|
-
adjustmentCode: string
|
|
130
|
-
|
|
131
|
-
@Column({ nullable: true })
|
|
132
|
-
@Field({ nullable: true })
|
|
133
|
-
adjustmentNote: string
|
|
134
|
-
|
|
135
123
|
@Column()
|
|
136
124
|
@Field()
|
|
137
125
|
status: string
|
|
@@ -131,7 +131,7 @@ export async function generateInventoryHistory(
|
|
|
131
131
|
|
|
132
132
|
inventory = await invRepo.findOne({
|
|
133
133
|
where: { id: inventory.id },
|
|
134
|
-
relations: ['domain', 'bizplace', 'product', 'warehouse', 'location', 'productDetail']
|
|
134
|
+
relations: ['domain', 'bizplace', 'product', 'warehouse', 'location', 'productDetail', 'reusablePallet']
|
|
135
135
|
})
|
|
136
136
|
|
|
137
137
|
const domain: Domain = inventory.domain
|
|
@@ -523,7 +523,6 @@ export async function getInventoriesByStrategy(
|
|
|
523
523
|
) AS rn
|
|
524
524
|
FROM inventories i
|
|
525
525
|
INNER JOIN locations l ON i.location_id = l.id
|
|
526
|
-
INNER JOIN products p ON p.id = i.product_id
|
|
527
526
|
AND l.TYPE NOT IN ($1, $2)
|
|
528
527
|
INNER JOIN temp_op2 op ON i.product_id = op."productId"::uuid
|
|
529
528
|
AND i.batch_id = op."batchId"
|
|
@@ -533,8 +532,6 @@ export async function getInventoriesByStrategy(
|
|
|
533
532
|
WHERE i.domain_id = $3
|
|
534
533
|
AND i.bizplace_id = $4
|
|
535
534
|
AND i.status = $5
|
|
536
|
-
AND i.obsolete = false
|
|
537
|
-
AND case when i.expiration_date is not null and p.shell_life is not null then CURRENT_DATE < i.expiration_date - p.shell_life else true end
|
|
538
535
|
ORDER BY op."productId", rn
|
|
539
536
|
`,
|
|
540
537
|
[LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE, domainId, bizplaceId, INVENTORY_STATUS.STORED]
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ADJUSTMENT_CODE = void 0;
|
|
4
|
-
exports.ADJUSTMENT_CODE = {
|
|
5
|
-
AC01: 'AC-01: LOST INVENTORY',
|
|
6
|
-
AC02: 'AC-02: DAMAGE',
|
|
7
|
-
AC03: 'AC-03: SHELF LIFE',
|
|
8
|
-
AC04: 'AC-04: STOCK NUMBER CHANGE',
|
|
9
|
-
AC05: 'AC-05: OWNERSHIP CHANGE',
|
|
10
|
-
AC06: 'AC-06: TRANSFER',
|
|
11
|
-
AC07: 'AC-07: OTHERS'
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=adjustment-code.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adjustment-code.js","sourceRoot":"","sources":["../../server/constants/adjustment-code.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,eAAe;CACtB,CAAA"}
|