X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=gocash.go;h=9e74149d26a9261c36c4cc20b61dfe33ef34b8e7;hb=9dc8babad5442ff2ade2864e74f5d966209e322e;hp=5b999ee194a479b9dc0662c87a709c60da4f04f2;hpb=ee8f0fb10c55cd0aff3427c3ede1be60a76df3b7;p=outofuni%2Fgocash.git diff --git a/gocash.go b/gocash.go index 5b999ee..9e74149 100644 --- a/gocash.go +++ b/gocash.go @@ -43,9 +43,23 @@ var iaa []inv_accnts = []inv_accnts{ { "38bf40d16529f2a1e611c073c6c1dc9c", 7,true,false }, } -// transacion exception list -var trn_exc = []string{ +// +// account exceptions +// +// account exceptions: nineteen to seven +var n2s_exc = []string{ +} +// account exceptions: nineteen to zero +var n2z_exc = []string{ + "4970 Nebenkosten des", + "4910 Porto", +} +// transaction exceptions: nineteen to seven +var n2s_exc_ta = []string{ "GEMA", +} +// transaction exceptions: nineteen to zero +var n2z_exc_ta = []string{ "Deutsche Post", "gesetz IHK", "Gesundheitsbelehrung", @@ -54,11 +68,11 @@ var trn_exc = []string{ "ENTGELT SPK", "ttenrecht und F", "Unterrichtung Gastst", + "MPLC", } -// account exception list -var account_exc = []string{ - "4970 Nebenkosten des", +// transacion exception list --- the rest, required? +var trn_exc = []string{ } // account maps @@ -155,10 +169,25 @@ func main() { for iac := range iaa { // consider account if pid or aid matches if pid == iaa[iac].id || aid == iaa[iac].id { + taxval := iaa[iac].taxval + for ec := range n2s_exc { + if strings.Contains(data.Accnt[ac].Name, + n2s_exc[ec]) { + taxval=7 + break + } + } + for ec := range n2z_exc { + if strings.Contains(data.Accnt[ac].Name, + n2z_exc[ec]) { + taxval=0 + break + } + } accnt[aid]=amap{ pid, ac, - iaa[iac].taxval, + taxval, iaa[iac].buy, iaa[iac].tax, } @@ -208,7 +237,21 @@ func check_balance(ta *Transaction,accnt map[string]amap,sel_date string) bool { tdate := strings.Fields(ta.Date)[0] if !strings.Contains(tdate,sel_date) { return true - } else { + } + + // exceptions + tv_ow := -1 + for ec := range n2s_exc_ta { + if strings.Contains(ta.Description,n2s_exc_ta[ec]) { + tv_ow=7 + break + } + } + for ec := range n2z_exc_ta { + if strings.Contains(ta.Description,n2z_exc_ta[ec]) { + tv_ow=0 + break + } } // [taxval: 19=0 7=1][tax: no=0 yes=1][buy: no=0 yes=1] @@ -218,10 +261,33 @@ func check_balance(ta *Transaction,accnt map[string]amap,sel_date string) bool { aid := ta.Spl[sc].AccountId //accnt[aid].tax for iac := range iaa { - // taxval tv := int(0) - if iaa[iac].taxval == 7 { - tv = 1 + // taxval - check accnt instead of iaa! + if tv_ow != -1 { + if tv_ow == 7 { + tv=1 + } + if tv_ow == 0 { + // reset taxvalues of involved accounts + // (to drop an error) + if accnt[aid].tax { + if accnt[aid].taxval==7 { + tv=1 + } + } else { + continue + } + } + } else { + if accnt[aid].taxval == 0 { + if accnt[aid].tax { + fmt.Println("FATAL!"); + } + continue + } + if accnt[aid].taxval == 7 { + tv = 1 + } } // tax tax := int(0)