Skip to content

Manual Input Saving Process

Milan Gruner edited this page Oct 15, 2024 · 4 revisions
  1. Save button is pressed in form, data is serialized and sent to ActivityValue POST or PUT route (to create or update respectively)
  2. ActivityValue route checks validity of data according to validation (done with Zod)
  3. Access control is performed with InventoryService (is user allowed to modify inventory => part of city or admin?)
  4. ActivityService is called to create the activity
  5. ManualInputValidationService is called to validate the data and rules (e.g. exclusive dropdown values)
  6. DataSource is created (deprecated, will be removed soon)
  7. InventoryValue is either queried or created by using GPCService to look up the correct sector/ sub-sector/ sub-category [sic!, to be renamed in future release] IDs for the given GPC reference number
  8. ActivityValue entry is created
  9. Total gas amounts and total CO2eq are calculated in CalculationService
  10. CalculationService selects the right formula function from formulas.ts to execute depending on the methodology selected by the user
  11. Totals for each gas are calculated and total CO2eq is determined using their GWPs (global warming potentials) from the GasToCO2Eq database table
  12. InventoryValue and ActivityValue are updated with the new totals
  13. Up to 3 GasValue entries are created with the total amounts for each gas and the respective emission factor references