@things-factory/operato-pms 3.8.13 → 3.8.26

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 (60) hide show
  1. package/client/pages/dispatchment/daily-dispatch-detail.js +1 -1
  2. package/client/pages/dispatchment/dispatchment-create-record.js +20 -44
  3. package/client/pages/harvesting/daily-harvesting-detail.js +2 -2
  4. package/client/pages/harvesting/edit-harvesting-record.js +2 -2
  5. package/client/pages/harvesting/harvesting-create-record.js +2 -2
  6. package/client/pages/inventory/inventory-ramp-tonnage.js +23 -31
  7. package/client/pages/report/report-daily-ffb-dispatch-and-production.js +167 -124
  8. package/client/pages/report/report-ffb-tonnage-between-individual-block.js +12 -7
  9. package/dist-server/constants/transaction.js +2 -1
  10. package/dist-server/constants/transaction.js.map +1 -1
  11. package/dist-server/entities/daily-dispatch.js +1 -2
  12. package/dist-server/entities/daily-dispatch.js.map +1 -1
  13. package/dist-server/graphql/resolvers/daily-dispatch/update-daily-dispatch.js +1 -1
  14. package/dist-server/graphql/resolvers/daily-dispatch/update-daily-dispatch.js.map +1 -1
  15. package/dist-server/graphql/resolvers/daily-harvest/generate-daily-harvest.js +2 -2
  16. package/dist-server/graphql/resolvers/daily-harvest/generate-daily-harvest.js.map +1 -1
  17. package/dist-server/graphql/resolvers/daily-loading/update-daily-loading.js +19 -6
  18. package/dist-server/graphql/resolvers/daily-loading/update-daily-loading.js.map +1 -1
  19. package/dist-server/graphql/resolvers/dashboard/dashboard-query.js +165 -43
  20. package/dist-server/graphql/resolvers/dashboard/dashboard-query.js.map +1 -1
  21. package/dist-server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.js +111 -0
  22. package/dist-server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.js.map +1 -0
  23. package/dist-server/graphql/resolvers/report/daily-production-reports.js +6 -6
  24. package/dist-server/graphql/resolvers/report/index.js +2 -1
  25. package/dist-server/graphql/resolvers/report/index.js.map +1 -1
  26. package/dist-server/graphql/resolvers/report/monthly-block-dispatch-reports.js +10 -8
  27. package/dist-server/graphql/resolvers/report/monthly-block-dispatch-reports.js.map +1 -1
  28. package/dist-server/graphql/resolvers/report/monthly-ffb-sale-reports.js +1 -1
  29. package/dist-server/graphql/resolvers/report/monthly-production-reports.js +1 -1
  30. package/dist-server/graphql/types/report/daily-ffb-dispatch-production-report-list.js +14 -0
  31. package/dist-server/graphql/types/report/daily-ffb-dispatch-production-report-list.js.map +1 -0
  32. package/dist-server/graphql/types/report/daily-ffb-dispatch-production-report.js +15 -0
  33. package/dist-server/graphql/types/report/daily-ffb-dispatch-production-report.js.map +1 -0
  34. package/dist-server/graphql/types/report/index.js +13 -0
  35. package/dist-server/graphql/types/report/index.js.map +1 -1
  36. package/dist-server/utils/core-values.js +2 -2
  37. package/dist-server/utils/transaction-util.js +2 -1
  38. package/dist-server/utils/transaction-util.js.map +1 -1
  39. package/package.json +4 -4
  40. package/server/constants/transaction.ts +2 -1
  41. package/server/entities/daily-dispatch.ts +1 -4
  42. package/server/graphql/resolvers/daily-dispatch/update-daily-dispatch.ts +2 -2
  43. package/server/graphql/resolvers/daily-harvest/generate-daily-harvest.ts +2 -2
  44. package/server/graphql/resolvers/daily-loading/update-daily-loading.ts +39 -11
  45. package/server/graphql/resolvers/dashboard/dashboard-query.ts +208 -52
  46. package/server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.ts +138 -0
  47. package/server/graphql/resolvers/report/daily-production-reports.ts +6 -6
  48. package/server/graphql/resolvers/report/index.ts +3 -1
  49. package/server/graphql/resolvers/report/monthly-block-dispatch-reports.ts +11 -9
  50. package/server/graphql/resolvers/report/monthly-ffb-sale-reports.ts +1 -1
  51. package/server/graphql/resolvers/report/monthly-production-reports.ts +1 -1
  52. package/server/graphql/types/report/daily-ffb-dispatch-production-report-list.ts +8 -0
  53. package/server/graphql/types/report/daily-ffb-dispatch-production-report.ts +9 -0
  54. package/server/graphql/types/report/index.ts +13 -0
  55. package/server/utils/core-values.ts +2 -2
  56. package/server/utils/transaction-util.ts +2 -1
  57. package/translations/en.json +7 -6
  58. package/translations/ko.json +7 -6
  59. package/translations/ms.json +10 -9
  60. package/translations/zh.json +7 -6
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
- // import { EntityManager } from 'typeorm'
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Query = void 0;
3
+ exports.getDailyProductionData = exports.Query = void 0;
5
4
  // import { buildQuery, ListParam } from '@things-factory/shell'
