Ignore:
Timestamp:
02/25/26 20:46:23 (5 months ago)
Author:
Mihail <mihail2.naumov@…>
Branches:
main
Children:
ad3c219
Parents:
4f2900a
Message:

Fixed total build price error and other small errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • database/drizzle/queries/components.ts

    r4f2900a r9d40151  
    10671067            );
    10681068
    1069         // const totalPrice = buildComponents.reduce((sum, c) =>
    1070         //     sum + (Number(c.price) * c.quantity), 0
    1071         // );
    1072 
    1073         // await tx
    1074         //     .update(buildsTable)
    1075         //     .set({
    1076         //         totalPrice: totalPrice.toFixed(2)
    1077         //     })
    1078         //     .where(
    1079         //         eq(buildsTable.id, buildId)
    1080         //     );
     1069        const totalPrice = buildComponents.reduce((sum, c) =>
     1070            sum + (Number(c.price) * c.quantity), 0
     1071        );
     1072
     1073        await tx
     1074            .update(buildsTable)
     1075            .set({
     1076                totalPrice: totalPrice.toFixed(2)
     1077            })
     1078            .where(
     1079                eq(buildsTable.id, buildId)
     1080            );
    10811081
    10821082        return buildId;
     
    11511151            );
    11521152
    1153         // const totalPrice = buildComponents.reduce((sum, c) =>
    1154         //     sum + (Number(c.price) * c.quantity), 0
    1155         // );
    1156 
    1157         // await tx
    1158         //     .update(buildsTable)
    1159         //     .set({
    1160         //         totalPrice: totalPrice.toFixed(2)
    1161         //     })
    1162         //     .where(
    1163         //         eq(buildsTable.id, buildId)
    1164         //     );
     1153        const totalPrice = buildComponents.reduce((sum, c) =>
     1154            sum + (Number(c.price) * c.quantity), 0
     1155        );
     1156
     1157        await tx
     1158            .update(buildsTable)
     1159            .set({
     1160                totalPrice: totalPrice.toFixed(2)
     1161            })
     1162            .where(
     1163                eq(buildsTable.id, buildId)
     1164            );
    11651165
    11661166        return componentId;
Note: See TracChangeset for help on using the changeset viewer.