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
- Valid JWT token is present in the request for authentication.
- Request contains valid form data including
master,time_level,runDate,budget_scenario_name, andoperation. - The request contains the file to be uploaded.
- The database contains relevant user and role data for validation.
Course of Events
- Extract JSON data from the request form.
- Retrieve JWT data and extract
companyId,userId, androleId. - Populate requestJson with
companyId,userId, androleId. - Query the database for user and role information.
- Validate user authorization based on roles and accessible companies.
- Validate screen permissions based on the user's role and level.
- Initiate a notification task for the file upload.
- Save the uploaded file to a specified directory.
- Validate the uploaded file's columns against the expected columns.
- Perform role permission validation if necessary.
- Trigger file processing tasks and initiate data validation processes.
- Return a JSON response indicating the success or failure of the operation.
Validation Checks
- Validate presence of
companyId,userId,roleId, andmasterin 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
budget_scenario_data
Exceptions
- None