Skip to content

Commit

Permalink
import etrade with no investments, use to fail due to no commas in pl…
Browse files Browse the repository at this point in the history
…aceholder line
  • Loading branch information
rrelyea committed Dec 19, 2023
1 parent a4c515d commit 3114e09
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
34 changes: 19 additions & 15 deletions Shared/Models/Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,23 +372,27 @@ private static async Task<List<Account>> ImportETrade(IAsyncEnumerator<string[]>
var symbol = chunks[0];
string? investmentName = null;

double shares = FormatUtilities.ParseDouble(chunks[4]);
double value = FormatUtilities.ParseDouble(chunks[9], allowCurrency:true);
double price = FormatUtilities.ParseDouble(chunks[1], allowCurrency:true);
double costBasis = value - FormatUtilities.ParseDouble(chunks[7], allowCurrency:true);

if (symbol == "CASH") {
shares = value;
assetType = AssetType.Cash_MoneyMarket;
} else if (symbol == "TOTAL") {
break;
}
if (chunks.Length > 1)
{
double shares = FormatUtilities.ParseDouble(chunks[4]);
double value = FormatUtilities.ParseDouble(chunks[9], allowCurrency:true);
double price = FormatUtilities.ParseDouble(chunks[1], allowCurrency:true);
double costBasis = value - FormatUtilities.ParseDouble(chunks[7], allowCurrency:true);

if (symbol == "CASH") {
shares = value;
assetType = AssetType.Cash_MoneyMarket;
price = 1.0;
} else if (symbol == "TOTAL") {
break;
}

Investment newInvestment = new (PIN) { funds = funds, Ticker = symbol, Price = price, Name = (investmentName != null ? investmentName : null), Value = value, SharesPIN = shares, CostBasis = costBasis };
if (assetType != null) {
newInvestment.AssetType = assetType;
Investment newInvestment = new (PIN) { funds = funds, Ticker = symbol, Price = price, Name = (investmentName != null ? investmentName : null), Value = value, SharesPIN = shares, CostBasis = costBasis };
if (assetType != null) {
newInvestment.AssetType = assetType;
}
newAccount?.Investments.Add(newInvestment);
}
newAccount?.Investments.Add(newInvestment);
}

return importedAccounts;
Expand Down
2 changes: 1 addition & 1 deletion wwwroot/cache.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CACHE MANIFEST

# Version 1.0098
# Version 1.0099

NETWORK:
*

0 comments on commit 3114e09

Please sign in to comment.