@things-factory/operato-pms 4.3.591 → 4.3.601

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.
Files changed (68) hide show
  1. package/client/pages/harvesting/harvesting-create-record.js +5 -2
  2. package/client/pages/loading/edit-loading-record.js +2 -0
  3. package/client/pages/report/report-daily-ffb-dispatch-and-production.js +19 -23
  4. package/dist-server/entities/daily-dispatch.js +2 -2
  5. package/dist-server/entities/daily-dispatch.js.map +1 -1
  6. package/dist-server/entities/ramp-block-history.js.map +1 -1
  7. package/dist-server/graphql/resolvers/daily-dispatch/delete-daily-dispatch.js +49 -1
  8. package/dist-server/graphql/resolvers/daily-dispatch/delete-daily-dispatch.js.map +1 -1
  9. package/dist-server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.js +124 -112
  10. package/dist-server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.js.map +1 -1
  11. package/dist-server/graphql/resolvers/daily-dispatch/update-daily-dispatch.js +51 -2
  12. package/dist-server/graphql/resolvers/daily-dispatch/update-daily-dispatch.js.map +1 -1
  13. package/dist-server/graphql/resolvers/daily-harvest/delete-daily-harvest.js +5 -7
  14. package/dist-server/graphql/resolvers/daily-harvest/delete-daily-harvest.js.map +1 -1
  15. package/dist-server/graphql/resolvers/daily-harvest/generate-daily-harvest.js +3 -3
  16. package/dist-server/graphql/resolvers/daily-harvest/generate-daily-harvest.js.map +1 -1
  17. package/dist-server/graphql/resolvers/daily-loading/delete-daily-loading.js +6 -0
  18. package/dist-server/graphql/resolvers/daily-loading/delete-daily-loading.js.map +1 -1
  19. package/dist-server/graphql/resolvers/daily-loading/generate-daily-loading.js +68 -52
  20. package/dist-server/graphql/resolvers/daily-loading/generate-daily-loading.js.map +1 -1
  21. package/dist-server/graphql/resolvers/daily-loading/update-daily-loading.js +16 -22
  22. package/dist-server/graphql/resolvers/daily-loading/update-daily-loading.js.map +1 -1
  23. package/dist-server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.js +50 -19
  24. package/dist-server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.js.map +1 -1
  25. package/dist-server/graphql/resolvers/report/daily-production-reports.js +96 -67
  26. package/dist-server/graphql/resolvers/report/daily-production-reports.js.map +1 -1
  27. package/dist-server/graphql/resolvers/report/daily-staff-harvest-reports.js +1 -0
  28. package/dist-server/graphql/resolvers/report/daily-staff-harvest-reports.js.map +1 -1
  29. package/dist-server/graphql/resolvers/report/monthly-block-dispatch-reports.js +7 -2
  30. package/dist-server/graphql/resolvers/report/monthly-block-dispatch-reports.js.map +1 -1
  31. package/dist-server/graphql/resolvers/report/monthly-dispatch-summary-reports.js +11 -5
  32. package/dist-server/graphql/resolvers/report/monthly-dispatch-summary-reports.js.map +1 -1
  33. package/dist-server/graphql/resolvers/report/monthly-ffb-sale-reports.js +21 -9
  34. package/dist-server/graphql/resolvers/report/monthly-ffb-sale-reports.js.map +1 -1
  35. package/dist-server/graphql/resolvers/report/monthly-production-reports.js +5 -2
  36. package/dist-server/graphql/resolvers/report/monthly-production-reports.js.map +1 -1
  37. package/dist-server/graphql/resolvers/report/yearly-production-reports.js +5 -2
  38. package/dist-server/graphql/resolvers/report/yearly-production-reports.js.map +1 -1
  39. package/dist-server/graphql/types/daily-loading-detail/daily-loading-detail-patch.js +2 -0
  40. package/dist-server/graphql/types/daily-loading-detail/daily-loading-detail-patch.js.map +1 -1
  41. package/dist-server/utils/transaction-util.js +32 -53
  42. package/dist-server/utils/transaction-util.js.map +1 -1
  43. package/package.json +3 -3
  44. package/server/entities/daily-dispatch.ts +2 -2
  45. package/server/entities/ramp-block-history.ts +2 -5
  46. package/server/graphql/resolvers/daily-dispatch/delete-daily-dispatch.ts +69 -2
  47. package/server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.ts +179 -141
  48. package/server/graphql/resolvers/daily-dispatch/update-daily-dispatch.ts +68 -5
  49. package/server/graphql/resolvers/daily-harvest/delete-daily-harvest.ts +9 -26
  50. package/server/graphql/resolvers/daily-harvest/generate-daily-harvest.ts +3 -3
  51. package/server/graphql/resolvers/daily-loading/delete-daily-loading.ts +11 -1
  52. package/server/graphql/resolvers/daily-loading/generate-daily-loading.ts +95 -98
  53. package/server/graphql/resolvers/daily-loading/update-daily-loading.ts +44 -47
  54. package/server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.ts +61 -26
  55. package/server/graphql/resolvers/report/daily-production-reports.ts +103 -72
  56. package/server/graphql/resolvers/report/daily-staff-harvest-reports.ts +5 -2
  57. package/server/graphql/resolvers/report/monthly-block-dispatch-reports.ts +20 -9
  58. package/server/graphql/resolvers/report/monthly-dispatch-summary-reports.ts +16 -12
  59. package/server/graphql/resolvers/report/monthly-ffb-sale-reports.ts +26 -12
  60. package/server/graphql/resolvers/report/monthly-production-reports.ts +5 -3
  61. package/server/graphql/resolvers/report/yearly-production-reports.ts +5 -2
  62. package/server/graphql/types/daily-loading-detail/daily-loading-detail-patch.ts +2 -0
  63. package/server/utils/transaction-util.ts +36 -56
  64. package/translations/en.json +1 -1
  65. package/translations/ja.json +1 -1
  66. package/translations/ko.json +1 -1
  67. package/translations/ms.json +1 -1
  68. package/translations/zh.json +1 -1
