From a568e743b5ffd6bd7308c526e76a3ec551614f9f Mon Sep 17 00:00:00 2001 From: Nikolaus Gotsche Date: Tue, 26 Mar 2019 12:23:08 +0100 Subject: Edit Bills --- interact.go | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'interact.go') diff --git a/interact.go b/interact.go index 143df51..640723e 100644 --- a/interact.go +++ b/interact.go @@ -343,6 +343,37 @@ func interact(fulldb bool) { c.Println(promptcol("______________________")) }, }) + editcmd.AddCmd(&ishell.Cmd{ + Name: "bill", + Help: " Edit a Bill of the following id", + LongHelp: ` Usage: edit bill + Edit Bill of the set . + Press on empty line to keep the old entry`, + Func: func(c *ishell.Context) { + arg := "none" + if len(c.Args) > 0 { + arg = strings.Join(c.Args, " ") + argi, err := strconv.Atoi(arg) + if err == nil { + editBill(argi) + } else { + c.Println(boldRed(arg, "is not a valid id!")) + } + } 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 { + editBill(selids[choice]) + //c.Println(choice,selids[choice]) + } + //c.Println(boldRed("edittask - Please enter an id")) + } + c.Println(promptcol("______________________")) + }, + }) shell.AddCmd(editcmd) } @@ -683,7 +714,7 @@ func interact(fulldb bool) { Help: "Select Tasks to be charged", LongHelp: ` Usage: charge Select the tasks that should be merged into a Bill. - The Initial selection cannot be changed afterward. Only the complete + The Task selection cannot be changed afterward. The bill can be deleted and a new selection made.`, Func: func(c *ishell.Context) { nix := []int{0} @@ -761,13 +792,17 @@ func interact(fulldb bool) { //SELECT SUBSET AND NAME BILLITEM //c.clear()//Println(some,"Str2:",str2) for { - doneinfo := "Already Billed\n" + doneinfo2 := "" + sumh := 0.0 if len(restids) == 0 { break } for _,itm := range allitems { - doneinfo = fmt.Sprintf("%s %s - %v(h)\n",doneinfo,itm.Task,itm.Hours) + doneinfo2 = fmt.Sprintf("%s %s - %v(h)\n",doneinfo2,itm.Task,itm.Hours) + sumh += itm.Hours } + doneinfo1 := fmt.Sprintf("Already Billed: %v(h)\n",sumh) + doneinfo := fmt.Sprintf("%s%s",doneinfo1,doneinfo2) resttasks := GetSelectedTasks(restids) rcount, rhours, _ := AnalyzeTasks(resttasks) -- cgit v1.2.3