Skip to content

Commit

Permalink
give warning if stocks + bonds != 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
rrelyea committed Jul 30, 2023
1 parent d688795 commit 6aa7ecd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Pages/Portfolio-Review.razor
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,10 @@ Portfolio Review@(stepPath==null?"":": "+stepPath.Replace('-',' ')) - bogle.tool
<p><b>Worksheet:</b> </p>

<EditForm Model="familyData" style=margin-left:25px>
<label>Desired Asset Allocation:</label><br/>
<label style=padding-left:20px>Stock:</label> <input style=width:50px;text-align:right type=text @bind-Value=familyData.Stocks @bind-Value:event=oninput />%<br/>
<label style=padding-left:20px>Bond:</label> <input style=width:50px;text-align:right type=text @bind-Value=familyData.Bonds @bind-Value:event=oninput />%<br/>
<label>Desired Asset Allocation:</label> <br/>
<label style=padding-left:20px>Stocks:</label> <input style=width:50px;text-align:right type=text @bind=familyData.Stocks />%<br/>
<label style=padding-left:20px>Bonds:</label> <input style=width:50px;text-align:right type=text @bind=familyData.Bonds />%<br/>
@if (familyData.AssetAllocationError) { <span style=background-color:yellow>&nbsp;Stocks and Bonds should equal 100%</span><br/> }
<hr/>
<label style=padding-left:20px>Desired International allocation (% of Stock):</label><br/>
<label style=padding-left:40px>International:</label> <input style=width:50px;text-align:right type=text @bind-Value=familyData.International @bind-Value:event=oninput />%<br/>
Expand Down
30 changes: 28 additions & 2 deletions Shared/Models/FamilyData/FamilyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,34 @@ public string? StateMarginalTaxBracket {
public string? StateOfResidence { get; set; }

public bool NotSureNeedHelpWithAssetAllocation { get; set; }
public double? Stocks { get; set; }
public double? Bonds { get; set; }

private double? _Stocks;
public double? Stocks {
get {
return _Stocks;
}
set {
_Stocks = value;
if (_Stocks != null && Bonds == null) { Bonds = 100.0 - _Stocks; }
if (_Stocks != null || _Bonds != null) { AssetAllocationError = ((_Bonds + _Stocks) != 100.0); }
}
}

private double? _Bonds;
public double? Bonds {
get {
return _Bonds;
}
set {
_Bonds = value;
if (_Bonds != null && Stocks == null) { Stocks = 100.0 - _Bonds; }
if (_Stocks != null || _Bonds != null) { AssetAllocationError = ((_Bonds + _Stocks) != 100.0); }
}
}

[JsonIgnore]
public bool AssetAllocationError { get; set; }

public int? International { get; set; }

public double? StockBalance { get; set; }
Expand Down

0 comments on commit 6aa7ecd

Please sign in to comment.