# Payments Generate

## OWS Dependencies:
- [ows-payee](https://github.com/theorchard/ows-payee)
- [ows-payment](https://github.com/theorchard/ows-payment)

## Overview
This lambda generates a payment set by 
1. Using the `target_id` of the received `abacus_event` to get a `payment_group`'s `group_criteria` from `ows-payment`
2. Using the `group_criteria` to grab eligible payees from `ows-payee`.
3. Getting the `last_payment` amount for each eligible payee from `ows_payment`.
4. Bulk inserting into `payment_group_payment_payee` through `ows-payment`.

This lambda is executed as a part of the payment workflow.

It expects an `abacus_event` JSON object as an argument where the target is a `payment_group_payment`.

## Running
To run the function with a mock event, execute the command:
> make run

## Deployment
Deployment is managed by [zappa](https://github.com/Miserlou/Zappa).
The scripting is in `deploy.sh`, and the configuration is in `zappa_settings.json`.

## Integration testing
OWS services can be added to the `docker-compose.yml` file in order to test
integrations.
