Skip to content

Upload Document

Introduction

This function handles file uploads, processes the data, and performs various validation checks. It focuses on uploading and validating Excel or CSV files.

Pre-Conditions

  1. Valid JWT token is present in the request for authentication.
  2. Request contains valid form data including master, time_level, runDate, budget_scenario_name, and operation.
  3. The request contains the file to be uploaded.
  4. The database contains relevant user and role data for validation.

Course of Events

  1. Extract JSON data from the request form.
  2. Retrieve JWT data and extract companyId, userId, and roleId.
  3. Populate requestJson with companyId, userId, and roleId.
  4. Query the database for user and role information.
  5. Validate user authorization based on roles and accessible companies.
  6. Validate screen permissions based on the user's role and level.
  7. Initiate a notification task for the file upload.
  8. Save the uploaded file to a specified directory.
  9. Validate the uploaded file's columns against the expected columns.
  10. Perform role permission validation if necessary.
  11. Trigger file processing tasks and initiate data validation processes.
  12. Return a JSON response indicating the success or failure of the operation.

Validation Checks

  • Validate presence of companyId, userId, roleId, and master in the request.
  • Validate the JWT token and extract user information.
  • Validate user authorization and accessible companies.
  • Validate screen permissions based on the user's role and level.
  • Validate the presence and format of the uploaded file.
  • Validate file columns against expected schema.

Post Conditions

  1. budget_scenario_data

Exceptions

  1. None