From: hackbard Date: Sun, 9 Nov 2014 23:10:32 +0000 (+0100) Subject: exceptions in tax X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=7bac337349d7f798f79ed6a9a27f460b26a25fa9;p=outofuni%2Fgocash.git exceptions in tax --- diff --git a/gocash.go b/gocash.go index 2c3646d..276ac53 100644 --- a/gocash.go +++ b/gocash.go @@ -124,8 +124,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() { @@ -230,6 +241,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 +328,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 +339,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