Skip to content

Commit aa5ffb0

Browse files
committed
feat(holdings): add premium_usd column to the Holdings grid
Mirror the face_value_usd money column across all five grid touch points: FlatHolding gains premium_usd, a "Premium $" column sits next to Basis $/Face $, load() maps premium_usd in, toHolding() writes it back, and blank() defaults it. toHolding() writing premium_usd is the critical line — without it the API's bare json.Unmarshal zeroes the field on every save. Because premium_usd is now a required FlatHolding field, the three Do-tab quick-entry workflows that build a FlatHolding (NewBullion, LoggedFinds, Reconcile) default it to 0. Refs: om-0pqe
1 parent a7f39be commit aa5ffb0

4 files changed

Lines changed: 8 additions & 0 deletions

File tree

web/app/src/lib/components/workflows/LoggedFinds.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
fine_oz_each: Number(f.fineOz) || 0,
161161
qty: Number(f.qty) || 0,
162162
basis_usd: faceTotal,
163+
premium_usd: 0, // CRH finds carry no premium over melt (acquired at face)
163164
face_value_usd: faceTotal,
164165
acquired: chosenDate || today(),
165166
source: chosenBank.trim(),

web/app/src/lib/components/workflows/NewBullion.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
fine_oz_each: Number(fineOz) || 0,
8888
qty: Number(qty) || 0,
8989
basis_usd: Number(basis) || 0,
90+
premium_usd: 0, // not collected in the quick-entry form; editable in the Holdings grid
9091
face_value_usd: 0,
9192
acquired: acquired || today(),
9293
source: source.trim(),

web/app/src/lib/components/workflows/Reconcile.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
fine_oz_each: Number(fFineOz) || 0,
135135
qty: Number(fQty) || 0,
136136
basis_usd: faceTotal,
137+
premium_usd: 0, // CRH finds carry no premium over melt (acquired at face)
137138
face_value_usd: faceTotal,
138139
acquired: today(),
139140
source: fBox ? (buys.find((b) => String(b.id) === fBox)?.bank ?? '') : '',

web/app/src/lib/grids.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export interface FlatHolding {
115115
weight_unit?: string
116116
qty: number
117117
basis_usd: number
118+
premium_usd: number
118119
face_value_usd: number
119120
acquired: string
120121
source: string
@@ -162,6 +163,7 @@ function toHolding(row: Omit<FlatHolding, 'id'>, item_type_id: number): Omit<Hol
162163
purity: row.purity,
163164
weight_unit: row.weight_unit,
164165
basis_usd: Number(row.basis_usd) || 0,
166+
premium_usd: Number(row.premium_usd) || 0,
165167
face_value_usd: Number(row.face_value_usd) || 0,
166168
acquired: row.acquired,
167169
source: row.source,
@@ -197,6 +199,7 @@ export const holdingsGrid: GridConfig<FlatHolding> = {
197199
{ accessorKey: 'weight_unit', header: 'Unit', meta: { editor: 'select', options: ['ozt', 'g', 'kg'], width: '90px' } },
198200
{ accessorKey: 'qty', header: 'Qty', meta: { editor: 'number', step: 1, align: 'right', width: '80px' } },
199201
{ accessorKey: 'basis_usd', header: 'Basis $', meta: { editor: 'number', step: 0.01, align: 'right', width: '110px' } },
202+
{ accessorKey: 'premium_usd', header: 'Premium $', meta: { editor: 'number', step: 0.01, align: 'right', width: '110px' } },
200203
{ accessorKey: 'face_value_usd', header: 'Face $', meta: { editor: 'number', step: 0.01, align: 'right', width: '100px' } },
201204
{ accessorKey: 'acquired', header: 'Acquired', meta: { editor: 'date', width: '150px' } },
202205
{ accessorKey: 'source', header: 'Source', meta: { editor: 'autocomplete', placeholder: 'APMEX', suggestions: () => holdingSources } },
@@ -238,6 +241,7 @@ export const holdingsGrid: GridConfig<FlatHolding> = {
238241
weight_unit: h.weight_unit,
239242
qty: h.qty,
240243
basis_usd: h.basis_usd,
244+
premium_usd: h.premium_usd ?? 0,
241245
face_value_usd: h.face_value_usd,
242246
acquired: h.acquired,
243247
source: h.source,
@@ -268,6 +272,7 @@ export const holdingsGrid: GridConfig<FlatHolding> = {
268272
weight_unit: 'ozt',
269273
qty: 1,
270274
basis_usd: 0,
275+
premium_usd: 0,
271276
face_value_usd: 0,
272277
acquired: today(),
273278
source: '',

0 commit comments

Comments
 (0)