@things-factory/operato-pms 4.3.373 → 4.3.379
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/client/pages/dispatchment/dispatchment-list.js +17 -3
- package/client/pages/harvesting/harvesting-list.js +17 -3
- package/client/pages/loading/loading-list.js +17 -3
- package/dist-server/graphql/resolvers/daily-dispatch/daily-dispatch-query.js +24 -7
- package/dist-server/graphql/resolvers/daily-dispatch/daily-dispatch-query.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.js +60 -4
- package/dist-server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-harvest/daily-harvest-query.js +24 -2
- package/dist-server/graphql/resolvers/daily-harvest/daily-harvest-query.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-loading/daily-loading-query.js +24 -2
- package/dist-server/graphql/resolvers/daily-loading/daily-loading-query.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-loading/generate-daily-loading.js +3 -2
- package/dist-server/graphql/resolvers/daily-loading/generate-daily-loading.js.map +1 -1
- package/dist-server/utils/transaction-util.js +68 -1
- package/dist-server/utils/transaction-util.js.map +1 -1
- package/package.json +41 -41
- package/server/graphql/resolvers/daily-dispatch/daily-dispatch-query.ts +25 -8
- package/server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.ts +100 -16
- package/server/graphql/resolvers/daily-harvest/daily-harvest-query.ts +26 -0
- package/server/graphql/resolvers/daily-loading/daily-loading-query.ts +26 -0
- package/server/graphql/resolvers/daily-loading/generate-daily-loading.ts +64 -53
- package/server/utils/transaction-util.ts +95 -1
- package/translations/en.json +2 -0
- package/translations/ja.json +9 -9
- package/translations/ko.json +9 -9
- package/translations/zh.json +9 -9
- package/config.development.js +0 -81
|
@@ -27,10 +27,31 @@ export const Query = {
|
|
|
27
27
|
const { tx }: { tx: EntityManager } = context.state
|
|
28
28
|
|
|
29
29
|
try {
|
|
30
|
-
const
|
|
31
|
-
|
|
30
|
+
const fromDateParamIdx = params.filters.findIndex(param => param.name === 'fromDate')
|
|
31
|
+
if (fromDateParamIdx >= 0) {
|
|
32
|
+
let dispatchDateFrom = params.filters.find(param => param.name === 'fromDate')?.value
|
|
33
|
+
params.filters.splice(fromDateParamIdx, 1)
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
params.filters.push({
|
|
36
|
+
name: 'dispatchAt',
|
|
37
|
+
operator: 'gte',
|
|
38
|
+
value: dispatchDateFrom,
|
|
39
|
+
relation: false
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const toDateParamIdx = params.filters.findIndex(param => param.name === 'toDate')
|
|
44
|
+
if (toDateParamIdx >= 0) {
|
|
45
|
+
let dispatchDateTo = params.filters.find(param => param.name === 'toDate')?.value
|
|
46
|
+
params.filters.splice(toDateParamIdx, 1)
|
|
47
|
+
|
|
48
|
+
params.filters.push({
|
|
49
|
+
name: 'dispatchAt',
|
|
50
|
+
operator: 'lte',
|
|
51
|
+
value: dispatchDateTo,
|
|
52
|
+
relation: false
|
|
53
|
+
})
|
|
54
|
+
}
|
|
34
55
|
|
|
35
56
|
const queryBuilder = tx.getRepository(DailyDispatchEntity).createQueryBuilder()
|
|
36
57
|
buildQuery(queryBuilder, params, context)
|
|
@@ -46,14 +67,10 @@ export const Query = {
|
|
|
46
67
|
|
|
47
68
|
if (params.filters?.length > 0) {
|
|
48
69
|
queryBuilder.andWhere('DailyDispatch.deletedAt IS NULL')
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
70
|
+
} else {
|
|
51
71
|
queryBuilder.where('DailyDispatch.deletedAt IS NULL')
|
|
52
72
|
}
|
|
53
73
|
|
|
54
|
-
if (dispatchAt)
|
|
55
|
-
queryBuilder.andWhere(`DailyDispatch.dispatchAt between :dispatchAt::timestamp and :dispatchAt::timestamp + interval '1 day' `, { dispatchAt })
|
|
56
|
-
|
|
57
74
|
const [items, total] = await queryBuilder.getManyAndCount()
|
|
58
75
|
|
|
59
76
|
return { items, total }
|
|
@@ -4,8 +4,16 @@ import { User } from '@things-factory/auth-base'
|
|
|
4
4
|
import { Domain } from '@things-factory/shell'
|
|
5
5
|
|
|
6
6
|
import { RECORD_STATUS, TRANSACTION_TYPE } from '../../../constants'
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
Block,
|
|
9
|
+
DailyDispatch,
|
|
10
|
+
DailyDispatchDetail,
|
|
11
|
+
Organization,
|
|
12
|
+
OrganizationStaff,
|
|
13
|
+
Ramp,
|
|
14
|
+
Truck
|
|
15
|
+
} from '../../../entities'
|
|
16
|
+
import { generateRampBlockHistories, generateTransactionHistory, NoGenerator } from '../../../utils'
|
|
9
17
|
|
|
10
18
|
export const generateDailyDispatch = {
|
|
11
19
|
async generateDailyDispatch(_: any, { dailyDispatch }, context: any) {
|
|
@@ -108,24 +116,100 @@ export async function generateDispatchTransaction(
|
|
|
108
116
|
user: User,
|
|
109
117
|
tx?: EntityManager
|
|
110
118
|
): Promise<void> {
|
|
111
|
-
|
|
112
|
-
dailyDispatchDetails.map(async record => {
|
|
113
|
-
const dispatchedTonnage: number = record.collectedRampWeight
|
|
114
|
-
const dispatchDate: string = newDailyDispatch.dispatchAt.toString().split('T')[0]
|
|
119
|
+
const blockRepo: Repository<Block> = tx?.getRepository(Block) || getRepository(Block)
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
for (let dailyDispatch of dailyDispatchDetails) {
|
|
122
|
+
const dispatchedTonnage: number = dailyDispatch.collectedRampWeight
|
|
123
|
+
const dispatchDate: string = newDailyDispatch.dispatchAt.toString().split('T')[0]
|
|
124
|
+
const ramp: Ramp = dailyDispatch.ramp
|
|
125
|
+
|
|
126
|
+
await generateTransactionHistory(
|
|
127
|
+
null,
|
|
128
|
+
domain,
|
|
129
|
+
dailyDispatch.ramp,
|
|
130
|
+
newDailyDispatch.id,
|
|
131
|
+
newDailyDispatch.name,
|
|
132
|
+
TRANSACTION_TYPE.DISPATCHMENT,
|
|
133
|
+
dispatchDate,
|
|
134
|
+
0,
|
|
135
|
+
-dispatchedTonnage,
|
|
136
|
+
user,
|
|
137
|
+
tx
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
let rampBlockHistory = await tx.query(
|
|
141
|
+
`
|
|
142
|
+
SELECT * FROM (
|
|
143
|
+
SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc, transaction_type) AS rn FROM ramp_block_histories
|
|
144
|
+
WHERE ramp_id =$1 AND transaction_date <= $2
|
|
145
|
+
) foo WHERE rn = 1
|
|
146
|
+
`,
|
|
147
|
+
[ramp.id, dispatchDate]
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
let totalRampWeight: number = rampBlockHistory.reduce((total, currentValue) => {
|
|
151
|
+
total += currentValue.previous_weight + currentValue.weight
|
|
152
|
+
return total
|
|
153
|
+
}, 0)
|
|
154
|
+
|
|
155
|
+
for (let index = 0; index < rampBlockHistory.length; index++) {
|
|
156
|
+
const dt2 = rampBlockHistory[index]
|
|
157
|
+
const block: Block = await blockRepo.findOne({ id: dt2.block_id })
|
|
158
|
+
|
|
159
|
+
let currentRampBlockWeight = dt2.previous_weight + dt2.weight
|
|
160
|
+
let percentage = parseFloat((currentRampBlockWeight / totalRampWeight).toFixed(4))
|
|
161
|
+
let weight = (-dispatchedTonnage * percentage).toFixed(4)
|
|
162
|
+
|
|
163
|
+
// // insert into ramp_block_histories (id,transaction_type, creator_id, updater_id, transaction_date, created_at, updated_at, weight, domain_id, block_id, ramp_id)
|
|
164
|
+
// let processedData = await tx.query(
|
|
165
|
+
// `
|
|
166
|
+
// insert into ramp_block_histories (id, seq, transaction_type, creator_id, updater_id, transaction_date, created_at, updated_at, domain_id, ramp_id, weight, previous_weight, current_weight, block_id, daily_dispatch_id)
|
|
167
|
+
// SELECT uuid_generate_v4() AS id, (select seq from ramp_block_histories where ramp_id = '${ramp.id}' and domain_id = '${domain.id}' order by seq desc limit 1) + 1,'DISPATCH' AS transaction_type,
|
|
168
|
+
// '0933baea-e099-494b-9791-3dfe805731f0' AS creator_id, '0933baea-e099-494b-9791-3dfe805731f0' AS updater_id,
|
|
169
|
+
// $1 AS transaction_date, $2 AS created_at, $3 AS updated_at,
|
|
170
|
+
// $4 AS domain_id, $5 AS ramp_id,
|
|
171
|
+
// $6 AS weight,
|
|
172
|
+
// $7 AS previous_weight,
|
|
173
|
+
// $8 AS current_weight,
|
|
174
|
+
// $9 AS block_id,
|
|
175
|
+
// $10 AS daily_dispatch_id
|
|
176
|
+
// `,
|
|
177
|
+
// [
|
|
178
|
+
// dispatchDate,
|
|
179
|
+
// dt2.created_at,
|
|
180
|
+
// dt2.updated_at,
|
|
181
|
+
// domain.id,
|
|
182
|
+
// ramp.id,
|
|
183
|
+
// parseFloat(weight),
|
|
184
|
+
// parseFloat(currentRampBlockWeight),
|
|
185
|
+
// parseFloat(currentRampBlockWeight) + parseFloat(weight),
|
|
186
|
+
// dt2.block_id,
|
|
187
|
+
// newDailyDispatch.id
|
|
188
|
+
// ]
|
|
189
|
+
// )
|
|
190
|
+
|
|
191
|
+
await generateRampBlockHistories(
|
|
192
|
+
block,
|
|
118
193
|
domain,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
newDailyDispatch.name,
|
|
122
|
-
TRANSACTION_TYPE.DISPATCHMENT,
|
|
194
|
+
ramp,
|
|
195
|
+
'DISPATCH',
|
|
123
196
|
dispatchDate,
|
|
124
|
-
|
|
125
|
-
-dispatchedTonnage,
|
|
197
|
+
parseFloat(weight),
|
|
126
198
|
user,
|
|
199
|
+
null,
|
|
200
|
+
newDailyDispatch,
|
|
127
201
|
tx
|
|
128
202
|
)
|
|
129
|
-
|
|
130
|
-
|
|
203
|
+
|
|
204
|
+
// await txMgr.query(`
|
|
205
|
+
// SELECT * FROM (
|
|
206
|
+
// SELECT *, ROW_NUMBER () OVER (PARTITION BY ramp_id, block_id ORDER BY transaction_date desc) AS rn FROM ramp_block_histories
|
|
207
|
+
// WHERE ramp_id =$1 AND transaction_date <= $2
|
|
208
|
+
// ) foo WHERE rn = 1
|
|
209
|
+
// `, [dt.ramp_id, dt.transaction_date]
|
|
210
|
+
// )
|
|
211
|
+
let x = dt2
|
|
212
|
+
}
|
|
213
|
+
let x = rampBlockHistory
|
|
214
|
+
}
|
|
131
215
|
}
|
|
@@ -27,6 +27,32 @@ export const Query = {
|
|
|
27
27
|
async dailyHarvests(_: any, params: ListParam, context: any) {
|
|
28
28
|
const { tx }: { tx: EntityManager } = context.state
|
|
29
29
|
|
|
30
|
+
const fromDateParamIdx = params.filters.findIndex(param => param.name === 'fromDate')
|
|
31
|
+
if (fromDateParamIdx >= 0) {
|
|
32
|
+
let harvestDateFrom = params.filters.find(param => param.name === 'fromDate')?.value
|
|
33
|
+
params.filters.splice(fromDateParamIdx, 1)
|
|
34
|
+
|
|
35
|
+
params.filters.push({
|
|
36
|
+
name: 'harvestDate',
|
|
37
|
+
operator: 'gte',
|
|
38
|
+
value: harvestDateFrom,
|
|
39
|
+
relation: false
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const toDateParamIdx = params.filters.findIndex(param => param.name === 'toDate')
|
|
44
|
+
if (toDateParamIdx >= 0) {
|
|
45
|
+
let harvestDateTo = params.filters.find(param => param.name === 'toDate')?.value
|
|
46
|
+
params.filters.splice(toDateParamIdx, 1)
|
|
47
|
+
|
|
48
|
+
params.filters.push({
|
|
49
|
+
name: 'harvestDate',
|
|
50
|
+
operator: 'lte',
|
|
51
|
+
value: harvestDateTo,
|
|
52
|
+
relation: false
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
30
56
|
const queryBuilder = tx.getRepository(DailyHarvestEntity).createQueryBuilder()
|
|
31
57
|
buildQuery(queryBuilder, params, context)
|
|
32
58
|
|
|
@@ -25,6 +25,32 @@ export const Query = {
|
|
|
25
25
|
async dailyLoadings(_: any, params: ListParam, context: any) {
|
|
26
26
|
const { tx }: { tx: EntityManager } = context.state
|
|
27
27
|
|
|
28
|
+
const fromDateParamIdx = params.filters.findIndex(param => param.name === 'fromDate')
|
|
29
|
+
if (fromDateParamIdx >= 0) {
|
|
30
|
+
let loadingDateFrom = params.filters.find(param => param.name === 'fromDate')?.value
|
|
31
|
+
params.filters.splice(fromDateParamIdx, 1)
|
|
32
|
+
|
|
33
|
+
params.filters.push({
|
|
34
|
+
name: 'loadingDate',
|
|
35
|
+
operator: 'gte',
|
|
36
|
+
value: loadingDateFrom,
|
|
37
|
+
relation: false
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const toDateParamIdx = params.filters.findIndex(param => param.name === 'toDate')
|
|
42
|
+
if (toDateParamIdx >= 0) {
|
|
43
|
+
let loadingDateTo = params.filters.find(param => param.name === 'toDate')?.value
|
|
44
|
+
params.filters.splice(toDateParamIdx, 1)
|
|
45
|
+
|
|
46
|
+
params.filters.push({
|
|
47
|
+
name: 'loadingDate',
|
|
48
|
+
operator: 'lte',
|
|
49
|
+
value: loadingDateTo,
|
|
50
|
+
relation: false
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
28
54
|
const queryBuilder = tx.getRepository(DailyLoadingEntity).createQueryBuilder()
|
|
29
55
|
buildQuery(queryBuilder, params, context)
|
|
30
56
|
|
|
@@ -5,7 +5,7 @@ import { Domain } from '@things-factory/shell'
|
|
|
5
5
|
|
|
6
6
|
import { INVENTORY_STATUS, INVENTORY_TYPE, RECORD_STATUS, TRANSACTION_TYPE } from '../../../constants'
|
|
7
7
|
import { Block, DailyLoading, DailyLoadingDetail, PlantationInventory, Ramp, Truck } from '../../../entities'
|
|
8
|
-
import { generateTransactionHistory, NoGenerator } from '../../../utils'
|
|
8
|
+
import { generateTransactionHistory, generateRampBlockHistories, NoGenerator } from '../../../utils'
|
|
9
9
|
|
|
10
10
|
export const generateDailyLoading = {
|
|
11
11
|
async generateDailyLoading(_: any, { dailyLoading }, context: any) {
|
|
@@ -93,57 +93,68 @@ export async function updatePlantationInventory(
|
|
|
93
93
|
const plantationInvRepo: Repository<PlantationInventory> =
|
|
94
94
|
tx?.getRepository(PlantationInventory) || getRepository(PlantationInventory)
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
relations: ['domain', 'block', 'ramp']
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
if (existingRampTonnage) {
|
|
104
|
-
existingRampTonnage.totalTonnage = existingRampTonnage.totalTonnage + dailyLoadingDetail.totalBunchWeight
|
|
105
|
-
existingRampTonnage.updater = user
|
|
106
|
-
await plantationInvRepo.save(existingRampTonnage)
|
|
107
|
-
|
|
108
|
-
await generateTransactionHistory(
|
|
109
|
-
dailyLoadingDetail.block,
|
|
110
|
-
domain,
|
|
111
|
-
dailyLoadingDetail.ramp,
|
|
112
|
-
newDailyLoading.id,
|
|
113
|
-
newDailyLoading.name,
|
|
114
|
-
TRANSACTION_TYPE.LOADING,
|
|
115
|
-
newDailyLoading.loadingDate,
|
|
116
|
-
0,
|
|
117
|
-
dailyLoadingDetail.totalBunchWeight,
|
|
118
|
-
user,
|
|
119
|
-
tx
|
|
120
|
-
)
|
|
121
|
-
} else {
|
|
122
|
-
let plantationInventory: PlantationInventory = new PlantationInventory()
|
|
123
|
-
plantationInventory.domain = domain
|
|
124
|
-
plantationInventory.name = NoGenerator.rampTonnageName()
|
|
125
|
-
plantationInventory.block = dailyLoadingDetail.block
|
|
126
|
-
plantationInventory.type = INVENTORY_TYPE.RAMP_TONNAGE
|
|
127
|
-
plantationInventory.totalTonnage = dailyLoadingDetail.totalBunchWeight
|
|
128
|
-
plantationInventory.status = INVENTORY_STATUS.STORED
|
|
129
|
-
plantationInventory.ramp = dailyLoadingDetail.ramp
|
|
130
|
-
plantationInventory.creator = user
|
|
131
|
-
plantationInventory = await plantationInvRepo.save(plantationInventory)
|
|
132
|
-
|
|
133
|
-
await generateTransactionHistory(
|
|
134
|
-
dailyLoadingDetail.block,
|
|
135
|
-
domain,
|
|
136
|
-
dailyLoadingDetail.ramp,
|
|
137
|
-
newDailyLoading.id,
|
|
138
|
-
newDailyLoading.name,
|
|
139
|
-
TRANSACTION_TYPE.LOADING,
|
|
140
|
-
newDailyLoading.loadingDate,
|
|
141
|
-
0,
|
|
142
|
-
dailyLoadingDetail.totalBunchWeight,
|
|
143
|
-
user,
|
|
144
|
-
tx
|
|
145
|
-
)
|
|
146
|
-
}
|
|
96
|
+
for (let dailyLoadingDetail of dailyLoadingDetails) {
|
|
97
|
+
let existingRampTonnage: PlantationInventory = await plantationInvRepo.findOne({
|
|
98
|
+
where: { domain, type: INVENTORY_TYPE.RAMP_TONNAGE, ramp: dailyLoadingDetail.ramp },
|
|
99
|
+
relations: ['domain', 'block', 'ramp']
|
|
147
100
|
})
|
|
148
|
-
|
|
101
|
+
|
|
102
|
+
if (existingRampTonnage) {
|
|
103
|
+
existingRampTonnage.totalTonnage = existingRampTonnage.totalTonnage + dailyLoadingDetail.totalBunchWeight
|
|
104
|
+
existingRampTonnage.updater = user
|
|
105
|
+
await plantationInvRepo.save(existingRampTonnage)
|
|
106
|
+
|
|
107
|
+
await generateTransactionHistory(
|
|
108
|
+
dailyLoadingDetail.block,
|
|
109
|
+
domain,
|
|
110
|
+
dailyLoadingDetail.ramp,
|
|
111
|
+
newDailyLoading.id,
|
|
112
|
+
newDailyLoading.name,
|
|
113
|
+
TRANSACTION_TYPE.LOADING,
|
|
114
|
+
newDailyLoading.loadingDate,
|
|
115
|
+
0,
|
|
116
|
+
dailyLoadingDetail.totalBunchWeight,
|
|
117
|
+
user,
|
|
118
|
+
tx
|
|
119
|
+
)
|
|
120
|
+
} else {
|
|
121
|
+
let plantationInventory: PlantationInventory = new PlantationInventory()
|
|
122
|
+
plantationInventory.domain = domain
|
|
123
|
+
plantationInventory.name = NoGenerator.rampTonnageName()
|
|
124
|
+
plantationInventory.block = dailyLoadingDetail.block
|
|
125
|
+
plantationInventory.type = INVENTORY_TYPE.RAMP_TONNAGE
|
|
126
|
+
plantationInventory.totalTonnage = dailyLoadingDetail.totalBunchWeight
|
|
127
|
+
plantationInventory.status = INVENTORY_STATUS.STORED
|
|
128
|
+
plantationInventory.ramp = dailyLoadingDetail.ramp
|
|
129
|
+
plantationInventory.creator = user
|
|
130
|
+
plantationInventory = await plantationInvRepo.save(plantationInventory)
|
|
131
|
+
|
|
132
|
+
await generateTransactionHistory(
|
|
133
|
+
dailyLoadingDetail.block,
|
|
134
|
+
domain,
|
|
135
|
+
dailyLoadingDetail.ramp,
|
|
136
|
+
newDailyLoading.id,
|
|
137
|
+
newDailyLoading.name,
|
|
138
|
+
TRANSACTION_TYPE.LOADING,
|
|
139
|
+
newDailyLoading.loadingDate,
|
|
140
|
+
0,
|
|
141
|
+
dailyLoadingDetail.totalBunchWeight,
|
|
142
|
+
user,
|
|
143
|
+
tx
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
await generateRampBlockHistories(
|
|
148
|
+
dailyLoadingDetail.block,
|
|
149
|
+
domain,
|
|
150
|
+
dailyLoadingDetail.ramp,
|
|
151
|
+
'LOADING',
|
|
152
|
+
newDailyLoading.loadingDate,
|
|
153
|
+
dailyLoadingDetail.totalBunchWeight,
|
|
154
|
+
user,
|
|
155
|
+
null,
|
|
156
|
+
null,
|
|
157
|
+
tx
|
|
158
|
+
)
|
|
159
|
+
}
|
|
149
160
|
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { User } from '@things-factory/auth-base'
|
|
2
2
|
import { Domain } from '@things-factory/shell'
|
|
3
3
|
import { INVENTORY_STATUS, RAMP_STATUS, TRANSACTION_TYPE } from '../constants'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
DailyDispatch,
|
|
6
|
+
DailyLoading,
|
|
7
|
+
PlantationInventory,
|
|
8
|
+
RecordTransaction,
|
|
9
|
+
Ramp,
|
|
10
|
+
Block,
|
|
11
|
+
RampBlockHistory
|
|
12
|
+
} from '../entities'
|
|
5
13
|
import { NoGenerator } from '../utils'
|
|
6
14
|
import { EntityManager, getRepository, Repository } from 'typeorm'
|
|
7
15
|
|
|
@@ -53,6 +61,92 @@ export async function generateTransactionHistory(
|
|
|
53
61
|
return recTransactionHistory
|
|
54
62
|
}
|
|
55
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @description It will insert new record into transaction table.
|
|
66
|
+
* seq will be calculated based on number of records for one specific plantation inventory
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
export async function generateRampBlockHistories(
|
|
70
|
+
block: Block,
|
|
71
|
+
domain: Domain,
|
|
72
|
+
ramp: Ramp,
|
|
73
|
+
transactionType: string,
|
|
74
|
+
transactionDate: string,
|
|
75
|
+
rampWeight: number,
|
|
76
|
+
user: User,
|
|
77
|
+
deletedAt?: any,
|
|
78
|
+
dailyDispatch?: DailyDispatch,
|
|
79
|
+
trxMgr?: EntityManager
|
|
80
|
+
): Promise<RampBlockHistory> {
|
|
81
|
+
console.log(block, domain, ramp, user)
|
|
82
|
+
const rampBlockHistoryRepo: Repository<RampBlockHistory> =
|
|
83
|
+
trxMgr?.getRepository(RampBlockHistory) || getRepository(RampBlockHistory)
|
|
84
|
+
|
|
85
|
+
if (!ramp?.id) throw new Error(`Can't find a matching ramp.`)
|
|
86
|
+
|
|
87
|
+
const lastRampBlockHistory: RampBlockHistory = await rampBlockHistoryRepo.findOne({
|
|
88
|
+
where: { domain, ramp, block },
|
|
89
|
+
order: { seq: 'DESC' }
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
let res: any
|
|
93
|
+
|
|
94
|
+
if (!lastRampBlockHistory) {
|
|
95
|
+
res = await rampBlockHistoryRepo
|
|
96
|
+
.createQueryBuilder()
|
|
97
|
+
.insert()
|
|
98
|
+
.into(RampBlockHistory)
|
|
99
|
+
.values([
|
|
100
|
+
{
|
|
101
|
+
transactionDate,
|
|
102
|
+
transactionType,
|
|
103
|
+
seq: 0,
|
|
104
|
+
domain,
|
|
105
|
+
block,
|
|
106
|
+
ramp,
|
|
107
|
+
weight: rampWeight,
|
|
108
|
+
previousWeight: 0,
|
|
109
|
+
currentWeight: rampWeight,
|
|
110
|
+
dailyDispatch,
|
|
111
|
+
deletedAt: deletedAt ? deletedAt : null,
|
|
112
|
+
creator: user,
|
|
113
|
+
updater: user
|
|
114
|
+
}
|
|
115
|
+
])
|
|
116
|
+
.returning('*')
|
|
117
|
+
.execute()
|
|
118
|
+
} else {
|
|
119
|
+
const previousWeight: number = lastRampBlockHistory.currentWeight
|
|
120
|
+
|
|
121
|
+
res = await rampBlockHistoryRepo
|
|
122
|
+
.createQueryBuilder()
|
|
123
|
+
.insert()
|
|
124
|
+
.into(RampBlockHistory)
|
|
125
|
+
.values([
|
|
126
|
+
{
|
|
127
|
+
domain,
|
|
128
|
+
block,
|
|
129
|
+
ramp,
|
|
130
|
+
transactionType,
|
|
131
|
+
transactionDate,
|
|
132
|
+
weight: rampWeight,
|
|
133
|
+
previousWeight,
|
|
134
|
+
currentWeight: parseFloat((previousWeight + rampWeight).toFixed(4)),
|
|
135
|
+
creator: user,
|
|
136
|
+
updater: user,
|
|
137
|
+
seq: () =>
|
|
138
|
+
`(select seq from ramp_block_histories where ramp_id = '${ramp.id}' and block_id = '${block.id}' and domain_id = '${domain.id}' order by seq desc limit 1) + 1`
|
|
139
|
+
}
|
|
140
|
+
])
|
|
141
|
+
.returning('*')
|
|
142
|
+
.execute()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let newRampBlockHistory: RampBlockHistory = res.generatedMaps[0]
|
|
146
|
+
|
|
147
|
+
return newRampBlockHistory
|
|
148
|
+
}
|
|
149
|
+
|
|
56
150
|
/**
|
|
57
151
|
* @description: Check ramp emptiness and update status of ramp
|
|
58
152
|
* @param domain
|
package/translations/en.json
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"field.estimated_ffb": "estimated ffb",
|
|
32
32
|
"field.estimated_last_ffb": "estimated last ffb",
|
|
33
33
|
"field.field_bunches": "field bunches",
|
|
34
|
+
"field.from": "from",
|
|
34
35
|
"field.harvest_date": "harvest date",
|
|
35
36
|
"field.harvested_today": "harvested today",
|
|
36
37
|
"field.harvesting_rd": "harvesting rd",
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
"field.staff": "staff",
|
|
67
68
|
"field.status": "status",
|
|
68
69
|
"field.task_no": "task no",
|
|
70
|
+
"field.to": "to",
|
|
69
71
|
"field.to_date_bunch_harvest": "to date bunch harvest",
|
|
70
72
|
"field.to_date_out_turn": "to date out turn",
|
|
71
73
|
"field.to_date_weight_dispatch": "to date weight dispatch",
|
package/translations/ja.json
CHANGED
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"field.total_no_of_bunches": "total no of bunches",
|
|
31
31
|
"field.total_stand": "total stand",
|
|
32
32
|
"field.total_tonnage": "total tonnage",
|
|
33
|
-
"field.total_tonnage_estimated": "total tonnage (estimated)",
|
|
34
33
|
"field.total_weight_loaded": "total weight loaded",
|
|
35
34
|
"field.total_weight": "total weight",
|
|
36
35
|
"field.trip": "trip",
|
|
36
|
+
"field.total_tonnage_estimated": "total tonnage (estimated)",
|
|
37
37
|
"field.type": "type",
|
|
38
38
|
"field.valid_from": "valid from",
|
|
39
39
|
"field.year_planted": "year planted",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"label.block": "block",
|
|
42
42
|
"label.chit_no": "chit no",
|
|
43
43
|
"label.collected_bunch": "collected bunch",
|
|
44
|
-
"label.contractor": "
|
|
44
|
+
"label.contractor": "kontraktor",
|
|
45
45
|
"label.coverage": "coverage",
|
|
46
46
|
"label.date": "date",
|
|
47
47
|
"label.harvesting_round": "harvesting round",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"label.total_task_covered": "total task covered",
|
|
56
56
|
"label.total_tonnage": "total tonnage",
|
|
57
57
|
"label.yesterday_balance_bunch": "yesterday balance bunch",
|
|
58
|
-
"text.code-management": "[
|
|
58
|
+
"text.code-management": "[ms] code management",
|
|
59
59
|
"text.create_harvesting_record": "create harvesting record",
|
|
60
60
|
"text.create_loading_record": "create loading record",
|
|
61
61
|
"text.destination_is_not_selected": "destination is not selected",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"text.harvesting_record_invalid": "harvesting record invalid",
|
|
65
65
|
"text.loading_record_created": "loading record created",
|
|
66
66
|
"text.loading_record_invalid": "loading record invalid",
|
|
67
|
-
"text.invalid_percentage_value": "invalid percentage value",
|
|
68
67
|
"text.no_records": "no records",
|
|
68
|
+
"text.invalid_percentage_value": "invalid percentage value",
|
|
69
69
|
"text.there_is_duplicated_staff_in_record": "there is duplicated staff in this record",
|
|
70
70
|
"text.total_bunch_weight_should_be_positive": "total bunch weight should be positive",
|
|
71
71
|
"text.total_bunches_loaded_should_be_positive": "total bunches loaded should be positive",
|
|
@@ -75,16 +75,16 @@
|
|
|
75
75
|
"text.x_has_invalid_value": "{x} has invalid value",
|
|
76
76
|
"text.x_should_be_positive": "{x} should be positive",
|
|
77
77
|
"text.you_wont_be_able_to_revert_this": "you wont be able to revert this",
|
|
78
|
-
"title.are_you_sure": "
|
|
79
|
-
"title.block_details": "
|
|
80
|
-
"title.block": "
|
|
81
|
-
"title.company": "
|
|
78
|
+
"title.are_you_sure": "adakah anda pasti",
|
|
79
|
+
"title.block_details": "butiran blok",
|
|
80
|
+
"title.block": "blok",
|
|
81
|
+
"title.company": "syarikat",
|
|
82
82
|
"title.create_harvesting_record": "create harvesting record",
|
|
83
83
|
"title.create_loading_record": "create loading record",
|
|
84
84
|
"title.daily_ffb_dispatch_and_production": "daily FFB dispatch and production",
|
|
85
85
|
"title.daily_loading_record": "daily loading record",
|
|
86
86
|
"title.daily_production_report": "daily production report",
|
|
87
|
-
"title.global_plantation_setting": "[
|
|
87
|
+
"title.global_plantation_setting": "[ms] global plantation setting",
|
|
88
88
|
"title.harvest_data": "harvest data",
|
|
89
89
|
"title.harvest_list": "harvesting list",
|
|
90
90
|
"title.harvest_no": "harvest no",
|
package/translations/ko.json
CHANGED
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"field.total_no_of_bunches": "total no of bunches",
|
|
31
31
|
"field.total_stand": "total stand",
|
|
32
32
|
"field.total_tonnage": "total tonnage",
|
|
33
|
-
"field.total_tonnage_estimated": "total tonnage (estimated)",
|
|
34
33
|
"field.total_weight_loaded": "total weight loaded",
|
|
35
34
|
"field.total_weight": "total weight",
|
|
36
35
|
"field.trip": "trip",
|
|
36
|
+
"field.total_tonnage_estimated": "total tonnage (estimated)",
|
|
37
37
|
"field.type": "type",
|
|
38
38
|
"field.valid_from": "valid from",
|
|
39
39
|
"field.year_planted": "year planted",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"label.block": "block",
|
|
42
42
|
"label.chit_no": "chit no",
|
|
43
43
|
"label.collected_bunch": "collected bunch",
|
|
44
|
-
"label.contractor": "
|
|
44
|
+
"label.contractor": "kontraktor",
|
|
45
45
|
"label.coverage": "coverage",
|
|
46
46
|
"label.date": "date",
|
|
47
47
|
"label.harvesting_round": "harvesting round",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"label.total_task_covered": "total task covered",
|
|
56
56
|
"label.total_tonnage": "total tonnage",
|
|
57
57
|
"label.yesterday_balance_bunch": "yesterday balance bunch",
|
|
58
|
-
"text.code-management": "[
|
|
58
|
+
"text.code-management": "[ms] code management",
|
|
59
59
|
"text.create_harvesting_record": "create harvesting record",
|
|
60
60
|
"text.create_loading_record": "create loading record",
|
|
61
61
|
"text.destination_is_not_selected": "destination is not selected",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"text.harvesting_record_invalid": "harvesting record invalid",
|
|
65
65
|
"text.loading_record_created": "loading record created",
|
|
66
66
|
"text.loading_record_invalid": "loading record invalid",
|
|
67
|
-
"text.invalid_percentage_value": "invalid percentage value",
|
|
68
67
|
"text.no_records": "no records",
|
|
68
|
+
"text.invalid_percentage_value": "invalid percentage value",
|
|
69
69
|
"text.there_is_duplicated_staff_in_record": "there is duplicated staff in this record",
|
|
70
70
|
"text.total_bunch_weight_should_be_positive": "total bunch weight should be positive",
|
|
71
71
|
"text.total_bunches_loaded_should_be_positive": "total bunches loaded should be positive",
|
|
@@ -75,16 +75,16 @@
|
|
|
75
75
|
"text.x_has_invalid_value": "{x} has invalid value",
|
|
76
76
|
"text.x_should_be_positive": "{x} should be positive",
|
|
77
77
|
"text.you_wont_be_able_to_revert_this": "you wont be able to revert this",
|
|
78
|
-
"title.are_you_sure": "
|
|
79
|
-
"title.block_details": "
|
|
80
|
-
"title.block": "
|
|
81
|
-
"title.company": "
|
|
78
|
+
"title.are_you_sure": "adakah anda pasti",
|
|
79
|
+
"title.block_details": "butiran blok",
|
|
80
|
+
"title.block": "blok",
|
|
81
|
+
"title.company": "syarikat",
|
|
82
82
|
"title.create_harvesting_record": "create harvesting record",
|
|
83
83
|
"title.create_loading_record": "create loading record",
|
|
84
84
|
"title.daily_ffb_dispatch_and_production": "daily FFB dispatch and production",
|
|
85
85
|
"title.daily_loading_record": "daily loading record",
|
|
86
86
|
"title.daily_production_report": "daily production report",
|
|
87
|
-
"title.global_plantation_setting": "[
|
|
87
|
+
"title.global_plantation_setting": "[ms] global plantation setting",
|
|
88
88
|
"title.harvest_data": "harvest data",
|
|
89
89
|
"title.harvest_list": "harvesting list",
|
|
90
90
|
"title.harvest_no": "harvest no",
|