aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/customer
diff options
context:
space:
mode:
Diffstat (limited to 'customer')
-rw-r--r--customer/controller.go10
-rw-r--r--customer/customer.go25
-rw-r--r--customer/hooks.go2
3 files changed, 19 insertions, 18 deletions
diff --git a/customer/controller.go b/customer/controller.go
index 83423da..b9b2b25 100644
--- a/customer/controller.go
+++ b/customer/controller.go
@@ -18,13 +18,13 @@
package customer
import (
- e "vidhukant.com/openbills/errors"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
+ e "vidhukant.com/openbills/errors"
)
-func handleGetSingleCustomer (ctx *gin.Context) {
+func handleGetSingleCustomer(ctx *gin.Context) {
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {
ctx.Error(e.ErrInvalidID)
@@ -44,7 +44,7 @@ func handleGetSingleCustomer (ctx *gin.Context) {
})
}
-func handleGetCustomers (ctx *gin.Context) {
+func handleGetCustomers(ctx *gin.Context) {
var customers []Customer
err := getCustomers(&customers)
@@ -59,7 +59,7 @@ func handleGetCustomers (ctx *gin.Context) {
})
}
-func handleSaveCustomer (ctx *gin.Context) {
+func handleSaveCustomer(ctx *gin.Context) {
var customer Customer
ctx.Bind(&customer)
@@ -75,7 +75,7 @@ func handleSaveCustomer (ctx *gin.Context) {
})
}
-func handleDelCustomer (ctx *gin.Context) {
+func handleDelCustomer(ctx *gin.Context) {
id, err := strconv.ParseUint(ctx.Param("id"), 10, 64)
if err != nil {
ctx.Error(e.ErrInvalidID)
diff --git a/customer/customer.go b/customer/customer.go
index 0d107d7..cf5c3f1 100644
--- a/customer/customer.go
+++ b/customer/customer.go
@@ -23,6 +23,7 @@ import (
)
var db *gorm.DB
+
func init() {
db = d.DB
@@ -31,18 +32,18 @@ func init() {
type Customer struct {
gorm.Model
- FirmName string
- Gstin string
- ContactName string
- Phone string
- Email string
- Website string
-
- BillingAddressText string
- BillingAddressCity string
- BillingAddressState string
- BillingAddressPostalCode string
- BillingAddressCountry string
+ FirmName string
+ Gstin string
+ ContactName string
+ Phone string
+ Email string
+ Website string
+
+ BillingAddressText string
+ BillingAddressCity string
+ BillingAddressState string
+ BillingAddressPostalCode string
+ BillingAddressCountry string
ShippingAddressText string
ShippingAddressCity string
diff --git a/customer/hooks.go b/customer/hooks.go
index 7f715c3..2160f40 100644
--- a/customer/hooks.go
+++ b/customer/hooks.go
@@ -34,7 +34,7 @@ func (c *Customer) BeforeSave(tx *gorm.DB) error {
}
func (c *Customer) BeforeDelete(tx *gorm.DB) error {
- // if ID is 0, customer won't be deleted
+ // if ID is 0, customer won't be deleted
if c.ID == 0 {
return errors.ErrNoWhereCondition
}