"io/ioutil"
"os"
"strings"
+ "strconv"
)
//
aid := data.Trn[tc].Spl[tsc].AccountId
if check_trn(&data.Trn[tc],accnt,aid) == false {
ac := accnt[aid].num
- fmt.Println("")
- fmt.Println(data.Trn[tc].Date)
+ fmt.Println(" ",data.Trn[tc].Date)
fmt.Println(" ",data.Trn[tc].Description)
fmt.Println(" ",data.Accnt[ac].Name)
+ fmt.Println("")
}
}
}
case accnt[aid].tax && accnt[aid].buy:
// check pids
if accnt[oaid].pid == accnt[aid].rid[ra] {
- return true
+ return check_vals(accnt,aid,oaid,ta)
}
default:
// check aids
if ta.Spl[ea].AccountId == accnt[aid].rid[ra] {
- return true
+ return check_vals(accnt,aid,oaid,ta)
}
}
//fmt.Println(data.Accnt[accnt[oaid].num].Name)
}
}
- // some exceptions
- wordlist := []string{
+ // some exceptions - transaction description
+ desclist := []string{
"GEMA",
"Deutsche Post",
"gesetz IHK",
"ENTGELT SPK",
"ttenrecht und F",
}
- for wc := range wordlist {
- if strings.Contains(ta.Description,wordlist[wc]){
+ for dc := range desclist {
+ if strings.Contains(ta.Description,desclist[dc]){
+ return true
+ }
+ }
+ // some exceptions - account name
+ accountlist := []string{
+ "4970 Nebenkosten des",
+ }
+ anum := accnt[aid].num
+ for ac := range accountlist {
+ if strings.Contains(data.Accnt[anum].Name,accountlist[ac]){
return true
}
}
+ fmt.Println("E: No correpsonding account!")
+
return false
}
+func check_vals(accnt map[string]amap,aid string,oaid string,ta *Transaction) bool {
+ qa, _ := strconv.Atoi(get_val(ta,aid))
+ qb, _ := strconv.Atoi(get_val(ta,oaid))
+
+ var val, cmp int
+
+
+ switch {
+ case accnt[aid].tax:
+ // aid = taxval * oaid / 100
+ val = int((qb*accnt[aid].taxval)/100.0)
+ cmp = qa
+ default:
+ // oaid = taxval * aid / 100
+ val = int((qa*accnt[aid].taxval)/100.0)
+ cmp = qb
+ }
+
+ if cmp >= val-1 && cmp <= val+1 {
+ return true
+ } else {
+ fmt.Println("E:",qa,qb,"<- ",accnt[aid].taxval,"->",cmp,val)
+ return false
+ }
+}
+
+func get_val(ta *Transaction,aid string) string {
+ for sc := range ta.Spl {
+ if ta.Spl[sc].AccountId == aid {
+ return strings.TrimSuffix(ta.Spl[sc].Value,"/100")
+ }
+ }
+ return ""
+}
+
+func round(v float64) int {
+ if v < 0.0 {
+ v -= 0.5
+ } else {
+ v += 0.5
+ }
+ return int(v)
+}