diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2018-09-05 04:10:54 +0200 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2018-09-05 04:10:54 +0200 |
| commit | 4a4f372605d56f2241699da6a5bf8dae7eda2b86 (patch) | |
| tree | 80025d8ee00a1ea37ff94b351ca720b7e2fc110e /interact.go | |
| parent | d6dd3088da980467909a5a43fb393260c3ff7c93 (diff) | |
TOML Configuration added. texification working. outsourced some functions to my utilitys. billed tasks not yet checked
Diffstat (limited to 'interact.go')
| -rw-r--r-- | interact.go | 82 |
1 files changed, 72 insertions, 10 deletions
diff --git a/interact.go b/interact.go index f555b55..918b2a9 100644 --- a/interact.go +++ b/interact.go @@ -5,6 +5,7 @@ import ( "strings" "strconv" "fmt" + "time" "github.com/abiosoft/ishell" "github.com/fatih/color" @@ -34,7 +35,27 @@ func interact() { showLastProject() }, }) - + + shell.AddCmd(&ishell.Cmd{ + Name: "config", + Help: "View and Edit Configuration", + Func: func(c *ishell.Context) { + //c.Print("\033[H\033[2J") + //c.Println(boldGreen("Start New Project")) + editConf() + }, + }) + + shell.AddCmd(&ishell.Cmd{ + Name: "show", + Help: "Show Current State", + Func: func(c *ishell.Context) { + //c.Print("\033[H\033[2J") + //c.Println(boldGreen("Start New Project")) + stdOut() + }, + }) + shell.AddCmd(&ishell.Cmd{ Name: "add", Help: "Add new Customer", @@ -319,19 +340,22 @@ func interact() { //c.Printf("%v Tasks Selected. Totaling %.2f (h) - Dates: %s\n",count,hours,dur) proj,cust := getProject(billprojid) - billid := 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) - c.Println("Projected Income:",hours*cust.satz,"€") + //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 + //c.Println("Create New Bill:",billid) + //c.ReadLine() //Make NEW BILL WITH ID and INV No + c.ShowPrompt(false) - 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) + 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) sep := "-------------------------\n" restinfo := "Here some Info about the rest" restids := selids + var allitems []billitem + //allaccounted := false //resttasks := seltasks //SELECT SUBSET AND NAME BILLITEM @@ -340,8 +364,12 @@ func interact() { if len(restids) == 0 { break } + resttasks := getSelectedTasks(restids) + rcount,rhours,_ := analyzeTasks(resttasks) + rids,rstr := getTaskList(restids,false) - restinfo = "Select Tasks to Group as Billitem" + qu := "Select Tasks to Group as Billitem" + restinfo = fmt.Sprintf("%v Tasks Left, Total %.2f(h)\n%s",rcount,rhours,qu) pre := fmt.Sprintf("%s%s%s",fullbillinfo,sep,restinfo) choices2 := c.Checklist(rstr,pre,nil) @@ -353,9 +381,43 @@ func interact() { } taskids := out() restids = removeItems(restids,taskids) - c.Println("Full",selids,"Your choices are",taskids,"Rest:",removeItems(selids,taskids)) + + if len(taskids)>0 { + ittasks := getSelectedTasks(taskids) + itcount,ithours,itdur := analyzeTasks(ittasks) + c.Printf("\n%v Tasks Selected, Total %.2f(h), Date: %s\n",itcount,ithours,itdur) + c.ShowPrompt(false) + c.Print("Name your Task for the Bill: ") + tsk := c.ReadLine() + var hrf float64 + for { + c.Print("How Many Hours: ") + hr := c.ReadLine() + hrf,err = strconv.ParseFloat(hr,64) + if err != nil { + c.Println(hr,boldRed("can not be Parsed as a Float."),"Try a shape of X.X") + }else{break} + } + c.Printf("%T %v - %T %v\n",tsk,tsk,hrf,hrf) + allitems = append(allitems,billitem{tsk,itdur,hrf,hrf*cust.satz}) + c.Print("<<Continue>>") + c.ReadLine() + //c.ShowPrompt(true) + } } + c.Println(green("Bill Completed")) + fullbill := bill{billid,billident,dur,proj.id,proj.name,time.Time{},time.Time{},allitems} + saveBill(fullbill) + testid := []int{billid} + testbill := loadBills(testid) + //c.Println(testbill[0].projectname,testbill[0].items) + files := billTemplate(testbill[0],cust) + c.Println(files) + c.Print("<<Continue>>") + c.ReadLine() + stdOut() } + c.ShowPrompt(true) }, }) |
