From 31bea987b8e6fbcbe0c34f1ea5f2b96e436da41a Mon Sep 17 00:00:00 2001 From: Nikolaus Gotsche Date: Sat, 30 Mar 2019 00:57:02 +0100 Subject: show invoice details --- interact.go | 40 +++++++++++++++++++++++++++++++++++++++- sqlite.go | 6 ++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/interact.go b/interact.go index 4cdb1a7..4aad9d1 100644 --- a/interact.go +++ b/interact.go @@ -490,7 +490,7 @@ func interact(fulldb bool) { showcmd.AddCmd(&ishell.Cmd{ Name: "bills", Help: " - Show the last n bills. If no n specified all Bills are shown ", - LongHelp: ` Usage: all bills + LongHelp: ` Usage: show bills Show the last n Bills with a small summary. If no is specified all bills are shown.`, Func: func(c *ishell.Context) { //c.ClearScreen() @@ -511,6 +511,44 @@ func interact(fulldb bool) { c.Println(promptcol("______________________")) }, }) + showcmd.AddCmd(&ishell.Cmd{ + Name: "invoice", + Help: " - Show details of the invoice with given id.", + LongHelp: ` Usage: show invoice + Show detailed information of Invoice with given id. If no is specified a selection screen is shown.`, + Func: func(c *ishell.Context) { + //c.ClearScreen() + arg := "none" + if len(c.Args) > 0 { + arg = strings.Join(c.Args, " ") + argi, err := strconv.Atoi(arg) + if err == nil { + if isBill(argi){ + mid := []int{argi} + thebill := loadBills(mid) + ShowBill(thebill[0], true) + }else{ + c.Println(boldRed(arg, "is not a valid id!")) + } + } else { + c.Println(boldRed(arg, "is not a valid integer!")) + } + } else { + tids := GetBillIds() + selids, lids := GetBillList(tids) + choice := c.MultiChoice(lids, "Select a Bill to Edit") + //c.Println(tids) + //c.Println(selids) + if choice > -1 { + mid := []int{selids[choice]} + thebill := loadBills(mid) + ShowBill(thebill[0], true) + } + } + //stdOut() + c.Println(promptcol("______________________")) + }, + }) shell.AddCmd(showcmd) } /* diff --git a/sqlite.go b/sqlite.go index d9d31db..c6e6a3a 100644 --- a/sqlite.go +++ b/sqlite.go @@ -448,7 +448,9 @@ func ShowBill(in bill,fullest bool) { tsks = append(tsks,Task{id,prj,start,stop,tas,comm,chk}) } for _,t := range tsks { - addText += fmt.Sprintf("%sId: %v - Project: %v : %s\n",nli,t.Id,t.Projectid,t.Taskname) + stastr := t.Start.Local().Format("2006-01-02 15:04") + endstr := t.Stop.Local().Format("15:04") + addText += fmt.Sprintf("%sId: %v - Project: %v : %s (%s - %s)\n",nli,t.Id,t.Projectid,t.Taskname,stastr,endstr) } } fmt.Println(frame(boldGreen("Show Bill ", in.id),true)) @@ -463,7 +465,7 @@ func ShowBill(in bill,fullest bool) { fmt.Println(StrLines(ShowItems(in.items),nli)) if fullest { fmt.Println(sub("Billed Tasks")) - fmt.Println(addText) + fmt.Print(addText) } fmt.Println(frame("",false)) } -- cgit v1.2.3