reduce balance by amount

This commit is contained in:
SimonFJ20 2025-03-18 15:16:32 +01:00
parent 27b633cc1e
commit 2306db2254
2 changed files with 6 additions and 1 deletions

View File

@ -42,7 +42,7 @@ void route_post_carts_purchase(HttpCtx* ctx)
RESPOND_SERVER_ERROR(ctx);
goto l0_return;
}
total_dkk_cent += price.price_dkk_cent;
total_dkk_cent += price.price_dkk_cent * req.items.data[i].amount;
product_price_vec_push(&prices, price);
}

View File

@ -101,6 +101,10 @@ async function testCartsAndReceipts(t: Deno.TestContext, token: string) {
const user2 = await sessionUser(token);
assertNotEquals(user1.balance_dkk_cent, user2.balance_dkk_cent);
assertEquals(
user1.balance_dkk_cent - user2.balance_dkk_cent,
1195 * 2 + 1295 * 5,
);
if (!receiptId) {
return;
@ -150,6 +154,7 @@ async function sessionUser(
if (!res.ok) {
throw new Error();
}
// console.log(res.user);
return res.user;
}