X-Git-Url: https://www.hackdaworld.org/gitweb/?a=blobdiff_plain;f=gocash.go;h=5b999ee194a479b9dc0662c87a709c60da4f04f2;hb=ee8f0fb10c55cd0aff3427c3ede1be60a76df3b7;hp=2c3646df6d50f90b55bde08c6be848f19f620d1c;hpb=a21585db9f2366a60de0ba6dfe94d9dc0bc8ca29;p=outofuni%2Fgocash.git diff --git a/gocash.go b/gocash.go index 2c3646d..5b999ee 100644 --- a/gocash.go +++ b/gocash.go @@ -9,31 +9,6 @@ import ( "strconv" ) -// -// hardcoded account ids we have to look at -// -// --- buy -// wareneingang 19% and 7% -const pid_buy_n = string("8e3b7c42e3173ed85f3d4736e82afb4d") -const pid_buy_s = string("0cfd2ceb45fff89b9d1b7ce3af66cdf3") -const pid_misc = string("e3acc2865dbf931e41cf2b90240de5c2") -const pid_rep = string("b1d04ad157cac569f4299d4ddf94ed6f") -const pid_room = string("4394ed4ffa7266f8f8731080926a7a61") -const pid_cap = string("4196ee026d1bdb785df2c975fca91ae0") -const aid_werbe = string("cb67d346eac01c2b66e2394df4e8d6e8") -// abziehbare vst 19% and 7% -const aid_vst_n = string("7c449e13125d6b93043f963628106db2") -const aid_vst_s = string("006643c1c0a91f2b40614c75a49c6295") -// --- sales -// receipts -const aid_rec_n = string("f3e905732b729ba096a50dab60559ce7") -const aid_rec_s = string("66c1b04bd897766cb2be538094e1db6a") -const aid_tip = string("1d20024badc11a99a8e1cf3a9a64a501") -const aid_dep = string("9772f4e231f6f5e3100132cc53eb3447") -// ust -const aid_ust_n = string("e4bd6ff52408be8076f24aeb105893d9") -const aid_ust_s = string("38bf40d16529f2a1e611c073c6c1dc9c") - type inv_accnts struct { id string taxval int @@ -41,9 +16,9 @@ type inv_accnts struct { buy bool } -// make these account data the only one, above p/aids redundant! -// we have all the information in here! - +// +// account data --- add accounts to consider here! +// var iaa []inv_accnts = []inv_accnts{ // wareneingang 19% and 7% (note: pids!) { "8e3b7c42e3173ed85f3d4736e82afb4d",19,false,true }, @@ -93,7 +68,6 @@ type amap struct { taxval int // 7 or 19 buy bool // buy or sales tax bool // tax or non-tax(=goods) account - rid []string // required transaction account(s) } // xml @@ -124,8 +98,19 @@ type ParsedData struct { Trn []Transaction `xml:"book>transaction"` } +// tax +type TaxReport struct { + Expenses [2]int + InputTax [2]int + ExpExc [2]int + ITExc [2]int + Receipts [2]int + SalesTax [2]int +} + // 'global' data var data ParsedData +var tax_report TaxReport func main() { @@ -167,60 +152,18 @@ func main() { for ac := range data.Accnt { aid := data.Accnt[ac].AccountId pid := data.Accnt[ac].ParentId - // general map - rid := make ([]string,10,10) - accnt[aid]=amap{ - pid,ac,0,false,false,rid, - } - rid[0]="NONE" - tmp := accnt[aid] - switch { - // ---- buy - // -- goods - case pid == pid_buy_n || pid == pid_misc || pid == pid_rep || pid == pid_room || pid == pid_cap || aid == aid_werbe: - tmp.taxval=19 - tmp.buy=true - rid[0]=aid_vst_n - accnt[aid]=tmp - case pid == pid_buy_s: - tmp.taxval=7 - tmp.buy=true - rid[0]=aid_vst_s - accnt[aid]=tmp - // -- tax - case aid == aid_vst_n: - tmp.taxval=19 - tmp.buy=true - tmp.tax=true - rid=[]string{pid_buy_n,pid_misc,pid_rep,pid_room,pid_cap,aid_werbe,} - accnt[aid]=tmp - case aid == aid_vst_s: - tmp.taxval=7 - tmp.buy=true - tmp.tax=true - rid[0]=pid_buy_s - accnt[aid]=tmp - // ---- sales ---- - // -- receipts - case aid == aid_rec_n || aid == aid_tip || aid == aid_dep: - tmp.taxval=19 - rid[0]=aid_ust_n - accnt[aid]=tmp - case aid == aid_rec_s: - tmp.taxval=7 - rid[0]=aid_ust_s - accnt[aid]=tmp - // -- tax - case aid == aid_ust_n: - tmp.taxval=19 - tmp.tax=true - rid=[]string{aid_rec_n,aid_tip,aid_dep,} - accnt[aid]=tmp - case aid == aid_ust_s: - tmp.taxval=7 - tmp.tax=true - rid[0]=aid_rec_s - accnt[aid]=tmp + for iac := range iaa { + // consider account if pid or aid matches + if pid == iaa[iac].id || aid == iaa[iac].id { + accnt[aid]=amap{ + pid, + ac, + iaa[iac].taxval, + iaa[iac].buy, + iaa[iac].tax, + } + break + } } } @@ -230,6 +173,33 @@ func main() { check_balance(&data.Trn[tc],accnt,sel_date) } + // tax report + fmt.Println("Umsatzsteuervoranmeldung (19% | 7%):") + fmt.Println("------------------------------------") + fmt.Println("Aufwendungen:",tax_report.Expenses[0], + tax_report.Expenses[1]); + fmt.Println("ohne Ausn. :",tax_report.Expenses[0]- + tax_report.ExpExc[0], + tax_report.Expenses[1]- + tax_report.ExpExc[1]); + fmt.Println("gesch. Vst. :",int((tax_report.Expenses[0]*19)/100.0), + int((tax_report.Expenses[1]*7)/100.0)) + fmt.Println("ohne Ausn. :",int(((tax_report.Expenses[0]- + tax_report.ExpExc[0])*19)/100.0), + int(((tax_report.Expenses[1]- + tax_report.ExpExc[1])*7)/100.0)) + fmt.Println("Vorsteuer :",tax_report.InputTax[0], + tax_report.InputTax[1], + "->",tax_report.InputTax[0]+tax_report.InputTax[1]); + fmt.Println("------------------------------------") + fmt.Println("Einnahmen :",-tax_report.Receipts[0], + -tax_report.Receipts[1]); + fmt.Println("gesch. Ust. :",int((-tax_report.Receipts[0]*19)/100.0), + int((-tax_report.Receipts[1]*7)/100.0)); + fmt.Println("Umsatzsteuer:",-tax_report.SalesTax[0], + -tax_report.SalesTax[1]); + fmt.Println("------------------------------------") + } func check_balance(ta *Transaction,accnt map[string]amap,sel_date string) bool { @@ -290,7 +260,7 @@ func check_balance(ta *Transaction,accnt map[string]amap,sel_date string) bool { // check for exceptions exc := false for ec := range trn_exc { - if ta.Description == trn_exc[ec] { + if strings.Contains(ta.Description,trn_exc[ec]) { exc = true break } @@ -301,6 +271,18 @@ func check_balance(ta *Transaction,accnt map[string]amap,sel_date string) bool { // } //} + // tax report + for tv := 0; tv<2; tv++ { + tax_report.Expenses[tv] += sum[tv][0][1] + tax_report.InputTax[tv] += sum[tv][1][1] + tax_report.Receipts[tv] += sum[tv][0][0] + tax_report.SalesTax[tv] += sum[tv][1][0] + if exc { + tax_report.ExpExc[tv] += sum[tv][0][1] + tax_report.ITExc[tv] += sum[tv][1][1] + } + } + // check var expected [2]int check := true