From: hackbard Date: Mon, 10 Nov 2014 22:26:16 +0000 (+0100) Subject: transaction and account exceptions X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a5153a22e430f598fd82fc56cd56df5c48e0a5d;p=outofuni%2Fgocash.git transaction and account exceptions --- diff --git a/gocash.go b/gocash.go index 5b999ee..676bf73 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", @@ -56,9 +70,8 @@ var trn_exc = []string{ "Unterrichtung Gastst", } -// account exception list -var account_exc = []string{ - "4970 Nebenkosten des", +// transacion exception list --- the rest, required? +var trn_exc = []string{ } // account maps @@ -155,10 +168,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 +236,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 +260,22 @@ 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 { + continue + } + } else { + if accnt[aid].taxval == 0 { + continue + } + if accnt[aid].taxval == 7 { + tv = 1 + } } // tax tax := int(0)