# Process
##  Create schemas
- truncate or create empty tables
- accountingflat:
    - dig_sales_statements,
    - TEMP_dig_sales_statements
    - TEMP_dig_sales_processed
    - processed_dig_sales

- art_relations:
    - product_split
    - track_split
    - publishing_escrow

(file `schema_2019_05_30.sql` contains schemas that can be imported.)

## Prepare test data
- Insert test transactions into accountingflat.dig_sales_detail
- Run `outfile.sql`, replacing _XXX_ with the current period.
- Run `populate_TEMP_dig_sales_statements.sql`, replacing _XXX_ with the current period.
- Launch `docker-compose -f ../oa_docker/docker-compose.yml up -d` (read docs to see which cli args are required.)

## Run
```sh
# Include the month and year of the accounting period you want to test.
> docker exec ac_old_app php scripts/Accounting/publishAccountingQueue.php -m 4 -y 2019 -b 1
> docker exec ac_old_app php scripts/Accounting/processAccountingQueue.php -m 4 -y 2019

```

After running `publishAccountingQueue`, the queues should be visibly populated [here](http://localhost:8161/admin/queues.jsp)

## Reset data
```mysql
UPDATE `accountingflat`.`TEMP_dig_sales_processed` d
SET d.`processed` = 'Y' 
WHERE 1;

UPDATE `accountingflat`.`TEMP_dig_sales_processed` d
INNER JOIN `accountingflat`.`product_split_statement_id` p USING(`statement_detail_id`)
SET d.`processed` = 'N' 
WHERE 1;

TRUNCATE `accountingflat`.`processed_dig_sales`;
TRUNCATE `art_relations`.`publishing_escrow`;
```

## Data retrieval
```sql
SELECT * FROM `accountingflat`.`processed_dig_sales` WHERE 1;
SELECT * FROM `art_relations`.`publishing_escrow` WHERE 1;
```