@@ -80,7 +80,7 @@ export async function updateTransactionHistory(
80
80
 
81
81
  await transactionRepo.update(
82
82
  { id: existingTransactionRecord.id },
83
- { fieldBunches: totalBunches, updater: user, updatedAt: new Date() }
83
+ { fieldBunches: totalBunches, transactionDate, block, updater: user, updatedAt: new Date() }
84
84
  )
85
85
  }
86
86
 
@@ -104,70 +104,50 @@ export async function generateRampBlockHistories(
104
104
  dailyDispatch?: DailyDispatch,
105
105
  trxMgr?: EntityManager
106
106
  ): Promise<RampBlockHistory> {
107
- console.log(block, domain, ramp, user)
108
107
  const rampBlockHistoryRepo: Repository<RampBlockHistory> =
109
108
  trxMgr?.getRepository(RampBlockHistory) || getRepository(RampBlockHistory)
110
109
 
111
110
  if (!ramp?.id) throw new Error(`Can't find a matching ramp.`)
112
111
 
112
+ // Fetch the last ramp block history for the given block, ramp, and domain
113
113
  const lastRampBlockHistory: RampBlockHistory = await rampBlockHistoryRepo.findOne({
114
114
  where: { domain, ramp, block },
115
- order: { seq: 'DESC' }
115
+ order: { createdAt: 'DESC' }
116
116
  })
117
117
 
118
- let res: any
119
-
120
- if (!lastRampBlockHistory) {
121
- res = await rampBlockHistoryRepo
122
- .createQueryBuilder()
123
- .insert()
124
- .into(RampBlockHistory)
125
- .values([
126
- {
127
- transactionDate,
128
- transactionType,
129
- seq: 0,
130
- domain,
131
- block,
132
- ramp,
133
- weight: rampWeight,
134
- previousWeight: 0,
135
- currentWeight: rampWeight,
136
- dailyDispatch,
137
- deletedAt: deletedAt ? deletedAt : null,
138
- creator: user,
139
- updater: user
140
- }
141
- ])
142
- .returning('*')
143
- .execute()
144
- } else {
145
- const previousWeight: number = lastRampBlockHistory.currentWeight
146
-
147
- res = await rampBlockHistoryRepo
148
- .createQueryBuilder()
149
- .insert()
150
- .into(RampBlockHistory)
151
- .values([
152
- {
153
- domain,
154
- block,
155
- ramp,
156
- transactionType,
157
- transactionDate,
158
- weight: rampWeight,
159
- previousWeight,
160
- currentWeight: parseFloat((previousWeight + rampWeight).toFixed(4)),
161
- creator: user,
162
- updater: user,
163
- seq: () =>
164
- `(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`
165
- }
166
- ])
167
- .returning('*')
168
- .execute()
169
- }
170
-
118
+ // if (!lastRampBlockHistory) {
119
+ // throw new Error(
120
+ // `No opening quantity defined for block ${block.id} in ramp ${ramp.id}. Please set an opening quantity before creating dispatch records to avoid negative calculation in report.`
121
+ // )
122
+ // }
123
+
124
+ const previousWeight: number = lastRampBlockHistory.currentWeight
125
+
126
+ const res: any = await rampBlockHistoryRepo
127
+ .createQueryBuilder()
128
+ .insert()
129
+ .into(RampBlockHistory)
130
+ .values([
131
+ {
132
+ domain,
133
+ block,
134
+ ramp,
135
+ transactionType,
136
+ transactionDate,
137
+ weight: rampWeight,
138
+ previousWeight,
139
+ currentWeight: parseFloat((previousWeight + rampWeight).toFixed(4)),
140
+ dailyDispatch, // Include dailyDispatch object
141
+ creator: user,
142
+ updater: user,
143
+ seq: () =>
144
+ `(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`
145
+ }
146
+ ])
147
+ .returning('*')
148
+ .execute()
149
+
150
+ // Extract the newly created ramp block history
171
151
  let newRampBlockHistory: RampBlockHistory = res.generatedMaps[0]
172
152
 
173
153
  return newRampBlockHistory
@@ -200,7 +200,7 @@
200
200
  "text.there_is_no_selected_items": "there is no selected items",
201
201
  "text.total_bunch_weight_should_be_positive": "total bunch weight should be positive",
202
202
  "text.total_bunches_loaded_should_be_positive": "total bunches loaded should be positive",
203
- "text.total_no_of_bunches_should_be_positive": "total no of bunches should be positive",
203
+ "text.total_no_of_bunches_should_be_positive_and_whole_number": "total no of bunches should be positive and whole number",
204
204
  "text.total_tonnage_harvested_should_be_positive": "total tonnage harvested should be positive",
205
205
  "text.tracked_inventory_setting": "tracked inventory setting",
206
206
  "text.truck_is_not_selected": "truck not selected",
@@ -69,7 +69,7 @@
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",
72
- "text.total_no_of_bunches_should_be_positive": "total no of bunches should be positive",
72
+ "text.total_no_of_bunches_should_be_positive_and_whole_number": "total no of bunches should be positive and whole number",
73
73
  "text.total_tonnage_harvested_should_be_positive": "total tonnage harvested should be positive",
74
74
  "text.tracked_inventory_setting": "tracked inventory setting",
75
75
  "text.x_has_invalid_value": "{x} has invalid value",
@@ -69,7 +69,7 @@
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",
72
- "text.total_no_of_bunches_should_be_positive": "total no of bunches should be positive",
72
+ "text.total_no_of_bunches_should_be_positive_and_whole_number": "total no of bunches should be positive and whole number",
73
73
  "text.total_tonnage_harvested_should_be_positive": "total tonnage harvested should be positive",
74
74
  "text.tracked_inventory_setting": "tracked inventory setting",
75
75
  "text.x_has_invalid_value": "{x} has invalid value",
@@ -69,7 +69,7 @@
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",
72
- "text.total_no_of_bunches_should_be_positive": "total no of bunches should be positive",
72
+ "text.total_no_of_bunches_should_be_positive_and_whole_number": "total no of bunches should be positive and whole number",
73
73
  "text.total_tonnage_harvested_should_be_positive": "total tonnage harvested should be positive",
74
74
  "text.tracked_inventory_setting": "tracked inventory setting",
75
75
  "text.x_has_invalid_value": "{x} has invalid value",
@@ -69,7 +69,7 @@
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",
72
- "text.total_no_of_bunches_should_be_positive": "total no of bunches should be positive",
72
+ "text.total_no_of_bunches_should_be_positive_and_whole_number": "total no of bunches should be positive and whole number",
73
73
  "text.total_tonnage_harvested_should_be_positive": "total tonnage harvested should be positive",
74
74
  "text.tracked_inventory_setting": "tracked inventory setting",
75
75
  "text.x_has_invalid_value": "{x} has invalid value",