diff --git a/backend/app/models/dividend.rb b/backend/app/models/dividend.rb index 756a4972f6..70e567a6d1 100644 --- a/backend/app/models/dividend.rb +++ b/backend/app/models/dividend.rb @@ -29,6 +29,7 @@ class Dividend < ApplicationRecord validates :withholding_percentage, numericality: { greater_than_or_equal_to: 0, only_integer: true }, allow_nil: true validates :net_amount_in_cents, numericality: { greater_than_or_equal_to: 0, only_integer: true }, allow_nil: true validates :qualified_amount_cents, numericality: { greater_than_or_equal_to: 0, only_integer: true } + validates :investment_amount_cents, numericality: { greater_than_or_equal_to: 0, only_integer: true } scope :pending_signup, -> { where(status: PENDING_SIGNUP) } scope :paid, -> { where(status: PAID) } diff --git a/backend/config/data/seed_templates/gumroad.json b/backend/config/data/seed_templates/gumroad.json index fbdb50990d..d101dca62f 100644 --- a/backend/config/data/seed_templates/gumroad.json +++ b/backend/config/data/seed_templates/gumroad.json @@ -243,6 +243,7 @@ "withheld_tax_cents": 0, "qualified_amount_cents": 0, "number_of_shares": 1230, + "investment_amount_cents": 100000, "status": "Paid" }, "convertible_securities": [ diff --git a/backend/db/migrate/20260212085651_make_investment_amount_cents_not_null_on_dividends.rb b/backend/db/migrate/20260212085651_make_investment_amount_cents_not_null_on_dividends.rb new file mode 100644 index 0000000000..c746496574 --- /dev/null +++ b/backend/db/migrate/20260212085651_make_investment_amount_cents_not_null_on_dividends.rb @@ -0,0 +1,9 @@ +class MakeInvestmentAmountCentsNotNullOnDividends < ActiveRecord::Migration[8.0] + def up + change_column_null :dividends, :investment_amount_cents, false + end + + def down + change_column_null :dividends, :investment_amount_cents, true + end +end diff --git a/backend/db/schema.rb b/backend/db/schema.rb index 3840ce08b8..f65441ff73 100644 --- a/backend/db/schema.rb +++ b/backend/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2026_02_02_034515) do +ActiveRecord::Schema[8.0].define(version: 2026_02_12_085651) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_catalog.plpgsql" @@ -377,7 +377,7 @@ t.bigint "user_compliance_info_id" t.bigint "qualified_amount_cents", null: false t.datetime "signed_release_at" - t.bigint "investment_amount_cents" + t.bigint "investment_amount_cents", null: false t.string "external_id", null: false t.index ["company_id"], name: "index_dividends_on_company_id" t.index ["company_investor_id"], name: "index_dividends_on_company_investor_id" diff --git a/frontend/app/(dashboard)/equity/dividend_rounds/[type]/[id]/page.tsx b/frontend/app/(dashboard)/equity/dividend_rounds/[type]/[id]/page.tsx index 8d9635e60b..deae14771a 100644 --- a/frontend/app/(dashboard)/equity/dividend_rounds/[type]/[id]/page.tsx +++ b/frontend/app/(dashboard)/equity/dividend_rounds/[type]/[id]/page.tsx @@ -42,9 +42,6 @@ const DividendRound = ({ id }: { id: string }) => { dividendRoundId: id, }); - // Old dividend records don't have an investment amount - const hasInvestmentAmounts = dividends.some((dividend) => dividend.investmentAmountCents !== null); - const columnHelper = createColumnHelper(); const columns = useMemo( () => [ @@ -54,18 +51,14 @@ const DividendRound = ({ id }: { id: string }) => { cell: (info) =>
{info.getValue() || "Unknown"}
, footer: "Total", }), - ...(hasInvestmentAmounts - ? [ - columnHelper.accessor("investmentAmountCents", { - header: "Investment amount", - cell: (info) => formatMoneyFromCents(Number(info.getValue())), - meta: { numeric: true }, - footer: formatMoneyFromCents( - dividends.reduce((sum, dividend) => sum + Number(dividend.investmentAmountCents), 0), - ), - }), - ] - : []), + columnHelper.accessor("investmentAmountCents", { + header: "Investment amount", + cell: (info) => formatMoneyFromCents(Number(info.getValue())), + meta: { numeric: true }, + footer: formatMoneyFromCents( + dividends.reduce((sum, dividend) => sum + Number(dividend.investmentAmountCents), 0), + ), + }), columnHelper.accessor("totalAmountInCents", { header: "Return amount", cell: (info) => formatMoney(Number(info.getValue()) / 100), diff --git a/frontend/app/(dashboard)/equity/dividends/page.tsx b/frontend/app/(dashboard)/equity/dividends/page.tsx index 4457da7f31..4b907a2e9b 100644 --- a/frontend/app/(dashboard)/equity/dividends/page.tsx +++ b/frontend/app/(dashboard)/equity/dividends/page.tsx @@ -134,7 +134,7 @@ export default function Dividends() { columnHelper.simple( "investmentAmountCents", "Investment amount", - (value) => (value ? formatMoneyFromCents(value) : "N/A"), + (value) => formatMoneyFromCents(value), "numeric", ), columnHelper.simple("totalAmountInCents", "Gross amount", (value) => formatMoneyFromCents(value), "numeric"), diff --git a/frontend/db/schema.ts b/frontend/db/schema.ts index 2d0690e80b..3d6d84dcd9 100644 --- a/frontend/db/schema.ts +++ b/frontend/db/schema.ts @@ -447,7 +447,7 @@ export const dividends = pgTable( userComplianceInfoId: bigint("user_compliance_info_id", { mode: "bigint" }), qualifiedAmountCents: bigint("qualified_amount_cents", { mode: "bigint" }).notNull(), signedReleaseAt: timestamp("signed_release_at", { precision: 6, mode: "date" }), - investmentAmountCents: bigint("investment_amount_cents", { mode: "bigint" }), + investmentAmountCents: bigint("investment_amount_cents", { mode: "bigint" }).notNull(), externalId: varchar("external_id").$default(nanoid).notNull(), }, (table) => [