aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/invoice/controller.go
diff options
context:
space:
mode:
Diffstat (limited to 'invoice/controller.go')
-rw-r--r--invoice/controller.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/invoice/controller.go b/invoice/controller.go
index b03ec22..bb51628 100644
--- a/invoice/controller.go
+++ b/invoice/controller.go
@@ -18,13 +18,13 @@
package invoice
import (
- e "vidhukant.com/openbills/errors"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
+ e "vidhukant.com/openbills/errors"
)
-func handleGetSingleInvoice (ctx *gin.Context) {
+func handleGetSingleInvoice(ctx *gin.Context) {
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {
ctx.Error(e.ErrInvalidID)
@@ -47,22 +47,22 @@ func handleGetSingleInvoice (ctx *gin.Context) {
func handleGetInvoices(getDrafts bool) func(*gin.Context) {
return func(ctx *gin.Context) {
- var invoices []Invoice
+ var invoices []Invoice
- err := getInvoices(&invoices, getDrafts)
- if err != nil {
- ctx.Error(err)
- ctx.Abort()
- return
- }
+ err := getInvoices(&invoices, getDrafts)
+ if err != nil {
+ ctx.Error(err)
+ ctx.Abort()
+ return
+ }
- ctx.JSON(http.StatusOK, gin.H{
- "data": invoices,
- })
+ ctx.JSON(http.StatusOK, gin.H{
+ "data": invoices,
+ })
}
}
-func handleSaveInvoice (ctx *gin.Context) {
+func handleSaveInvoice(ctx *gin.Context) {
var invoice Invoice
ctx.Bind(&invoice)
@@ -92,7 +92,7 @@ func handleSaveInvoice (ctx *gin.Context) {
})
}
-func handleDelInvoice (ctx *gin.Context) {
+func handleDelInvoice(ctx *gin.Context) {
// TODO: only drafts can be deleted, non-drafts should be "cancelled"
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {
@@ -115,7 +115,7 @@ func handleDelInvoice (ctx *gin.Context) {
}
// get items belonging to a certain invoice
-func handleGetInvoiceItems (ctx *gin.Context) {
+func handleGetInvoiceItems(ctx *gin.Context) {
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {
ctx.Error(e.ErrInvalidID)
@@ -136,7 +136,7 @@ func handleGetInvoiceItems (ctx *gin.Context) {
})
}
-func addItem (ctx *gin.Context) {
+func addItem(ctx *gin.Context) {
// TODO: only drafts can be edited
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {
@@ -160,7 +160,7 @@ func addItem (ctx *gin.Context) {
ctx.JSON(http.StatusOK, nil)
}
-func removeItem (ctx *gin.Context) {
+func removeItem(ctx *gin.Context) {
// TODO: only drafts can be edited
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {
@@ -183,7 +183,7 @@ func removeItem (ctx *gin.Context) {
}
// get custom fields belonging to a certain invoice
-func handleGetInvoiceCustomFields (ctx *gin.Context) {
+func handleGetInvoiceCustomFields(ctx *gin.Context) {
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {
ctx.Error(e.ErrInvalidID)
@@ -204,7 +204,7 @@ func handleGetInvoiceCustomFields (ctx *gin.Context) {
})
}
-func addCustomField (ctx *gin.Context) {
+func addCustomField(ctx *gin.Context) {
// TODO: only drafts can be edited
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {
@@ -229,7 +229,7 @@ func addCustomField (ctx *gin.Context) {
})
}
-func removeCustomField (ctx *gin.Context) {
+func removeCustomField(ctx *gin.Context) {
// TODO: only drafts can be edited
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {