@@ -125,6 +125,7 @@ export const SharedAssetDialog: React.FC<SharedAssetDialogProps> = ({
125125 const [ isin , setIsin ] = useState ( '' ) ;
126126 const [ shares , setShares ] = useState < string > ( '1' ) ;
127127 const [ pricePerShare , setPricePerShare ] = useState < string > ( '' ) ;
128+ const [ acquisitionPrice , setAcquisitionPrice ] = useState < string > ( '' ) ;
128129 const [ currency , setCurrency ] = useState < SupportedCurrency > ( defaultCurrency ) ;
129130 const [ targetMode , setTargetMode ] = useState < AllocationMode > ( 'PERCENTAGE' ) ;
130131 const [ targetPercent , setTargetPercent ] = useState < string > ( '0' ) ;
@@ -178,6 +179,7 @@ export const SharedAssetDialog: React.FC<SharedAssetDialogProps> = ({
178179 setIsin ( asset . isin || '' ) ;
179180 setShares ( asset . shares ?. toString ( ) || '1' ) ;
180181 setPricePerShare ( asset . pricePerShare ?. toString ( ) || '' ) ;
182+ setAcquisitionPrice ( asset . acquisitionPrice ?. toString ( ) || '' ) ;
181183 setCurrency ( asset . originalCurrency || 'EUR' ) ;
182184 setTargetMode ( asset . targetMode ) ;
183185 setTargetPercent ( asset . targetPercent ?. toString ( ) || '0' ) ;
@@ -206,6 +208,7 @@ export const SharedAssetDialog: React.FC<SharedAssetDialogProps> = ({
206208 setTicker ( holding . ticker ) ;
207209 setShares ( holding . shares . toString ( ) ) ;
208210 setPricePerShare ( holding . pricePerShare . toString ( ) ) ;
211+ setAcquisitionPrice ( holding . acquisitionPrice ?. toString ( ) || '' ) ;
209212 setCurrency ( holding . currency ) ;
210213 setNote ( holding . note || '' ) ;
211214 setInstitutionCode ( '' ) ;
@@ -246,6 +249,7 @@ export const SharedAssetDialog: React.FC<SharedAssetDialogProps> = ({
246249 setIsin ( '' ) ;
247250 setShares ( '1' ) ;
248251 setPricePerShare ( '' ) ;
252+ setAcquisitionPrice ( '' ) ;
249253 setCurrency ( defaultCurrency ) ;
250254 setTargetMode ( 'PERCENTAGE' ) ;
251255 setTargetPercent ( '0' ) ;
@@ -514,6 +518,7 @@ export const SharedAssetDialog: React.FC<SharedAssetDialogProps> = ({
514518
515519 if ( mode === 'assetAllocation' ) {
516520 // Asset Allocation mode
521+ const acqPriceNum = parseFloat ( acquisitionPrice ) || undefined ;
517522 const asset : Omit < Asset , 'id' > & { id ?: string } = {
518523 ...( initialData && { id : ( initialData as Asset ) . id } ) ,
519524 name : name . trim ( ) ,
@@ -524,6 +529,7 @@ export const SharedAssetDialog: React.FC<SharedAssetDialogProps> = ({
524529 currentValue : valueInEUR ,
525530 shares : sharesNum ,
526531 pricePerShare : priceNum ,
532+ acquisitionPrice : acqPriceNum ,
527533 marketPrice : priceNum ,
528534 originalCurrency : currency !== 'EUR' ? currency : undefined ,
529535 originalValue : currency !== 'EUR' ? valueNum : undefined ,
@@ -539,12 +545,14 @@ export const SharedAssetDialog: React.FC<SharedAssetDialogProps> = ({
539545 onSubmit ( asset ) ;
540546 } else {
541547 // Net Worth Tracker mode
548+ const acqPriceNum = parseFloat ( acquisitionPrice ) || undefined ;
542549 const holding : Omit < AssetHolding , 'id' > & { id ?: string } = {
543550 ...( initialData && { id : ( initialData as AssetHolding ) . id } ) ,
544551 name : name . trim ( ) ,
545552 ticker : generatedTicker ,
546553 shares : sharesNum ,
547554 pricePerShare : priceNum ,
555+ acquisitionPrice : acqPriceNum ,
548556 currency,
549557 assetClass : mapToNetWorthAssetClass ( assetClass , subAssetType ) ,
550558 note : note . trim ( ) || undefined ,
@@ -562,6 +570,7 @@ export const SharedAssetDialog: React.FC<SharedAssetDialogProps> = ({
562570 setIsin ( '' ) ;
563571 setShares ( '1' ) ;
564572 setPricePerShare ( '' ) ;
573+ setAcquisitionPrice ( '' ) ;
565574 setCurrency ( defaultCurrency ) ;
566575 setTargetPercent ( '0' ) ;
567576 setNote ( '' ) ;
@@ -838,37 +847,61 @@ export const SharedAssetDialog: React.FC<SharedAssetDialogProps> = ({
838847
839848 { /* Only show shares and price fields for non-cash accounts, non-value-only assets, or for MONEY_ETF */ }
840849 { ( assetClass !== 'CASH' || subAssetType === 'MONEY_ETF' ) && ! VALUE_ONLY_TYPES . includes ( subAssetType ) && (
841- < div className = "form-row" >
842- < div className = "form-group" >
843- < label > Number of Shares *</ label >
844- < input
845- type = "number"
846- value = { shares }
847- onChange = { ( e ) => handleSharesChange ( e . target . value ) }
848- placeholder = "e.g., 100"
849- className = "dialog-input"
850- min = "0"
851- step = "any"
852- required
853- />
854- </ div >
850+ < >
851+ < div className = "form-row" >
852+ < div className = "form-group" >
853+ < label > Number of Shares *</ label >
854+ < input
855+ type = "number"
856+ value = { shares }
857+ onChange = { ( e ) => handleSharesChange ( e . target . value ) }
858+ placeholder = "e.g., 100"
859+ className = "dialog-input"
860+ min = "0"
861+ step = "any"
862+ required
863+ />
864+ </ div >
855865
856- < div className = "form-group" >
857- < label > Price per Share (Market)</ label >
858- < input
859- type = "text"
860- value = { pricePerShare ? `${ parseFloat ( pricePerShare ) . toFixed ( 2 ) } ` : '—' }
861- className = "dialog-input dialog-input-calculated"
862- disabled
863- title = "Fetched automatically from Yahoo Finance"
864- />
865- { ! pricePerShare && needsTicker && ticker . trim ( ) && (
866- < span className = "setting-help" style = { { color : 'var(--warning)' } } >
867- Click the fetch button next to the ticker to get the price
868- </ span >
869- ) }
866+ < div className = "form-group" >
867+ < label > Price per Share (Market)</ label >
868+ < input
869+ type = "text"
870+ value = { pricePerShare ? `${ parseFloat ( pricePerShare ) . toFixed ( 2 ) } ` : '—' }
871+ className = "dialog-input dialog-input-calculated"
872+ disabled
873+ title = "Fetched automatically from Yahoo Finance"
874+ />
875+ { ! pricePerShare && needsTicker && ticker . trim ( ) && (
876+ < span className = "setting-help" style = { { color : 'var(--warning)' } } >
877+ Click the fetch button next to the ticker to get the price
878+ </ span >
879+ ) }
880+ </ div >
870881 </ div >
871- </ div >
882+
883+ { /* Acquisition price — editable, shown for share-based assets */ }
884+ { needsTicker && (
885+ < div className = "form-row" >
886+ < div className = "form-group" >
887+ < label > Acquisition Price per Share</ label >
888+ < input
889+ type = "number"
890+ value = { acquisitionPrice }
891+ onChange = { ( e ) => setAcquisitionPrice ( e . target . value ) }
892+ placeholder = { pricePerShare ? `Defaults to ${ parseFloat ( pricePerShare ) . toFixed ( 2 ) } ` : 'Price you paid' }
893+ className = "dialog-input"
894+ min = "0"
895+ step = "any"
896+ title = "The price at which you originally bought this asset"
897+ />
898+ < span className = "setting-help" >
899+ Leave blank to use market price as acquisition price
900+ </ span >
901+ </ div >
902+ </ div >
903+ ) }
904+ </ >
872905 ) }
873906
874907 { /* Value is directly editable for cash accounts (not MONEY_ETF) and PROPERTY assets */ }
0 commit comments