@things-factory/operato-pms 3.7.7 → 3.8.19
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/bootstrap.js +20 -7
- package/client/component/block-selector-popup.js +125 -24
- package/client/component/driver-selector-popup.js +223 -0
- package/client/component/mill-selector-popup.js +200 -0
- package/client/component/tracked-plantation-setting.js +113 -0
- package/client/component/truck-selector-popup.js +202 -0
- package/client/menu.js +34 -2
- package/client/pages/constants/index.js +1 -0
- package/client/pages/constants/organization.js +5 -0
- package/client/pages/dispatchment/daily-dispatch-detail.js +57 -18
- package/client/pages/dispatchment/dispatchment-create-record.js +154 -52
- package/client/pages/dispatchment/dispatchment-list.js +26 -34
- package/client/pages/harvesting/daily-harvesting-detail.js +55 -18
- package/client/pages/harvesting/edit-harvesting-record.js +89 -23
- package/client/pages/harvesting/harvesting-create-record.js +102 -16
- package/client/pages/harvesting/harvesting-list.js +58 -12
- package/client/pages/inventory/inventory-field-bunches.js +6 -4
- package/client/pages/inventory/inventory-ramp-tonnage.js +23 -31
- package/client/pages/loading/daily-loading-detail.js +47 -93
- package/client/pages/loading/edit-loading-record.js +75 -294
- package/client/pages/loading/loading-create-record.js +52 -329
- package/client/pages/loading/loading-list.js +20 -83
- package/client/pages/master/block.js +1 -0
- package/client/pages/master/company.js +26 -13
- package/client/pages/master/home.js +67 -65
- package/client/pages/master/ramp.js +1 -0
- package/client/pages/master/staff.js +54 -3
- package/client/pages/master/truck.js +416 -0
- package/client/pages/report/home.js +72 -65
- package/client/pages/report/report-daily-ffb-dispatch-and-production.js +436 -0
- package/client/pages/report/report-daily-production.js +38 -6
- package/client/pages/report/report-daily-staff-harvest.js +50 -5
- package/client/pages/report/report-ffb-tonnage-between-individual-block.js +398 -0
- package/client/pages/report/report-monthly-ffb-sale.js +413 -0
- package/client/pages/report/report-monthly-production.js +33 -4
- package/client/pages/report/report-yearly-production.js +24 -8
- package/client/pages/setting/home.js +107 -0
- package/client/pages/setting/plantation-setting.js +109 -0
- package/client/route.js +25 -0
- package/dist-server/constants/index.js +1 -0
- package/dist-server/constants/index.js.map +1 -1
- package/dist-server/constants/organization.js +9 -0
- package/dist-server/constants/organization.js.map +1 -0
- package/dist-server/constants/transaction.js +2 -1
- package/dist-server/constants/transaction.js.map +1 -1
- package/dist-server/controllers/render-dispatchment.js +1 -1
- package/dist-server/controllers/render-dispatchment.js.map +1 -1
- package/dist-server/entities/daily-dispatch.js +18 -4
- package/dist-server/entities/daily-dispatch.js.map +1 -1
- package/dist-server/entities/daily-harvest-detail.js +9 -11
- package/dist-server/entities/daily-harvest-detail.js.map +1 -1
- package/dist-server/entities/daily-harvest.js +16 -6
- package/dist-server/entities/daily-harvest.js.map +1 -1
- package/dist-server/entities/daily-loading-detail.js +14 -6
- package/dist-server/entities/daily-loading-detail.js.map +1 -1
- package/dist-server/entities/daily-loading.js +3 -11
- package/dist-server/entities/daily-loading.js.map +1 -1
- package/dist-server/entities/index.js +7 -1
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/organization-staff.js +5 -1
- package/dist-server/entities/organization-staff.js.map +1 -1
- package/dist-server/entities/plantation-inventory.js +4 -10
- package/dist-server/entities/plantation-inventory.js.map +1 -1
- package/dist-server/entities/plantation-setting.js +76 -0
- package/dist-server/entities/plantation-setting.js.map +1 -0
- package/dist-server/entities/truck.js +77 -0
- package/dist-server/entities/truck.js.map +1 -0
- package/dist-server/graphql/resolvers/daily-dispatch/daily-dispatch-query.js +13 -2
- 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 +25 -11
- package/dist-server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-dispatch/update-daily-dispatch.js +4 -3
- package/dist-server/graphql/resolvers/daily-dispatch/update-daily-dispatch.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-harvest/daily-harvest-query.js +3 -1
- package/dist-server/graphql/resolvers/daily-harvest/daily-harvest-query.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-harvest/generate-daily-harvest.js +21 -2
- package/dist-server/graphql/resolvers/daily-harvest/generate-daily-harvest.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-harvest/update-daily-harvest.js +8 -2
- package/dist-server/graphql/resolvers/daily-harvest/update-daily-harvest.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-loading/daily-loading-query.js +4 -6
- 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 +20 -54
- package/dist-server/graphql/resolvers/daily-loading/generate-daily-loading.js.map +1 -1
- package/dist-server/graphql/resolvers/daily-loading/update-daily-loading.js +31 -106
- package/dist-server/graphql/resolvers/daily-loading/update-daily-loading.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/dashboard-query.js +204 -0
- package/dist-server/graphql/resolvers/dashboard/dashboard-query.js.map +1 -0
- package/dist-server/graphql/resolvers/dashboard/index.js +8 -0
- package/dist-server/graphql/resolvers/dashboard/index.js.map +1 -0
- package/dist-server/graphql/resolvers/index.js +9 -6
- package/dist-server/graphql/resolvers/index.js.map +1 -1
- package/dist-server/graphql/resolvers/organization-staff/organization-staff-query.js +7 -3
- package/dist-server/graphql/resolvers/organization-staff/organization-staff-query.js.map +1 -1
- package/dist-server/graphql/resolvers/plantation-setting/create-plantation-setting.js +12 -0
- package/dist-server/graphql/resolvers/plantation-setting/create-plantation-setting.js.map +1 -0
- package/dist-server/graphql/resolvers/plantation-setting/delete-plantation-setting.js +13 -0
- package/dist-server/graphql/resolvers/plantation-setting/delete-plantation-setting.js.map +1 -0
- package/dist-server/graphql/resolvers/plantation-setting/delete-plantation-settings.js +16 -0
- package/dist-server/graphql/resolvers/plantation-setting/delete-plantation-settings.js.map +1 -0
- package/dist-server/graphql/resolvers/plantation-setting/index.js +15 -0
- package/dist-server/graphql/resolvers/plantation-setting/index.js.map +1 -0
- package/dist-server/graphql/resolvers/plantation-setting/plantation-setting-query.js +33 -0
- package/dist-server/graphql/resolvers/plantation-setting/plantation-setting-query.js.map +1 -0
- package/dist-server/graphql/resolvers/plantation-setting/update-multiple-plantation-setting.js +31 -0
- package/dist-server/graphql/resolvers/plantation-setting/update-multiple-plantation-setting.js.map +1 -0
- package/dist-server/graphql/resolvers/plantation-setting/update-plantation-setting.js +16 -0
- package/dist-server/graphql/resolvers/plantation-setting/update-plantation-setting.js.map +1 -0
- package/dist-server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.js +111 -0
- package/dist-server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.js.map +1 -0
- package/dist-server/graphql/resolvers/report/daily-production-reports.js +50 -37
- package/dist-server/graphql/resolvers/report/daily-production-reports.js.map +1 -1
- package/dist-server/graphql/resolvers/report/daily-staff-harvest-reports.js +21 -10
- package/dist-server/graphql/resolvers/report/daily-staff-harvest-reports.js.map +1 -1
- package/dist-server/graphql/resolvers/report/index.js +5 -1
- package/dist-server/graphql/resolvers/report/index.js.map +1 -1
- package/dist-server/graphql/resolvers/report/monthly-block-dispatch-reports.js +91 -0
- package/dist-server/graphql/resolvers/report/monthly-block-dispatch-reports.js.map +1 -0
- package/dist-server/graphql/resolvers/report/monthly-dispatch-summary-reports.js +89 -0
- package/dist-server/graphql/resolvers/report/monthly-dispatch-summary-reports.js.map +1 -0
- package/dist-server/graphql/resolvers/report/monthly-ffb-sale-reports.js +87 -0
- package/dist-server/graphql/resolvers/report/monthly-ffb-sale-reports.js.map +1 -0
- package/dist-server/graphql/resolvers/report/monthly-production-reports.js +46 -31
- package/dist-server/graphql/resolvers/report/monthly-production-reports.js.map +1 -1
- package/dist-server/graphql/resolvers/report/yearly-production-reports.js +38 -28
- package/dist-server/graphql/resolvers/report/yearly-production-reports.js.map +1 -1
- package/dist-server/graphql/resolvers/truck/delete-trucks.js +18 -0
- package/dist-server/graphql/resolvers/truck/delete-trucks.js.map +1 -0
- package/dist-server/graphql/resolvers/truck/index.js +12 -0
- package/dist-server/graphql/resolvers/truck/index.js.map +1 -0
- package/dist-server/graphql/resolvers/truck/truck-query.js +46 -0
- package/dist-server/graphql/resolvers/truck/truck-query.js.map +1 -0
- package/dist-server/graphql/resolvers/truck/update-multiple-truck.js +40 -0
- package/dist-server/graphql/resolvers/truck/update-multiple-truck.js.map +1 -0
- package/dist-server/graphql/types/daily-dispatch/daily-dispatch-patch.js +4 -1
- package/dist-server/graphql/types/daily-dispatch/daily-dispatch-patch.js.map +1 -1
- package/dist-server/graphql/types/daily-dispatch/daily-dispatch.js +4 -1
- package/dist-server/graphql/types/daily-dispatch/daily-dispatch.js.map +1 -1
- package/dist-server/graphql/types/daily-dispatch/index.js +6 -1
- package/dist-server/graphql/types/daily-dispatch/index.js.map +1 -1
- package/dist-server/graphql/types/daily-dispatch/new-daily-dispatch.js +4 -1
- package/dist-server/graphql/types/daily-dispatch/new-daily-dispatch.js.map +1 -1
- package/dist-server/graphql/types/daily-harvest/daily-harvest-patch.js +5 -2
- package/dist-server/graphql/types/daily-harvest/daily-harvest-patch.js.map +1 -1
- package/dist-server/graphql/types/daily-harvest/daily-harvest.js +3 -0
- package/dist-server/graphql/types/daily-harvest/daily-harvest.js.map +1 -1
- package/dist-server/graphql/types/daily-harvest/new-daily-harvest.js +4 -1
- package/dist-server/graphql/types/daily-harvest/new-daily-harvest.js.map +1 -1
- package/dist-server/graphql/types/daily-harvest-detail/daily-harvest-detail-patch.js +1 -0
- package/dist-server/graphql/types/daily-harvest-detail/daily-harvest-detail-patch.js.map +1 -1
- package/dist-server/graphql/types/daily-harvest-detail/daily-harvest-detail.js +1 -0
- package/dist-server/graphql/types/daily-harvest-detail/daily-harvest-detail.js.map +1 -1
- package/dist-server/graphql/types/daily-harvest-detail/new-daily-harvest-detail.js +1 -0
- package/dist-server/graphql/types/daily-harvest-detail/new-daily-harvest-detail.js.map +1 -1
- package/dist-server/graphql/types/daily-loading/daily-loading-patch.js +0 -2
- package/dist-server/graphql/types/daily-loading/daily-loading-patch.js.map +1 -1
- package/dist-server/graphql/types/daily-loading/daily-loading.js +0 -2
- package/dist-server/graphql/types/daily-loading/daily-loading.js.map +1 -1
- package/dist-server/graphql/types/daily-loading/new-daily-loading.js +0 -2
- package/dist-server/graphql/types/daily-loading/new-daily-loading.js.map +1 -1
- package/dist-server/graphql/types/daily-loading-detail/daily-loading-detail-patch.js +6 -3
- package/dist-server/graphql/types/daily-loading-detail/daily-loading-detail-patch.js.map +1 -1
- package/dist-server/graphql/types/daily-loading-detail/daily-loading-detail.js +3 -0
- package/dist-server/graphql/types/daily-loading-detail/daily-loading-detail.js.map +1 -1
- package/dist-server/graphql/types/daily-loading-detail/new-daily-loading-detail.js +6 -3
- package/dist-server/graphql/types/daily-loading-detail/new-daily-loading-detail.js.map +1 -1
- package/dist-server/graphql/types/dashboard/bunches-count.js +15 -0
- package/dist-server/graphql/types/dashboard/bunches-count.js.map +1 -0
- package/dist-server/graphql/types/dashboard/index.js +32 -0
- package/dist-server/graphql/types/dashboard/index.js.map +1 -0
- package/dist-server/graphql/types/dashboard/productions-overview.js +15 -0
- package/dist-server/graphql/types/dashboard/productions-overview.js.map +1 -0
- package/dist-server/graphql/types/dashboard/tonnage-bunches-inventories.js +14 -0
- package/dist-server/graphql/types/dashboard/tonnage-bunches-inventories.js.map +1 -0
- package/dist-server/graphql/types/dashboard/tonnage-production.js +17 -0
- package/dist-server/graphql/types/dashboard/tonnage-production.js.map +1 -0
- package/dist-server/graphql/types/dashboard/yield-production.js +17 -0
- package/dist-server/graphql/types/dashboard/yield-production.js.map +1 -0
- package/dist-server/graphql/types/index.js +9 -6
- package/dist-server/graphql/types/index.js.map +1 -1
- package/dist-server/graphql/types/organization-staff/organization-staff-patch.js +2 -0
- package/dist-server/graphql/types/organization-staff/organization-staff-patch.js.map +1 -1
- package/dist-server/graphql/types/organization-staff/organization-staff.js +3 -0
- package/dist-server/graphql/types/organization-staff/organization-staff.js.map +1 -1
- package/dist-server/graphql/types/plantation-setting/index.js +36 -0
- package/dist-server/graphql/types/plantation-setting/index.js.map +1 -0
- package/dist-server/graphql/types/plantation-setting/new-plantation-setting.js +16 -0
- package/dist-server/graphql/types/plantation-setting/new-plantation-setting.js.map +1 -0
- package/dist-server/graphql/types/plantation-setting/plantation-setting-list.js +14 -0
- package/dist-server/graphql/types/plantation-setting/plantation-setting-list.js.map +1 -0
- package/dist-server/graphql/types/plantation-setting/plantation-setting-patch.js +18 -0
- package/dist-server/graphql/types/plantation-setting/plantation-setting-patch.js.map +1 -0
- package/dist-server/graphql/types/plantation-setting/plantation-setting.js +22 -0
- package/dist-server/graphql/types/plantation-setting/plantation-setting.js.map +1 -0
- package/dist-server/graphql/types/report/daily-ffb-dispatch-production-report-list.js +14 -0
- package/dist-server/graphql/types/report/daily-ffb-dispatch-production-report-list.js.map +1 -0
- package/dist-server/graphql/types/report/daily-ffb-dispatch-production-report.js +15 -0
- package/dist-server/graphql/types/report/daily-ffb-dispatch-production-report.js.map +1 -0
- package/dist-server/graphql/types/report/index.js +33 -0
- package/dist-server/graphql/types/report/index.js.map +1 -1
- package/dist-server/graphql/types/report/monthly-block-dispatch-report-list.js +14 -0
- package/dist-server/graphql/types/report/monthly-block-dispatch-report-list.js.map +1 -0
- package/dist-server/graphql/types/report/monthly-block-dispatch-report.js +19 -0
- package/dist-server/graphql/types/report/monthly-block-dispatch-report.js.map +1 -0
- package/dist-server/graphql/types/report/monthly-dispatch-summary-report-list.js +14 -0
- package/dist-server/graphql/types/report/monthly-dispatch-summary-report-list.js.map +1 -0
- package/dist-server/graphql/types/report/monthly-dispatch-summary-report.js +25 -0
- package/dist-server/graphql/types/report/monthly-dispatch-summary-report.js.map +1 -0
- package/dist-server/graphql/types/report/monthly-ffb-sale-report-list.js +14 -0
- package/dist-server/graphql/types/report/monthly-ffb-sale-report-list.js.map +1 -0
- package/dist-server/graphql/types/report/monthly-ffb-sale-report.js +24 -0
- package/dist-server/graphql/types/report/monthly-ffb-sale-report.js.map +1 -0
- package/dist-server/graphql/types/truck/index.js +33 -0
- package/dist-server/graphql/types/truck/index.js.map +1 -0
- package/dist-server/graphql/types/truck/new-truck.js +14 -0
- package/dist-server/graphql/types/truck/new-truck.js.map +1 -0
- package/dist-server/graphql/types/truck/truck-list.js +14 -0
- package/dist-server/graphql/types/truck/truck-list.js.map +1 -0
- package/dist-server/graphql/types/truck/truck-patch.js +17 -0
- package/dist-server/graphql/types/truck/truck-patch.js.map +1 -0
- package/dist-server/graphql/types/truck/truck.js +22 -0
- package/dist-server/graphql/types/truck/truck.js.map +1 -0
- package/dist-server/utils/core-values.js +2 -2
- package/dist-server/utils/transaction-util.js +2 -1
- package/dist-server/utils/transaction-util.js.map +1 -1
- package/package.json +29 -29
- package/server/constants/index.ts +1 -0
- package/server/constants/organization.ts +5 -0
- package/server/constants/transaction.ts +2 -1
- package/server/controllers/render-dispatchment.ts +1 -1
- package/server/entities/daily-dispatch.ts +18 -5
- package/server/entities/daily-harvest-detail.ts +10 -11
- package/server/entities/daily-harvest.ts +16 -7
- package/server/entities/daily-loading-detail.ts +14 -6
- package/server/entities/daily-loading.ts +7 -11
- package/server/entities/index.ts +6 -0
- package/server/entities/organization-staff.ts +6 -1
- package/server/entities/plantation-inventory.ts +6 -10
- package/server/entities/plantation-setting.ts +60 -0
- package/server/entities/truck.ts +58 -0
- package/server/graphql/resolvers/daily-dispatch/daily-dispatch-query.ts +15 -2
- package/server/graphql/resolvers/daily-dispatch/generate-daily-dispatch.ts +40 -14
- package/server/graphql/resolvers/daily-dispatch/update-daily-dispatch.ts +8 -4
- package/server/graphql/resolvers/daily-harvest/daily-harvest-query.ts +7 -2
- package/server/graphql/resolvers/daily-harvest/generate-daily-harvest.ts +50 -4
- package/server/graphql/resolvers/daily-harvest/update-daily-harvest.ts +12 -2
- package/server/graphql/resolvers/daily-loading/daily-loading-query.ts +6 -6
- package/server/graphql/resolvers/daily-loading/generate-daily-loading.ts +27 -109
- package/server/graphql/resolvers/daily-loading/update-daily-loading.ts +56 -214
- package/server/graphql/resolvers/dashboard/dashboard-query.ts +252 -0
- package/server/graphql/resolvers/dashboard/index.ts +5 -0
- package/server/graphql/resolvers/index.ts +10 -6
- package/server/graphql/resolvers/organization-staff/organization-staff-query.ts +13 -4
- package/server/graphql/resolvers/plantation-setting/create-plantation-setting.ts +16 -0
- package/server/graphql/resolvers/plantation-setting/delete-plantation-setting.ts +13 -0
- package/server/graphql/resolvers/plantation-setting/delete-plantation-settings.ts +16 -0
- package/server/graphql/resolvers/plantation-setting/index.ts +19 -0
- package/server/graphql/resolvers/plantation-setting/plantation-setting-query.ts +38 -0
- package/server/graphql/resolvers/plantation-setting/update-multiple-plantation-setting.ts +46 -0
- package/server/graphql/resolvers/plantation-setting/update-plantation-setting.ts +19 -0
- package/server/graphql/resolvers/report/daily-ffb-dispatch-production-reports.ts +138 -0
- package/server/graphql/resolvers/report/daily-production-reports.ts +59 -48
- package/server/graphql/resolvers/report/daily-staff-harvest-reports.ts +28 -20
- package/server/graphql/resolvers/report/index.ts +9 -1
- package/server/graphql/resolvers/report/monthly-block-dispatch-reports.ts +114 -0
- package/server/graphql/resolvers/report/monthly-dispatch-summary-reports.ts +110 -0
- package/server/graphql/resolvers/report/monthly-ffb-sale-reports.ts +107 -0
- package/server/graphql/resolvers/report/monthly-production-reports.ts +54 -40
- package/server/graphql/resolvers/report/yearly-production-reports.ts +43 -38
- package/server/graphql/resolvers/truck/delete-trucks.ts +21 -0
- package/server/graphql/resolvers/truck/index.ts +12 -0
- package/server/graphql/resolvers/truck/truck-query.ts +52 -0
- package/server/graphql/resolvers/truck/update-multiple-truck.ts +55 -0
- package/server/graphql/types/daily-dispatch/daily-dispatch-patch.ts +4 -1
- package/server/graphql/types/daily-dispatch/daily-dispatch.ts +4 -1
- package/server/graphql/types/daily-dispatch/index.ts +6 -1
- package/server/graphql/types/daily-dispatch/new-daily-dispatch.ts +4 -1
- package/server/graphql/types/daily-harvest/daily-harvest-patch.ts +5 -2
- package/server/graphql/types/daily-harvest/daily-harvest.ts +3 -0
- package/server/graphql/types/daily-harvest/new-daily-harvest.ts +4 -1
- package/server/graphql/types/daily-harvest-detail/daily-harvest-detail-patch.ts +1 -0
- package/server/graphql/types/daily-harvest-detail/daily-harvest-detail.ts +1 -0
- package/server/graphql/types/daily-harvest-detail/new-daily-harvest-detail.ts +1 -0
- package/server/graphql/types/daily-loading/daily-loading-patch.ts +0 -2
- package/server/graphql/types/daily-loading/daily-loading.ts +0 -2
- package/server/graphql/types/daily-loading/new-daily-loading.ts +0 -2
- package/server/graphql/types/daily-loading-detail/daily-loading-detail-patch.ts +6 -3
- package/server/graphql/types/daily-loading-detail/daily-loading-detail.ts +3 -0
- package/server/graphql/types/daily-loading-detail/new-daily-loading-detail.ts +6 -3
- package/server/graphql/types/dashboard/bunches-count.ts +9 -0
- package/server/graphql/types/dashboard/index.ts +17 -0
- package/server/graphql/types/dashboard/productions-overview.ts +9 -0
- package/server/graphql/types/dashboard/tonnage-bunches-inventories.ts +8 -0
- package/server/graphql/types/dashboard/tonnage-production.ts +11 -0
- package/server/graphql/types/dashboard/yield-production.ts +11 -0
- package/server/graphql/types/index.ts +10 -6
- package/server/graphql/types/organization-staff/organization-staff-patch.ts +2 -0
- package/server/graphql/types/organization-staff/organization-staff.ts +3 -0
- package/server/graphql/types/plantation-setting/index.ts +21 -0
- package/server/graphql/types/plantation-setting/new-plantation-setting.ts +10 -0
- package/server/graphql/types/plantation-setting/plantation-setting-list.ts +8 -0
- package/server/graphql/types/plantation-setting/plantation-setting-patch.ts +12 -0
- package/server/graphql/types/plantation-setting/plantation-setting.ts +16 -0
- package/server/graphql/types/report/daily-ffb-dispatch-production-report-list.ts +8 -0
- package/server/graphql/types/report/daily-ffb-dispatch-production-report.ts +9 -0
- package/server/graphql/types/report/index.ts +33 -0
- package/server/graphql/types/report/monthly-block-dispatch-report-list.ts +7 -0
- package/server/graphql/types/report/monthly-block-dispatch-report.ts +13 -0
- package/server/graphql/types/report/monthly-dispatch-summary-report-list.ts +7 -0
- package/server/graphql/types/report/monthly-dispatch-summary-report.ts +19 -0
- package/server/graphql/types/report/monthly-ffb-sale-report-list.ts +7 -0
- package/server/graphql/types/report/monthly-ffb-sale-report.ts +18 -0
- package/server/graphql/types/truck/index.ts +18 -0
- package/server/graphql/types/truck/new-truck.ts +8 -0
- package/server/graphql/types/truck/truck-list.ts +8 -0
- package/server/graphql/types/truck/truck-patch.ts +11 -0
- package/server/graphql/types/truck/truck.ts +16 -0
- package/server/utils/core-values.ts +2 -2
- package/server/utils/transaction-util.ts +2 -1
- package/things-factory.config.js +27 -1
- package/translations/en.json +79 -16
- package/translations/ko.json +78 -48
- package/translations/ms.json +78 -48
- package/translations/zh.json +78 -48
|
@@ -1,17 +1,11 @@
|
|
|
1
|
+
import { EntityManager, getRepository, Repository } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { User } from '@things-factory/auth-base'
|
|
2
4
|
import { Domain } from '@things-factory/shell'
|
|
3
|
-
|
|
4
|
-
import { INVENTORY_TYPE,
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
DailyLoading,
|
|
8
|
-
DailyLoadingDetail,
|
|
9
|
-
DailyLoadingRamp,
|
|
10
|
-
Ramp,
|
|
11
|
-
OrganizationStaff,
|
|
12
|
-
PlantationInventory
|
|
13
|
-
} from '../../../entities'
|
|
14
|
-
import { NoGenerator, generateTransactionHistory } from '../../../utils'
|
|
5
|
+
|
|
6
|
+
import { INVENTORY_TYPE, TRANSACTION_TYPE } from '../../../constants'
|
|
7
|
+
import { Block, DailyLoading, DailyLoadingDetail, PlantationInventory, Ramp, Truck } from '../../../entities'
|
|
8
|
+
import { generateTransactionHistory, NoGenerator } from '../../../utils'
|
|
15
9
|
|
|
16
10
|
export const updateDailyLoading = {
|
|
17
11
|
async updateDailyLoading(_: any, { name, dailyLoadingPatch }, context: any) {
|
|
@@ -21,23 +15,13 @@ export const updateDailyLoading = {
|
|
|
21
15
|
let dailyLoading: DailyLoading = await dailyLoadingRepo.findOne({
|
|
22
16
|
where: { name },
|
|
23
17
|
relations: [
|
|
24
|
-
'block',
|
|
25
18
|
'dailyLoadingDetails',
|
|
26
|
-
'dailyLoadingDetails.
|
|
27
|
-
'
|
|
28
|
-
'
|
|
19
|
+
'dailyLoadingDetails.truck',
|
|
20
|
+
'dailyLoadingDetails.ramp',
|
|
21
|
+
'dailyLoadingDetails.block'
|
|
29
22
|
]
|
|
30
23
|
})
|
|
31
24
|
|
|
32
|
-
const block: Block = await tx.getRepository(Block).findOne({
|
|
33
|
-
where: { name: dailyLoadingPatch.block }
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const {
|
|
37
|
-
totalBunch: prevLoadedBunch,
|
|
38
|
-
totalWeight: prevLoadedTonnage
|
|
39
|
-
}: { totalBunch: number; totalWeight: number } = dailyLoading
|
|
40
|
-
|
|
41
25
|
// get sum of bunch loaded from all trip
|
|
42
26
|
var totalBunch: number = dailyLoadingPatch.dailyLoadingDetails.reduce(function (prev, cur) {
|
|
43
27
|
return prev + cur.totalBunchLoaded
|
|
@@ -47,7 +31,6 @@ export const updateDailyLoading = {
|
|
|
47
31
|
return prev + cur.totalBunchWeight
|
|
48
32
|
}, 0)
|
|
49
33
|
|
|
50
|
-
dailyLoading.block = block
|
|
51
34
|
dailyLoading.totalBunch = totalBunch
|
|
52
35
|
dailyLoading.totalWeight = totalWeight
|
|
53
36
|
dailyLoading.loadingDate = dailyLoadingPatch.loadingDate
|
|
@@ -56,8 +39,6 @@ export const updateDailyLoading = {
|
|
|
56
39
|
|
|
57
40
|
// 2. Create daily loading detail
|
|
58
41
|
await updateDailyLoadingDetail(domain, dailyLoading, dailyLoadingPatch.dailyLoadingDetails, user, tx)
|
|
59
|
-
await updateDailyLoadingRamp(domain, dailyLoading, dailyLoadingPatch.dailyLoadingRamps, user, tx)
|
|
60
|
-
await updatePlantationInventory(domain, dailyLoading, prevLoadedBunch, prevLoadedTonnage, block, user, tx)
|
|
61
42
|
|
|
62
43
|
return dailyLoading
|
|
63
44
|
}
|
|
@@ -70,8 +51,9 @@ export async function updateDailyLoadingDetail(
|
|
|
70
51
|
user: User,
|
|
71
52
|
tx?: EntityManager
|
|
72
53
|
): Promise<void> {
|
|
73
|
-
const
|
|
74
|
-
|
|
54
|
+
const truckRepo: Repository<Truck> = tx?.getRepository(Truck) || getRepository(Truck)
|
|
55
|
+
const blockRepo: Repository<Block> = tx?.getRepository(Block) || getRepository(Block)
|
|
56
|
+
const rampRepo: Repository<Ramp> = tx?.getRepository(Ramp) || getRepository(Ramp)
|
|
75
57
|
const dailyLoadingDetailRepo: Repository<DailyLoadingDetail> =
|
|
76
58
|
tx?.getRepository(DailyLoadingDetail) || getRepository(DailyLoadingDetail)
|
|
77
59
|
|
|
@@ -87,25 +69,29 @@ export async function updateDailyLoadingDetail(
|
|
|
87
69
|
|
|
88
70
|
if (existingDailyLoadingDetails?.length > 0) {
|
|
89
71
|
updatedDailyLoadingDetails = await Promise.all(
|
|
90
|
-
dailyLoadingDetails.map(async (
|
|
91
|
-
const foundDailyLoadingDetailPatch = dailyLoadingDetailPatches.find(
|
|
72
|
+
dailyLoadingDetails.map(async (existingRecord: DailyLoadingDetail) => {
|
|
73
|
+
const foundDailyLoadingDetailPatch = dailyLoadingDetailPatches.find(
|
|
74
|
+
detail => detail.name === existingRecord.name
|
|
75
|
+
)
|
|
92
76
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
77
|
+
if (foundDailyLoadingDetailPatch.totalBunchWeight !== existingRecord.totalBunchWeight) {
|
|
78
|
+
await updatePlantationInventory(domain, dailyLoading, foundDailyLoadingDetailPatch, existingRecord, user, tx)
|
|
79
|
+
}
|
|
96
80
|
|
|
97
81
|
return {
|
|
98
|
-
...
|
|
82
|
+
...existingRecord,
|
|
99
83
|
dailyLoading,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
84
|
+
truck: await truckRepo.findOne({ id: existingRecord.truck.id }),
|
|
85
|
+
block: await blockRepo.findOne({ id: existingRecord.block.id }),
|
|
86
|
+
ramp: await rampRepo.findOne({ id: existingRecord.ramp.id }),
|
|
87
|
+
totalBunchLoaded: foundDailyLoadingDetailPatch?.totalBunchLoaded || 0,
|
|
88
|
+
totalBunchWeight: foundDailyLoadingDetailPatch?.totalBunchWeight || 0,
|
|
89
|
+
remark: foundDailyLoadingDetailPatch?.remark || null,
|
|
104
90
|
updater: user
|
|
105
91
|
}
|
|
106
92
|
})
|
|
107
93
|
)
|
|
108
|
-
await dailyLoadingDetailRepo.save(updatedDailyLoadingDetails)
|
|
94
|
+
updatedDailyLoadingDetails = await dailyLoadingDetailRepo.save(updatedDailyLoadingDetails)
|
|
109
95
|
}
|
|
110
96
|
|
|
111
97
|
if (newDailyLoadingDetail?.length > 0) {
|
|
@@ -114,14 +100,13 @@ export async function updateDailyLoadingDetail(
|
|
|
114
100
|
let newDailyLoadingDetail: DailyLoadingDetail = new DailyLoadingDetail()
|
|
115
101
|
newDailyLoadingDetail.domain = domain
|
|
116
102
|
newDailyLoadingDetail.name = NoGenerator.dailyLoadingDetail()
|
|
117
|
-
newDailyLoadingDetail.
|
|
118
|
-
|
|
119
|
-
})
|
|
120
|
-
newDailyLoadingDetail.totalBunchLoaded = dailyLoadingDetail
|
|
121
|
-
newDailyLoadingDetail.totalBunchWeight = dailyLoadingDetail
|
|
122
|
-
newDailyLoadingDetail.remark = dailyLoadingDetail
|
|
103
|
+
newDailyLoadingDetail.truck = await truckRepo.findOne({ id: dailyLoadingDetail.truck.id })
|
|
104
|
+
newDailyLoadingDetail.block = await blockRepo.findOne({ id: dailyLoadingDetail.block.id })
|
|
105
|
+
newDailyLoadingDetail.ramp = await rampRepo.findOne({ id: dailyLoadingDetail.ramp.id })
|
|
106
|
+
newDailyLoadingDetail.totalBunchLoaded = dailyLoadingDetail?.totalBunchLoaded || 0
|
|
107
|
+
newDailyLoadingDetail.totalBunchWeight = dailyLoadingDetail?.totalBunchWeight || 0
|
|
108
|
+
newDailyLoadingDetail.remark = dailyLoadingDetail?.remark || null
|
|
123
109
|
newDailyLoadingDetail.creator = user
|
|
124
|
-
newDailyLoadingDetail.updater = user
|
|
125
110
|
newDailyLoadingDetail.dailyLoading = dailyLoading
|
|
126
111
|
|
|
127
112
|
await dailyLoadingDetailRepo.save(newDailyLoadingDetail)
|
|
@@ -130,181 +115,38 @@ export async function updateDailyLoadingDetail(
|
|
|
130
115
|
}
|
|
131
116
|
}
|
|
132
117
|
|
|
133
|
-
export async function updateDailyLoadingRamp(
|
|
134
|
-
domain: Domain,
|
|
135
|
-
dailyLoading: DailyLoading,
|
|
136
|
-
dailyLoadingRampPatches: DailyLoadingRamp[],
|
|
137
|
-
user: User,
|
|
138
|
-
tx?: EntityManager
|
|
139
|
-
): Promise<void> {
|
|
140
|
-
const rampRepo: Repository<Ramp> = tx?.getRepository(Ramp) || getRepository(Ramp)
|
|
141
|
-
const dailyLoadingRampRepo: Repository<DailyLoadingRamp> =
|
|
142
|
-
tx?.getRepository(DailyLoadingRamp) || getRepository(DailyLoadingRamp)
|
|
143
|
-
|
|
144
|
-
let updatedDailyLoadingRamps: any[] = []
|
|
145
|
-
const dailyLoadingRamps: DailyLoadingRamp[] = dailyLoading.dailyLoadingRamps
|
|
146
|
-
const existingDailyLoadingRamps: DailyLoadingRamp[] = dailyLoadingRampPatches.filter(detail => detail.name !== null)
|
|
147
|
-
|
|
148
|
-
// new row added in client side
|
|
149
|
-
const newDailyLoadingRamps: DailyLoadingRamp[] = dailyLoadingRampPatches.filter(detail => detail.name === null)
|
|
150
|
-
|
|
151
|
-
if (existingDailyLoadingRamps?.length > 0) {
|
|
152
|
-
// TODO: delete function for removing data
|
|
153
|
-
updatedDailyLoadingRamps = await Promise.all(
|
|
154
|
-
dailyLoadingRamps.map(async (dailyLoadingRamp: DailyLoadingRamp) => {
|
|
155
|
-
const foundDailyLoadingRampPatch = dailyLoadingRampPatches.find(detail => detail.name === dailyLoadingRamp.name)
|
|
156
|
-
|
|
157
|
-
const foundRamp: Ramp = await rampRepo.findOne({
|
|
158
|
-
where: { id: foundDailyLoadingRampPatch.ramp.id }
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
return {
|
|
162
|
-
...dailyLoadingRamp,
|
|
163
|
-
dailyLoading,
|
|
164
|
-
ramp: foundRamp,
|
|
165
|
-
totalBunchWeight: foundDailyLoadingRampPatch.totalBunchWeight,
|
|
166
|
-
updater: user
|
|
167
|
-
}
|
|
168
|
-
})
|
|
169
|
-
)
|
|
170
|
-
await dailyLoadingRampRepo.save(updatedDailyLoadingRamps)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (newDailyLoadingRamps?.length > 0) {
|
|
174
|
-
await Promise.all(
|
|
175
|
-
newDailyLoadingRamps.map(async (dailyLoadingRamp: DailyLoadingRamp) => {
|
|
176
|
-
let newDailyLoadingRamp: DailyLoadingRamp = new DailyLoadingRamp()
|
|
177
|
-
newDailyLoadingRamp.domain = domain
|
|
178
|
-
newDailyLoadingRamp.name = NoGenerator.dailyLoadingDetail()
|
|
179
|
-
newDailyLoadingRamp.ramp = await rampRepo.findOne({ id: dailyLoadingRamp.ramp.id })
|
|
180
|
-
newDailyLoadingRamp.totalBunchWeight = dailyLoadingRamp.totalBunchWeight
|
|
181
|
-
newDailyLoadingRamp.creator = user
|
|
182
|
-
newDailyLoadingRamp.updater = user
|
|
183
|
-
newDailyLoadingRamp.dailyLoading = dailyLoading
|
|
184
|
-
|
|
185
|
-
await dailyLoadingRampRepo.save(newDailyLoadingRamp)
|
|
186
|
-
})
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
118
|
export async function updatePlantationInventory(
|
|
192
119
|
domain: Domain,
|
|
193
120
|
dailyLoading: DailyLoading,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
block: Block,
|
|
121
|
+
foundDailyLoadingDetailPatch: any,
|
|
122
|
+
existingRecord: DailyLoadingDetail,
|
|
197
123
|
user: User,
|
|
198
124
|
tx?: EntityManager
|
|
199
125
|
): Promise<void> {
|
|
200
126
|
const plantationInvRepo: Repository<PlantationInventory> =
|
|
201
127
|
tx?.getRepository(PlantationInventory) || getRepository(PlantationInventory)
|
|
202
128
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
where: { domain, block, type: INVENTORY_TYPE.FIELD_BUNCHES },
|
|
207
|
-
relations: ['domain', 'block']
|
|
129
|
+
let existingRampTonnage: PlantationInventory = await plantationInvRepo.findOne({
|
|
130
|
+
where: { domain, type: INVENTORY_TYPE.RAMP_TONNAGE, ramp: existingRecord.ramp },
|
|
131
|
+
relations: ['domain', 'block', 'ramp']
|
|
208
132
|
})
|
|
209
133
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
)
|
|
229
|
-
|
|
230
|
-
await generateTransactionHistory(
|
|
231
|
-
existingBunchesInventory,
|
|
232
|
-
dailyLoading.id,
|
|
233
|
-
dailyLoading.name,
|
|
234
|
-
TRANSACTION_TYPE.BUNCHES_ADJUSTMENT,
|
|
235
|
-
dailyLoading.loadingDate,
|
|
236
|
-
-loadedFieldBunches,
|
|
237
|
-
0,
|
|
238
|
-
user,
|
|
239
|
-
tx
|
|
240
|
-
)
|
|
241
|
-
|
|
242
|
-
await Promise.all(
|
|
243
|
-
dailyLoading.dailyLoadingRamps.map(async (record: any) => {
|
|
244
|
-
const ramp: Ramp = await rampRepo.findOne({
|
|
245
|
-
where: { domain, id: record.ramp.id }
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
let existingRampTonnage: PlantationInventory = await plantationInvRepo.findOne({
|
|
249
|
-
where: { domain, type: INVENTORY_TYPE.RAMP_TONNAGE, ramp },
|
|
250
|
-
relations: ['domain', 'block', 'ramp']
|
|
251
|
-
})
|
|
252
|
-
|
|
253
|
-
const originRampTonnage: number = existingRampTonnage.totalTonnage - prevLoadedTonnage
|
|
254
|
-
const loadedRampTonnage: number = dailyLoading.totalWeight
|
|
255
|
-
|
|
256
|
-
if (existingRampTonnage) {
|
|
257
|
-
existingRampTonnage.totalTonnage = originRampTonnage - loadedRampTonnage
|
|
258
|
-
existingRampTonnage.updater = user
|
|
259
|
-
await plantationInvRepo.save(existingRampTonnage)
|
|
260
|
-
|
|
261
|
-
await generateTransactionHistory(
|
|
262
|
-
existingRampTonnage,
|
|
263
|
-
dailyLoading.id,
|
|
264
|
-
dailyLoading.name,
|
|
265
|
-
TRANSACTION_TYPE.TONNAGE_ADJUSTMENT,
|
|
266
|
-
dailyLoading.loadingDate,
|
|
267
|
-
0,
|
|
268
|
-
-prevLoadedTonnage,
|
|
269
|
-
user,
|
|
270
|
-
tx
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
await generateTransactionHistory(
|
|
274
|
-
existingRampTonnage,
|
|
275
|
-
dailyLoading.id,
|
|
276
|
-
dailyLoading.name,
|
|
277
|
-
TRANSACTION_TYPE.TONNAGE_ADJUSTMENT,
|
|
278
|
-
dailyLoading.loadingDate,
|
|
279
|
-
0,
|
|
280
|
-
loadedRampTonnage,
|
|
281
|
-
user,
|
|
282
|
-
tx
|
|
283
|
-
)
|
|
284
|
-
} else {
|
|
285
|
-
let plantationInventory: PlantationInventory = new PlantationInventory()
|
|
286
|
-
plantationInventory.domain = domain
|
|
287
|
-
plantationInventory.name = NoGenerator.rampTonnageName()
|
|
288
|
-
plantationInventory.block = block
|
|
289
|
-
plantationInventory.type = INVENTORY_TYPE.RAMP_TONNAGE
|
|
290
|
-
plantationInventory.totalTonnage = record.totalBunchWeight
|
|
291
|
-
plantationInventory.status = INVENTORY_STATUS.STORED
|
|
292
|
-
plantationInventory.ramp = ramp
|
|
293
|
-
plantationInventory.creator = user
|
|
294
|
-
plantationInventory = await plantationInvRepo.save(plantationInventory)
|
|
295
|
-
|
|
296
|
-
await generateTransactionHistory(
|
|
297
|
-
plantationInventory,
|
|
298
|
-
dailyLoading.id,
|
|
299
|
-
dailyLoading.name,
|
|
300
|
-
TRANSACTION_TYPE.LOADING,
|
|
301
|
-
dailyLoading.loadingDate,
|
|
302
|
-
0,
|
|
303
|
-
record.totalBunchWeight,
|
|
304
|
-
user,
|
|
305
|
-
tx
|
|
306
|
-
)
|
|
307
|
-
}
|
|
308
|
-
})
|
|
309
|
-
)
|
|
134
|
+
if (existingRampTonnage) {
|
|
135
|
+
const tonnageChanges: number = foundDailyLoadingDetailPatch.totalBunchWeight - existingRecord.totalBunchWeight
|
|
136
|
+
existingRampTonnage.totalTonnage = existingRampTonnage.totalTonnage + tonnageChanges
|
|
137
|
+
existingRampTonnage.updater = user
|
|
138
|
+
await plantationInvRepo.save(existingRampTonnage)
|
|
139
|
+
|
|
140
|
+
await generateTransactionHistory(
|
|
141
|
+
existingRampTonnage,
|
|
142
|
+
dailyLoading.id,
|
|
143
|
+
dailyLoading.name,
|
|
144
|
+
TRANSACTION_TYPE.LOADING_ADJUSTMENT,
|
|
145
|
+
dailyLoading.loadingDate,
|
|
146
|
+
0,
|
|
147
|
+
tonnageChanges,
|
|
148
|
+
user,
|
|
149
|
+
tx
|
|
150
|
+
)
|
|
151
|
+
}
|
|
310
152
|
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { ListParam } from '@things-factory/shell'
|
|
4
|
+
|
|
5
|
+
import { Block } from '../../../entities'
|
|
6
|
+
|
|
7
|
+
// import { buildQuery, ListParam } from '@things-factory/shell'
|
|
8
|
+
|
|
9
|
+
export const Query = {
|
|
10
|
+
/**
|
|
11
|
+
* @param blockId: id of the block
|
|
12
|
+
* @param yearAndMonth: the format will be something like 202001; combination of year 2020 and month 01
|
|
13
|
+
* @returns tonnage data with its sorted date
|
|
14
|
+
*/
|
|
15
|
+
async monthlyTonnageProductions(_: any, { blockId, yearAndMonth }, context: any) {
|
|
16
|
+
try {
|
|
17
|
+
const { tx }: { tx: EntityManager } = context.state
|
|
18
|
+
|
|
19
|
+
const year = parseInt(yearAndMonth.substring(0, 4))
|
|
20
|
+
const month = parseInt(yearAndMonth.substring(4))
|
|
21
|
+
|
|
22
|
+
let data: any[] = await getDailyProductionData(blockId, year, month, tx);
|
|
23
|
+
let result = []
|
|
24
|
+
|
|
25
|
+
result = data.map(itm => {
|
|
26
|
+
return {
|
|
27
|
+
...itm,
|
|
28
|
+
blockId,
|
|
29
|
+
tonnage: itm.todayWeightCollected,
|
|
30
|
+
year: itm.dateDay.getFullYear(),
|
|
31
|
+
month: itm.dateDay.getMonth(),
|
|
32
|
+
date: itm.dateDay.toLocaleString('default', { day: '2-digit', month: 'short' })
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return result
|
|
37
|
+
} catch (ex) {
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
async monthlyYields(_: any, { blockId, yearAndMonth }, context: any) {
|
|
42
|
+
try {
|
|
43
|
+
const { tx }: { tx: EntityManager } = context.state
|
|
44
|
+
|
|
45
|
+
const year = parseInt(yearAndMonth.substring(0, 4))
|
|
46
|
+
const month = parseInt(yearAndMonth.substring(4))
|
|
47
|
+
|
|
48
|
+
let data: any[] = await getDailyProductionData(blockId, year, month, tx);
|
|
49
|
+
let result = []
|
|
50
|
+
|
|
51
|
+
result = data.map(itm => {
|
|
52
|
+
return {
|
|
53
|
+
...itm,
|
|
54
|
+
blockId,
|
|
55
|
+
yield: (itm.todayHectareCover != 0 ? itm.todayWeightCollected / itm.todayHectareCover : 0).toFixed(4),
|
|
56
|
+
year: itm.dateDay.getFullYear(),
|
|
57
|
+
month: itm.dateDay.getMonth(),
|
|
58
|
+
date: itm.dateDay.toLocaleString('default', { day: '2-digit', month: 'short' })
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
return result
|
|
63
|
+
} catch (ex) {
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
async weeklyBunchesCount(_: any, { targetDate }, context: any) {
|
|
68
|
+
if (!targetDate || targetDate == '') targetDate = new Date()
|
|
69
|
+
|
|
70
|
+
let bunchesCount = []
|
|
71
|
+
|
|
72
|
+
for (let i = 0; i < 7; i++) {
|
|
73
|
+
bunchesCount.push({
|
|
74
|
+
date: new Date(targetDate).toLocaleString('default', { day: '2-digit', month: 'short' }),
|
|
75
|
+
harvestedCount: 0,
|
|
76
|
+
collectedCount: 0
|
|
77
|
+
// harvestedCount: Math.floor(Math.random() * 1000) + 500,
|
|
78
|
+
// collectedCount: Math.floor(Math.random() * 500) + 50
|
|
79
|
+
})
|
|
80
|
+
targetDate.setDate(targetDate.getDate() - 1)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return bunchesCount.reverse()
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
async tonnageAndBunchesInventories(_: any, { something }, context: any) {
|
|
87
|
+
return {
|
|
88
|
+
bunches: 0,
|
|
89
|
+
tonnage: 0
|
|
90
|
+
// bunches: Math.floor(Math.random() * 10000) + 500,
|
|
91
|
+
// tonnage: Math.floor(Math.random() * 10000) + 500
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
async productionsOverview(_: any, { something }, context: any) {
|
|
96
|
+
return {
|
|
97
|
+
averageBunchWeight: 0,
|
|
98
|
+
bunchesCount: 0,
|
|
99
|
+
tonnageWeighed: 0,
|
|
100
|
+
// averageBunchWeight: Math.floor(Math.random() * 150) + 70,
|
|
101
|
+
// bunchesCount: Math.floor(Math.random() * 10000) + 500,
|
|
102
|
+
// tonnageWeighed: Math.floor(Math.random() * 10000) + 500
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
export async function getDailyProductionData(
|
|
109
|
+
blockId: String,
|
|
110
|
+
year: number,
|
|
111
|
+
month: number,
|
|
112
|
+
tx: EntityManager
|
|
113
|
+
): Promise<any> {
|
|
114
|
+
await tx.query(`
|
|
115
|
+
CREATE TEMP TABLE temp_blocks on commit drop AS (
|
|
116
|
+
WITH RECURSIVE b AS (
|
|
117
|
+
SELECT b.id AS block_id, * FROM blocks b
|
|
118
|
+
WHERE b.deleted_at IS null
|
|
119
|
+
UNION ALL
|
|
120
|
+
SELECT b.id AS block_id, cb.* FROM blocks cb
|
|
121
|
+
INNER JOIN b ON b.id = cb.parent_block_id
|
|
122
|
+
WHERE cb.deleted_at IS null
|
|
123
|
+
)
|
|
124
|
+
SELECT block_id, id, name FROM b
|
|
125
|
+
${blockId != 'all-blocks' && blockId != '' ? `WHERE block_id = '${blockId}' or id = '${blockId}'` : ``}
|
|
126
|
+
GROUP BY block_id, id, name
|
|
127
|
+
ORDER BY block_id, id, name
|
|
128
|
+
);
|
|
129
|
+
`)
|
|
130
|
+
|
|
131
|
+
let fromDate = new Date(year, month - 1, 1)
|
|
132
|
+
let toDate = new Date(year, month, 1)
|
|
133
|
+
toDate.setDate(toDate.getDate() - 1)
|
|
134
|
+
|
|
135
|
+
let fromDateString = [
|
|
136
|
+
fromDate.getFullYear().toString(),
|
|
137
|
+
String(fromDate.getMonth() + 1).padStart(2, '0'),
|
|
138
|
+
'01'
|
|
139
|
+
].join('-')
|
|
140
|
+
|
|
141
|
+
let toDateString = [
|
|
142
|
+
toDate.getFullYear().toString(),
|
|
143
|
+
String(toDate.getMonth() + 1).padStart(2, '0'),
|
|
144
|
+
String(toDate.getDate()).padStart(2, '0')
|
|
145
|
+
].join('-')
|
|
146
|
+
|
|
147
|
+
await tx.query(`
|
|
148
|
+
CREATE TEMP TABLE temp_records on commit drop AS (
|
|
149
|
+
select blk.block_id, coalesce(sum(field_bunches),0) AS today_field_bunches,
|
|
150
|
+
round(coalesce(sum(ramp_weight),0)::numeric,4) AS today_ramp_weight,
|
|
151
|
+
sum(case when transaction_type = 'HARVEST' OR transaction_type = 'BUNCHES_ADJUSTMENT' then field_bunches else 0 end) as today_bunch_harvest,
|
|
152
|
+
sum(case when transaction_type = 'LOADING' OR transaction_type = 'LOADING_ADJUSTMENT' then -field_bunches else 0 end) as today_bunch_collected,
|
|
153
|
+
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,
|
|
154
|
+
round(sum(case when transaction_type = 'DISPATCHMENT' OR transaction_type = 'DISPATCHMENT_ADJUSTMENT' then -ramp_weight else 0 end)::numeric,4) as today_weight_dispatch,
|
|
155
|
+
transaction_date
|
|
156
|
+
from record_transactions t2
|
|
157
|
+
inner join temp_blocks blk on blk.id = t2.block_id
|
|
158
|
+
where transaction_date <= $1
|
|
159
|
+
group by blk.block_id, transaction_date
|
|
160
|
+
)
|
|
161
|
+
`,
|
|
162
|
+
[toDateString]
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
await tx.query(
|
|
166
|
+
`
|
|
167
|
+
create temp table temp_daily_production_data on commit drop as (
|
|
168
|
+
select *,
|
|
169
|
+
prev_bunch_bal_in_field + today_bunch_harvest as today_bunch_in_field,
|
|
170
|
+
prev_bunch_bal_in_field + today_bunch_harvest - today_bunch_collected as today_bunch_bal_in_field,
|
|
171
|
+
prev_weight_bal_in_ramp + today_ramp_weight_collected - today_weight_dispatch as today_weight_bal_in_ramp FROM (
|
|
172
|
+
select md.dateDay as date_day,
|
|
173
|
+
coalesce(
|
|
174
|
+
(
|
|
175
|
+
select sum(today_field_bunches) from temp_records t2
|
|
176
|
+
where transaction_date::timestamp < md.dateDay
|
|
177
|
+
)
|
|
178
|
+
, 0) as prev_bunch_bal_in_field,
|
|
179
|
+
coalesce(
|
|
180
|
+
(
|
|
181
|
+
select sum(today_ramp_weight) from temp_records t2
|
|
182
|
+
where transaction_date::timestamp < md.dateDay
|
|
183
|
+
)
|
|
184
|
+
, 0) as prev_weight_bal_in_ramp,
|
|
185
|
+
coalesce(today_bunch_harvest, 0) as today_bunch_harvest,
|
|
186
|
+
coalesce(sum(today_bunch_harvest) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_bunch_harvest,
|
|
187
|
+
coalesce(today_bunch_collected, 0) as today_bunch_collected,
|
|
188
|
+
coalesce(sum(today_bunch_collected) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_bunch_collected,
|
|
189
|
+
coalesce(today_ramp_weight_collected, 0) as today_ramp_weight_collected,
|
|
190
|
+
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,
|
|
191
|
+
coalesce(today_weight_dispatch, 0) as today_weight_dispatch,
|
|
192
|
+
coalesce(sum(today_weight_dispatch) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_weight_dispatch,
|
|
193
|
+
coalesce(tot.today_out_turn, 0) as today_out_turn,
|
|
194
|
+
coalesce(sum(tot.today_out_turn) over (order by dateDay asc rows between unbounded preceding and current row), 0) as to_date_out_turn,
|
|
195
|
+
${blockId != 'all-blocks' && blockId != '' ? `(select name from blocks b2 WHERE id = '${blockId}')` : `''`} as block,
|
|
196
|
+
coalesce(thr.today_harvesting_round, 0) as today_harvesting_round,
|
|
197
|
+
coalesce(thr.today_hectare_cover, 0) as today_hectare_cover
|
|
198
|
+
from
|
|
199
|
+
(select generate_series((date '${fromDateString}')::timestamp, (date '${toDateString}')::timestamp, interval '1 day')::date as dateDay) as md
|
|
200
|
+
left join (
|
|
201
|
+
select * from temp_records trx
|
|
202
|
+
where transaction_date between $1 and $2
|
|
203
|
+
order by transaction_date
|
|
204
|
+
) as dt on dt.transaction_date::date = md.dateDay
|
|
205
|
+
LEFT JOIN (
|
|
206
|
+
select sum(harvesting_round) AS today_harvesting_round, sum(coverage) AS today_hectare_cover, harvest_date
|
|
207
|
+
from daily_harvests dh
|
|
208
|
+
inner join temp_blocks blk on blk.id = dh.block_id
|
|
209
|
+
where harvest_date between $1 and $2
|
|
210
|
+
group by blk.block_id, harvest_date
|
|
211
|
+
) as thr ON thr.harvest_date::date = md.dateDay
|
|
212
|
+
LEFT JOIN (
|
|
213
|
+
select count(*) AS today_out_turn, dh.harvest_date
|
|
214
|
+
from daily_harvest_details dhd
|
|
215
|
+
inner join daily_harvests dh on dh.id = dhd.daily_harvest_id
|
|
216
|
+
inner join temp_blocks blk on blk.id = dh.block_id
|
|
217
|
+
where dh.harvest_date between $1 and $2
|
|
218
|
+
GROUP BY blk.block_id, dh.harvest_date
|
|
219
|
+
) as tot ON tot.harvest_date::date = md.dateDay
|
|
220
|
+
) dt
|
|
221
|
+
)`,
|
|
222
|
+
[fromDateString, toDateString]
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
const result: any = await tx.query(`
|
|
226
|
+
select * from temp_daily_production_data dt
|
|
227
|
+
`)
|
|
228
|
+
|
|
229
|
+
return result.map(itm => {
|
|
230
|
+
return {
|
|
231
|
+
block: itm.block,
|
|
232
|
+
dateDay: itm.date_day,
|
|
233
|
+
diffInBunches: parseFloat(itm.diff_in_bunches).toFixed(1),
|
|
234
|
+
prevBunchBalInField: parseFloat(itm.prev_bunch_bal_in_field).toFixed(1),
|
|
235
|
+
prevWeightBalInRamp: parseFloat(itm.prev_weight_bal_in_ramp).toFixed(4),
|
|
236
|
+
toDateBunchHarvest: parseFloat(itm.to_date_bunch_harvest).toFixed(1),
|
|
237
|
+
toDateOutTurn: itm.to_date_out_turn,
|
|
238
|
+
toDateWeightDispatch: parseFloat(itm.to_date_weight_dispatch).toFixed(4),
|
|
239
|
+
todayBunchBalInField: parseFloat(itm.today_bunch_bal_in_field).toFixed(1),
|
|
240
|
+
todayBunchCollected: parseFloat(itm.today_bunch_collected).toFixed(1),
|
|
241
|
+
todayBunchHarvest: parseFloat(itm.today_bunch_harvest).toFixed(1),
|
|
242
|
+
todayBunchInField: parseFloat(itm.today_bunch_in_field).toFixed(1),
|
|
243
|
+
todayHarvestingRound: itm.today_harvesting_round,
|
|
244
|
+
todayHectareCover: parseFloat(itm.today_hectare_cover).toFixed(4),
|
|
245
|
+
todayOutTurn: itm.today_out_turn,
|
|
246
|
+
todayWeightCollected: parseFloat(itm.today_ramp_weight_collected).toFixed(4),
|
|
247
|
+
todayWeightBalInRamp: parseFloat(itm.today_weight_bal_in_ramp).toFixed(4),
|
|
248
|
+
todayWeightDispatch: parseFloat(itm.today_weight_dispatch).toFixed(4),
|
|
249
|
+
}
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
export * from './block'
|
|
2
1
|
export * from './block-detail'
|
|
2
|
+
export * from './block'
|
|
3
3
|
export * from './daily-block-detail'
|
|
4
|
-
export * from './daily-dispatch'
|
|
5
4
|
export * from './daily-dispatch-detail'
|
|
6
|
-
export * from './daily-
|
|
5
|
+
export * from './daily-dispatch'
|
|
7
6
|
export * from './daily-harvest-detail'
|
|
8
|
-
export * from './daily-
|
|
7
|
+
export * from './daily-harvest'
|
|
9
8
|
export * from './daily-loading-detail'
|
|
10
9
|
export * from './daily-loading-ramp'
|
|
11
|
-
export * from './
|
|
10
|
+
export * from './daily-loading'
|
|
11
|
+
export * from './dashboard'
|
|
12
12
|
export * from './organization-staff'
|
|
13
|
+
export * from './organization'
|
|
13
14
|
export * from './plantation-inventory'
|
|
15
|
+
export * from './plantation-setting'
|
|
14
16
|
export * from './ramp'
|
|
15
|
-
export * from './report'
|
|
16
17
|
export * from './record-transaction'
|
|
18
|
+
export * from './report'
|
|
19
|
+
|
|
20
|
+
export * from './truck'
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { EntityManager, IsNull } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { buildQuery, Domain, ListParam } from '@things-factory/shell'
|
|
4
|
+
|
|
3
5
|
import { OrganizationStaff as OrganizationStaffEntity } from '../../../entities'
|
|
4
6
|
|
|
5
7
|
export const Query = {
|
|
@@ -15,7 +17,7 @@ export const Query = {
|
|
|
15
17
|
async organizationStaffs(_: any, params: ListParam, context: any) {
|
|
16
18
|
const { tx }: { tx: EntityManager } = context.state
|
|
17
19
|
|
|
18
|
-
const queryBuilder = tx.getRepository(OrganizationStaffEntity).createQueryBuilder()
|
|
20
|
+
const queryBuilder = await tx.getRepository(OrganizationStaffEntity).createQueryBuilder()
|
|
19
21
|
buildQuery(queryBuilder, params, context)
|
|
20
22
|
|
|
21
23
|
queryBuilder
|
|
@@ -27,7 +29,14 @@ export const Query = {
|
|
|
27
29
|
if (params.filters?.length > 0) queryBuilder.andWhere('OrganizationStaff.deletedAt IS NULL')
|
|
28
30
|
else queryBuilder.where('OrganizationStaff.deletedAt IS NULL')
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
let [items, total] = await queryBuilder.getManyAndCount()
|
|
33
|
+
|
|
34
|
+
items = items.map(item => {
|
|
35
|
+
return {
|
|
36
|
+
...item,
|
|
37
|
+
organizationName: item.organization?.name
|
|
38
|
+
}
|
|
39
|
+
})
|
|
31
40
|
|
|
32
41
|
return { items, total }
|
|
33
42
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getRepository } from 'typeorm'
|
|
2
|
+
import { PlantationSetting } from '../../../entities'
|
|
3
|
+
|
|
4
|
+
export const createPlantationSetting = {
|
|
5
|
+
async createPlantationSetting(_: any, { plantationSetting }, context: any) {
|
|
6
|
+
const { domain, user } = context.state
|
|
7
|
+
|
|
8
|
+
return await getRepository(PlantationSetting).save({
|
|
9
|
+
...plantationSetting,
|
|
10
|
+
domain,
|
|
11
|
+
creator: user,
|
|
12
|
+
updater: user
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|