|
|
|
@ -68,7 +68,7 @@ namespace BunyMuny {
|
|
|
|
|
while (csv.Read()) {
|
|
|
|
|
switch (bank) {
|
|
|
|
|
case Bank.ME:
|
|
|
|
|
var value = double.Parse(csv.GetField("Debits and credits").TrimStart().Replace("$", ""));
|
|
|
|
|
var value = decimal.Parse(csv.GetField("Debits and credits").TrimStart().Replace("$", ""));
|
|
|
|
|
var (category, description) = MatchAgainstRules(rules, csv.GetField("Description"));
|
|
|
|
|
|
|
|
|
|
statements.Add(new Statement() {
|
|
|
|
@ -95,11 +95,28 @@ namespace BunyMuny {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var statement in statements.
|
|
|
|
|
// Where(s => s.Category != null).
|
|
|
|
|
// Where(s => s.Category == null).
|
|
|
|
|
OrderBy(s => s.Date)) {
|
|
|
|
|
Console.WriteLine(statement);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Summary:");
|
|
|
|
|
Console.WriteLine("==================");
|
|
|
|
|
var summaries = statements.
|
|
|
|
|
GroupBy(s => s.Category). // group statements by category
|
|
|
|
|
Select(summary => new { // and then select:
|
|
|
|
|
Name = summary.First().Category?? "Other", // the name of the category...
|
|
|
|
|
Total = summary.Sum(s => s.Value).ToString() // ...and the sum of all the statement's values in that category
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var longestCategoryName = summaries.
|
|
|
|
|
ToList().
|
|
|
|
|
Max(summary => summary.Name.Length);
|
|
|
|
|
|
|
|
|
|
foreach (var summary in summaries) {
|
|
|
|
|
Console.WriteLine("{0}: {1}", summary.Name.PadLeft(longestCategoryName), summary.Total);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|