# Adjustments Json Import

Read and process the JSON file to import multiple adjustment records.

## Overview
This lambda retrieves a zipped JSON file from an S3 bucket, extracts the JSON file, processes and formats the data, and inserts the records into the worksheet_adjustment table.

## Event Schema

**Input Event:**
```json
{
    "abacus_event_id": 1,
    "target_type": "statement_period_adjustment_file",
    "target_id": "1",
    "event_name": "generate_flowthrough_adjustments",
    "event_date": "2026-02-13T11:20:35.45+01:00",
    "statement_period_id": 325
}
```

**Output Response:**
```json
{}
```

## Requirements

- Python 3.13
- [uv](https://docs.astral.sh/uv/) - Fast Python package manager
- Docker (for containerized testing)

## OWS Dependencies

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

## Local Development

### Setup
1.  Copy the environment file:
    ```bash
    cp .env.shadow .env
    ```
2.  Install dependencies:
    ```bash
    make env_dev
    ```

### Running Tests
*   **Unit Tests:** `make test` (runs pytest with coverage)
*   **Linting:** `make lint` (check) or `make lint_fix` (auto-fix)
*   **Formatting:** `make format` (check) or `make format_fix` (auto-fix)
*   **Docker Tests:** `make docker_test` (runs linting and tests inside a container)
*   **Integration Tests:** `make docker_test_local_integration` (runs integration tests in Docker with full service dependencies)

### Running Locally
Run the Lambda function handler locally as a script:
```bash
make run
```

Or run as a Docker container:
```bash
make docker_local_up
```

## Deployment

Deploys via the [Jenkins pipeline](https://pipeline.theorchard.io/job/lambda-abacus-pipeline/). A webhook triggers the deploy for changes in this directory.
