diff --git a/backend/src/controllers/carts.c b/backend/src/controllers/carts.c index 0dcd38b..7ca6dad 100644 --- a/backend/src/controllers/carts.c +++ b/backend/src/controllers/carts.c @@ -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); } diff --git a/backend/test/test.ts b/backend/test/test.ts index 97af7f5..2551656 100644 --- a/backend/test/test.ts +++ b/backend/test/test.ts @@ -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; }