]> hackdaworld.org Git - outofuni/gocash.git/commitdiff
exceptions in tax
authorhackbard <hackbard@hackdaworld.org>
Sun, 9 Nov 2014 23:10:32 +0000 (00:10 +0100)
committerhackbard <hackbard@hackdaworld.org>
Sun, 9 Nov 2014 23:10:32 +0000 (00:10 +0100)
gocash.go

index 2c3646df6d50f90b55bde08c6be848f19f620d1c..276ac535e681dc2c5d363dce8b4fb6b323720f07 100644 (file)
--- 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