diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2018-09-03 03:17:43 +0200 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2018-09-03 03:17:43 +0200 |
| commit | d6dd3088da980467909a5a43fb393260c3ff7c93 (patch) | |
| tree | 9349252e785db39b1dd3e2f54e6acb8be0c45af9 /interact.go | |
| parent | 0dfd786bdd7dffc13f941d5a37e814f9f8bda846 (diff) | |
Task Selection For Billing
Diffstat (limited to 'interact.go')
| -rw-r--r-- | interact.go | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/interact.go b/interact.go index 55dcabb..f555b55 100644 --- a/interact.go +++ b/interact.go @@ -4,6 +4,7 @@ import ( //"os" "strings" "strconv" + "fmt" "github.com/abiosoft/ishell" "github.com/fatih/color" @@ -281,7 +282,8 @@ func interact() { Name: "bill", Help: "Select Tasks to be billed", Func: func(c *ishell.Context) { - ids,str := getUnfinishedList() + nix := []int{0} + ids,str := getTaskList(nix,true) choices := c.Checklist(str, "What Tasks do you want to bill ?", nil) @@ -291,8 +293,70 @@ func interact() { } return } - c.Println("Your choices are",out() ) - }, + + selids := out() + //bids,str2 := getTaskList(selids,false) + //c.Println(bids,str2) + c.Println(len(out()),"Tasks Selected") + multicust, multiproj,projids := checkCustomerProjects(selids) + // CHECK IF ONLY ONE CUSTOMER + billprojid := 0 + + if multicust { + c.Println("Cannot Write One Bill to multiple Customers! Please Select different Tasks") + + }else{ + // CHECK IF ONLY ONE PROJECT ELSE CHOOSE ONE + if multiproj { + prid,prstr :=getProjectList(projids) + sel := c.MultiChoice(prstr, "What Project Should be Billed ?") + billprojid = prid[sel] + }else{ + billprojid = projids[0] + } + seltasks := getSelectedTasks(selids) + count,hours,dur := analyzeTasks(seltasks) + + //c.Printf("%v Tasks Selected. Totaling %.2f (h) - Dates: %s\n",count,hours,dur) + proj,cust := getProject(billprojid) + billid := newBill(billprojid) + //prs,cus := getProjectName(billprojid) + c.Println("For",cust.company,"-",cust.name) + c.Println("Project:",proj.name,"- ID:",proj.id) + c.Println("Projected Income:",hours*cust.satz,"€") + + c.Println("Create New Bill:",billid) + c.ReadLine() //Make NEW BILL WITH ID and INV No + + fullbillinfo := fmt.Sprintf("For: %s - %s - Invoice: %s\nProject: %s - Id:%v\n%v Tasks Selected. Totaling %.2f (h) - Dates: %s\nProjected Income: %.2f(€)\n",cust.company,cust.name,billid,proj.name,proj.id,count,hours,dur,hours*cust.satz) + sep := "-------------------------\n" + restinfo := "Here some Info about the rest" + restids := selids + //allaccounted := false + //resttasks := seltasks + //SELECT SUBSET AND NAME BILLITEM + //c.clear()//Println(some,"Str2:",str2) + for { + if len(restids) == 0 { + break + } + rids,rstr := getTaskList(restids,false) + restinfo = "Select Tasks to Group as Billitem" + pre := fmt.Sprintf("%s%s%s",fullbillinfo,sep,restinfo) + + choices2 := c.Checklist(rstr,pre,nil) + out = func() (c []int) { + for _, v := range choices2 { + c = append(c, rids[v]) + } + return + } + taskids := out() + restids = removeItems(restids,taskids) + c.Println("Full",selids,"Your choices are",taskids,"Rest:",removeItems(selids,taskids)) + } + } + }, }) |
