diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2018-09-26 00:45:08 +0200 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2018-09-26 00:45:08 +0200 |
| commit | bf11a0caa0d71b253b1172bf96765f5e53f7a4d4 (patch) | |
| tree | 0c3459186eba3ee800575f1ab044ddcaa5563b44 | |
| parent | 0e7435a36e71b1e5f2fe0a7076c2c4e8cbdc2011 (diff) | |
Ctrl-C proof billing.. i hope
| -rw-r--r-- | interact.go | 37 | ||||
| -rw-r--r-- | main.go | 4 |
2 files changed, 26 insertions, 15 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) @@ -110,7 +110,7 @@ func main() { } if help { - fmt.Printf("Usage of %s Version %s:\n Use Commands as Parameters\n If Commands or flags other than -f were passed $s exits after execution of command.\n\n", os.Args[0],version.os.Args[0]) + fmt.Printf("Usage of %s Version %s:\n Use Commands as Parameters\n If Commands or flags other than -f were passed %s exits after execution of command.\n\n", os.Args[0],version,os.Args[0]) getopt.Usage() interArgs = append([]string{"help"},interArgs...) @@ -152,5 +152,5 @@ func main() { interact() - fmt.Println("Laboravi emeritus...") + fmt.Println("Laboravi finietur...") } |
