# Backfill SAP Contracts
This is a helper to create 'sap_sync_contract' `abacus_event` records so that contracts/accounts can sync with SAP.

The creation of the event triggers the `lambda-abacus-contract-sync-sap` function, which formats data and sends it to SAP.


## Prerequisites
* python 3.10
* poetry
* An 'sap_sync' `abacus_state` record will need to exist for each contract that is being sent to SAP. The lambda will try to update this state and if it doesn't exist, the lambda will error.


## Getting Started
* `cp .env.shadow .env` and add your DB credentials
* update the script in `backfill_sap_contracts/main.py` with the relevant `RUN_CONTROLLER_ID` and optionally a list of `CONTRACT_IDS_TO_RUN` (you can also include your DB creds right in the script if preferred)
* activate a virtual environment with a python version of 3.10^
* if you do not have [poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) installed, try `pip install poetry` or `pip3 install -r requirements.txt`

```sh
pyenv activate <your 3.10 virtualenv>
pip3 install -r requirements.txt
poetry init
poetry install
python3 backfill_sap_contracts/main.py
```

**Note:** to run this script in PROD you will need access to a devbox with the required python version. You can SCP the script onto the box or git clone (like one would do when running legacy).
