mirror of
https://github.com/Mercantec-GHC/h4-projekt-gruppe-0-sm.git
synced 2025-04-27 16:24:07 +02:00
reduce balance by amount
This commit is contained in:
parent
27b633cc1e
commit
2306db2254
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user