summaryrefslogtreecommitdiff
path: root/interact.go
diff options
context:
space:
mode:
Diffstat (limited to 'interact.go')
-rw-r--r--interact.go41
1 files changed, 38 insertions, 3 deletions
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: "<id> Edit a Bill of the following id",
+ LongHelp: ` Usage: edit bill <id>
+ Edit Bill of the set <id>.
+ Press <Enter> 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 <id> - 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)