From 545fdbc473bccb20182110f726064f27728f61c9 Mon Sep 17 00:00:00 2001 From: Marcus Fequiere Date: Sat, 21 Mar 2026 12:50:26 -0400 Subject: [PATCH] fix: increase unit_price decimal precision from 2 to 4 (closes #66) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The unit_price column in invoice_items used NUMERIC(10,2) which truncated values beyond 2 decimal places. For example, 0.141 would be stored as 0.14 and lose the third decimal place on page reload. Changed to NUMERIC(10,4) to support up to 4 decimal places, which covers common use cases like per-unit costs (e.g., $0.0375/kWh). Note: Existing data with 2 decimal places is unaffected — the migration just adds capacity for more precision. --- packages/db/src/schema/invoice.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/db/src/schema/invoice.ts b/packages/db/src/schema/invoice.ts index 1e950d8..f34eeab 100644 --- a/packages/db/src/schema/invoice.ts +++ b/packages/db/src/schema/invoice.ts @@ -106,7 +106,7 @@ export const invoiceItems = pgTable("invoice_items", { name: text("name").notNull(), description: text("description").notNull(), quantity: integer("quantity").notNull(), - unitPrice: Numeric("unit_price", { precision: 10, scale: 2 }).notNull(), + unitPrice: Numeric("unit_price", { precision: 10, scale: 4 }).notNull(), invoiceFieldId: uuid("invoice_field_id") .references(() => invoiceFields.id, { onDelete: "cascade" }) .notNull(),