diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2019-05-10 01:08:05 +0200 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2019-05-10 01:08:05 +0200 |
| commit | bf7dfda3e67f67687109290209c8b09576a417fd (patch) | |
| tree | f19288849c4b839f2b751302668bb3a835ce1c83 | |
| parent | eeca61f9137ef70f53e03cf0df8e0c2cda4bb9ce (diff) | |
Minor beautifications
| -rw-r--r-- | analyze.go | 25 | ||||
| -rw-r--r-- | main.go | 4 | ||||
| -rw-r--r-- | sqlite.go | 16 |
3 files changed, 32 insertions, 13 deletions
@@ -14,6 +14,7 @@ type Month struct { Earnings float64 + Workvalue float64 Workhours float64 //Workdays int Tasks []int @@ -36,11 +37,13 @@ func MakeAnalysis() { monthstr := fmt.Sprintf("%v",monthn) exist, exid := MonthExists(year,month) dur := ta.Duration() + val := ta.Money() if exist { if !isElement(day,analysis[exid].Days){ analysis[exid].Days = append(analysis[exid].Days,day) } + analysis[exid].Workvalue += val analysis[exid].Workhours += dur analysis[exid].Tasks = append(analysis[exid].Tasks,ta.Id) if !isElement(ta.Projectid,analysis[exid].Projects){ @@ -55,6 +58,7 @@ func MakeAnalysis() { 0.0, //Earning + val, // Workvalue dur, //Workhours []int{ta.Id},[]int{ta.Projectid}}) } @@ -78,6 +82,7 @@ func MakeAnalysis() { py.Amount, //Earning + 0.0, //Workvalue 0.0, //Workhours []int{}, []int{}}) @@ -92,14 +97,20 @@ func MakeAnalysis() { func ShowFullAnalysis() { fmt.Println(frame("Full Analysis",true)) for _,mo := range analysis { - fmt.Println(sli,mo.Year,mo.MonthName) - fmt.Printf("%s Workhours: %.2f[h]\n",nli,mo.Workhours) - fmt.Printf("%s Earnings: %.2f[€]\n",nli,mo.Earnings) - fmt.Println(nli," Days:",len(mo.Days)) cnt, hr, dur := AnalyzeTasks(GetSelectedTasks(mo.Tasks)) - fmt.Println(nli," Tasks:",cnt,"Hours:", hr) - fmt.Println(nli," ",dur) - fmt.Println(nli,"Projects:",len(mo.Projects)) + + fmt.Println(sli,mo.Year,mo.MonthName) + fmt.Printf("%s Workhours: %.2f[h]\n",nli,mo.Workhours) + fmt.Printf("%s Earnings: %.2f[€]\n",nli,mo.Earnings) + fmt.Printf("%s Workvalue: %.2f[€]\n",nli,mo.Workvalue) + fmt.Printf("%s Projects: %v\n",nli,len(mo.Projects)) + fmt.Printf("%s Days: %v\n",nli,len(mo.Days)) + fmt.Printf("%s Tasks: %v Hours: %.2f[€]\n",nli,cnt, hr) + fmt.Printf("%s %s\n",nli,dur) + fmt.Printf("%s Hourly Rate: %.2f[€/h]\n",nli,mo.Earnings/mo.Workhours) + fmt.Printf("%s Productivity: %.2f[h/d]\n",nli,mo.Workhours/float64(len(mo.Days))) + + fmt.Println(nli) } fmt.Println(frame("",false)) @@ -82,7 +82,9 @@ func title(frame bool) { bHiM := color.New(color.FgHiMagenta, color.Bold).SprintFunc() bM := color.New(color.FgMagenta, color.Bold).SprintFunc() line := "___" - compyear = compdate[len(compdate)-4:] + if len(compdate) > 4 { + compyear = compdate[len(compdate)-4:] + } if frame { fmt.Printf("%s%s%s%s%s%s%s%s\n\n", bR(line), bHiR(line), bHiY(line), bHiG(line), bHiC(line), bHiB(line), bHiM(line), bM(line)) @@ -87,8 +87,10 @@ func (t Task) Duration() float64 { dur := t.Stop.Sub(t.Start) return dur.Hours() } - - +func (t Task) Money() float64 { + _,cu := GetProject(t.Projectid) + return t.Duration()*cu.Satz +} // Global Variables @@ -1565,8 +1567,12 @@ func AddPayment(dat string) { if len(selids)>0{ break }else{ + // TODO allow no bills and ask fmt.Println(boldRed("At least one Bill should Correspont to a payment!")) - getInterInput("<continue>") + if isInterSure(sli+"Do you want to continue without a selection?") { + //getInterInput("<continue>") + break + } } } mybills := loadBills(selids) @@ -1578,7 +1584,7 @@ func AddPayment(dat string) { } fmt.Println(frame(boldGreen("New Payment"),true)) - fmt.Println(nli," Amount:",amtfl) + fmt.Println(nli," Amount:",amtfl,"[€]") fmt.Println(nli," Date:",date.Format("2006-01-02")) fmt.Println(nli,"Customer:",getCustomerName(icust)) fmt.Println(sub("Invoices")) @@ -1590,7 +1596,7 @@ func AddPayment(dat string) { hsum += it.Hours } fmt.Printf("%s %s : %s (%s) %.1f[h] %.2f[€]\n",nli,bi.identity,bi.projectname,bi.date.Format("2006-01-02 15:04"),hsum,bsum) - sum += bsum + //sum += bsum } if amtfl != sum { fmt.Println(sli,boldRed(" The sum of the bills (",sum,"€) does not match Payment amount!")) |
