# Bulk Add UPC Lists to Product Contract Terms

Generate SQL scripts to bulk add UPC lists to product contract terms with automatic deduplication.

## Quick Start

### 1. One-time setup
```bash
cp scripts/.env.shadow scripts/.env
# Edit scripts/.env with your DEV_USERNAME and DEV_IDENTITY_ID
```

### 2. Create your JSON input file

The input file must be a JSON object with a `ticket_id` and a `data` array, for example:

```json
{
  "ticket_id": "ACC-9468",
  "data": [
    {
      "account_id": "59317",
      "contract_id": "532783",
      "contract_term_id": "136663",
      "upcs": ["20000000211705", "20000000211729"]
    },
    {
      "account_id": "59317",
      "contract_id": "532783",
      "contract_term_id": "136662",
      "upcs": ["20000000226860"]
    }
  ]
}
```

- `ticket_id`: The ticket identifier (e.g., ACC-9468). This is used for output file naming and in the generated SQL.
- `data`: An array of objects, each specifying the account, contract, contract term, and UPCs to add.

### 3. Generate SQL

```bash
./scripts/generate.sh bulk-add-upcs scripts/examples/ACC-9468.json
```

Output: `royalty_accounting/build/changelog/dml/ACC-9468-bulk-add-upcs.sql`
