Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/app/models/dividend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
1 change: 1 addition & 0 deletions backend/config/data/seed_templates/gumroad.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
"withheld_tax_cents": 0,
"qualified_amount_cents": 0,
"number_of_shares": 1230,
"investment_amount_cents": 100000,
"status": "Paid"
},
"convertible_securities": [
Expand Down
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions backend/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dividend>();
const columns = useMemo(
() => [
Expand All @@ -54,18 +51,14 @@ const DividendRound = ({ id }: { id: string }) => {
cell: (info) => <div className="font-light">{info.getValue() || "Unknown"}</div>,
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", {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make investment amount column always visible since investment_amount_cents is now NOT NULL

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),
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/(dashboard)/equity/dividends/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default function Dividends() {
columnHelper.simple(
"investmentAmountCents",
"Investment amount",
(value) => (value ? formatMoneyFromCents(value) : "N/A"),
(value) => formatMoneyFromCents(value),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove null fallback since investment_amount_cents is now NOT NULL

"numeric",
),
columnHelper.simple("totalAmountInCents", "Gross amount", (value) => formatMoneyFromCents(value), "numeric"),
Expand Down
2 changes: 1 addition & 1 deletion frontend/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => [
Expand Down
Loading