-- Add as_on_date and email_sent flag to balance_letter_data
-- as_on_date : admin sets this per customer (or same date for all)
-- email_sent : NULL = not yet sent, 'YES' = already sent (skip on next run)
ALTER TABLE `balance_letter_data`
  ADD COLUMN `as_on_date`  date        DEFAULT NULL AFTER `balance_amount`,
  ADD COLUMN `email_sent`  varchar(5)  DEFAULT NULL AFTER `pdf_delivery`;

-- To reset and allow re-send for a customer:
-- UPDATE balance_letter_data SET email_sent = NULL WHERE code = 'CUST001';
