diff options
Diffstat (limited to 'interact.go')
| -rw-r--r-- | interact.go | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/interact.go b/interact.go index 6616f8f..f4a8b4b 100644 --- a/interact.go +++ b/interact.go @@ -442,22 +442,26 @@ func interact() { nil) out := func() (c []int) { for _, v := range choices { - c = append(c, ids[v]) - } + if v > -1 { + c = append(c, ids[v]) + } + } return } - + //All selected ids selids := out() //bids,str2 := getTaskList(selids,false) //c.Println(bids,str2) c.Println(len(selids),"Tasks Selected") - if len(selids) == 0 { + //If None Selected end + if len(selids) == 0 { return } - multicust, multiproj,projids := checkCustomerProjects(selids) - // CHECK IF ONLY ONE CUSTOMER + //get if selected tasks have multicustomers, are from multipe projects, and get the ids of the projects + multicust, multiproj,projids := checkCustomerProjects(selids) billprojid := 0 + // CHECK IF ONLY ONE CUSTOMER if multicust { c.Println(boldRed("Cannot Write One Bill to multiple Customers! Please Select different Tasks")) @@ -466,8 +470,10 @@ func interact() { if multiproj { prid,prstr :=getProjectList(projids) sel := c.MultiChoice(prstr, "What Project Should be Billed ?") - billprojid = prid[sel] - }else{ + if sel > -1 { + billprojid = prid[sel] + } + }else{ billprojid = projids[0] } @@ -476,12 +482,13 @@ func interact() { //c.Printf("%v Tasks Selected. Totaling %.2f (h) - Dates: %s\n",count,hours,dur) proj,cust := getProject(billprojid) - if cust.id == 0 { + // IF CUSTOMER 0 NO BILL CAN BE CREATED + if cust.id == 0 { c.Println(boldRed("Customer ",cust.company," with id ",cust.id," Cannot be billed. Please move ",proj.name," to a valid Customer")) return } - billid,billident := newBill(billprojid) + //billid,billident := newBill(billprojid) //prs,cus := getProjectName(billprojid) //c.Println("For",cust.company,"-",cust.name) //c.Println("Project:",proj.name,"- ID:",proj.id) @@ -491,7 +498,8 @@ func interact() { //c.ReadLine() //Make NEW BILL WITH ID and INV No c.ShowPrompt(false) - fullbillinfo := fmt.Sprintf("For: %s - %s - %.2f(€/h) - Invoice: %s Id:%v\nProject: %s - Id:%v\n%v Tasks Selected. Totaling %.2f (h) - Dates: %s\nProjected Income: %.2f(€)\n",cust.company,cust.name,cust.satz,billident,billid,proj.name,proj.id,count,hours,dur,hours*cust.satz) + //fullbillinfo := fmt.Sprintf("For: %s - %s - %.2f(€/h) - Invoice: %s Id:%v\nProject: %s - Id:%v\n%v Tasks Selected. Totaling %.2f (h) - Dates: %s\nProjected Income: %.2f(€)\n",cust.company,cust.name,cust.satz,billident,billid,proj.name,proj.id,count,hours,dur,hours*cust.satz) + fullbillinfo := fmt.Sprintf("For: %s - %s - %.2f(€/h) \nProject: %s - Id:%v\n%v Tasks Selected. Totaling %.2f (h) - Dates: %s\nProjected Income: %.2f(€)\n",cust.company,cust.name,cust.satz,proj.name,proj.id,count,hours,dur,hours*cust.satz) sep := "-------------------------\n" restinfo := "Here some Info about the rest" restids := selids @@ -516,8 +524,10 @@ func interact() { choices2 := c.Checklist(rstr,pre,nil) out = func() (c []int) { for _, v := range choices2 { - c = append(c, rids[v]) - } + if v > -1 { + c = append(c, rids[v]) + } + } return } taskids := out() @@ -546,6 +556,7 @@ func interact() { //c.ShowPrompt(true) } } + billid,billident := newBill(billprojid) c.Println(green("Bill Completed")) fullbill := bill{billid,billident,dur,proj.id,proj.name,time.Time{},time.Time{},allitems} saveBill(fullbill) |
