final touches for beta skymoney (at least i think)
This commit is contained in:
41
api/test-overdue-api.sh
Normal file
41
api/test-overdue-api.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/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}'
|
||||
Reference in New Issue
Block a user