Free person slots (up to 30), Páros 3 500 Ft
- Persons are free up to FREE_PERSON_SLOTS (30); packages give no person slots, the "+5 személy" add-on is retired (still known for old orders and payments in flight). At the cap: write to us, an admin grants more. - Páros 3 500 Ft; "bought one by one" prices without persons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1391,17 +1391,17 @@ async fn persons_use_package_slots(pool: PgPool) {
|
||||
assert_eq!(r.status, StatusCode::NO_CONTENT);
|
||||
assert_eq!(persons(app.get("/v1/me", Some(&anna)).await.body)["left"], 0);
|
||||
|
||||
// a person package adds five slots
|
||||
// packages give no slots any more (they are free, up to a cap)
|
||||
let r = app.post("/v1/payments/mock", Some(&anna), json!({"package": "family"})).await;
|
||||
assert_eq!(r.body["persons"], json!({"used": 1, "limit": 1, "left": 0, "unlimited": false}), "{}", r.body);
|
||||
let r = app.post("/v1/payments/mock", Some(&anna), json!({"package": "addon_persons"})).await;
|
||||
assert_eq!(r.body["persons"], json!({"used": 1, "limit": 6, "left": 5, "unlimited": false}), "{}", r.body);
|
||||
assert_eq!(r.status, StatusCode::NOT_FOUND);
|
||||
// more slots from an admin (as granted units)
|
||||
grant_units(&app, &anna, "person", 5).await;
|
||||
let second = app.chart(&anna, "Cili", false, "1986-01-01").await;
|
||||
app.chart(&anna, "Dani", false, "1987-01-01").await;
|
||||
assert_eq!(persons(app.get("/v1/me", Some(&anna)).await.body)["left"], 3);
|
||||
|
||||
// the family package adds five more
|
||||
let r = app.post("/v1/payments/mock", Some(&anna), json!({"package": "family"})).await;
|
||||
assert_eq!(r.body["persons"], json!({"used": 3, "limit": 11, "left": 8, "unlimited": false}));
|
||||
app.chart(&anna, "Emma", false, "1988-01-01").await;
|
||||
assert_eq!(persons(app.get("/v1/me", Some(&anna)).await.body)["left"], 2);
|
||||
let list = app.get("/v1/charts", Some(&anna)).await.body;
|
||||
let kinds: Vec<&str> = list["charts"].as_array().unwrap().iter().map(|c| c["kind"].as_str().unwrap()).collect();
|
||||
assert_eq!(kinds, ["own", "person", "person", "person"]);
|
||||
@@ -1656,7 +1656,6 @@ async fn packages_grant_units(pool: PgPool) {
|
||||
"family",
|
||||
"addon_synastry",
|
||||
"addon_forecast",
|
||||
"addon_persons",
|
||||
"addon_questions",
|
||||
"addon_tarot"
|
||||
]
|
||||
@@ -1685,7 +1684,7 @@ async fn packages_grant_units(pool: PgPool) {
|
||||
r.body
|
||||
);
|
||||
let me = app.get("/v1/me", Some(&anna)).await.body;
|
||||
assert_eq!(me["persons"]["limit"], 10); // 5 free + 5
|
||||
assert_eq!(me["persons"]["limit"], 5); // the free ones: packages give no person slots
|
||||
let (source, price): (String, i32) =
|
||||
sqlx::query_as("SELECT source, price_huf FROM package_orders WHERE package = 'family'")
|
||||
.fetch_one(&pool)
|
||||
@@ -1703,9 +1702,9 @@ async fn packages_grant_units(pool: PgPool) {
|
||||
);
|
||||
let (price,): (i32,) =
|
||||
sqlx::query_as("SELECT price_huf FROM package_orders WHERE package = 'couple'").fetch_one(&pool).await.unwrap();
|
||||
assert_eq!(price, 5000);
|
||||
assert_eq!(price, 3500);
|
||||
// the header shows the latest main package; a top-up does not change it
|
||||
app.post("/v1/payments/mock", Some(&anna), json!({"package": "addon_persons"})).await;
|
||||
app.post("/v1/payments/mock", Some(&anna), json!({"package": "addon_questions"})).await;
|
||||
assert_eq!(app.get("/v1/me", Some(&anna)).await.body["package"]["name"], "Páros");
|
||||
|
||||
// the unlimited package is not sold any more; an old order of it is skipped
|
||||
@@ -2632,7 +2631,7 @@ async fn stripe_checkout_grants_the_paid_package_once(pool: PgPool) {
|
||||
let url = r.body["url"].as_str().unwrap();
|
||||
let id = url.rsplit('/').next().unwrap().to_string();
|
||||
assert_eq!(stripe_form(&id, "line_items[0][price_data][currency]").as_deref(), Some("huf"));
|
||||
assert_eq!(stripe_form(&id, "line_items[0][price_data][unit_amount]").as_deref(), Some("500000"));
|
||||
assert_eq!(stripe_form(&id, "line_items[0][price_data][unit_amount]").as_deref(), Some("350000"));
|
||||
assert_eq!(
|
||||
stripe_form(&id, "line_items[0][price_data][product_data][name]").as_deref(),
|
||||
Some("Sorsfonalak – Páros")
|
||||
@@ -2694,7 +2693,7 @@ async fn stripe_checkout_grants_the_paid_package_once(pool: PgPool) {
|
||||
.await;
|
||||
assert_eq!(r.status, StatusCode::OK, "{}", r.body);
|
||||
}
|
||||
assert_eq!(stripe_orders(&app.pool, "anna@example.com").await, vec![("couple".to_string(), 5000)]);
|
||||
assert_eq!(stripe_orders(&app.pool, "anna@example.com").await, vec![("couple".to_string(), 3500)]);
|
||||
// What the invoice needs is kept, and the invoice is queued.
|
||||
let (intent, amount, customer, terms): (String, i32, Value, Option<String>) = sqlx::query_as(
|
||||
"SELECT payment_intent, amount_huf, customer, terms_version FROM stripe_checkouts \
|
||||
@@ -2809,7 +2808,7 @@ async fn stripe_checkout_grants_the_paid_package_once(pool: PgPool) {
|
||||
assert_eq!(r.body["status"], "paid");
|
||||
assert_eq!(
|
||||
stripe_orders(&app.pool, "anna@example.com").await,
|
||||
vec![("couple".to_string(), 5000), ("single".to_string(), 2000)]
|
||||
vec![("couple".to_string(), 3500), ("single".to_string(), 2000)]
|
||||
);
|
||||
let (name, tax_type): (String, String) =
|
||||
sqlx::query_as("SELECT buyer_name, buyer_tax_type FROM invoices WHERE checkout_id = $1")
|
||||
|
||||
Reference in New Issue
Block a user