I assumed the payload has the shape {"invoices": [...]}, and that a bare list is also accepted. The task did not specify the payload shape, so this is a guess. The policy values are filled in from the CURRENT policy.

Key design choices:
- Money is parsed with `Decimal` and rounded with `ROUND_HALF_UP`.
- Duplicate events use `first` mode, so the first event with a given eid is kept.
- Refunds are moved ahead of other events with a stable sort.
- Void and restore handling: the invoice starts active. A void sets active to False. With `void_is_tombstone`, a void also sets a tombstone flag so later restores are ignored.
- Refund ceiling and overflow: the ceiling is charge (principal plus fee) because `fee_refundable` is true. The `cap` overflow mode limits a refund to the remaining ceiling.
- Age check: the refund age is event day minus created day. It must be nonnegative and at most 30, since `inclusive_limit` is true.
- Status: void if the invoice is inactive, refunded if refunded equals charge, otherwise open.
- Charge and refund edge cases:
  - Charge is the sum of the rounded lines plus the fee. Invoices with a charge below `min_invoice_cents` are skipped.
  - A refund of zero cents is still processed and changes nothing.
  - A charge of zero is below the minimum, so it is skipped.

```json
{"files": {"main.py": "from core import run\nfrom policy import POLICY\ndef evaluate(payload):\n    return run(payload, POLICY)\n", "policy.py": "POLICY = {\"currency\": \"USD\", \"duplicate_event\": \"first\", \"fee_refundable\": True, \"inclusive_limit\": True, \"max_refund_age_days\": 30, \"min_invoice_cents\": 10, \"order\": \"id\", \"refund_overflow\": \"cap\", \"refunds_first\": True, \"rounding\": \"per_line\", \"status_case\": \"lower\", \"void_is_tombstone\": True}\n", "helpers.py": "from decimal import Decimal, ROUND_HALF_UP\n\ndef to_cents(s):\n    return int((Decimal(str(s)) * 100).quantize(Decimal(1), rounding=ROUND_HALF_UP))\n\ndef dedupe(events, mode):\n    d = {}\n    for e in events:\n        k = e['eid']\n        if k in d:\n            if mode == 'last':\n                d[k] = e\n        else:\n            d[k] = e\n    return list(d.values())\n", "core.py": "from decimal import Decimal, ROUND_HALF_UP\nfrom helpers import to_cents, dedupe\n\ndef run(payload, policy):\n    if payload is None:\n        return {'invoices': []}\n    if isinstance(payload, dict):\n        invs = payload.get('invoices') or []\n    else:\n        invs = payload or []\n    out = []\n    for inv in invs:\n        if inv.get('currency') != policy['currency']:\n            continue\n        lines = inv.get('lines') or []\n        if policy['rounding'] == 'per_line':\n            principal = sum(to_cents(x) for x in lines)\n        else:\n            tot = sum((Decimal(str(x)) for x in lines), Decimal(0))\n            principal = int((tot * 100).quantize(Decimal(1), rounding=ROUND_HALF_UP))\n        fee = int(inv.get('fee_cents', 0) or 0)\n        charge = principal + fee\n        if charge < policy['min_invoice_cents']:\n            continue\n        created = inv['created']\n        events = dedupe(list(inv.get('events') or []), policy['duplicate_event'])\n        if policy['refunds_first']:\n            events = sorted(events, key=lambda e: 0 if e['kind'] == 'refund' else 1)\n        active = True\n        tomb = False\n        refunded = 0\n        ceiling = charge if policy['fee_refundable'] else principal\n        for e in events:\n            k = e['kind']\n            if k == 'void':\n                active = False\n                if policy['void_is_tombstone']:\n                    tomb = True\n            elif k == 'restore':\n                if not tomb:\n                    active = True\n            elif k == 'refund':\n                if not active:\n                    continue\n                age = e['day'] - created\n                lim = policy['max_refund_age_days']\n                if age < 0:\n                    continue\n                if age > lim or (age == lim and not policy['inclusive_limit']):\n                    continue\n                amt = int(e['cents'])\n                room = ceiling - refunded\n                if amt > room:\n                    if policy['refund_overflow'] == 'cap':\n                        amt = room\n                    else:\n                        continue\n                refunded += amt\n        if not active:\n            status = 'void'\n        elif refunded == charge:\n            status = 'refunded'\n        else:\n            status = 'open'\n        if policy['status_case'] == 'upper':\n            status = status.upper()\n        else:\n            status = status.lower()\n        out.append({'id': inv['id'], 'charge': charge, 'refunded': refunded,\n                    'balance': charge - refunded, 'status': status, '_c': created})\n    if policy['order'] == 'id':\n        out.sort(key=lambda r: r['id'])\n    else:\n        out.sort(key=lambda r: (r['_c'], r['id']))\n    for r in out:\n        del r['_c']\n    return {'invoices': out}\n"}}
```