#!/bin/bash # Test overdue payment via API endpoint # Login to get token echo "šŸ” Logging in..." LOGIN_RESPONSE=$(curl -s -X POST http://localhost:8080/api/auth/login \ -H "Content-Type: application/json" \ -d '{"email":"test@skymoney.com","password":"password123"}') TOKEN=$(echo $LOGIN_RESPONSE | grep -o '"token":"[^"]*' | cut -d'"' -f4) if [ -z "$TOKEN" ]; then echo "āŒ Login failed" exit 1 fi echo "āœ… Logged in successfully" # Check current state echo -e "\nšŸ“‹ Checking current plans..." curl -s -X GET http://localhost:8080/api/fixed-plans \ -H "Authorization: Bearer $TOKEN" | jq '.plans[] | {name: .name, funded: .fundedCents, total: .totalCents, isOverdue: .isOverdue, overdueAmount: .overdueAmount}' # Post $500 income - should pay $500 to overdue (was $1000, now $500 remaining) echo -e "\nšŸ’° Posting $500 income..." INCOME_RESPONSE=$(curl -s -X POST http://localhost:8080/api/income \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "amountCents": 50000, "postedAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'", "note": "Test income for overdue" }') echo $INCOME_RESPONSE | jq '.' # Check state after income echo -e "\nšŸ“‹ Checking plans after income..." curl -s -X GET http://localhost:8080/api/fixed-plans \ -H "Authorization: Bearer $TOKEN" | jq '.plans[] | {name: .name, funded: .fundedCents, total: .totalCents, isOverdue: .isOverdue, overdueAmount: .overdueAmount}'