Given two datasets of transactions and refunds, write a function to join them and flag any anomalies.
Implement reconcile_transactions(transactions, refunds). Each transaction has a unique string transaction_id, integer amount in cents, and currency. Each refund has a string refund_id, transaction_id, integer amount, and currency. Return one anomaly object per affected transaction, ordered by transaction_id. Flag unmatched refunds, currency mismatches, and cases where total refunds exceed the transaction amount.
Input: two lists of dictionaries. Output: a list of dictionaries containing transaction_id, types, transaction, and refunds.
def reconcile_transactions(transactions, refunds):