Skip to content

Commit

Permalink
Update postfinance parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvio Böhler committed Mar 1, 2024
1 parent d7b1f53 commit 941c872
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 10 additions & 2 deletions cmd/importer/postfinance/postfinance.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ const (
bfAvisierungstext
bfGutschriftInCHF
bfLastschriftInCHF
bfLabel
bfKategorie
bfValuta
bfSaldoInCHF
)
Expand All @@ -176,7 +178,8 @@ func (p *Parser) readBookingLine() (bool, error) {
if err != nil {
return false, err
}
if len(rec) < 5 || len(rec) > 6 {
if len(rec) < 7 || len(rec) > 8 {
fmt.Println(len(rec), rec)
return false, nil
}
date, err := time.Parse("02.01.2006", rec[bfBuchungsdatum])
Expand All @@ -187,9 +190,14 @@ func (p *Parser) readBookingLine() (bool, error) {
if err != nil {
return false, err
}
desc := strings.Join([]string{
strings.TrimSpace(rec[bfAvisierungstext]),
strings.TrimSpace(rec[bfKategorie]),
strings.TrimSpace(rec[bfLabel]),
}, " ")
p.builder.Add(transaction.Builder{
Date: date,
Description: strings.TrimSpace(rec[bfAvisierungstext]),
Description: strings.TrimSpace(desc),
Postings: posting.Builder{
Credit: p.registry.Accounts().TBDAccount(),
Debit: p.account,
Expand Down
2 changes: 1 addition & 1 deletion cmd/importer/postfinance/testdata/example1.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Expenses:TBD Assets:Postfinance 4.95 CHF
2022-03-07 "desc3"
Assets:Postfinance Expenses:TBD 1139.6 CHF

2022-03-08 "desc1"
2022-03-08 "desc1 bar foo"
Assets:Postfinance Expenses:TBD 19 CHF

8 changes: 4 additions & 4 deletions cmd/importer/postfinance/testdata/example1.input
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Konto:;="CH4609000000877991229"
Währung:;="CHF"

Buchungsdatum;Avisierungstext;Gutschrift in CHF;Lastschrift in CHF;Valuta;Saldo in CHF
Buchungsdatum;Avisierungstext;Gutschrift in CHF;Lastschrift in CHF;Label;Kategorie;Valuta;Saldo in CHF

08.03.2022;desc1 ;;-19;08.03.2022;796.44
07.03.2022;desc2;4.95;;07.03.2022;787.44
07.03.2022;desc3;;-1139.6;07.03.2022;
08.03.2022;desc1 ;;-19;foo;bar;08.03.2022;796.44
07.03.2022;desc2;4.95;;;;07.03.2022;787.44
07.03.2022;desc3;;-1139.6;;;07.03.2022;

Disclaimer:
Dies ist kein durch PostFinance AG erstelltes Dokument. PostFinance AG ist nicht verantwortlich für den Inhalt.

0 comments on commit 941c872

Please sign in to comment.