X-Git-Url: https://www.hackdaworld.org/gitweb/?p=outofuni%2Fgocash.git;a=blobdiff_plain;f=gocash.go;h=e9d37de8aa038e3b4badc2a5f800de2838895eb8;hp=676bf73fda01ee8d91a6c9d813c2cbf48f70f560;hb=HEAD;hpb=8a5153a22e430f598fd82fc56cd56df5c48e0a5d diff --git a/gocash.go b/gocash.go index 676bf73..e9d37de 100644 --- a/gocash.go +++ b/gocash.go @@ -17,7 +17,7 @@ type inv_accnts struct { } // -// account data --- add accounts to consider here! +// accounts considered in tax included balance check // var iaa []inv_accnts = []inv_accnts{ // wareneingang 19% and 7% (note: pids!) @@ -68,12 +68,29 @@ var n2z_exc_ta = []string{ "ENTGELT SPK", "ttenrecht und F", "Unterrichtung Gastst", + "MPLC", } // transacion exception list --- the rest, required? var trn_exc = []string{ } +// +// accounts which will be summed up +// + +type sum_accnt struct { + name string + aid string + valplus int + valminus int +} + +var summed_accounts = []sum_accnt{ + {"Bankkonto","02ea930fdcc500cf7d3a21b80a126eb0",0,0}, + {"Kasse","04e71353130ccb554ebaf4c2438d6b2f",0,0}, +} + // account maps type amap struct { pid string // parent id @@ -228,6 +245,16 @@ func main() { -tax_report.SalesTax[1]); fmt.Println("------------------------------------") + // summed accounts + fmt.Println("") + fmt.Println("Summen einiger Konten:") + fmt.Println("----------------------") + for sac := range summed_accounts { + saccnt := summed_accounts[sac] + fmt.Println(" Konto: ",saccnt.name) + fmt.Println(" +: ",saccnt.valplus) + fmt.Println(" -: ",saccnt.valminus) + } } func check_balance(ta *Transaction,accnt map[string]amap,sel_date string) bool { @@ -256,21 +283,35 @@ func check_balance(ta *Transaction,accnt map[string]amap,sel_date string) bool { // [taxval: 19=0 7=1][tax: no=0 yes=1][buy: no=0 yes=1] var sum [2][2][2]int + // loop over splits within the transaction for sc := range ta.Spl { aid := ta.Spl[sc].AccountId //accnt[aid].tax + // loop over all considered accounts (defined earlier as global) for iac := range iaa { tv := int(0) - // taxval - check accnt instead of iaa! + // taxval changed by exception if tv_ow != -1 { if tv_ow == 7 { tv=1 } if tv_ow == 0 { - continue + // reset taxvalues of involved accounts + // (to drop an error) + if accnt[aid].tax { + if accnt[aid].taxval==7 { + tv=1 + } + } else { + continue + } } + // taxval as defined by account } else { if accnt[aid].taxval == 0 { + if accnt[aid].tax { + fmt.Println("FATAL!"); + } continue } if accnt[aid].taxval == 7 { @@ -309,6 +350,17 @@ func check_balance(ta *Transaction,accnt map[string]amap,sel_date string) bool { break } } + // now get the sums + for sac := range summed_accounts { + if summed_accounts[sac].aid == aid { + inc, _ := strconv.Atoi(strings.TrimSuffix(ta.Spl[sc].Value,"/100")) + if inc >= 0 { + summed_accounts[sac].valplus += inc + } else { + summed_accounts[sac].valminus += inc + } + } + } } // check for exceptions