6
5
  exports.Query = {
7
6
  /**
@@ -10,46 +9,34 @@ exports.Query = {
10
9
  * @returns tonnage data with its sorted date
11
10
  */
12
11
  async monthlyTonnageProductions(_, { blockId, yearAndMonth }, context) {
13
- if (blockId == 'ALL_BLOCKS') {
14
- // should remove block filter
15
- // 'ALL_BLOCKS' was hardcoded from dashboard
16
- }
17
- const year = yearAndMonth.substring(0, 4);
18
- const month = yearAndMonth.substring(4);
19
- let data = [];
20
- for (let i = 1, l = new Date(Number(year), Number(month), 0).getDate(); i <= l; i++) {
21
- let theDate = new Date(`${year}-${month}-${i}`);
22
- theDate.setHours(8, 0, 0, 0);
23
- data.push({
24
- blockId,
25
- tonnage: Math.floor(Math.random() * 1000) + 200,
26
- year,
27
- month,
28
- date: theDate.toLocaleString('default', { day: '2-digit', month: 'short' })
12
+ try {
13
+ const { tx } = context.state;
14
+ const year = parseInt(yearAndMonth.substring(0, 4));
15
+ const month = parseInt(yearAndMonth.substring(4));
16
+ let data = await getDailyProductionData(blockId, year, month, tx);
17
+ let result = [];
18
+ result = data.map(itm => {
19
+ return Object.assign(Object.assign({}, itm), { blockId, tonnage: itm.todayWeightCollected, year: itm.dateDay.getFullYear(), month: itm.dateDay.getMonth(), date: itm.dateDay.toLocaleString('default', { day: '2-digit', month: 'short' }) });
29
20
  });
21
+ return result;
22
+ }
23
+ catch (ex) {
30
24
  }
31
- return data.sort((a, b) => (a.date > b.date ? 1 : -1));
32
25
  },
33
26
  async monthlyYields(_, { blockId, yearAndMonth }, context) {
34
- if (blockId == 'ALL_BLOCKS') {
35
- // should remove block filter
36
- // 'ALL_BLOCKS' was hardcoded from dashboard
37
- }
38
- const year = yearAndMonth.substring(0, 4);
39
- const month = yearAndMonth.substring(4);
40
- let data = [];
41
- for (let i = 1, l = new Date(Number(year), Number(month), 0).getDate(); i <= l; i++) {
42
- let theDate = new Date(`${year}-${month}-${i}`);
43
- theDate.setHours(8, 0, 0, 0);
44
- data.push({
45
- blockId,
46
- yield: Math.floor(Math.random() * 1000) + 200,
47
- year,
48
- month,
49
- date: theDate.toLocaleString('default', { day: '2-digit', month: 'short' })
27
+ try {
28
+ const { tx } = context.state;
29
+ const year = parseInt(yearAndMonth.substring(0, 4));
30
+ const month = parseInt(yearAndMonth.substring(4));
31
+ let data = await getDailyProductionData(blockId, year, month, tx);
32
+ let result = [];
33
+ result = data.map(itm => {
34
+ return Object.assign(Object.assign({}, itm), { blockId, yield: (itm.todayHectareCover != 0 ? itm.todayWeightCollected / itm.todayHectareCover : 0).toFixed(4), year: itm.dateDay.getFullYear(), month: itm.dateDay.getMonth(), date: itm.dateDay.toLocaleString('default', { day: '2-digit', month: 'short' }) });
50
35
  });
36
+ return result;
37
+ }
38
+ catch (ex) {
51
39
  }
52
- return data.sort((a, b) => (a.date > b.date ? 1 : -1));
53
40
  },
54
41
  async weeklyBunchesCount(_, { targetDate }, context) {
55
42
  if (!targetDate || targetDate == '')
@@ -58,8 +45,10 @@ exports.Query = {
58
45
  for (let i = 0; i < 7; i++) {
59
46
  bunchesCount.push({
60
47
  date: new Date(targetDate).toLocaleString('default', { day: '2-digit', month: 'short' }),
61
- harvestedCount: Math.floor(Math.random() * 1000) + 500,
62
- collectedCount: Math.floor(Math.random() * 500) + 50
48
+ harvestedCount: 0,
49
+ collectedCount: 0
50
+ // harvestedCount: Math.floor(Math.random() * 1000) + 500,
51
+ // collectedCount: Math.floor(Math.random() * 500) + 50
63
52
  });
64
53
  targetDate.setDate(targetDate.getDate() - 1);
65
54
  }
@@ -67,16 +56,149 @@ exports.Query = {
67
56
  },
68
57
  async tonnageAndBunchesInventories(_, { something }, context) {
69
58
  return {
70
- bunches: Math.floor(Math.random() * 10000) + 500,
71
- tonnage: Math.floor(Math.random() * 10000) + 500
59
+ bunches: 0,
60
+ tonnage: 0
61
+ // bunches: Math.floor(Math.random() * 10000) + 500,
62
+ // tonnage: Math.floor(Math.random() * 10000) + 500
72
63
  };
73
64
  },
74
65
  async productionsOverview(_, { something }, context) {
75
66
  return {
76
- averageBunchWeight: Math.floor(Math.random() * 150) + 70,
77
- bunchesCount: Math.floor(Math.random() * 10000) + 500,
78
- tonnageWeighed: Math.floor(Math.random() * 10000) + 500
67
+ averageBunchWeight: 0,
68
+ bunchesCount: 0,
69
+ tonnageWeighed: 0,
70
+ // averageBunchWeight: Math.floor(Math.random() * 150) + 70,
71
+ // bunchesCount: Math.floor(Math.random() * 10000) + 500,
72
+ // tonnageWeighed: Math.floor(Math.random() * 10000) + 500
79
73
  };
80
74
  }
81
75
  };
76
+ async function getDailyProductionData(blockId, year, month, tx) {
77
+ await tx.query(`
78
+ CREATE TEMP TABLE temp_blocks on commit drop AS (
79
+ WITH RECURSIVE b AS (
80
+ SELECT b.id AS block_id, * FROM blocks b
81
+ WHERE b.deleted_at IS null
82
+ UNION ALL
83
+ SELECT b.id AS block_id, cb.* FROM blocks cb
84
+ INNER JOIN b ON b.id = cb.parent_block_id
85
+ WHERE cb.deleted_at IS null
86
+ )
87
+ SELECT block_id, id, name FROM b
88
+ ${blockId != 'all-blocks' && blockId != '' ? `WHERE block_id = '${blockId}' or id = '${blockId}'` : ``}
89
+ GROUP BY block_id, id, name
90
+ ORDER BY block_id, id, name
91
+ );
92
+ `);
93
+ let fromDate = new Date(year, month - 1, 1);
94
+ let toDate = new Date(year, month, 1);
95
+ toDate.setDate(toDate.getDate() - 1);
96
+ let fromDateString = [
97
+ fromDate.getFullYear().toString(),
98
+ String(fromDate.getMonth() + 1).padStart(2, '0'),
99
+ '01'
100
+ ].join('-');
101
+ let toDateString = [
102
+ toDate.getFullYear().toString(),
103
+ String(toDate.getMonth() + 1).padStart(2, '0'),
104
+ String(toDate.getDate()).padStart(2, '0')
105
+ ].join('-');
106
+ await tx.query(`
107
+ CREATE TEMP TABLE temp_records on commit drop AS (
108
+ select blk.block_id, coalesce(sum(field_bunches),0) AS today_field_bunches,
109
+ round(coalesce(sum(ramp_weight),0)::numeric,4) AS today_ramp_weight,
110
+ sum(case when transaction_type = 'HARVEST' OR transaction_type = 'BUNCHES_ADJUSTMENT' then field_bunches else 0 end) as today_bunch_harvest,
111
+ sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then -field_bunches else 0 end) as today_bunch_collected,
112
+ round(sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then ramp_weight else 0 end)::numeric,4) as today_ramp_weight_collected,
113
+ round(sum(case when transaction_type = 'DISPATCHMENT' OR transaction_type = 'DISPATCHMENT_ADJUSTMENT' then -ramp_weight else 0 end)::numeric,4) as today_weight_dispatch,
114
+ transaction_date
115
+ from record_transactions t2
116
+ inner join temp_blocks blk on blk.id = t2.block_id
117
+ where transaction_date <= $1
118
+ group by blk.block_id, transaction_date
119
+ )
120
+ `, [toDateString]);
121
+ await tx.query(`
122
+ create temp table temp_daily_production_data on commit drop as (
123
+ select *,
124
+ prev_bunch_bal_in_field + today_bunch_harvest as today_bunch_in_field,
125
+ prev_bunch_bal_in_field + today_bunch_harvest - today_bunch_collected as today_bunch_bal_in_field,
126
+ prev_weight_bal_in_ramp + today_ramp_weight_collected - today_weight_dispatch as today_weight_bal_in_ramp FROM (
127
+ select md.dateDay as date_day,
128
+ coalesce(
129
+ (
130
+ select sum(today_field_bunches) from temp_records t2
131
+ where transaction_date::timestamp < md.dateDay
132
+ )
133
+ , 0) as prev_bunch_bal_in_field,
134
+ coalesce(
135
+ (
136
+ select sum(today_ramp_weight) from temp_records t2
137
+ where transaction_date::timestamp < md.dateDay
138
+ )
139
+ , 0) as prev_weight_bal_in_ramp,
140
+ coalesce(today_bunch_harvest, 0) as today_bunch_harvest,
141
+ coalesce(sum(today_bunch_harvest) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_bunch_harvest,
142
+ coalesce(today_bunch_collected, 0) as today_bunch_collected,
143
+ coalesce(sum(today_bunch_collected) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_bunch_collected,
144
+ coalesce(today_ramp_weight_collected, 0) as today_ramp_weight_collected,
145
+ coalesce(sum(today_ramp_weight_collected) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_ramp_weight_collected,
146
+ coalesce(today_weight_dispatch, 0) as today_weight_dispatch,
147
+ coalesce(sum(today_weight_dispatch) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_weight_dispatch,
148
+ coalesce(tot.today_out_turn, 0) as today_out_turn,
149
+ coalesce(sum(tot.today_out_turn) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_out_turn,
150
+ ${blockId != 'all-blocks' && blockId != '' ? `(select name from blocks b2 WHERE id = '${blockId}')` : `''`} as block,
151
+ coalesce(thr.today_harvesting_round, 0) as today_harvesting_round,
152
+ coalesce(thr.today_hectare_cover, 0) as today_hectare_cover
153
+ from
154
+ (select generate_series((date '${fromDateString}')::timestamp, (date '${toDateString}')::timestamp, interval '1 day')::date as dateDay) as md
155
+ left join (
156
+ select * from temp_records trx
157
+ where transaction_date between $1 and $2
158
+ order by transaction_date
159
+ ) as dt on dt.transaction_date::date = md.dateDay
160
+ LEFT JOIN (
161
+ select sum(harvesting_round) AS today_harvesting_round, sum(coverage) AS today_hectare_cover, harvest_date
162
+ from daily_harvests dh
163
+ inner join temp_blocks blk on blk.id = dh.block_id
164
+ where harvest_date between $1 and $2
165
+ group by blk.block_id, harvest_date
166
+ ) as thr ON thr.harvest_date::date = md.dateDay
167
+ LEFT JOIN (
168
+ select count(*) AS today_out_turn, dh.harvest_date
169
+ from daily_harvest_details dhd
170
+ inner join daily_harvests dh on dh.id = dhd.daily_harvest_id
171
+ inner join temp_blocks blk on blk.id = dh.block_id
172
+ where dh.harvest_date between $1 and $2
173
+ GROUP BY blk.block_id, dh.harvest_date
174
+ ) as tot ON tot.harvest_date::date = md.dateDay
175
+ ) dt
176
+ )`, [fromDateString, toDateString]);
177
+ const result = await tx.query(`
178
+ select * from temp_daily_production_data dt
179
+ `);
180
+ return result.map(itm => {
181
+ return {
182
+ block: itm.block,
183
+ dateDay: itm.date_day,
184
+ diffInBunches: parseFloat(itm.diff_in_bunches).toFixed(1),
185
+ prevBunchBalInField: parseFloat(itm.prev_bunch_bal_in_field).toFixed(1),
186
+ prevWeightBalInRamp: parseFloat(itm.prev_weight_bal_in_ramp).toFixed(4),
187
+ toDateBunchHarvest: parseFloat(itm.to_date_bunch_harvest).toFixed(1),
188
+ toDateOutTurn: itm.to_date_out_turn,
189
+ toDateWeightDispatch: parseFloat(itm.to_date_weight_dispatch).toFixed(4),
190
+ todayBunchBalInField: parseFloat(itm.today_bunch_bal_in_field).toFixed(1),
191
+ todayBunchCollected: parseFloat(itm.today_bunch_collected).toFixed(1),
192
+ todayBunchHarvest: parseFloat(itm.today_bunch_harvest).toFixed(1),
193
+ todayBunchInField: parseFloat(itm.today_bunch_in_field).toFixed(1),
194
+ todayHarvestingRound: itm.today_harvesting_round,
195
+ todayHectareCover: parseFloat(itm.today_hectare_cover).toFixed(4),
196
+ todayOutTurn: itm.today_out_turn,
197
+ todayWeightCollected: parseFloat(itm.today_ramp_weight_collected).toFixed(4),
198
+ todayWeightBalInRamp: parseFloat(itm.today_weight_bal_in_ramp).toFixed(4),
199
+ todayWeightDispatch: parseFloat(itm.today_weight_dispatch).toFixed(4),
200
+ };
201
+ });
202
+ }
203
+ exports.getDailyProductionData = getDailyProductionData;
82
204
  //# sourceMappingURL=dashboard-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard-query.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/dashboard/dashboard-query.ts"],"names":[],"mapp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,oBAAoB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YAClE,oBAAoB,EAAE,GAAG,CAAC,sBAAsB;YAChD,iBAAiB,EAAE,UAAU,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACjE,YAAY,EAAE,GAAG,CAAC,cAAc;YAChC,oBAAoB,EAAE,UAAU,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5E,oBAAoB,EAAE,UAAU,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACzE,mBAAmB,EAAE,UAAU,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;SACtE,CAAA;IACH,CAAC,CAAC,CAAA;AAEJ,CAAC;AAhJD,wDAgJC"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dailyFfbDispatchProductionReports = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ exports.dailyFfbDispatchProductionReports = {
7
+ async dailyFfbDispatchProductionReports(_, params, context) {
8
+ try {
9
+ const { domain, tx } = context.state;
10
+ let year = parseInt(params.filters.filter(x => x.name == 'month')[0].value.split('-')[0]);
11
+ let month = parseInt(params.filters.filter(x => x.name == 'month')[0].value.split('-')[1]);
12
+ let fromDate = new Date(year, month - 1, 1);
13
+ let toDate = new Date(year, month, 1);
14
+ toDate.setDate(toDate.getDate() - 1);
15
+ let fromDateString = [
16
+ fromDate.getFullYear().toString(),
17
+ String(fromDate.getMonth() + 1).padStart(2, '0'),
18
+ '01'
19
+ ].join('-');
20
+ let toDateString = [
21
+ toDate.getFullYear().toString(),
22
+ String(toDate.getMonth() + 1).padStart(2, '0'),
23
+ String(toDate.getDate()).padStart(2, '0')
24
+ ].join('-');
25
+ let ramps = await (0, typeorm_1.getRepository)(entities_1.Ramp).find({
26
+ where: { domain: domain.id, deletedAt: (0, typeorm_1.IsNull)() },
27
+ relations: ['block']
28
+ });
29
+ let organizations = await (0, typeorm_1.getRepository)(entities_1.Organization).find({
30
+ where: { domain: domain.id, deletedAt: (0, typeorm_1.IsNull)() }
31
+ });
32
+ let blocks = await tx.getRepository(entities_1.Block).query(`
33
+ SELECT b.id, b.name FROM ramps r
34
+ INNER JOIN blocks b ON b.id = r.block_id
35
+ WHERE b.deleted_at IS NULL
36
+ AND r.domain_id = $1
37
+ GROUP BY b.id, b.name
38
+ `, [domain.id]);
39
+ // -- WHERE dd.dispatch_at::timestamp between $1::timestamp and $2::timestamp
40
+ // [fromDateString, toDateString]
41
+ await tx.query(`create extension if not exists tablefunc`);
42
+ await tx.query(`
43
+ CREATE TEMP TABLE raw_block_dispatch ON COMMIT DROP AS (
44
+ SELECT "name", "dispatch_at", sum(weight) AS weight FROM(
45
+ SELECT * FROM (
46
+ SELECT dd.id,COALESCE(b.name, 'unknown') AS name, 1 AS "rank", dd.dispatch_at::date AS dispatch_at,
47
+ COALESCE(ddd.adjusted_weight, ddd.collected_ramp_weight, 0) AS weight
48
+ FROM daily_dispatches dd
49
+ INNER JOIN daily_dispatch_details ddd ON ddd.daily_dispatch_id = dd.id
50
+ INNER JOIN ramps r ON r.id = ddd.ramp_id
51
+ INNER JOIN blocks b ON b.id = r.block_id
52
+ WHERE dd.dispatch_at::date between $1 and $2
53
+ UNION
54
+ SELECT dd.id, COALESCE(c.name, 'unknown') AS name, CASE WHEN c.name IS NULL THEN 3 ELSE 2 END AS "rank", dd.dispatch_at::date AS dispatch_at,
55
+ COALESCE((SELECT SUM(COALESCE(ddd.adjusted_weight, ddd.collected_ramp_weight, 0)) FROM daily_dispatch_details ddd WHERE ddd.daily_dispatch_id = dd.id),0) AS weight
56
+ FROM daily_dispatches dd
57
+ LEFT JOIN organizations c ON c.id = dd.dispatch_to_id
58
+ WHERE dd.dispatch_at::date between $1 and $2
59
+ ) foo
60
+ ORDER BY "rank", "name", "dispatch_at"
61
+ ) foo
62
+ GROUP BY "name", "dispatch_at"
63
+ ORDER BY name, "dispatch_at"
64
+ )
65
+ `, [fromDateString, toDateString]);
66
+ await tx.query(`
67
+ CREATE TEMP TABLE pivot_block_dispatch ON COMMIT DROP AS (
68
+ SELECT * FROM crosstab(
69
+ $$
70
+ SELECT rbd."dispatch_at", rbd."name",
71
+ CONCAT('today: ', round(rbd.weight,2)::varchar, ' | todate: ', round(coalesce(sum(rbd.weight) over (PARTITION BY "name" ORDER BY name, dispatch_at asc rows between unbounded preceding and current row), 0),2)::varchar) AS weight
72
+ FROM raw_block_dispatch rbd
73
+ ORDER BY rbd."dispatch_at", rbd."name"
74
+ $$,
75
+ $$
76
+ SELECT b.name FROM ramps r INNER JOIN blocks b ON b.id = r.block_id WHERE r.deleted_at IS NULL AND r.domain_id = '${domain.id}'
77
+ GROUP BY b.id, b.name
78
+ UNION
79
+ SELECT c.name FROM organizations c
80
+ $$
81
+ ) AS (dispatch_at date, ${[...blocks.map(block => `"${block.name}" varchar`), ...organizations.map(organization => `"${organization.name}" varchar`)].join(',')},"unknown" varchar)
82
+ );
83
+ `);
84
+ await tx.query(`
85
+ CREATE TEMP TABLE temp_monthly_production_data ON COMMIT DROP AS (
86
+ SELECT TO_CHAR(md.dateDay:: DATE, 'dd/mm/yyyy') as "date"
87
+ , row_to_json((SELECT d FROM (SELECT ${[...blocks.map(block => `pbd."${block.name}"`), ...organizations.map(organization => `pbd."${organization.name}"`)].join(',')}, pbd."unknown") d))::varchar as "blockData"
88
+ , (SELECT sum(weight) FROM raw_block_dispatch rbd WHERE rbd.dispatch_at = pbd.dispatch_at) AS "today"
89
+ FROM (select generate_series((date '${fromDateString}')::timestamp, (date '${toDateString}')::timestamp, interval '1 day')::date as dateDay) as md
90
+ LEFT JOIN pivot_block_dispatch pbd on pbd.dispatch_at::date = md.dateDay
91
+ );
92
+ `);
93
+ const result = await tx.query(`
94
+ select "date", "blockData", "today"
95
+ from temp_monthly_production_data dt
96
+ `);
97
+ const total = await tx.query(`
98
+ select count(*) from temp_monthly_production_data
99
+ `);
100
+ return {
101
+ items: result.map(itm => {
102
+ return Object.assign({}, itm);
103
+ }), total: total[0].count
104
+ };
105
+ }
106
+ catch (error) {
107
+ throw error;
108
+ }
109
+ }
110
+ };
111
+ //# sourceMappingURL=daily-ffb-dispatch-production-reports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daily-ffb-dispatch-production-reports.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.ts"],"names":[],"mappings":";;;AAAA,qCAAmE;AAGnE,gDAA6D;AAEhD,QAAA,iCAAiC,GAAG;IAC/C,KAAK,CAAC,iCAAiC,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QAC7E,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAA0C,OAAO,CAAC,KAAK,CAAA;YAE3E,IAAI,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YACzF,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAE1F,IAAI,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;YAC3C,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;YACrC,MAAM,CAA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CAAA"}
@@ -42,10 +42,10 @@ exports.dailyProductionReports = {
42
42
  CREATE TEMP TABLE temp_records on commit drop AS (
43
43
  select blk.block_id, coalesce(sum(field_bunches),0) AS today_field_bunches,
44
44
  round(coalesce(sum(ramp_weight),0)::numeric,4) AS today_ramp_weight,
45
- sum(case when transaction_type = 'HARVEST' then field_bunches else 0 end) as today_bunch_harvest,
46
- sum(case when transaction_type = 'LOADING' then -field_bunches else 0 end) as today_bunch_collected,
47
- round(sum(case when transaction_type = 'LOADING' then ramp_weight else 0 end)::numeric,4) as today_ramp_weight_collected,
48
- round(sum(case when transaction_type = 'DISPATCHMENT' then -ramp_weight else 0 end)::numeric,4) as today_weight_dispatch,
45
+ sum(case when transaction_type = 'HARVEST' OR transaction_type = 'BUNCHES_ADJUSTMENT' then field_bunches else 0 end) as today_bunch_harvest,
46
+ sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then -field_bunches else 0 end) as today_bunch_collected,
47
+ round(sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then ramp_weight else 0 end)::numeric,4) as today_ramp_weight_collected,
48
+ round(sum(case when transaction_type = 'DISPATCHMENT' OR transaction_type = 'DISPATCHMENT_ADJUSTMENT' then -ramp_weight else 0 end)::numeric,4) as today_weight_dispatch,
49
49
  transaction_date
50
50
  from record_transactions t2
51
51
  inner join temp_blocks blk on blk.id = t2.block_id
@@ -110,10 +110,10 @@ exports.dailyProductionReports = {
110
110
  ) dt
111
111
  )`, [fromDateString, toDateString, block.id]);
112
112
  const result = await tx.query(`
113
- select * from temp_daily_production_data dt
113
+ select * from temp_daily_production_data dt
114
114
  `);
115
115
  const total = await tx.query(`
116
- select count(*) from temp_daily_production_data
116
+ select count(*) from temp_daily_production_data
117
117
  `);
118
118
  let items = result.map(itm => {
119
119
  return {
@@ -8,8 +8,9 @@ const yearly_production_reports_1 = require("./yearly-production-reports");
8
8
  const daily_staff_harvest_reports_1 = require("./daily-staff-harvest-reports");
9
9
  const monthly_block_dispatch_reports_1 = require("./monthly-block-dispatch-reports");
10
10
  const monthly_ffb_sale_reports_1 = require("./monthly-ffb-sale-reports");
11
+ const daily_ffb_dispatch_production_reports_1 = require("./daily-ffb-dispatch-production-reports");
11
12
  exports.ReportResolver = {
12
- Query: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, daily_production_reports_1.dailyProductionReports), monthly_production_reports_1.monthlyProductionReports), monthly_dispatch_summary_reports_1.monthlyDispatchSummaryReports), yearly_production_reports_1.yearlyProductionReports), daily_staff_harvest_reports_1.dailyStaffHarvestReports), monthly_block_dispatch_reports_1.monthlyBlockDispatchReports), monthly_ffb_sale_reports_1.monthlyFfbSaleReports),
13
+ Query: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, daily_production_reports_1.dailyProductionReports), monthly_production_reports_1.monthlyProductionReports), monthly_dispatch_summary_reports_1.monthlyDispatchSummaryReports), yearly_production_reports_1.yearlyProductionReports), daily_staff_harvest_reports_1.dailyStaffHarvestReports), monthly_block_dispatch_reports_1.monthlyBlockDispatchReports), monthly_ffb_sale_reports_1.monthlyFfbSaleReports), daily_ffb_dispatch_production_reports_1.dailyFfbDispatchProductionReports),
13
14
  Mutation: {}
14
15
  };
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/report/index.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,6EAAuE;AACvE,yFAAkF;AAClF,2EAAqE;AACrE,+EAAwE;AACxE,qFAA8E;AAC9E,yEAAkE;AAErD,QAAA,cAAc,GAAG;IAC5B,KAAK,wGACA,iDAAsB,GACtB,qDAAwB,GACxB,gEAA6B,GAC7B,mDAAuB,GACvB,sDAAwB,GACxB,4DAA2B,GAC3B,gDAAqB,CACzB;IACD,QAAQ,EAAE,EAAE;CACb,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/report/index.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,6EAAuE;AACvE,yFAAkF;AAClF,2EAAqE;AACrE,+EAAwE;AACxE,qFAA8E;AAC9E,yEAAkE;AAClE,mGAA2F;AAE9E,QAAA,cAAc,GAAG;IAC5B,KAAK,sHACA,iDAAsB,GACtB,qDAAwB,GACxB,gEAA6B,GAC7B,mDAAuB,GACvB,sDAAwB,GACxB,4DAA2B,GAC3B,gDAAqB,GACrB,yEAAiC,CACrC;IACD,QAAQ,EAAE,EAAE;CACb,CAAA"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.monthlyBlockDispatchReports = void 0;
4
- const typeorm_1 = require("typeorm");
5
4
  const entities_1 = require("../../../entities");
6
5
  exports.monthlyBlockDispatchReports = {
7
6
  async monthlyBlockDispatchReports(_, params, context) {
@@ -22,10 +21,13 @@ exports.monthlyBlockDispatchReports = {
22
21
  String(toDate.getMonth() + 1).padStart(2, '0'),
23
22
  String(toDate.getDate()).padStart(2, '0')
24
23
  ].join('-');
25
- let ramps = await (0, typeorm_1.getRepository)(entities_1.Ramp).find({
26
- where: { domain: domain.id, deletedAt: (0, typeorm_1.IsNull)() },
27
- relations: ['block']
28
- });
24
+ let blocks = await tx.getRepository(entities_1.Block).query(`
25
+ SELECT b.id, b.name FROM ramps r
26
+ INNER JOIN blocks b ON b.id = r.block_id
27
+ WHERE b.deleted_at IS NULL
28
+ AND r.domain_id = $1
29
+ GROUP BY b.id, b.name
30
+ `, [domain.id]);
29
31
  // -- WHERE dd.dispatch_at::timestamp between $1::timestamp and $2::timestamp
30
32
  // [fromDateString, toDateString]
31
33
  await tx.query(`create extension if not exists tablefunc`);
@@ -44,8 +46,8 @@ exports.monthlyBlockDispatchReports = {
44
46
  CREATE TEMP TABLE pivot_block_dispatch ON COMMIT DROP AS (
45
47
  SELECT * FROM crosstab(
46
48
  $$SELECT rbd.id, rbd.block_name, round(rbd.weight, 2 )::varchar FROM raw_block_dispatch rbd$$,
47
- $$SELECT b.name FROM ramps r INNER JOIN blocks b ON b.id = r.block_id WHERE r.deleted_at IS NULL$$
48
- ) AS ("id" uuid, ${ramps.map(ramp => `"${ramp.block.name}" varchar`).join(',')})
49
+ $$SELECT b.name FROM ramps r INNER JOIN blocks b ON b.id = r.block_id WHERE r.deleted_at IS NULL AND r.domain_id = '${domain.id}' GROUP BY b.id, b.name$$
50
+ ) AS ("id" uuid, ${blocks.map(block => `"${block.name}" varchar`).join(',')})
49
51
  );
50
52
  `);
51
53
  await tx.query(`
@@ -59,7 +61,7 @@ exports.monthlyBlockDispatchReports = {
59
61
  , dd.transport_no as "lorryNo"
60
62
  , dd.driver_identification as "driverIdentification"
61
63
  , TO_CHAR(dd.dispatch_at:: DATE, 'dd/mm/yyyy') as "date"
62
- , row_to_json((SELECT d FROM (SELECT ${ramps.map(ramp => `pbd."${ramp.block.name}"`).join(',')}) d))::varchar as "blockData"
64
+ , row_to_json((SELECT d FROM (SELECT ${blocks.map(block => `pbd."${block.name}"`).join(',')}) d))::varchar as "blockData"
63
65
  , (SELECT sum(weight) FROM raw_block_dispatch rbd WHERE rbd.id = dd.id) AS "today"
64
66
  FROM daily_dispatches dd
65
67
  INNER JOIN pivot_block_dispatch pbd ON pbd.id = dd.id
@@ -1 +1 @@
1
- {"version":3,"file":"monthly-block-dispatch-reports.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/report/monthly-block-dispatch-reports.ts"],"names":[],"mappings":";;;AAAA,qCAAmE;AAGnE,gDAAwC;AAE3B,QAAA,2BAA2B,GAAG;IACzC,KAAK,CAAC,2BAA2B,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QACvE,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAA0C,OAAO,CAAC,KAAK,CAAA;YAE3E,IAAI,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,O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,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;oBACtB,yBACK,GAAG,EACP;gBACH,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;aAC1B,CAAA;SACF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF,CAAA"}
@@ -35,7 +35,7 @@ exports.monthlyFfbSaleReports = {
35
35
  SELECT "id", dispatch_at, transport_no AS "lorryNo",
36
36
  driver_identification AS "driverIdentification", chit_no AS "chitNo", round(COALESCE(percentage,0)::numeric, 2)::varchar AS "percentage",
37
37
  COALESCE(diapatch_to_name, 'UNKNOWN') AS "dispatchTo", round(COALESCE(tonnage,0), 2)::varchar AS "tonnage",
38
- CASE WHEN forward_rn = 1 THEN dispatch_at::date::varchar ELSE '' END AS "dispatchAt",
38
+ CASE WHEN forward_rn = 1 THEN TO_CHAR(dispatch_at:: DATE, 'dd/mm/yyyy') ELSE '' END AS "dispatchAt",
39
39
  CASE WHEN reverse_rn = 1 THEN round((coalesce(sum(percentage) over (PARTITION BY dispatch_to_id, dispatch_at::date ORDER BY dispatch_at asc rows between unbounded preceding and current row), 0)/forward_rn)::numeric,2)::varchar ELSE '' END AS "todayAvg",
40
40
  CASE WHEN reverse_rn = 1 THEN round((coalesce(sum(percentage) over (PARTITION BY dispatch_to_id ORDER BY dispatch_at asc rows between unbounded preceding and current row), 0)/forward_rn)::numeric,2)::varchar ELSE '' END AS "todateAvg",
41
41
  CASE WHEN reverse_rn = 1 THEN round(coalesce(sum(tonnage) over (PARTITION BY dispatch_to_id, dispatch_at::date ORDER BY dispatch_at asc rows between unbounded preceding and current row), 0),2)::varchar ELSE '' END AS "today",
@@ -70,8 +70,8 @@ exports.monthlyProductionReports = {
70
70
  left join(
71
71
  select blk.block_id, sum(total_weight) as total_weight_loaded, sum(total_bunch) as total_bunch_loaded
72
72
  from daily_loadings dl
73
- inner join temp_blocks blk on blk.id = dl.block_id
74
73
  inner join daily_loading_details dld on dld.daily_loading_id = dl.id
74
+ inner join temp_blocks blk on blk.id = dld.block_id
75
75
  where dl.loading_date::timestamp between $1::timestamp and $2::timestamp
76
76
  group by blk.block_id
77
77
  ) as loading on loading.block_id = b.id
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DailyFfbDispatchProductionReportList = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.DailyFfbDispatchProductionReportList = (0, graphql_tag_1.default) `
9
+ type DailyFfbDispatchProductionReportList {
10
+ items: [DailyFfbDispatchProductionReport]
11
+ total: Int
12
+ }
13
+ `;
14
+ //# sourceMappingURL=daily-ffb-dispatch-production-report-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daily-ffb-dispatch-production-report-list.js","sourceRoot":"","sources":["../../../../server/graphql/types/report/daily-ffb-dispatch-production-report-list.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,oCAAoC,GAAG,IAAA,qBAAG,EAAA;;;;;CAKtD,CAAA"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DailyFfbDispatchProductionReport = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.DailyFfbDispatchProductionReport = (0, graphql_tag_1.default) `
9
+ type DailyFfbDispatchProductionReport {
10
+ date: String
11
+ blockData: String
12
+ today: String
13
+ }
14
+ `;
15
+ //# sourceMappingURL=daily-ffb-dispatch-production-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daily-ffb-dispatch-production-report.js","sourceRoot":"","sources":["../../../../server/graphql/types/report/daily-ffb-dispatch-production-report.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,gCAAgC,GAAG,IAAA,qBAAG,EAAA;;;;;;CAMlD,CAAA"}
@@ -27,15 +27,19 @@ __exportStar(require("./monthly-production-report-list"), exports);
27
27
  __exportStar(require("./monthly-production-report"), exports);
28
28
  __exportStar(require("./yearly-production-report-list"), exports);
29
29
  __exportStar(require("./yearly-production-report"), exports);
30
+ __exportStar(require("./daily-ffb-dispatch-production-report"), exports);
31
+ __exportStar(require("./daily-ffb-dispatch-production-report-list"), exports);
30
32
  exports.ReportResolver = (0, graphql_tag_1.default) `
31
33
  extend type Query {
32
34
  dailyProductionReports(filters: [Filter], pagination: Pagination, sortings: [Sorting]): DailyProductionReportList
33
35
  @transaction
36
+
34
37
  monthlyProductionReports(
35
38
  filters: [Filter]
36
39
  pagination: Pagination
37
40
  sortings: [Sorting]
38
41
  ): MonthlyProductionReportList @transaction
42
+
39
43
  yearlyProductionReports(filters: [Filter], pagination: Pagination, sortings: [Sorting]): YearlyProductionReportList
40
44
  @transaction
41
45
  dailyStaffHarvestReports(
@@ -43,21 +47,30 @@ exports.ReportResolver = (0, graphql_tag_1.default) `
43
47
  pagination: Pagination
44
48
  sortings: [Sorting]
45
49
  ): DailyStaffHarvestReportList @transaction
50
+
46
51
  monthlyDispatchSummaryReports(
47
52
  filters: [Filter],
48
53
  pagination: Pagination,
49
54
  sortings: [Sorting]
50
55
  ): MonthlyDispatchSummaryReportList @transaction
56
+
51
57
  monthlyBlockDispatchReports(
52
58
  filters: [Filter],
53
59
  pagination: Pagination,
54
60
  sortings: [Sorting]
55
61
  ): MonthlyBlockDispatchReportList @transaction
62
+
56
63
  monthlyFfbSaleReports(
57
64
  filters: [Filter],
58
65
  pagination: Pagination,
59
66
  sortings: [Sorting]
60
67
  ): MonthlyDispatchSummaryReportList @transaction
68
+
69
+ dailyFfbDispatchProductionReports(
70
+ filters: [Filter],
71
+ pagination: Pagination,
72
+ sortings: [Sorting]
73
+ ): DailyFfbDispatchProductionReportList @transaction
61
74
  }
62
75
 
63
76
  `;