added commbank support
continuous-integration/drone/push Build is passing Details

master
Lynne Megido 2 years ago
parent 42be0862ca
commit ffc50f83a3
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90

1
.gitignore vendored

@ -3,5 +3,6 @@ bin/
obj/
test.csv
test2.csv
test3.csv
rules.csv
.~lock*

@ -2,6 +2,7 @@ namespace BunyMuny {
public enum Bank {
ME,
NAB,
CommBank,
Other
}
}

@ -55,6 +55,7 @@ namespace BunyMuny {
csv.Configuration.HasHeaderRecord = false;
var nabRegex = new Regex(@"^\d\d \w{3} \d\d");
var commbankRegex = new Regex(@"\d\d\/\d\d\/\d{4}");
if (header == null) {
Console.WriteLine("File is empty 0uo");
@ -74,12 +75,17 @@ namespace BunyMuny {
// i don't like it >:c
bank = Bank.NAB;
}
else if (commbankRegex.IsMatch(header)) {
bank = Bank.CommBank;
}
else {
Console.WriteLine($"Unknown header: [{header}]");
}
while (csv.Read()) {
decimal value;
DateTime date;
string originalDescription;
string category;
string description;
@ -87,27 +93,22 @@ namespace BunyMuny {
case Bank.ME:
value = decimal.Parse(csv.GetField("Debits and credits").TrimStart().Replace("$", ""));
(category, description) = MatchAgainstRules(rules, csv.GetField("Description"));
statements.Add(new Statement() {
Date = DateTime.ParseExact(csv.GetField("Date"), "dd/MM/yyyy", CultureInfo.InvariantCulture),
OriginalDescription = csv.GetField("Description"),
Description = description,
Category = category,
Value = value
});
date = DateTime.ParseExact(csv.GetField("Date"), "dd/MM/yyyy", CultureInfo.InvariantCulture);
originalDescription = csv.GetField("Description");
break;
case Bank.NAB:
// return 1;
value = decimal.Parse(csv.GetField(1));
(category, description) = MatchAgainstRules(rules, csv.GetField(5));
statements.Add(new Statement() {
Date = DateTime.ParseExact(csv.GetField(0), "dd MMM yy", CultureInfo.CurrentCulture),
OriginalDescription = csv.GetField(5),
Description = description,
Category = category,
Value = value
});
date = DateTime.ParseExact(csv.GetField(0), "dd MMM yy", CultureInfo.CurrentCulture);
originalDescription = csv.GetField(5);
break;
case Bank.CommBank:
value = decimal.Parse(csv.GetField(1));
(category, description) = MatchAgainstRules(rules, csv.GetField(2));
date = DateTime.ParseExact(csv.GetField(0), "dd/MM/yyyy", CultureInfo.InvariantCulture);
originalDescription = csv.GetField(2);
break;
case Bank.Other:
@ -118,6 +119,14 @@ namespace BunyMuny {
Console.WriteLine(":(");
return 1;
}
statements.Add(new Statement() {
Date = date,
OriginalDescription = originalDescription,
Description = description,
Category = category,
Value = value
});
}
foreach (var statement in statements.

@ -14,6 +14,7 @@ dotnet build
## Supported banks
- ME Bank ([guide](https://git.bune.city/lynnesbian/BunyMuny/raw/branch/master/guide/me.png))
- NAB
- CommBank
## The rules file
By default, BunyMuny checks for rules in `rules.csv` in the current directory.

Loading…
Cancel
Save