# Sync Contract SAP 

## Overview

Lambda to sync new contract and account records to the SAP system.

## Getting Started

### Requirements

- Python 3.11
- Docker

### OWS Dependencies

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

### Installation

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

```bash
$ cp .env.shadow .env
```

Install [uv](https://docs.astral.sh/uv/getting-started/installation/) then install dependencies:

```bash
make env_dev
```

### Running

You can run the function locally with: `make run`

Or you can run the function inside Docker with: `make docker_local_up` and trigger an event with `make local_event`

### Testing

You can run the linter and the unit tests locally with: `make lint` and `make test`

Or you can run the linter and the unit tests inside Docker with: `make docker_test`

The integration tests can only be run inside Docker with: `make docker_test_integration`

**Note:**
You might need to login to Docker with the shared AWS account in order to run the integration tests:

```bash
$ awsume <shared_profile>
$ make docker_login
```

### Adding new packages

- Regular packages: `uv add <pkg>`
- Dev packages: `uv add <pkg> --dev`
- Integration packages: `uv add <pkg> --group integration`

### Upgrading packages

- All packages: `uv sync --upgrade`
- A specific package: `uv sync --upgrade-package <pkg>`
