#+TITLE: Billing Portal — Due Bills Reminders Tasks
#+AUTHOR: Hephaestus (Backend Jobs & ETL & Automation Advisor)
* TODO Task 1: Create domain entities
Create ~src/main/groovy/com/flowkraft/bkend/domain/Customer.groovy~
Create ~src/main/groovy/com/flowkraft/bkend/domain/Bill.groovy~
- Customer: maps to existing Northwind Customers table (companyName, contactName, email, phone)
- Bill: billNumber, amount (BigDecimal), dueDate, status, pdfPath, customer (relationship)
- Reminder fields: reminderCount (Integer, default 0), lastReminderDate (Date, nullable)
- Status enum: UNPAID, PAID, OVERDUE
- Value: Foundation — all other tasks depend on these entities
* TODO Task 2: Create reminder email templates
Create ~src/main/resources/templates/reminders/~
- Files: friendly.html, firm.html, final-notice.html
- Each includes: bill number, amount, due date, payment link, customer name
- Value: Reviewable email content, independent of code
* TODO Task 3: Create ReminderConfigProperties
Create ~src/main/groovy/com/flowkraft/bkend/reminders/ReminderConfigProperties.groovy~
- Config: reminder day thresholds [1, 7, 14], max reminders (3), cron expression, from-address
- Value: All reminder behavior controlled via config, no hardcoded values
* TODO Task 4: Create OverdueBillDetector service
Create ~src/main/groovy/com/flowkraft/bkend/reminders/OverdueBillDetector.groovy~
- Logic: Query bills WHERE dueDate < today AND status != PAID AND reminderCount < maxReminders
- Value: Identifies which bills need attention
* TODO Task 5: Create ReminderService
Create ~src/main/groovy/com/flowkraft/bkend/reminders/ReminderService.groovy~
- Logic: For each overdue bill, pick template based on reminderCount, send email, update bill
- Depends on: Tasks 1-4
- Value: Core business logic — sending the right email at the right time
* TODO Task 6: Create ReminderScheduler
Create ~src/main/groovy/com/flowkraft/bkend/reminders/ReminderScheduler.groovy~
- Logic: @Scheduled(cron) → call detector → pass results to service
- Depends on: Tasks 4-5
- Value: Automation — reminders fire daily without manual intervention
* TODO Task 7: Add application.yml configuration
File: ~src/main/resources/application.yml~ (existing)
- Add: reminder section with thresholds, SMTP, cron, from-address
- Value: Operational — deploy with environment-specific settings
* TODO Task 8: Manual smoke test
- Insert a test bill with dueDate = 2 days ago
- Trigger scheduler (or wait for cron)
- Verify: email received, correct template, bill.reminderCount incremented
- Value: Confidence — it works before shipping