From 0b97a731b9f38f7d98bd9331453aae918953b26d Mon Sep 17 00:00:00 2001 From: Nikolaus Gotsche Date: Sun, 31 Mar 2019 01:59:49 +0100 Subject: Reprint Bills --- interact.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/interact.go b/interact.go index 4aad9d1..d25c644 100644 --- a/interact.go +++ b/interact.go @@ -448,6 +448,60 @@ func interact(fulldb bool) { }) shell.AddCmd(stopcmd) } + // PRINT commans + { + printcmd := &ishell.Cmd{ + Name: "print", + Help: "yyy / xxx / bills", + LongHelp: ` Usage: print + Print Bills and Reports.`, + } + printcmd.AddCmd(&ishell.Cmd{ + Name: "bills", + Help: "Print selected Bills again to pdf", + LongHelp: ` Usage: print bills + Show all Projects with a small summary, sorted by Customer.`, + Func: func(c *ishell.Context) { + tids := GetBillIds() + ids, str := GetBillList(tids) + choices := c.Checklist(str, + "Which Tasks should be charged in the new bill ?", + nil) + out := func() (c []int) { + for _, v := range choices { + if v > -1 { + c = append(c, ids[v]) + } + } + return + } + prbills := loadBills(out()) + if isInterSure(fmt.Sprintf("Print %v Bills?",len(prbills))) { + c.ProgressBar().Indeterminate(true) + c.ProgressBar().Start() + for i,_ := range prbills { + _, cust := GetProject(prbills[i].project) + files := billTemplate(prbills[i], cust) + err = runLatex(files.Main, prbills[i].identity) + } + c.ProgressBar().Stop() + if err == nil { + c.Println("Finished without Errors") + } else { + c.Println("Finished with error:", err) + } + c.Print("<>") + c.ReadLine() + }else{ + c.Println(boldRed("Charging Aborted")) + } + + + c.Println(promptcol("______________________")) + }, + }) + shell.AddCmd(printcmd) + } // SHOW commands { showcmd := &ishell.Cmd{ -- cgit v1.2.3