From 9684daedb6c572433773667a15ebe2b382a5a1bd Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Fri, 29 Dec 2023 17:35:53 +0100 Subject: [PATCH] start working on VAT XMLs... --- bookkeeper.go | 52 +++++++++++++++++++++++++++++++++++++++++-------- vat_xml.tmpl | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 vat_xml.tmpl diff --git a/bookkeeper.go b/bookkeeper.go index 2a37b09..bd50617 100644 --- a/bookkeeper.go +++ b/bookkeeper.go @@ -13,6 +13,7 @@ import ( "sort" "strconv" "strings" + "text/template" "time" ) @@ -36,6 +37,17 @@ type Balance struct { balance_end float64 } +type Data struct { + GenerationTime string + ReportingPeriodFrom string + ReportingPeriodTill string + BusinessReferenceId string + TotalConsideration string + DataTaxRates map[string]string + InputTaxInvestments string + PayableTax string +} + /* global variable declaration */ var pdf *fpdf.Fpdf var yPos float64 @@ -475,6 +487,35 @@ func calculateProfit() float64 { } +func outputMwst(whatquarter string) { + fmt.Printf("Create Mwst Report for %s\n", whatquarter) + + tm := time.Now() + gmt_location := time.FixedZone("GMT", 0) + + var data Data + data.GenerationTime = fmt.Sprintf("%s", tm.In(gmt_location).Format("2006-01-02T15:04:05Z")) + data.ReportingPeriodFrom = "2022-01-01" + data.ReportingPeriodFrom = "2022-03-31" + data.BusinessReferenceId = "ef1q2024_20220101_20220331_1" + data.TotalConsideration = "43517.04" + data.DataTaxRates = map[string]string{"7.70": "43517.04", "8.0": "Test only"} + data.InputTaxInvestments = "174.09" + data.PayableTax = "3176.72" + + tmp, err := template.ParseFiles("vat_xml.tmpl") + + if err != nil { + log.Fatal(err) + } + + err2 := tmp.Execute(os.Stdout, data) + + if err2 != nil { + log.Fatal(err2) + } +} + func usage() { fmt.Printf("usage: bookkeeper \n") fmt.Printf("\n") @@ -503,14 +544,9 @@ func main() { createBalanceSheet() case "journal": fmt.Println("Create Journal") - case "mwst1": - fmt.Println("Create Mwst1") - case "mstw2": - fmt.Println("Create Mwst2") - case "mwst3": - fmt.Println("Create Mwst3") - case "mwst4": - fmt.Println("Create Mwst4") + case "mwst1", "mwst2", "mwst3", "mwst4": + fmt.Println("Create Mwst Quarterly Report") + outputMwst(action) case "new_year": fmt.Println("Create New Year") default: diff --git a/vat_xml.tmpl b/vat_xml.tmpl new file mode 100644 index 0000000..148c490 --- /dev/null +++ b/vat_xml.tmpl @@ -0,0 +1,54 @@ + + + + + + CHE + 105687350 + + nbit Informatik GmbH + {{.GenerationTime}} + {{.ReportingPeriodFrom}} + {{.ReportingPeriodTill}} + 1 + 1 + {{.BusinessReferenceId}} + + nbit Informatik GmbH + bookkeeper + 1.0 + + + + {{.TotalConsideration}} + 0.00 + 0.00 + 0.00 + 0.00 + 0.00 + + 0.00 + + + + + 1 + 0.00 + {{ range $key, $value := .DataTaxRates -}} + + {{ $key }} + {{ $value }} + + {{ end -}} + 0.00 + {{.InputTaxInvestments}} + 0.00 + 0.00 + 0.00 + + {{.PayableTax}} + + 0.00 + 0.00 + +