summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolaus Gotsche <n@softwarefools.com>2019-05-03 01:31:44 +0200
committerNikolaus Gotsche <n@softwarefools.com>2019-05-03 01:31:44 +0200
commit8e7dec5dd1b4be5fd752acd6468d0cd801501e1f (patch)
tree6cef52e17a16d62afcc63f327da5eba6802c76cc
parent64b47d83073893b1442fd250005775f25ba4403e (diff)
Edit Payments
-rw-r--r--interact.go12
-rw-r--r--sqlite.go18
2 files changed, 21 insertions, 9 deletions
diff --git a/interact.go b/interact.go
index 44f8971..a03a672 100644
--- a/interact.go
+++ b/interact.go
@@ -403,17 +403,11 @@ func interact(fulldb bool) {
c.Println(boldRed(arg, "is not a valid id!"))
}
} else {
- /* pids := GetProjectIds()
- selids, lids := getProjectList(pids)
- choice := c.MultiChoice(lids, "Select a Project to Edit")
- //c.Println(pids)
- //c.Println(selids)
+ selids, lids := GetPaymentList()
+ choice := c.MultiChoice(lids, "Select a Payment to Edit")
if choice > -1 {
- editProject(selids[choice])
- //c.Println(choice,selids[choice])
+ EditPayment(selids[choice])
}
- //c.Println(boldRed("editproject <id> - Please enter an id"))
- */
}
c.Println(promptcol("______________________"))
},
diff --git a/sqlite.go b/sqlite.go
index b9234b1..c24aae6 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -1815,6 +1815,24 @@ func setProject(nid int) {
showCurrentTask()
}
+func GetPaymentList() (outint []int, outstr []string) {
+ rows, err := db.Query("SELECT id, customerid, amount, bills, date FROM payments")
+ checkErr(err)
+ var id, cuid int
+ var amt float64
+ var bills string
+ var dat time.Time
+
+ for rows.Next() {
+ err = rows.Scan(&id, &cuid, &amt, &bills, &dat)
+ checkErr(err)
+ cun := getCustomerName(cuid)
+ st := fmt.Sprintf("%v: (%s) %s : %.2f[€] - Bills: %s",id, dat.Local().Format("2006-01-02"),cun, amt,bills)
+ outint = append(outint, id)
+ outstr = append(outstr, st)
+ }
+ return
+}
func getCustomerList() (outint []int, outstr []string) {
rows, err := db.Query("SELECT id, company, name FROM customers")
checkErr(err)