diff options
Diffstat (limited to 'sqlite.go')
| -rw-r--r-- | sqlite.go | 59 |
1 files changed, 52 insertions, 7 deletions
@@ -428,6 +428,46 @@ func showLastBills(count int) { fmt.Println(frame("",false)) } +// Show Full Bill info of single bill, fullest to true for related tasks +func ShowBill(in bill,fullest bool) { + boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc() + //boldRed := color.New(color.FgRed, color.Bold).SprintFunc() + addText := "" + projn,custn := getProjectName(in.project) + var tsks []Task + if fullest { + rows, err := db.Query("SELECT * FROM timetable WHERE checkout = ? ORDER BY stop DESC", in.id) + checkErr(err) + var id,prj,chk int + var start, stop time.Time + var tas,comm string + defer rows.Close() + for rows.Next() { + err = rows.Scan(&id, &prj, &start, &stop, &tas, &comm, &chk) + checkErr(err) + tsks = append(tsks,Task{id,prj,start,stop,tas,comm,chk}) + } + for _,t := range tsks { + addText += fmt.Sprintf("%sId: %v - Project: %v : %s\n",nli,t.Id,t.Projectid,t.Taskname) + } + } + fmt.Println(frame(boldGreen("Show Bill ", in.id),true)) + if fullest { + fmt.Printf("%sId: %v - InvoiceNumber: %v\n",nli,in.id,in.identity) + }else{ + fmt.Println(nli," This Bill:") + } + fmt.Printf("%sFor: %s\n",nli,custn) + fmt.Printf("%sProject: %s\n",nli,projn) + fmt.Println(sub("Bill Items")) + fmt.Println(StrLines(ShowItems(in.items),nli)) + if fullest { + fmt.Println(sub("Billed Tasks")) + fmt.Println(addText) + } + fmt.Println(frame("",false)) +} + func loadBills(in []int) (out []bill) { ins := strings.Trim(strings.Replace(fmt.Sprint(in), " ", " , ", -1), "[]") que := fmt.Sprintf("SELECT * FROM bills WHERE id IN (%s) ORDER BY project DESC", ins) @@ -1865,6 +1905,7 @@ func editBill(id int) { ident = getNewInterInput("New Bill Identifier: ", ident, nli) timran = getNewInterInput("New Timerange:", timran, nli) + paiyr := pai.Local().Format("2006-01-02") paistr = pai.Local().Format("2006-01-02 15:04") datstr = dat.Local().Format("2006-01-02 15:04") for { @@ -1876,13 +1917,17 @@ func editBill(id int) { break } } - for { - newpaistr := getNewInterInput("New Paid date: ", paistr, nli) - if !isDateTime(newpaistr) { - fmt.Println(nli, newpaistr, boldRed("is Not a Valid Timestring!"), "use: 'YYYY-MM-DD HH:MM'") - } else { - paistr = newpaistr - break + if paiyr == "1791-09-30" { + fmt.Println(nli,boldRed("Open")) + }else{ + for { + newpaistr := getNewInterInput("New Paid date: ", paistr, nli) + if !isDateTime(newpaistr) { + fmt.Println(nli, newpaistr, boldRed("is Not a Valid Timestring!"), "use: 'YYYY-MM-DD HH:MM'") + } else { + paistr = newpaistr + break + } } } for { |
