added commbank support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
42be0862ca
commit
ffc50f83a3
4 changed files with 28 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,5 +3,6 @@ bin/
|
||||||
obj/
|
obj/
|
||||||
test.csv
|
test.csv
|
||||||
test2.csv
|
test2.csv
|
||||||
|
test3.csv
|
||||||
rules.csv
|
rules.csv
|
||||||
.~lock*
|
.~lock*
|
||||||
|
|
1
Bank.cs
1
Bank.cs
|
@ -2,6 +2,7 @@ namespace BunyMuny {
|
||||||
public enum Bank {
|
public enum Bank {
|
||||||
ME,
|
ME,
|
||||||
NAB,
|
NAB,
|
||||||
|
CommBank,
|
||||||
Other
|
Other
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
41
Program.cs
41
Program.cs
|
@ -55,6 +55,7 @@ namespace BunyMuny {
|
||||||
csv.Configuration.HasHeaderRecord = false;
|
csv.Configuration.HasHeaderRecord = false;
|
||||||
|
|
||||||
var nabRegex = new Regex(@"^\d\d \w{3} \d\d");
|
var nabRegex = new Regex(@"^\d\d \w{3} \d\d");
|
||||||
|
var commbankRegex = new Regex(@"\d\d\/\d\d\/\d{4}");
|
||||||
|
|
||||||
if (header == null) {
|
if (header == null) {
|
||||||
Console.WriteLine("File is empty 0uo");
|
Console.WriteLine("File is empty 0uo");
|
||||||
|
@ -74,12 +75,17 @@ namespace BunyMuny {
|
||||||
// i don't like it >:c
|
// i don't like it >:c
|
||||||
bank = Bank.NAB;
|
bank = Bank.NAB;
|
||||||
}
|
}
|
||||||
|
else if (commbankRegex.IsMatch(header)) {
|
||||||
|
bank = Bank.CommBank;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
Console.WriteLine($"Unknown header: [{header}]");
|
Console.WriteLine($"Unknown header: [{header}]");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (csv.Read()) {
|
while (csv.Read()) {
|
||||||
decimal value;
|
decimal value;
|
||||||
|
DateTime date;
|
||||||
|
string originalDescription;
|
||||||
string category;
|
string category;
|
||||||
string description;
|
string description;
|
||||||
|
|
||||||
|
@ -87,27 +93,22 @@ namespace BunyMuny {
|
||||||
case Bank.ME:
|
case Bank.ME:
|
||||||
value = decimal.Parse(csv.GetField("Debits and credits").TrimStart().Replace("$", ""));
|
value = decimal.Parse(csv.GetField("Debits and credits").TrimStart().Replace("$", ""));
|
||||||
(category, description) = MatchAgainstRules(rules, csv.GetField("Description"));
|
(category, description) = MatchAgainstRules(rules, csv.GetField("Description"));
|
||||||
|
date = DateTime.ParseExact(csv.GetField("Date"), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
||||||
statements.Add(new Statement() {
|
originalDescription = csv.GetField("Description");
|
||||||
Date = DateTime.ParseExact(csv.GetField("Date"), "dd/MM/yyyy", CultureInfo.InvariantCulture),
|
|
||||||
OriginalDescription = csv.GetField("Description"),
|
|
||||||
Description = description,
|
|
||||||
Category = category,
|
|
||||||
Value = value
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Bank.NAB:
|
case Bank.NAB:
|
||||||
// return 1;
|
|
||||||
value = decimal.Parse(csv.GetField(1));
|
value = decimal.Parse(csv.GetField(1));
|
||||||
(category, description) = MatchAgainstRules(rules, csv.GetField(5));
|
(category, description) = MatchAgainstRules(rules, csv.GetField(5));
|
||||||
statements.Add(new Statement() {
|
date = DateTime.ParseExact(csv.GetField(0), "dd MMM yy", CultureInfo.CurrentCulture);
|
||||||
Date = DateTime.ParseExact(csv.GetField(0), "dd MMM yy", CultureInfo.CurrentCulture),
|
originalDescription = csv.GetField(5);
|
||||||
OriginalDescription = csv.GetField(5),
|
break;
|
||||||
Description = description,
|
|
||||||
Category = category,
|
case Bank.CommBank:
|
||||||
Value = value
|
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;
|
break;
|
||||||
|
|
||||||
case Bank.Other:
|
case Bank.Other:
|
||||||
|
@ -118,6 +119,14 @@ namespace BunyMuny {
|
||||||
Console.WriteLine(":(");
|
Console.WriteLine(":(");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
statements.Add(new Statement() {
|
||||||
|
Date = date,
|
||||||
|
OriginalDescription = originalDescription,
|
||||||
|
Description = description,
|
||||||
|
Category = category,
|
||||||
|
Value = value
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var statement in statements.
|
foreach (var statement in statements.
|
||||||
|
|
|
@ -14,6 +14,7 @@ dotnet build
|
||||||
## Supported banks
|
## Supported banks
|
||||||
- ME Bank ([guide](https://git.bune.city/lynnesbian/BunyMuny/raw/branch/master/guide/me.png))
|
- ME Bank ([guide](https://git.bune.city/lynnesbian/BunyMuny/raw/branch/master/guide/me.png))
|
||||||
- NAB
|
- NAB
|
||||||
|
- CommBank
|
||||||
|
|
||||||
## The rules file
|
## The rules file
|
||||||
By default, BunyMuny checks for rules in `rules.csv` in the current directory.
|
By default, BunyMuny checks for rules in `rules.csv` in the current directory.
|
||||||
|
|
Loading…
Reference in a new issue