@things-factory/worksheet-base 4.0.29 → 4.0.33
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/inbound/unloading-worksheet-controller.js +2 -3
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-ro-do.js +7 -1
- package/dist-server/controllers/render-ro-do.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js +14 -2
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +30 -0
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.js +20 -5
- package/dist-server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +11 -0
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-return/complete-unload-returning.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-return/complete-unload-returning.js.map +1 -1
- package/dist-server/graphql/types/worksheet/index.js +2 -2
- package/package.json +17 -16
- package/server/controllers/inbound/unloading-worksheet-controller.ts +2 -3
- package/server/controllers/render-ro-do.ts +10 -1
- package/server/graphql/resolvers/worksheet/packing/activate-packing.ts +15 -3
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +37 -0
- package/server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.ts +31 -9
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +14 -1
- package/server/graphql/resolvers/worksheet/unloading-return/complete-unload-returning.ts +2 -2
- package/server/graphql/types/worksheet/index.ts +2 -2
- package/dist-server/graphql/resolvers/worksheet/edit-batch-no.js +0 -79
- package/dist-server/graphql/resolvers/worksheet/edit-batch-no.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/preunload-worksheet.js +0 -68
- package/dist-server/graphql/resolvers/worksheet/preunload-worksheet.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/proceed-edited-batch.js +0 -113
- package/dist-server/graphql/resolvers/worksheet/proceed-edited-batch.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/submit-adjustment-for-approval.js +0 -58
- package/dist-server/graphql/resolvers/worksheet/submit-adjustment-for-approval.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/complete-preunload.js +0 -23
- package/dist-server/graphql/resolvers/worksheet/unloading/complete-preunload.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/preunload.js +0 -16
- package/dist-server/graphql/resolvers/worksheet/unloading/preunload.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/undo-preunload.js +0 -16
- package/dist-server/graphql/resolvers/worksheet/unloading/undo-preunload.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/undo-product-scan-unload.js +0 -15
- package/dist-server/graphql/resolvers/worksheet/unloading/undo-product-scan-unload.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-return/undo-unload-returning.js +0 -15
- package/dist-server/graphql/resolvers/worksheet/unloading-return/undo-unload-returning.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-return/unload-return.js +0 -15
- package/dist-server/graphql/resolvers/worksheet/unloading-return/unload-return.js.map +0 -1
- package/dist-server/migrations/1605856745211-SeedPrivilege.js +0 -56
- package/dist-server/migrations/1605856745211-SeedPrivilege.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/worksheet-base",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.33",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,20 +24,21 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/auth-base": "^4.0.
|
|
28
|
-
"@things-factory/biz-base": "^4.0.
|
|
29
|
-
"@things-factory/document-template-base": "^4.0.
|
|
30
|
-
"@things-factory/id-rule-base": "^4.0.
|
|
31
|
-
"@things-factory/integration-lmd": "^4.0.
|
|
32
|
-
"@things-factory/integration-marketplace": "^4.0.
|
|
33
|
-
"@things-factory/integration-sellercraft": "^4.0.
|
|
34
|
-
"@things-factory/
|
|
35
|
-
"@things-factory/
|
|
36
|
-
"@things-factory/
|
|
37
|
-
"@things-factory/
|
|
38
|
-
"@things-factory/
|
|
39
|
-
"@things-factory/
|
|
40
|
-
"@things-factory/
|
|
27
|
+
"@things-factory/auth-base": "^4.0.33",
|
|
28
|
+
"@things-factory/biz-base": "^4.0.33",
|
|
29
|
+
"@things-factory/document-template-base": "^4.0.33",
|
|
30
|
+
"@things-factory/id-rule-base": "^4.0.33",
|
|
31
|
+
"@things-factory/integration-lmd": "^4.0.33",
|
|
32
|
+
"@things-factory/integration-marketplace": "^4.0.33",
|
|
33
|
+
"@things-factory/integration-sellercraft": "^4.0.33",
|
|
34
|
+
"@things-factory/integration-sftp": "^4.0.33",
|
|
35
|
+
"@things-factory/marketplace-base": "^4.0.33",
|
|
36
|
+
"@things-factory/notification": "^4.0.33",
|
|
37
|
+
"@things-factory/sales-base": "^4.0.33",
|
|
38
|
+
"@things-factory/setting-base": "^4.0.33",
|
|
39
|
+
"@things-factory/shell": "^4.0.33",
|
|
40
|
+
"@things-factory/transport-base": "^4.0.33",
|
|
41
|
+
"@things-factory/warehouse-base": "^4.0.33"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "0cd5e3b224feb8d526dd5ebc0ee838ff55e2c91c"
|
|
43
44
|
}
|
|
@@ -578,8 +578,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
578
578
|
oi =>
|
|
579
579
|
oi.batchId == inventory.batchId &&
|
|
580
580
|
oi.packingType == inventory.packingType &&
|
|
581
|
-
oi.product.id == inventory.product.id
|
|
582
|
-
oi.inventory.id == inventory.id
|
|
581
|
+
oi.product.id == inventory.product.id
|
|
583
582
|
)
|
|
584
583
|
if (inventory.status == INVENTORY_STATUS.UNLOADED) {
|
|
585
584
|
targetInventory.actualPackQty -= qty
|
|
@@ -609,7 +608,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
609
608
|
inventory.updater = this.user
|
|
610
609
|
await this.trxMgr.getRepository(Inventory).save(inventory)
|
|
611
610
|
|
|
612
|
-
if (inventory == 0) {
|
|
611
|
+
if (inventory.qty == 0) {
|
|
613
612
|
inventory.lastSeq++
|
|
614
613
|
inventory.status = INVENTORY_STATUS.DELETED
|
|
615
614
|
inventory = await this.transactionInventory(
|
|
@@ -6,6 +6,7 @@ import { Attachment, STORAGE } from '@things-factory/attachment-base'
|
|
|
6
6
|
import { Partner } from '@things-factory/auth-base'
|
|
7
7
|
import { Bizplace, ContactPoint } from '@things-factory/biz-base'
|
|
8
8
|
import { config } from '@things-factory/env'
|
|
9
|
+
import { ProductDetail } from '@things-factory/product-base'
|
|
9
10
|
import { DeliveryOrder, ORDER_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
10
11
|
import { Domain } from '@things-factory/shell'
|
|
11
12
|
import { Inventory, Pallet } from '@things-factory/warehouse-base'
|
|
@@ -93,6 +94,7 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
93
94
|
'targetInventory.inventory',
|
|
94
95
|
'targetInventory.inventory.location',
|
|
95
96
|
'targetInventory.inventory.product',
|
|
97
|
+
'targetInventory.inventory.product.productDetails',
|
|
96
98
|
'targetInventory.inventory.reusablePallet',
|
|
97
99
|
'updater'
|
|
98
100
|
]
|
|
@@ -129,12 +131,17 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
129
131
|
.map((wsd: WorksheetDetail) => {
|
|
130
132
|
const targetInventory: OrderInventory = wsd.targetInventory
|
|
131
133
|
const inventory: Inventory = targetInventory.inventory
|
|
134
|
+
const productDetails: ProductDetail[] = inventory.product.productDetails
|
|
135
|
+
const matchedProductDetail: ProductDetail = productDetails.find(
|
|
136
|
+
productDetail => productDetail.packingType === inventory.packingType
|
|
137
|
+
)
|
|
132
138
|
return {
|
|
133
139
|
product_name: `${inventory.product.name} (${inventory.product.description})`,
|
|
134
140
|
product_desc: `${inventory.product?.description || ''}`,
|
|
135
141
|
product_nameOnly: `${inventory.product.name}`,
|
|
136
142
|
product_sku: `${inventory.product.sku}`,
|
|
137
143
|
product_type: inventory.packingType,
|
|
144
|
+
product_size: matchedProductDetail ? matchedProductDetail.packingSize : inventory.packingSize,
|
|
138
145
|
product_batch: inventory.batchId,
|
|
139
146
|
product_qty: targetInventory.releaseQty,
|
|
140
147
|
product_weight: targetInventory.releaseWeight,
|
|
@@ -160,9 +167,11 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
160
167
|
product_sku: item.product_sku,
|
|
161
168
|
product_name: item.product_name,
|
|
162
169
|
product_type: item.product_type,
|
|
170
|
+
product_size: item.product_size,
|
|
163
171
|
product_batch: item.product_batch,
|
|
164
172
|
product_qty: item.product_qty,
|
|
165
173
|
product_weight: item.product_weight,
|
|
174
|
+
product_gross_weight: item.product_gross_weight,
|
|
166
175
|
product_uom_value: item.product_uom_value,
|
|
167
176
|
product_uom: item.product_uom,
|
|
168
177
|
product_desc: item.product_desc,
|
|
@@ -205,7 +214,7 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
205
214
|
company_domain: domainBizplace.company.name,
|
|
206
215
|
company_brn: domainBizplace.company.brn,
|
|
207
216
|
company_address: domainBizplace.company.address,
|
|
208
|
-
company_email: foundWarehouseCP
|
|
217
|
+
company_email: foundWarehouseCP ? foundWarehouseCP?.email : null,
|
|
209
218
|
company_phone: foundWarehouseCP ? foundWarehouseCP.phone : null,
|
|
210
219
|
warehouse_address: foundWarehouseCP ? foundWarehouseCP.address : null,
|
|
211
220
|
warehouse_address2: foundWarehouseCP ? foundWarehouseCP.address2 : null,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityManager } from 'typeorm'
|
|
1
|
+
import { EntityManager, getManager } from 'typeorm'
|
|
2
2
|
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
4
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
@@ -10,8 +10,20 @@ import { Worksheet } from '../../../../entities'
|
|
|
10
10
|
|
|
11
11
|
export const activatePackingResolver = {
|
|
12
12
|
async activatePacking(_: any, { worksheetNo }, context: any) {
|
|
13
|
-
const {
|
|
14
|
-
|
|
13
|
+
const { domain, user }: { domain: Domain; user: User } = context.state
|
|
14
|
+
|
|
15
|
+
let activatedPackingWs = []
|
|
16
|
+
|
|
17
|
+
await Promise.all(worksheetNo.map(async item => {
|
|
18
|
+
try {
|
|
19
|
+
await getManager().transaction(async txMgr => {
|
|
20
|
+
let result = await activatePacking(txMgr, domain, user, item)
|
|
21
|
+
activatedPackingWs.push(result)
|
|
22
|
+
})
|
|
23
|
+
} catch (error) {
|
|
24
|
+
}
|
|
25
|
+
}))
|
|
26
|
+
return activatedPackingWs
|
|
15
27
|
}
|
|
16
28
|
}
|
|
17
29
|
|
|
@@ -5,6 +5,7 @@ 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'
|
|
7
7
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
8
|
+
import { COMPLETEDATAPATH, generateFile, Sftp } from '@things-factory/integration-sftp'
|
|
8
9
|
import { MarketplaceOrder, MarketplaceOrderItem, MarketplaceOrderShipping } from '@things-factory/marketplace-base'
|
|
9
10
|
import { ORDER_INVENTORY_STATUS, ORDER_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
10
11
|
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
@@ -183,6 +184,42 @@ export async function completePicking(
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
|
|
187
|
+
const customerDomain: Domain = releaseGood.bizplace.domain
|
|
188
|
+
let customerAvailableSftp: Sftp = await tx.getRepository(Sftp).findOne({
|
|
189
|
+
where: { domain: customerDomain }
|
|
190
|
+
})
|
|
191
|
+
// to be changed to sftp api instead of doing in resolver
|
|
192
|
+
if (customerAvailableSftp && customerAvailableSftp.responseType == 'file') {
|
|
193
|
+
let responseFilePattern: any = customerAvailableSftp.responseFilePattern
|
|
194
|
+
const { suffix, warehouseCode, fileExtension, runningNumberDigit, sequence } = responseFilePattern
|
|
195
|
+
const folderType: string = customerAvailableSftp.isDevelopment ? `development` : `production`
|
|
196
|
+
const uploadPath: string = customerAvailableSftp.folderPath + '/' + folderType + COMPLETEDATAPATH
|
|
197
|
+
|
|
198
|
+
let newSeq: number = parseFloat(sequence) + 1
|
|
199
|
+
let newSequence = newSeq.toString().padStart(runningNumberDigit, '0')
|
|
200
|
+
let newResponseFilePattern: string = JSON.stringify({
|
|
201
|
+
...responseFilePattern,
|
|
202
|
+
sequence: newSeq
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
const title: string = suffix
|
|
206
|
+
? suffix
|
|
207
|
+
: `` + newSequence + warehouseCode
|
|
208
|
+
? `_` + warehouseCode
|
|
209
|
+
: `` + fileExtension
|
|
210
|
+
? fileExtension
|
|
211
|
+
: ``
|
|
212
|
+
const params: any = {
|
|
213
|
+
title,
|
|
214
|
+
uploadPath,
|
|
215
|
+
content: 'Complete Picking'
|
|
216
|
+
}
|
|
217
|
+
await generateFile(params)
|
|
218
|
+
|
|
219
|
+
customerAvailableSftp = { ...customerAvailableSftp, responseFilePattern: newResponseFilePattern }
|
|
220
|
+
customerAvailableSftp = await tx.getRepository(Sftp).save(customerAvailableSftp)
|
|
221
|
+
}
|
|
222
|
+
|
|
186
223
|
if (releaseGood.packingOption) {
|
|
187
224
|
const packingWSCtrl: PackingWorksheetController = new PackingWorksheetController(tx, domain, user)
|
|
188
225
|
|
|
@@ -11,7 +11,7 @@ import { pickingWorksheet } from '../picking-worksheet'
|
|
|
11
11
|
import { activatePicking } from './activate-picking'
|
|
12
12
|
|
|
13
13
|
export const fetchAndAssignPickingTaskResolver = {
|
|
14
|
-
async fetchAndAssignPickingTask(_: any, {
|
|
14
|
+
async fetchAndAssignPickingTask(_: any, {}, context: any) {
|
|
15
15
|
try {
|
|
16
16
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
17
17
|
const assignee: User = await tx.getRepository(User).findOne(user.id, { relations: ['domains'] })
|
|
@@ -21,12 +21,23 @@ export const fetchAndAssignPickingTaskResolver = {
|
|
|
21
21
|
if (!assignee) throw new Error('failed to find target user')
|
|
22
22
|
|
|
23
23
|
let worksheet: any
|
|
24
|
-
let worksheetQb = await tx
|
|
24
|
+
let worksheetQb = await tx
|
|
25
|
+
.getRepository(Worksheet)
|
|
26
|
+
.createQueryBuilder('ws')
|
|
25
27
|
.select('ws.id')
|
|
26
28
|
.addSelect('ws.name')
|
|
27
29
|
.addSelect('ws.status')
|
|
28
30
|
.addSelect('ws.release_good_id')
|
|
29
|
-
.where(
|
|
31
|
+
.where(
|
|
32
|
+
'(ws.domain_id = :domain_id AND ws.type = :type AND ws.assignee_id =:assignee AND (ws.status = :status1 OR ws.status = :status2))',
|
|
33
|
+
{
|
|
34
|
+
domain_id: domain.id,
|
|
35
|
+
type: WORKSHEET_TYPE.PICKING,
|
|
36
|
+
assignee: assignee.id,
|
|
37
|
+
status1: WORKSHEET_STATUS.EXECUTING,
|
|
38
|
+
status2: WORKSHEET_STATUS.DEACTIVATED
|
|
39
|
+
}
|
|
40
|
+
)
|
|
30
41
|
.andWhere(qb => {
|
|
31
42
|
const subQuery = qb
|
|
32
43
|
.subQuery()
|
|
@@ -40,15 +51,25 @@ export const fetchAndAssignPickingTaskResolver = {
|
|
|
40
51
|
return 'NOT EXISTS ' + subQuery
|
|
41
52
|
})
|
|
42
53
|
|
|
43
|
-
worksheet = await worksheetQb.getRawOne()
|
|
54
|
+
worksheet = await worksheetQb.getRawOne()
|
|
44
55
|
|
|
45
56
|
if (!worksheet) {
|
|
46
|
-
let worksheetQb = await tx
|
|
57
|
+
let worksheetQb = await tx
|
|
58
|
+
.getRepository(Worksheet)
|
|
59
|
+
.createQueryBuilder('ws')
|
|
47
60
|
.select('ws.id')
|
|
48
61
|
.addSelect('ws.name')
|
|
49
62
|
.addSelect('ws.status')
|
|
50
63
|
.addSelect('ws.release_good_id')
|
|
51
|
-
.where(
|
|
64
|
+
.where(
|
|
65
|
+
'(ws.domain_id = :domain_id AND ws.type = :type AND ws.assignee_id IS NULL AND (ws.status = :status1 OR ws.status = :status2))',
|
|
66
|
+
{
|
|
67
|
+
domain_id: domain.id,
|
|
68
|
+
type: WORKSHEET_TYPE.PICKING,
|
|
69
|
+
status1: WORKSHEET_STATUS.EXECUTING,
|
|
70
|
+
status2: WORKSHEET_STATUS.DEACTIVATED
|
|
71
|
+
}
|
|
72
|
+
)
|
|
52
73
|
.andWhere(qb => {
|
|
53
74
|
const subQuery = qb
|
|
54
75
|
.subQuery()
|
|
@@ -62,13 +83,14 @@ export const fetchAndAssignPickingTaskResolver = {
|
|
|
62
83
|
return 'NOT EXISTS ' + subQuery
|
|
63
84
|
})
|
|
64
85
|
|
|
65
|
-
worksheet = await worksheetQb.getRawOne()
|
|
86
|
+
worksheet = await worksheetQb.getRawOne()
|
|
66
87
|
|
|
67
88
|
if (!worksheet) throw new Error('no suitable worksheet found')
|
|
68
|
-
await getRepository(Worksheet).update({ id: worksheet.
|
|
89
|
+
await getRepository(Worksheet).update({ id: worksheet.ws_id }, { assignee: assignee })
|
|
69
90
|
}
|
|
70
91
|
|
|
71
|
-
if (worksheet.ws_status == WORKSHEET_STATUS.DEACTIVATED)
|
|
92
|
+
if (worksheet.ws_status == WORKSHEET_STATUS.DEACTIVATED)
|
|
93
|
+
await activatePicking(tx, domain, user, worksheet.ws_name)
|
|
72
94
|
|
|
73
95
|
const locationSortingRules: Setting = await tx.getRepository(Setting).findOne({
|
|
74
96
|
where: { domain, name: 'rule-for-picking-product' }
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { EntityManager, In, SelectQueryBuilder } from 'typeorm'
|
|
2
2
|
|
|
3
|
-
import { ORDER_INVENTORY_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
3
|
+
import { ORDER_INVENTORY_STATUS, OrderInventory, ReleaseGood, ShippingOrder } from '@things-factory/sales-base'
|
|
4
4
|
import { Domain } from '@things-factory/shell'
|
|
5
5
|
import { Inventory, Location } from '@things-factory/warehouse-base'
|
|
6
6
|
|
|
7
7
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
8
8
|
import { WorksheetDetail } from '../../../entities'
|
|
9
9
|
import { fetchExecutingWorksheet } from '../../../utils'
|
|
10
|
+
import { VasOrderWorksheet } from 'server/graphql/types/worksheet/vas-order-worksheet'
|
|
10
11
|
|
|
11
12
|
export const pickingWorksheetResolver = {
|
|
12
13
|
async pickingWorksheet(_: any, { releaseGoodNo, locationSortingRules }, context: any) {
|
|
@@ -53,6 +54,14 @@ export async function pickingWorksheet(
|
|
|
53
54
|
|
|
54
55
|
if (!releaseGood) throw new Error(`Couldn't find picking worksheet by order no (${releaseGoodNo})`)
|
|
55
56
|
|
|
57
|
+
if (releaseGood.exportOption) {
|
|
58
|
+
var shippingOrder: ShippingOrder = await tx.getRepository(ShippingOrder).findOne({
|
|
59
|
+
where: {
|
|
60
|
+
id: releaseGood?.shippingOrderId
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
56
65
|
const worksheet = await fetchExecutingWorksheet(
|
|
57
66
|
domain,
|
|
58
67
|
releaseGood.bizplace,
|
|
@@ -91,6 +100,10 @@ export async function pickingWorksheet(
|
|
|
91
100
|
refNo: releaseGood.refNo,
|
|
92
101
|
refNo2: releaseGood.refNo2,
|
|
93
102
|
refNo3: releaseGood.refNo3,
|
|
103
|
+
containerNo: shippingOrder?.containerNo,
|
|
104
|
+
marketplaceStatus: releaseGood.marketplaceOrderStatus,
|
|
105
|
+
shippingProvider: releaseGood.transporter,
|
|
106
|
+
trackingNo: releaseGood.trackingNo,
|
|
94
107
|
releaseGood
|
|
95
108
|
},
|
|
96
109
|
worksheetDetailInfos: worksheetDetails.map(async (pickingWSD: WorksheetDetail) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityManager } from 'typeorm'
|
|
1
|
+
import { EntityManager, In } from 'typeorm'
|
|
2
2
|
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
4
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
@@ -45,7 +45,7 @@ export const completeUnloadReturningResolver = {
|
|
|
45
45
|
putawayWorksheet = await putawayWSCtrl.findWorksheetByRefOrder(returnOrderNo, WORKSHEET_TYPE.PUTAWAY_RETURN)
|
|
46
46
|
} catch (e) {
|
|
47
47
|
const inventories: Inventory[] = await tx.getRepository(Inventory).find({
|
|
48
|
-
where: { domain, refOrderId: returnOrder.id, status: INVENTORY_STATUS.UNLOADED }
|
|
48
|
+
where: { domain, refOrderId: returnOrder.id, status: In([INVENTORY_STATUS.UNLOADED, INVENTORY_STATUS.CHECKED]) }
|
|
49
49
|
})
|
|
50
50
|
putawayWorksheet = await putawayWSCtrl.generatePutawayReturnWorksheet(returnOrder.name, inventories)
|
|
51
51
|
}
|
|
@@ -161,8 +161,8 @@ export const Mutation = /* GraphQL */ `
|
|
|
161
161
|
): Worksheet @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
162
162
|
|
|
163
163
|
activatePacking (
|
|
164
|
-
worksheetNo: String!
|
|
165
|
-
): Worksheet @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
164
|
+
worksheetNo: [String!]!
|
|
165
|
+
): [Worksheet] @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
166
166
|
|
|
167
167
|
activateBatchPicking (
|
|
168
168
|
worksheetNo: String!
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.editBatchNo = void 0;
|
|
4
|
-
const auth_base_1 = require("@things-factory/auth-base");
|
|
5
|
-
const sales_base_1 = require("@things-factory/sales-base");
|
|
6
|
-
const notification_1 = require("@things-factory/notification");
|
|
7
|
-
const constants_1 = require("../../../constants");
|
|
8
|
-
const entities_1 = require("../../../entities");
|
|
9
|
-
exports.editBatchNo = {
|
|
10
|
-
async editBatchNo(_, { worksheetNo, unloadingWorksheetDetails }, context) {
|
|
11
|
-
const { tx, domain, user } = context.state;
|
|
12
|
-
/**
|
|
13
|
-
* 1. Validation for worksheet
|
|
14
|
-
* - data existing
|
|
15
|
-
* - status of worksheet
|
|
16
|
-
*/
|
|
17
|
-
const foundWorksheet = await tx.getRepository(entities_1.Worksheet).findOne({
|
|
18
|
-
where: {
|
|
19
|
-
domain: domain,
|
|
20
|
-
name: worksheetNo,
|
|
21
|
-
type: constants_1.WORKSHEET_TYPE.UNLOADING,
|
|
22
|
-
status: constants_1.WORKSHEET_STATUS.DEACTIVATED
|
|
23
|
-
},
|
|
24
|
-
relations: ['bizplace', 'arrivalNotice', 'worksheetDetails', 'worksheetDetails.targetProduct']
|
|
25
|
-
});
|
|
26
|
-
if (!foundWorksheet)
|
|
27
|
-
throw new Error(`Worksheet doesn't exists`);
|
|
28
|
-
const foundGAN = foundWorksheet.arrivalNotice;
|
|
29
|
-
const foundWSDs = foundWorksheet.worksheetDetails;
|
|
30
|
-
let targetProducts = foundWSDs.map((foundWSD) => {
|
|
31
|
-
return Object.assign(Object.assign({}, foundWSD.targetProduct), { palletQty: foundWSD.targetProduct.palletQty
|
|
32
|
-
? foundWSD.targetProduct.palletQty
|
|
33
|
-
: unloadingWorksheetDetails.find((worksheetDetail) => worksheetDetail.name === foundWSD.name)
|
|
34
|
-
.palletQty, adjustedBatchId: unloadingWorksheetDetails.find((worksheetDetail) => worksheetDetail.name === foundWSD.name).batchId, status: unloadingWorksheetDetails.find((worksheetDetail) => worksheetDetail.name === foundWSD.name)
|
|
35
|
-
.initialBatchId ===
|
|
36
|
-
unloadingWorksheetDetails.find((worksheetDetail) => worksheetDetail.name === foundWSD.name)
|
|
37
|
-
.batchId
|
|
38
|
-
? sales_base_1.ORDER_PRODUCT_STATUS.READY_TO_UNLOAD
|
|
39
|
-
: sales_base_1.ORDER_PRODUCT_STATUS.PENDING_APPROVAL });
|
|
40
|
-
});
|
|
41
|
-
await tx.getRepository(sales_base_1.OrderProduct).save(targetProducts);
|
|
42
|
-
// notification logics
|
|
43
|
-
// get Office Admin Users
|
|
44
|
-
const users = await tx
|
|
45
|
-
.getRepository('users_roles')
|
|
46
|
-
.createQueryBuilder('ur')
|
|
47
|
-
.select('ur.users_id', 'id')
|
|
48
|
-
.where(qb => {
|
|
49
|
-
const subQuery = qb
|
|
50
|
-
.subQuery()
|
|
51
|
-
.select('role.id')
|
|
52
|
-
.from(auth_base_1.Role, 'role')
|
|
53
|
-
.where("role.name = 'Office Admin'")
|
|
54
|
-
.andWhere('role.domain_id = :domain', { domain: domain.id })
|
|
55
|
-
.getQuery();
|
|
56
|
-
return 'ur.roles_id IN ' + subQuery;
|
|
57
|
-
})
|
|
58
|
-
.getRawMany();
|
|
59
|
-
// send notification to Office Admin Users
|
|
60
|
-
if (users === null || users === void 0 ? void 0 : users.length) {
|
|
61
|
-
const receivers = users.map(user => user.id);
|
|
62
|
-
const msg = {
|
|
63
|
-
title: `Pending Adjustment for ${foundGAN.name} (${foundWorksheet.bizplace.name})`,
|
|
64
|
-
message: `Pending process for batch id adjustments`,
|
|
65
|
-
url: context.header.referer,
|
|
66
|
-
data: { url: context.header.referer }
|
|
67
|
-
};
|
|
68
|
-
await notification_1.sendNotification({
|
|
69
|
-
receivers,
|
|
70
|
-
message: Object.assign({}, msg)
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* 5. Update Worksheet (status: DEACTIVATED => PENDING_ADJUSTMENT)
|
|
75
|
-
*/
|
|
76
|
-
return await tx.getRepository(entities_1.Worksheet).save(Object.assign(Object.assign({}, foundWorksheet), { status: constants_1.WORKSHEET_STATUS.PENDING_ADJUSTMENT, updater: user }));
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=edit-batch-no.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edit-batch-no.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/worksheet/edit-batch-no.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAEtD,2DAA8F;AAC9F,+DAA+D;AAE/D,kDAAqE;AACrE,gDAA8D;AAEjD,QAAA,WAAW,GAAG;IACzB,KAAK,CAAC,WAAW,CAAC,CAAM,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,EAAE,OAAY;QAChF,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAC7F;;;;WAIG;QACH,MAAM,cAAc,GAAc,MAAM,EAAE,CAAC,aAAa,CAAC,oBAAS,CAAC,CAAC,OAAO,CAAC;YAC1E,KAAK,EAAE;gBACL,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,0BAAc,CAAC,SAAS;gBAC9B,MAAM,EAAE,4BAAgB,CAAC,WAAW;aACrC;YACD,SAAS,EAAE,CAAC,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,gCAAgC,CAAC;SAC/F,CAAC,CAAA;QAEF,IAAI,CAAC,cAAc;YAAE,MAAM,IAAI,KAAK,CAAC,0B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
-
exports.preunloadWorksheetResolver = void 0;
|
|
4
|
-
const sales_base_1 = require("@things-factory/sales-base");
|
|
5
|
-
const typeorm_1 = require("typeorm");
|
|
6
|
-
const constants_1 = require("../../../constants");
|
|
7
|
-
const entities_1 = require("../../../entities");
|
|
8
|
-
exports.preunloadWorksheetResolver = {
|
|
9
|
-
async preunloadWorksheet(_, { arrivalNoticeNo }, context) {
|
|
10
|
-
const { domain } = context.state;
|
|
11
|
-
const arrivalNotice = await typeorm_1.getRepository(sales_base_1.ArrivalNotice).findOne({
|
|
12
|
-
where: { domain, name: arrivalNoticeNo, status: sales_base_1.ORDER_STATUS.READY_TO_UNLOAD },
|
|
13
|
-
relations: ['bizplace']
|
|
14
|
-
});
|
|
15
|
-
if (!arrivalNotice)
|
|
16
|
-
throw new Error(`Arrival notice dosen't exist.`);
|
|
17
|
-
const customerBizplace = arrivalNotice.bizplace;
|
|
18
|
-
const worksheet = await typeorm_1.getRepository(entities_1.Worksheet).findOne({
|
|
19
|
-
where: {
|
|
20
|
-
domain,
|
|
21
|
-
arrivalNotice,
|
|
22
|
-
bizplace: customerBizplace,
|
|
23
|
-
type: constants_1.WORKSHEET_TYPE.UNLOADING,
|
|
24
|
-
status: constants_1.WORKSHEET_STATUS.DEACTIVATED
|
|
25
|
-
},
|
|
26
|
-
relations: [
|
|
27
|
-
'bizplace',
|
|
28
|
-
'bufferLocation',
|
|
29
|
-
'bufferLocation.warehouse',
|
|
30
|
-
'arrivalNotice',
|
|
31
|
-
'worksheetDetails',
|
|
32
|
-
'worksheetDetails.targetProduct',
|
|
33
|
-
'worksheetDetails.targetProduct.product',
|
|
34
|
-
'creator',
|
|
35
|
-
'updater'
|
|
36
|
-
]
|
|
37
|
-
});
|
|
38
|
-
if (!worksheet)
|
|
39
|
-
throw new Error(`Worksheet dosen't exist.`);
|
|
40
|
-
return {
|
|
41
|
-
worksheetInfo: {
|
|
42
|
-
bizplaceName: customerBizplace.name,
|
|
43
|
-
containerNo: arrivalNotice.containerNo,
|
|
44
|
-
bufferLocation: worksheet.bufferLocation.name,
|
|
45
|
-
startedAt: worksheet.startedAt,
|
|
46
|
-
refNo: arrivalNotice.refNo
|
|
47
|
-
},
|
|
48
|
-
worksheetDetailInfos: worksheet.worksheetDetails.map(async (productWSD) => {
|
|
49
|
-
const targetProduct = productWSD.targetProduct;
|
|
50
|
-
return {
|
|
51
|
-
name: productWSD.name,
|
|
52
|
-
batchId: targetProduct.batchId,
|
|
53
|
-
adjustedBatchId: (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.adjustedBatchId) ? targetProduct.adjustedBatchId : '',
|
|
54
|
-
product: targetProduct.product,
|
|
55
|
-
description: productWSD.description,
|
|
56
|
-
targetName: targetProduct.name,
|
|
57
|
-
packingType: targetProduct.packingType,
|
|
58
|
-
palletQty: targetProduct.palletQty,
|
|
59
|
-
adjustedPalletQty: (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.adjustedPalletQty) ? targetProduct.adjustedPalletQty : null,
|
|
60
|
-
packQty: targetProduct.packQty,
|
|
61
|
-
remark: targetProduct.remark,
|
|
62
|
-
status: targetProduct.status
|
|
63
|
-
};
|
|
64
|
-
})
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=preunload-worksheet.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preunload-worksheet.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/worksheet/preunload-worksheet.ts"],"names":[],"mappings":";;;AACA,2DAAsF;AAEtF,qCAAuC;AACvC,kDAAqE;AACrE,gDAA8D;AAEjD,QAAA,0BAA0B,GAAG;IACxC,KAAK,CAAC,kBAAkB,CAAC,CAAM,EAAE,EAAE,eAAe,EAAE,EAAE,OAAY;QAChE,MAAM,EAAE,MAAM,EAAE,GAAuB,OAAO,CAAC,KAAK,CAAA;QACpD,MAAM,aAAa,GAAkB,MAAM,uBAAa,CAAC,0BAAa,CAAC,CAAC,OAAO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9B,eAAe,EAAE,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,eAAe,EAAC,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;oBACpF,OAAO,EAAE,aAAa,CAAC,OAAO;oBAC9B,WAAW,EAAE,UAAU,CAAC,WAAW;oBACnC,UAAU,EAAE,aAAa,CAAC,IAAI;oBAC9B,WAAW,EAAE,aAAa,CAAC,WAAW;oBACtC,SAAS,EAAE,aAAa,CAAC,SAAS;oBAClC,iBAAiB,EAAE,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,iBAAiB,EAAC,CAAC,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;oBAC5F,OAAO,EAAE,aAAa,CAAC,OAAO;oBAC9B,MAAM,EAAE,aAAa,CAAC,MAAM;oBAC5B,MAAM,EAAE,aAAa,CAAC,MAAM;iBAC7B,CAAA;YACH,CAAC,CAAC;SACH,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.proceedEditedBatchResolver = void 0;
|
|
4
|
-
const auth_base_1 = require("@things-factory/auth-base");
|
|
5
|
-
const biz_base_1 = require("@things-factory/biz-base");
|
|
6
|
-
const notification_1 = require("@things-factory/notification");
|
|
7
|
-
const sales_base_1 = require("@things-factory/sales-base");
|
|
8
|
-
const constants_1 = require("../../../constants");
|
|
9
|
-
const entities_1 = require("../../../entities");
|
|
10
|
-
exports.proceedEditedBatchResolver = {
|
|
11
|
-
async proceedEditedBatch(_, { ganNo, bizplaceId, approvedProducts, rejectedProducts }, context) {
|
|
12
|
-
const { tx, domain, user } = context.state;
|
|
13
|
-
// Validation
|
|
14
|
-
// Check status of GAN
|
|
15
|
-
const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
|
16
|
-
where: {
|
|
17
|
-
id: bizplaceId
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const arrivalNotice = await tx.getRepository(sales_base_1.ArrivalNotice).findOne({
|
|
21
|
-
where: {
|
|
22
|
-
domain,
|
|
23
|
-
bizplace: customerBizplace,
|
|
24
|
-
name: ganNo
|
|
25
|
-
},
|
|
26
|
-
relations: ['orderProducts', 'orderProducts.product', 'orderVass', 'orderVass.targetProduct']
|
|
27
|
-
});
|
|
28
|
-
let foundOVs = arrivalNotice.orderVass;
|
|
29
|
-
let foundOPs = arrivalNotice.orderProducts;
|
|
30
|
-
if (arrivalNotice.status !== sales_base_1.ORDER_STATUS.PENDING_APPROVAL)
|
|
31
|
-
throw new Error(`Status (${arrivalNotice.status}) of GAN is not available to proceed extra products.`);
|
|
32
|
-
// Validation
|
|
33
|
-
// Check numbers of target products
|
|
34
|
-
// (approvedProducts + rejectedProducts = target order products)
|
|
35
|
-
const targetProdCnt = arrivalNotice.orderProducts.filter((op) => op.status === sales_base_1.ORDER_PRODUCT_STATUS.PENDING_APPROVAL).length;
|
|
36
|
-
if (approvedProducts.length + rejectedProducts.length != targetProdCnt)
|
|
37
|
-
throw new Error(`Invalid numbers of approved batch no`);
|
|
38
|
-
// Create worksheet details with approved order products
|
|
39
|
-
let unloadingWS = await tx.getRepository(entities_1.Worksheet).findOne({
|
|
40
|
-
where: {
|
|
41
|
-
domain,
|
|
42
|
-
arrivalNotice,
|
|
43
|
-
type: constants_1.WORKSHEET_TYPE.UNLOADING,
|
|
44
|
-
status: constants_1.WORKSHEET_STATUS.PENDING_APPROVAL
|
|
45
|
-
},
|
|
46
|
-
relations: ['worksheetDetails']
|
|
47
|
-
});
|
|
48
|
-
if (approvedProducts === null || approvedProducts === void 0 ? void 0 : approvedProducts.length) {
|
|
49
|
-
approvedProducts = await Promise.all(approvedProducts.map(async (approvedProd) => {
|
|
50
|
-
return Object.assign(Object.assign({}, approvedProd), { remark: `Previous Batch No - ${approvedProd.batchId}, has been adjusted into ${approvedProd.adjustedBatchId}`, batchId: approvedProd.adjustedBatchId, status: sales_base_1.ORDER_PRODUCT_STATUS.READY_TO_UNLOAD, updater: user });
|
|
51
|
-
}));
|
|
52
|
-
await tx.getRepository(sales_base_1.OrderProduct).save(approvedProducts);
|
|
53
|
-
}
|
|
54
|
-
if (foundOVs === null || foundOVs === void 0 ? void 0 : foundOVs.length) {
|
|
55
|
-
foundOVs = await Promise.all(foundOVs.map(async (ov) => {
|
|
56
|
-
if (ov.targetType === constants_1.TARGET_TYPE.BATCH_NO) {
|
|
57
|
-
const foundOP = foundOPs.find((op) => op.batchId === ov.targetBatchId);
|
|
58
|
-
return Object.assign(Object.assign({}, ov), { targetBatchId: foundOP.adjustedBatchId, updater: user });
|
|
59
|
-
}
|
|
60
|
-
else if (ov.targetType === constants_1.TARGET_TYPE.BATCH_AND_PRODUCT_TYPE) {
|
|
61
|
-
const foundOP = foundOPs.find((op) => op.batchId === ov.targetBatchId && op.product.name === ov.targetProduct.name);
|
|
62
|
-
return Object.assign(Object.assign({}, ov), { targetBatchId: foundOP.adjustedBatchId, updater: user });
|
|
63
|
-
}
|
|
64
|
-
}));
|
|
65
|
-
await tx.getRepository(sales_base_1.OrderVas).save(foundOVs);
|
|
66
|
-
}
|
|
67
|
-
if (rejectedProducts === null || rejectedProducts === void 0 ? void 0 : rejectedProducts.length) {
|
|
68
|
-
rejectedProducts = await Promise.all(rejectedProducts.map(async (rejectedProd) => {
|
|
69
|
-
return Object.assign(Object.assign({}, rejectedProd), { remark: `New adjustment batch no - ${rejectedProd.adjustedBatchId}, has been rejected`, status: sales_base_1.ORDER_PRODUCT_STATUS.READY_TO_UNLOAD, updater: user });
|
|
70
|
-
}));
|
|
71
|
-
await tx.getRepository(sales_base_1.OrderProduct).save(rejectedProducts);
|
|
72
|
-
}
|
|
73
|
-
let worksheetDetails = unloadingWS.worksheetDetails;
|
|
74
|
-
worksheetDetails.forEach((worksheetDetail) => {
|
|
75
|
-
worksheetDetail.status = constants_1.WORKSHEET_STATUS.DEACTIVATED;
|
|
76
|
-
});
|
|
77
|
-
await tx.getRepository(entities_1.WorksheetDetail).save(worksheetDetails);
|
|
78
|
-
await tx.getRepository(entities_1.Worksheet).save(Object.assign(Object.assign({}, unloadingWS), { status: constants_1.WORKSHEET_STATUS.DEACTIVATED, updater: user }));
|
|
79
|
-
await tx.getRepository(sales_base_1.ArrivalNotice).save(Object.assign(Object.assign({}, arrivalNotice), { status: sales_base_1.ORDER_STATUS.READY_TO_UNLOAD, updater: user }));
|
|
80
|
-
// notification logics
|
|
81
|
-
// get Office Admin Users
|
|
82
|
-
const users = await tx
|
|
83
|
-
.getRepository('users_roles')
|
|
84
|
-
.createQueryBuilder('ur')
|
|
85
|
-
.select('ur.users_id', 'id')
|
|
86
|
-
.where(qb => {
|
|
87
|
-
const subQuery = qb
|
|
88
|
-
.subQuery()
|
|
89
|
-
.select('role.id')
|
|
90
|
-
.from(auth_base_1.Role, 'role')
|
|
91
|
-
.where("role.name = 'Office Admin'")
|
|
92
|
-
.andWhere('role.domain_id = :domain', { domain: domain.id })
|
|
93
|
-
.getQuery();
|
|
94
|
-
return 'ur.roles_id IN ' + subQuery;
|
|
95
|
-
})
|
|
96
|
-
.getRawMany();
|
|
97
|
-
// send notification to Office Admin Users
|
|
98
|
-
if (users === null || users === void 0 ? void 0 : users.length) {
|
|
99
|
-
const receivers = users.map(user => user.id);
|
|
100
|
-
const msg = {
|
|
101
|
-
title: `Edited batch no approved/rejected by ${customerBizplace.name}`,
|
|
102
|
-
message: `Newly approved batch no is ready to be unloaded.`,
|
|
103
|
-
url: context.header.referer,
|
|
104
|
-
data: { url: context.header.referer }
|
|
105
|
-
};
|
|
106
|
-
await notification_1.sendNotification({
|
|
107
|
-
receivers,
|
|
108
|
-
message: Object.assign({}, msg)
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
//# sourceMappingURL=proceed-edited-batch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proceed-edited-batch.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/worksheet/proceed-edited-batch.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AACtD,uDAAkE;AAClE,+DAA+D;AAC/D,2DAAsH;AAGtH,kDAAkF;AAClF,gDAA8D;AAEjD,QAAA,0BAA0B,GAAG;IACxC,KAAK,CAAC,kBAAkB,CACtB,CAAM,EACN,EAAE,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,EACzD,OAAY;QAEZ,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAE7F,aAAa;QACb,sBAAsB;QACtB,MAAM,gBAAgB,GAAa,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;YAC1E,KAAK,EAAE;gBACL,EAAE,EAAE,UAAU;aACf;SACF,CAAC,CAAA;QACF,MAAM,aAAa,GAAkB,MAAM,EAAE,CAAC,aAAa,CAAC,0BAAa,CAAC,CAAC,OAAO,CAAC;YACjF,KAAK,EAAE;gBACL,MAAM;gBACN,QAAQ,EAAE,gBAAgB;gBAC1B,IAAI,EAAE,KAAK;aACZ;YACD,SAAS,EAAE,CAAC,eAAe,EAAE,uBAAuB,EAAE,WAAW,EAAE,yBAAyB,CAAC;SAC9F,CAAC,CAAA;QAEF,IAAI,QAAQ,GAAe,aAAa,CAAC,SAAS,CAAA;QAClD,IAAI,QAAQ,GAAmB,aAAa,CAAC,aAAa,CAAA;QAE1D,IAAI,aAAa,CAAC,MAAM,KAAK,yBAAY,CAAC,gBAAgB;YACxD,MAAM,IAAI,KAAK,CAAC,WAAW,aAAa,CAAC,MAAM,sDAAsD,CAAC,CAAA;QAExG,aAAa;QACb,mCAAmC;QACnC,gEAAgE;QAChE,MAAM,aAAa,GAAW,aAAa,CAAC,aAAa,CAAC,MAAM,CAC9D,CAAC,EAAgB,EAAE,EAAE,CAA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