@things-factory/warehouse-base 4.3.113-alpha.0 → 4.3.114
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/warehouse-controller.js.map +1 -1
- package/dist-server/service/inventory/inventory-query.js +36 -27
- package/dist-server/service/inventory/inventory-query.js.map +1 -1
- package/dist-server/service/inventory/inventory-types.js +12 -16
- package/dist-server/service/inventory/inventory-types.js.map +1 -1
- package/dist-server/service/inventory/inventory.js +1 -4
- package/dist-server/service/inventory/inventory.js.map +1 -1
- package/dist-server/service/inventory-change/inventory-change-mutation.js +3 -6
- package/dist-server/service/inventory-change/inventory-change-mutation.js.map +1 -1
- package/dist-server/service/inventory-history/inventory-history-query.js +3 -3
- package/dist-server/service/inventory-item/inventory-item.js +3 -8
- package/dist-server/service/inventory-item/inventory-item.js.map +1 -1
- package/dist-server/service/inventory-product/inventory-product.js +3 -8
- package/dist-server/service/inventory-product/inventory-product.js.map +1 -1
- package/dist-server/service/location/location-mutation.js +1 -3
- package/dist-server/service/location/location-mutation.js.map +1 -1
- package/dist-server/service/pallet/pallet-mutation.js +33 -35
- package/dist-server/service/pallet/pallet-mutation.js.map +1 -1
- package/dist-server/service/tote/tote-mutation.js +1 -1
- package/dist-server/service/tote/tote-mutation.js.map +1 -1
- package/dist-server/service/tote/tote-query.js +5 -7
- package/dist-server/service/tote/tote-query.js.map +1 -1
- package/dist-server/service/warehouse/warehouse-mutation.js +1 -33
- package/dist-server/service/warehouse/warehouse-mutation.js.map +1 -1
- package/dist-server/utils/inventory-util.js +25 -86
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +8 -8
- package/server/controllers/warehouse-controller.ts +1 -0
- package/server/service/inventory/inventory-query.ts +44 -32
- package/server/service/inventory/inventory-types.ts +0 -3
- package/server/service/inventory/inventory.ts +1 -3
- package/server/service/inventory-change/inventory-change-mutation.ts +7 -8
- package/server/service/inventory-history/inventory-history-query.ts +3 -3
- package/server/service/inventory-item/inventory-item.ts +2 -9
- package/server/service/inventory-product/inventory-product.ts +1 -5
- package/server/service/location/location-mutation.ts +1 -3
- package/server/service/pallet/pallet-mutation.ts +69 -50
- package/server/service/tote/tote-mutation.ts +1 -1
- package/server/service/tote/tote-query.ts +7 -9
- package/server/service/warehouse/warehouse-mutation.ts +2 -41
- package/server/utils/inventory-util.ts +51 -116
- package/translations/en.json +2 -4
- package/translations/ko.json +2 -4
- package/translations/ms.json +2 -4
- package/translations/zh.json +12 -14
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
-
import { EntityManager, In
|
|
2
|
+
import { EntityManager, In } from 'typeorm'
|
|
3
3
|
|
|
4
4
|
import { User } from '@things-factory/auth-base'
|
|
5
5
|
import { Bizplace } from '@things-factory/biz-base'
|
|
@@ -8,7 +8,6 @@ import { Domain } from '@things-factory/shell'
|
|
|
8
8
|
import { PalletHistory } from '../pallet-history/pallet-history'
|
|
9
9
|
import { Pallet } from './pallet'
|
|
10
10
|
import { NewPallet, PalletPatch } from './pallet-types'
|
|
11
|
-
import i18next from 'i18next'
|
|
12
11
|
|
|
13
12
|
@Resolver(Pallet)
|
|
14
13
|
export class PalletMutation {
|
|
@@ -26,8 +25,12 @@ export class PalletMutation {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
@Directive('@transaction')
|
|
29
|
-
@Mutation(returns =>
|
|
30
|
-
async updatePallet(
|
|
28
|
+
@Mutation(returns => Pallet)
|
|
29
|
+
async updatePallet(
|
|
30
|
+
@Arg('name') name: string,
|
|
31
|
+
@Arg('patch') patch: PalletPatch,
|
|
32
|
+
@Ctx() context: any
|
|
33
|
+
): Promise<Pallet> {
|
|
31
34
|
const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
|
|
32
35
|
|
|
33
36
|
const repository = tx.getRepository(Pallet)
|
|
@@ -43,66 +46,80 @@ export class PalletMutation {
|
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
@Directive('@transaction')
|
|
46
|
-
@Mutation(returns =>
|
|
47
|
-
async updateMultiplePallet(
|
|
49
|
+
@Mutation(returns => [Pallet])
|
|
50
|
+
async updateMultiplePallet(
|
|
51
|
+
@Arg('patches', type => [PalletPatch]) patches: PalletPatch[],
|
|
52
|
+
@Ctx() context: any
|
|
53
|
+
): Promise<Pallet[]> {
|
|
48
54
|
const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
|
|
49
55
|
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
let results = []
|
|
57
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
58
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
domain,
|
|
57
|
-
name: patch.name
|
|
58
|
-
},
|
|
59
|
-
relations: ['owner', 'holder']
|
|
60
|
-
})
|
|
61
|
-
} else if (patch.id) {
|
|
62
|
-
foundPallet = await getRepository(Pallet).findOne({
|
|
63
|
-
where: {
|
|
64
|
-
domain,
|
|
65
|
-
id: patch.id
|
|
66
|
-
},
|
|
67
|
-
relations: ['owner', 'holder']
|
|
68
|
-
})
|
|
69
|
-
}
|
|
60
|
+
if (_createRecords.length > 0) {
|
|
61
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
62
|
+
const newRecord = _createRecords[i]
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
if (newRecord.owner && newRecord.owner.id) {
|
|
65
|
+
newRecord.owner = await tx.getRepository(Bizplace).findOne(newRecord.owner.id)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (newRecord.holder && newRecord.holder.id) {
|
|
69
|
+
newRecord.holder = await tx.getRepository(Bizplace).findOne(newRecord.holder.id)
|
|
70
|
+
}
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
const result: Pallet = await tx.getRepository(Pallet).save({
|
|
73
|
+
domain: domain,
|
|
74
|
+
creator: user,
|
|
75
|
+
updater: user,
|
|
76
|
+
...newRecord
|
|
77
|
+
})
|
|
75
78
|
|
|
76
79
|
await tx.getRepository(PalletHistory).save({
|
|
77
|
-
...
|
|
78
|
-
pallet:
|
|
80
|
+
...newRecord,
|
|
81
|
+
pallet: result,
|
|
79
82
|
domain: domain,
|
|
80
83
|
creator: user,
|
|
81
84
|
updater: user,
|
|
82
85
|
transactionType: 'NEW'
|
|
83
86
|
})
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
|
|
88
|
+
results.push({ ...result, cuFlag: '+' })
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (_updateRecords.length > 0) {
|
|
93
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
94
|
+
const newRecord = _updateRecords[i]
|
|
95
|
+
const pallet = await tx.getRepository(Pallet).findOne({
|
|
96
|
+
where: { id: newRecord.id },
|
|
97
|
+
relations: ['owner', 'holder']
|
|
98
|
+
})
|
|
99
|
+
const seq = pallet.seq + 1
|
|
100
|
+
|
|
101
|
+
if (newRecord.owner && newRecord.owner.id) {
|
|
102
|
+
newRecord.owner = await tx.getRepository(Bizplace).findOne(newRecord.owner.id)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (newRecord.holder && newRecord.holder.id) {
|
|
106
|
+
newRecord.holder = await tx.getRepository(Bizplace).findOne(newRecord.holder.id)
|
|
87
107
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
refOrderNo: null
|
|
97
|
-
}
|
|
98
|
-
)
|
|
108
|
+
|
|
109
|
+
const result = await tx.getRepository(Pallet).save({
|
|
110
|
+
...pallet,
|
|
111
|
+
...newRecord,
|
|
112
|
+
seq,
|
|
113
|
+
updater: user,
|
|
114
|
+
refOrderNo: null
|
|
115
|
+
})
|
|
99
116
|
|
|
100
117
|
let newHistory = {
|
|
101
|
-
...
|
|
102
|
-
...
|
|
103
|
-
pallet:
|
|
104
|
-
seq
|
|
105
|
-
domain,
|
|
118
|
+
...pallet,
|
|
119
|
+
...newRecord,
|
|
120
|
+
pallet: result,
|
|
121
|
+
seq,
|
|
122
|
+
domain: domain,
|
|
106
123
|
creator: user,
|
|
107
124
|
updater: user,
|
|
108
125
|
transactionType: 'UPDATE'
|
|
@@ -113,10 +130,12 @@ export class PalletMutation {
|
|
|
113
130
|
await tx.getRepository(PalletHistory).save({
|
|
114
131
|
...newHistory
|
|
115
132
|
})
|
|
133
|
+
|
|
134
|
+
results.push({ ...result, cuFlag: 'M' })
|
|
116
135
|
}
|
|
117
136
|
}
|
|
118
137
|
|
|
119
|
-
return
|
|
138
|
+
return results
|
|
120
139
|
}
|
|
121
140
|
|
|
122
141
|
@Directive('@transaction')
|
|
@@ -97,7 +97,7 @@ export class ToteMutation {
|
|
|
97
97
|
|
|
98
98
|
let foundTote = await tx
|
|
99
99
|
.getRepository(Tote)
|
|
100
|
-
.findOne({ where: { domain, name:
|
|
100
|
+
.findOne({ where: { domain, name: newRecord.name, bizplace: newRecord.bizplace } })
|
|
101
101
|
|
|
102
102
|
if (foundTote) {
|
|
103
103
|
throw new Error('Duplicated tote found')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Arg, Ctx, FieldResolver, Query, Resolver, Root
|
|
2
|
-
import { getRepository, IsNull
|
|
1
|
+
import { Arg, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
+
import { getRepository, IsNull } from 'typeorm'
|
|
3
3
|
|
|
4
4
|
import { User } from '@things-factory/auth-base'
|
|
5
5
|
import { Bizplace } from '@things-factory/biz-base'
|
|
@@ -10,7 +10,6 @@ import { ToteList } from './tote-types'
|
|
|
10
10
|
|
|
11
11
|
@Resolver(Tote)
|
|
12
12
|
export class ToteQuery {
|
|
13
|
-
@Directive('@transaction')
|
|
14
13
|
@Query(returns => ToteList)
|
|
15
14
|
async totes(
|
|
16
15
|
@Ctx() context: any,
|
|
@@ -18,12 +17,11 @@ export class ToteQuery {
|
|
|
18
17
|
@Arg('pagination', type => Pagination, { nullable: true }) pagination?: Pagination,
|
|
19
18
|
@Arg('sortings', type => [Sorting], { nullable: true }) sortings?: Sorting[]
|
|
20
19
|
): Promise<ToteList> {
|
|
21
|
-
const { domain
|
|
20
|
+
const { domain }: { domain: Domain } = context.state
|
|
22
21
|
|
|
23
|
-
const deletedFilter: any = filters.find((filter: any) => filter.name === '
|
|
24
|
-
delete filters[filters.indexOf(deletedFilter)]
|
|
22
|
+
const deletedFilter: any = filters.find((filter: any) => filter.name === 'deleted' && filter.value === true)
|
|
25
23
|
|
|
26
|
-
const queryBuilder =
|
|
24
|
+
const queryBuilder = getRepository(Tote).createQueryBuilder()
|
|
27
25
|
buildQuery(queryBuilder, { filters, pagination, sortings }, context)
|
|
28
26
|
|
|
29
27
|
queryBuilder
|
|
@@ -31,9 +29,9 @@ export class ToteQuery {
|
|
|
31
29
|
.leftJoinAndSelect('Tote.bizplace', 'Bizplace')
|
|
32
30
|
.leftJoinAndSelect('Tote.creator', 'Creator')
|
|
33
31
|
.leftJoinAndSelect('Tote.updater', 'Updater')
|
|
34
|
-
.
|
|
32
|
+
.where('Domain.id = :domainId', { domainId: domain.id })
|
|
35
33
|
|
|
36
|
-
if (deletedFilter
|
|
34
|
+
if (deletedFilter) {
|
|
37
35
|
queryBuilder.andWhere('Tote.deletedAt IS NOT NULL')
|
|
38
36
|
} else {
|
|
39
37
|
queryBuilder.andWhere('Tote.deletedAt IS NULL')
|
|
@@ -7,8 +7,6 @@ import { Domain } from '@things-factory/shell'
|
|
|
7
7
|
import { Warehouse } from './warehouse'
|
|
8
8
|
import { NewWarehouse, WarehousePatch } from './warehouse-types'
|
|
9
9
|
|
|
10
|
-
import i18next from 'i18next'
|
|
11
|
-
|
|
12
10
|
@Resolver(Warehouse)
|
|
13
11
|
export class WarehouseMutation {
|
|
14
12
|
@Directive('@privilege(category: "warehouse", privilege: "mutation")')
|
|
@@ -31,48 +29,11 @@ export class WarehouseMutation {
|
|
|
31
29
|
|
|
32
30
|
@Directive('@privilege(category: "warehouse", privilege: "mutation")')
|
|
33
31
|
@Directive('@transaction')
|
|
34
|
-
@Mutation(returns =>
|
|
32
|
+
@Mutation(returns => [Warehouse])
|
|
35
33
|
async updateMultipleWarehouse(
|
|
36
34
|
@Arg('patches', type => [WarehousePatch]) patches: WarehousePatch[],
|
|
37
35
|
@Ctx() context: any
|
|
38
|
-
) {
|
|
39
|
-
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
40
|
-
|
|
41
|
-
for (let patch of patches) {
|
|
42
|
-
let foundWarehouse: Warehouse
|
|
43
|
-
|
|
44
|
-
if (patch?.name) {
|
|
45
|
-
foundWarehouse = await tx.getRepository(Warehouse).findOne({
|
|
46
|
-
domain,
|
|
47
|
-
name: patch.name
|
|
48
|
-
})
|
|
49
|
-
} else if (patch?.id) {
|
|
50
|
-
foundWarehouse = await tx.getRepository(Warehouse).findOne({
|
|
51
|
-
domain,
|
|
52
|
-
id: patch.id
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!foundWarehouse) {
|
|
57
|
-
delete patch?.id
|
|
58
|
-
await tx.getRepository(Warehouse).save({ ...patch, domain, creator: user, updater: user })
|
|
59
|
-
} else {
|
|
60
|
-
if (patch.cuFlag === '+') {
|
|
61
|
-
throw new Error(i18next.t('error.warehouse (x) already exists', { x: patch.name }))
|
|
62
|
-
}
|
|
63
|
-
delete patch.cuFlag
|
|
64
|
-
await tx.getRepository(Warehouse).update(
|
|
65
|
-
{ id: foundWarehouse.id },
|
|
66
|
-
{
|
|
67
|
-
...patch,
|
|
68
|
-
updater: user
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return true
|
|
75
|
-
|
|
36
|
+
): Promise<Warehouse[]> {
|
|
76
37
|
let results = []
|
|
77
38
|
const _createRecords = patches.filter((patch: any) => patch.cuFlag === '+')
|
|
78
39
|
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
@@ -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'
|
|
134
|
+
relations: ['domain', 'bizplace', 'product', 'warehouse', 'location']
|
|
135
135
|
})
|
|
136
136
|
|
|
137
137
|
const domain: Domain = inventory.domain
|
|
@@ -147,133 +147,68 @@ export async function generateInventoryHistory(
|
|
|
147
147
|
}
|
|
148
148
|
})
|
|
149
149
|
|
|
150
|
-
let
|
|
151
|
-
let
|
|
152
|
-
let
|
|
150
|
+
let seq: number = 0
|
|
151
|
+
let openingQty: number = 0
|
|
152
|
+
let openingUomValue: number = 0
|
|
153
|
+
|
|
154
|
+
if (lastInvHistory) {
|
|
155
|
+
openingQty = lastInvHistory.openingQty + lastInvHistory.qty
|
|
156
|
+
openingUomValue = lastInvHistory.openingUomValue + lastInvHistory.uomValue
|
|
157
|
+
seq = lastInvHistory.seq + 1
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let remainQty = (openingQty || 0) + (qty || 0)
|
|
161
|
+
|
|
162
|
+
let inventoryHistory: any = new InventoryHistory()
|
|
163
|
+
|
|
164
|
+
inventoryHistory = {
|
|
165
|
+
...inventory,
|
|
166
|
+
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
167
|
+
inventory,
|
|
168
|
+
seq: seq,
|
|
169
|
+
status: remainQty == 0 ? INVENTORY_STATUS.TERMINATED : inventory.status,
|
|
170
|
+
transactionType,
|
|
153
171
|
refOrderId: refOrder?.id || null,
|
|
154
172
|
orderNo: refOrder?.name || null,
|
|
155
173
|
orderRefNo: refOrder?.refNo || null,
|
|
156
|
-
|
|
157
|
-
|
|
174
|
+
qty,
|
|
175
|
+
openingQty,
|
|
176
|
+
uomValue,
|
|
177
|
+
openingUomValue: openingUomValue,
|
|
158
178
|
creator: user,
|
|
159
|
-
updater: user
|
|
160
|
-
domain: inventory?.domain,
|
|
161
|
-
bizplace: inventory?.bizplace,
|
|
162
|
-
reusablePallet: inventory?.reusablePallet,
|
|
163
|
-
inventory: inventory,
|
|
164
|
-
product: inventory?.product,
|
|
165
|
-
productDetail: inventory?.productDetail,
|
|
166
|
-
warehouse: inventory?.warehouse,
|
|
167
|
-
location: inventory?.location,
|
|
168
|
-
|
|
169
|
-
palletId: inventory?.palletId,
|
|
170
|
-
batchId: inventory?.batchId,
|
|
171
|
-
zone: inventory?.zone,
|
|
172
|
-
packingType: inventory?.packingType,
|
|
173
|
-
description: inventory?.description,
|
|
174
|
-
expirationDate: inventory?.expirationDate,
|
|
175
|
-
unitCost: inventory?.unitCost,
|
|
176
|
-
batchIdRef: inventory?.batchIdRef,
|
|
177
|
-
cartonId: inventory?.cartonId,
|
|
178
|
-
manufactureYear: inventory?.manufactureYear,
|
|
179
|
-
packingSize: inventory?.packingSize,
|
|
180
|
-
manufactureDate: inventory?.manufactureDate,
|
|
181
|
-
status: inventory.status
|
|
179
|
+
updater: user
|
|
182
180
|
}
|
|
183
181
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
.execute()
|
|
204
|
-
} else {
|
|
205
|
-
if (transactionType == 'PICKING' || transactionType == 'UNLOADING') {
|
|
206
|
-
const findSameOrderHistory: InventoryHistory[] = await invHistoryRepo.find({
|
|
207
|
-
domain: inventory.domain,
|
|
208
|
-
palletId: inventory.palletId,
|
|
209
|
-
refOrderId: refOrder.id
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
if (findSameOrderHistory.length > 0) {
|
|
213
|
-
let prevTotalQty = 0
|
|
214
|
-
let prevTotalUomValue = 0
|
|
215
|
-
for (let oh of findSameOrderHistory) {
|
|
216
|
-
prevTotalQty += oh.qty
|
|
217
|
-
prevTotalUomValue += oh.uomValue
|
|
218
|
-
}
|
|
219
|
-
qty -= prevTotalQty
|
|
220
|
-
uomValue -= prevTotalUomValue
|
|
221
|
-
}
|
|
182
|
+
delete inventoryHistory.updatedAt
|
|
183
|
+
delete inventoryHistory.createdAt
|
|
184
|
+
delete inventoryHistory.id
|
|
185
|
+
|
|
186
|
+
let newInventoryHistory = await invHistoryRepo.save(inventoryHistory)
|
|
187
|
+
|
|
188
|
+
if (remainQty == 0) {
|
|
189
|
+
seq = seq + 1
|
|
190
|
+
let terminatedHistory = {
|
|
191
|
+
...newInventoryHistory,
|
|
192
|
+
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
193
|
+
seq: seq,
|
|
194
|
+
status: INVENTORY_STATUS.TERMINATED,
|
|
195
|
+
transactionType: INVENTORY_TRANSACTION_TYPE.TERMINATED,
|
|
196
|
+
uom: inventory.uom,
|
|
197
|
+
qty: 0,
|
|
198
|
+
openingQty: 0,
|
|
199
|
+
uomValue: 0,
|
|
200
|
+
openingUomValue: 0
|
|
222
201
|
}
|
|
223
202
|
|
|
224
|
-
|
|
225
|
-
.createQueryBuilder()
|
|
226
|
-
.insert()
|
|
227
|
-
.into(InventoryHistory)
|
|
228
|
-
.values([
|
|
229
|
-
{
|
|
230
|
-
...inventoryHistoryFields,
|
|
231
|
-
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
232
|
-
transactionType,
|
|
233
|
-
qty,
|
|
234
|
-
openingQty: () =>
|
|
235
|
-
`(select opening_qty from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1) + (select qty from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1)`,
|
|
236
|
-
uomValue,
|
|
237
|
-
openingUomValue: () =>
|
|
238
|
-
`(select opening_uom_value from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1) + ${uomValue}`,
|
|
239
|
-
seq: () =>
|
|
240
|
-
`(select seq from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1) + 1`
|
|
241
|
-
}
|
|
242
|
-
])
|
|
243
|
-
.returning('*')
|
|
244
|
-
.execute()
|
|
245
|
-
}
|
|
203
|
+
delete terminatedHistory.id
|
|
246
204
|
|
|
247
|
-
|
|
248
|
-
lastSeq = newInventoryHistory.seq
|
|
249
|
-
|
|
250
|
-
if (newInventoryHistory.openingQty + qty == 0 && transactionType != 'UNDO_UNLOADING') {
|
|
251
|
-
let terminatedRes = await invHistoryRepo
|
|
252
|
-
.createQueryBuilder()
|
|
253
|
-
.insert()
|
|
254
|
-
.into(InventoryHistory)
|
|
255
|
-
.values([
|
|
256
|
-
{
|
|
257
|
-
...inventoryHistoryFields,
|
|
258
|
-
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
259
|
-
status: INVENTORY_STATUS.TERMINATED,
|
|
260
|
-
transactionType: INVENTORY_TRANSACTION_TYPE.TERMINATED,
|
|
261
|
-
qty: 0,
|
|
262
|
-
openingQty: 0,
|
|
263
|
-
uomValue: 0,
|
|
264
|
-
openingUomValue: 0,
|
|
265
|
-
seq: () =>
|
|
266
|
-
`(select seq from inventory_histories where inventory_id = '${inventory.id}' order by seq desc limit 1) + 1`
|
|
267
|
-
}
|
|
268
|
-
])
|
|
269
|
-
.returning('seq')
|
|
270
|
-
.execute()
|
|
271
|
-
|
|
272
|
-
lastSeq = terminatedRes.generatedMaps[0].seq
|
|
205
|
+
newInventoryHistory = await invHistoryRepo.save(terminatedHistory)
|
|
273
206
|
inventory.status = INVENTORY_STATUS.TERMINATED
|
|
274
207
|
}
|
|
275
208
|
|
|
276
|
-
|
|
209
|
+
if (inventory.lastSeq !== seq) {
|
|
210
|
+
await invRepo.update(inventory.id, { lastSeq: newInventoryHistory.seq, updater: user })
|
|
211
|
+
}
|
|
277
212
|
|
|
278
213
|
await switchLocationStatus(domain, location, user, trxMgr)
|
|
279
214
|
return newInventoryHistory
|
package/translations/en.json
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"error.no_location_found": "no location found",
|
|
3
|
-
"error.pallet (x) already exists": "Pallet ({x}) already exists",
|
|
4
|
-
"error.warehouse (x) already exists": "Warehouse ({x}) already exists",
|
|
5
2
|
"field.location": "location",
|
|
6
3
|
"field.product_batch": "product batch",
|
|
7
4
|
"field.lot": "lot",
|
|
@@ -19,5 +16,6 @@
|
|
|
19
16
|
"field.qty": "qty",
|
|
20
17
|
"field.state": "state",
|
|
21
18
|
"field.date": "date",
|
|
22
|
-
"field.type": "type"
|
|
19
|
+
"field.type": "type",
|
|
20
|
+
"error.no_location_found": "no location found"
|
|
23
21
|
}
|
package/translations/ko.json
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"error.no_location_found": "발견된 로케이션이 없습니다",
|
|
3
|
-
"error.pallet (x) already exists": "[ko] Pallet ({x}) already exists",
|
|
4
|
-
"error.warehouse (x) already exists": "[ko] Warehouse ({x}) already exists",
|
|
5
2
|
"field.location": "로케이션",
|
|
6
3
|
"field.product_batch": "제품 배치",
|
|
7
4
|
"field.lot": "롯트",
|
|
@@ -19,5 +16,6 @@
|
|
|
19
16
|
"field.qty": "수량",
|
|
20
17
|
"field.state": "국가",
|
|
21
18
|
"field.date": "날짜",
|
|
22
|
-
"field.type": "유형"
|
|
19
|
+
"field.type": "유형",
|
|
20
|
+
"error.no_location_found": "발견된 로케이션이 없습니다"
|
|
23
21
|
}
|
package/translations/ms.json
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"error.no_location_found": "[ms]no location found",
|
|
3
|
-
"error.pallet (x) already exists": "[ms] Pallet ({x}) already exists",
|
|
4
|
-
"error.warehouse (x) already exists": "[ko] Warehouse ({x}) already exists",
|
|
5
2
|
"field.location": "lokasi",
|
|
6
3
|
"field.product_batch": "kumpulan produk",
|
|
7
4
|
"field.lot": "lot",
|
|
@@ -19,5 +16,6 @@
|
|
|
19
16
|
"field.qty": "kuantiti",
|
|
20
17
|
"field.state": "keadaan",
|
|
21
18
|
"field.date": "tarikh",
|
|
22
|
-
"field.type": "jenis"
|
|
19
|
+
"field.type": "jenis",
|
|
20
|
+
"error.no_location_found": "[ms]no location found"
|
|
23
21
|
}
|
package/translations/zh.json
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
{
|
|
2
|
-
"error.no_location_found": "[zh]no location found",
|
|
3
|
-
"error.pallet (x) already exists": "[zh] Pallet ({x}) already exists",
|
|
4
|
-
"error.warehouse (x) already exists": "[ko] Warehouse ({x}) already exists",
|
|
5
|
-
"field.bizplace": "分部",
|
|
6
|
-
"field.date": "日期",
|
|
7
|
-
"field.end_qty": "最终数量",
|
|
8
|
-
"field.in_qty": "进口数量",
|
|
9
2
|
"field.location": "位置",
|
|
10
|
-
"field.lot": "地块",
|
|
11
|
-
"field.out_qty": "出口数量",
|
|
12
3
|
"field.product_batch": "产品批次",
|
|
13
|
-
"field.
|
|
14
|
-
"field.
|
|
4
|
+
"field.lot": "地块",
|
|
5
|
+
"field.warehouse": "仓库",
|
|
6
|
+
"field.zone": "区",
|
|
15
7
|
"field.section": "段",
|
|
8
|
+
"field.unit": "单元",
|
|
16
9
|
"field.shelf": "架子",
|
|
10
|
+
"field.bizplace": "分部",
|
|
17
11
|
"field.start_qty": "开始数量",
|
|
12
|
+
"field.in_qty": "进口数量",
|
|
13
|
+
"field.out_qty": "出口数量",
|
|
14
|
+
"field.end_qty": "最终数量",
|
|
15
|
+
"field.product": "产品",
|
|
16
|
+
"field.qty": "数量",
|
|
18
17
|
"field.state": "状态",
|
|
18
|
+
"field.date": "日期",
|
|
19
19
|
"field.type": "类型",
|
|
20
|
-
"
|
|
21
|
-
"field.warehouse": "仓库",
|
|
22
|
-
"field.zone": "区"
|
|
20
|
+
"error.no_location_found": "[zh]no location found"
|
|
23
21
|
}
|