Deposit tracking

This commit is contained in:
2026-03-03 21:40:39 +00:00
parent ec2dfb6934
commit 861dd11c5b
5 changed files with 780 additions and 682 deletions
+23 -2
View File
@@ -264,8 +264,10 @@ if api_post "$BASE_URL/register" "{\"firstName\":\"Oscar\",\"lastName\":\"Hughes
# Promote Admin
docker exec postgres psql -U myuser -d mydb -c "UPDATE users SET account_role = 'admin' WHERE email = '$ADMIN_EMAIL'" > /dev/null 2>&1
# Set deposits_required=0 for all users (so they can confirm bookings without deposit issues)
docker exec postgres psql -U myuser -d mydb -c "UPDATE users SET deposits_required = 0" > /dev/null 2>&1
# Set deposits_required=0 for main test user (so bookings can be created without 48h restriction)
# Set deposits_required=3 for some users to demonstrate deposit snapshot behavior
docker exec postgres psql -U myuser -d mydb -c "UPDATE users SET deposits_required = 0 WHERE email = '$USER_EMAIL'" > /dev/null 2>&1
docker exec postgres psql -U myuser -d mydb -c "UPDATE users SET deposits_required = 3 WHERE email IN ('poppy.thompson@example.com', 'mia.white@example.com')" > /dev/null 2>&1
echo "${C_GREEN}✅ Registered $success/$total Users${C_RESET}"
# 2. Login
@@ -454,6 +456,25 @@ echo "${C_GREEN}✅ Created $count_future/30 Bookings (Future)${C_RESET}"
echo "${C_GREEN}✅ Created $count_past/8 Bookings (Past)${C_RESET}"
echo "${C_GREEN}✅ Created $TOTAL/45 Bookings (Total)${C_RESET}"
# 4b. Create Booking for Deposit-Required User
echo -e "\n${C_BLUE}💰 Creating Booking for Deposit-Required User...${C_RESET}"
# Login as Poppy (deposits_required=3)
POPPY_LOGIN_RESP=$(curl -s -X POST -H 'Content-Type: application/json' -d '{"email":"poppy.thompson@example.com","password":"password"}' "$BASE_URL/login")
POPPY_TOKEN=$(echo "$POPPY_LOGIN_RESP" | tr -d '\r\n\t ' | sed -n 's/.*"token":"\([^"]*\).*/\1/p')
if [[ -n "$POPPY_TOKEN" ]]; then
# Book 3 days ahead (50h+ to satisfy 48h requirement for deposit-required users)
DEPOSIT_TIME=$(TZ=Europe/London date -d "3 days 10:00" +"%Y-%m-%dT%H:%M:%S%:z")
if create_booking "$POPPY_TOKEN" "$DEPOSIT_TIME" "[\"$(get_svc 0)\"]" "" "Poppy (deposit required)"; then
echo "${C_GREEN}✅ Created deposit-required booking (deposit_required=true snapshotted)${C_RESET}"
else
echo "${C_YELLOW}⚠️ Could not create deposit-required booking${C_RESET}"
fi
else
echo "${C_YELLOW}⚠️ Could not login as Poppy to create deposit-required booking${C_RESET}"
fi
# 5. Confirm Random Half of Upcoming Bookings
echo -e "\n${C_BLUE}🔒 Confirming Random Upcoming Bookings...${C_RESET}"
confirmed_count=0