# Adjustment File Validation

Lambda for validating adjustment file content.

## Overview

This Lambda is triggered by the "adjustment_file_upload" airflow DAG after the file has been successfully scanned by the AV scan. If the file contains any validation errors, the errors are written to the error column within the same file, and the file is then uploaded to the S3 bucket. The error_type and error file location are updated in the "statement_period_adjustment_file" table, along with the other fields.

## Requirements

- Python 3.13
- Docker
- uv

## OWS Dependencies

- [ows-royalties](https://github.com/theorchard/ows-royalties)


## Installing

Create a `.env` file based on the `.env.shadow` and fill in the values: `cp .env.shadow .env`

Create a virtual env and install the requirements: `make env_dev`

### AWS Credentials

See this Notion page to generate your AWS credentials using `awsume`: https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f

### ECR Login:

After exporting your AWS credentials, log into ECR with: `make docker_login`

### Snowflake Credentials

See this Notion page to generate your Snowflake credentials: https://www.notion.so/How-to-create-a-Snowflake-service-user-ac695c4deace461b8428e30fe225000e

## Executing

Execute the function locally: `make run`

**NOTE**: This will use the event from `tests/sample_event.json`. 


Alternatively, you can run the function inside a Docker container: `make docker_local`
And then send it an event: `make local_event`

## Linting and Formatting

Run the linter and show errors: `make lint`

Run the linter and fix errors: `make lint_fix`

Run the formatter and show diffs: `make format`

Run the formatter and apply diffs: `make format_fix`

## Testing

Run the unit tests: `make test`

Run the integration tests inside a Docker container: `make docker_test_integration`
