Skip to content

Commit

Permalink
added ffl address to order
Browse files Browse the repository at this point in the history
  • Loading branch information
KenWilliamson committed Aug 25, 2021
1 parent 2fa6939 commit c255382
Show file tree
Hide file tree
Showing 6 changed files with 811 additions and 797 deletions.
1,574 changes: 787 additions & 787 deletions coverage.out

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ require (
github.com/Ulbora/Level_Logger v1.0.2
github.com/Ulbora/dbinterface v1.0.5
github.com/Ulbora/dbinterface_mysql v1.0.7
github.com/Ulbora/six910-database-interface v1.1.1
github.com/Ulbora/six910-database-interface v1.1.2
github.com/go-sql-driver/mysql v1.6.0 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ github.com/Ulbora/six910-database-interface v1.1.0 h1:JjJKWsEfDu/Heq6wYnKYg0LZTq
github.com/Ulbora/six910-database-interface v1.1.0/go.mod h1:xKoESfGA7CV8kFeZwMtwnBAezrBFzTdtrSRaeUn0QBQ=
github.com/Ulbora/six910-database-interface v1.1.1 h1:LSCAw1d+SJnahx/aAltl+VDxUlmR15yaH5++GDxtsMk=
github.com/Ulbora/six910-database-interface v1.1.1/go.mod h1:xKoESfGA7CV8kFeZwMtwnBAezrBFzTdtrSRaeUn0QBQ=
github.com/Ulbora/six910-database-interface v1.1.2 h1:aQx2e/0iJnz196f+B4VGd/VnZUQ0Tyb132g+gTKN/ZI=
github.com/Ulbora/six910-database-interface v1.1.2/go.mod h1:xKoESfGA7CV8kFeZwMtwnBAezrBFzTdtrSRaeUn0QBQ=
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
Expand Down
8 changes: 6 additions & 2 deletions order.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (d *Six910Mysql) AddOrder(o *mdb.Order) (bool, int64) {
a = append(a, time.Now(), o.Status, o.Subtotal, o.ShippingHandling, o.Insurance, o.Taxes, o.Total,
o.CustomerID, o.BillingAddressID, o.ShippingAddressID, o.CustomerName, o.BillingAddress,
o.ShippingAddress, o.StoreID, o.OrderNumber, o.OrderType, o.Pickup, o.Username,
o.ShippingMethodID, o.ShippingMethodName)
o.ShippingMethodID, o.ShippingMethodName, o.FFLShippingAddressID, o.FFLShippingAddress)
suc, id := d.DB.Insert(insertOrder, a...)
d.Log.Debug("suc in add Order", suc)
d.Log.Debug("id in add Order", id)
Expand All @@ -54,7 +54,7 @@ func (d *Six910Mysql) UpdateOrder(o *mdb.Order) bool {
a = append(a, time.Now(), o.Status, o.Subtotal, o.ShippingHandling, o.Insurance, o.Taxes, o.Total,
o.BillingAddressID, o.ShippingAddressID, o.CustomerName, o.BillingAddress,
o.ShippingAddress, o.OrderType, o.Pickup, o.Username, o.ShippingMethodID, o.ShippingMethodName,
o.Refunded, o.ID)
o.Refunded, o.FFLShippingAddressID, o.FFLShippingAddress, o.ID)
suc := d.DB.Update(updateOrder, a...)
return suc
}
Expand Down Expand Up @@ -253,6 +253,8 @@ func (d *Six910Mysql) parseOrderRow(foundRow *[]string) *mdb.Order {
refunded, err := strconv.ParseFloat((*foundRow)[22], 64)
d.Log.Debug("refunded err in get Order", err)
if err == nil {
fflid, _ := strconv.ParseInt((*foundRow)[23], 10, 64)
d.Log.Debug("smid err in get Order", err)
rtn.ID = id
rtn.CustomerID = cid
rtn.OrderDate = oTime
Expand All @@ -267,6 +269,7 @@ func (d *Six910Mysql) parseOrderRow(foundRow *[]string) *mdb.Order {
rtn.Taxes = tax
rtn.Total = tot
rtn.Refunded = refunded
rtn.FFLShippingAddressID = fflid
rtn.Status = (*foundRow)[3]
rtn.CustomerName = (*foundRow)[12]
rtn.BillingAddress = (*foundRow)[13]
Expand All @@ -276,6 +279,7 @@ func (d *Six910Mysql) parseOrderRow(foundRow *[]string) *mdb.Order {
rtn.Username = (*foundRow)[19]
rtn.ShippingMethodID = smid
rtn.ShippingMethodName = (*foundRow)[21]
rtn.FFLShippingAddress = (*foundRow)[24]
}

}
Expand Down
7 changes: 7 additions & 0 deletions order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func TestSix910Mysql_Order(t *testing.T) {
odr.Taxes = 5.27
odr.Total = 146.32
odr.Username = "billybob"
odr.FFLShippingAddressID = 21
odr.FFLShippingAddress = "My FFL"

dbi.Close()
odrsuc, oid := si.AddOrder(&odr)
Expand Down Expand Up @@ -100,6 +102,8 @@ func TestSix910Mysql_Order(t *testing.T) {
odr.ShippingMethodID = 23
odr.ShippingMethodName = "UPS Ground"
odr.Refunded = 15.00
odr.FFLShippingAddressID = 22
odr.FFLShippingAddress = "My New FFL"

dbi.Close()
uodrsuc := si.UpdateOrder(&odr)
Expand All @@ -110,6 +114,8 @@ func TestSix910Mysql_Order(t *testing.T) {
dbi.Close()
fodr := si.GetOrder(oid)
fmt.Println("fodr: ", fodr)
fmt.Println("fodr fflid: ", fodr.FFLShippingAddressID)
fmt.Println("fodr ffl: ", fodr.FFLShippingAddress)
fmt.Println("Refunded: ", fodr.Refunded)
if fodr.CustomerID != odr.CustomerID || fodr.OrderType != odr.OrderType || fodr.Refunded != 15.00 {
t.Fail()
Expand Down Expand Up @@ -170,4 +176,5 @@ func TestSix910Mysql_Order(t *testing.T) {
}

dbi.Close()
// t.Fail()
}
15 changes: 8 additions & 7 deletions queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,42 +643,43 @@ const (
insertOrder = "INSERT INTO orders (order_date, status, subtotal, shipping_handling, " +
" insurance, taxes, total, customer_id, billing_address_id, shipping_address_id, customer_name, " +
" billing_address, shipping_address, store_id, order_number, order_type, pickup, username, " +
" shipping_method_id, shipping_method_name)" +
" values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "
" shipping_method_id, shipping_method_name, ffl_address_id, ffl_address)" +
" values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "

updateOrder = "UPDATE orders SET updated = ?, status = ?, subtotal = ?, shipping_handling = ?, " +
" insurance = ?, taxes = ?, total = ?, billing_address_id = ?, shipping_address_id = ?, customer_name = ?, " +
" billing_address = ?, shipping_address = ?, order_type = ?, pickup = ?, username = ?, " +
" shipping_method_id = ?, shipping_method_name = ?, refunded = ? " +
" shipping_method_id = ?, shipping_method_name = ?, refunded = ?, ffl_address_id = ?, " +
" ffl_address = ? " +
" WHERE id = ? "

getOrder = "SELECT id, order_date, updated, status, subtotal, shipping_handling, " +
" insurance, taxes, total, customer_id, billing_address_id, shipping_address_id, customer_name, " +
" billing_address, shipping_address, store_id, order_number, order_type, pickup, username, " +
" shipping_method_id, shipping_method_name, refunded " +
" shipping_method_id, shipping_method_name, refunded, ffl_address_id, ffl_address " +
" FROM orders " +
" WHERE id = ? "

getOrderByCid = "SELECT id, order_date, updated, status, subtotal, shipping_handling, " +
" insurance, taxes, total, customer_id, billing_address_id, shipping_address_id, customer_name, " +
" billing_address, shipping_address, store_id, order_number, order_type, pickup, username, " +
" shipping_method_id, shipping_method_name, refunded " +
" shipping_method_id, shipping_method_name, refunded, ffl_address_id, ffl_address " +
" FROM orders " +
" WHERE customer_id = ? and store_id = ? " +
" ORDER BY order_date "

getOrderForStore = "SELECT id, order_date, updated, status, subtotal, shipping_handling, " +
" insurance, taxes, total, customer_id, billing_address_id, shipping_address_id, customer_name, " +
" billing_address, shipping_address, store_id, order_number, order_type, pickup, username, " +
" shipping_method_id, shipping_method_name, refunded " +
" shipping_method_id, shipping_method_name, refunded, ffl_address_id, ffl_address " +
" FROM orders " +
" WHERE store_id = ? " +
" ORDER by status"

getOrderForStoreByStatus = "SELECT id, order_date, updated, status, subtotal, shipping_handling, " +
" insurance, taxes, total, customer_id, billing_address_id, shipping_address_id, customer_name, " +
" billing_address, shipping_address, store_id, order_number, order_type, pickup, username, " +
" shipping_method_id, shipping_method_name, refunded " +
" shipping_method_id, shipping_method_name, refunded, ffl_address_id, ffl_address " +
" FROM orders " +
" WHERE store_id = ? and status = ? "

Expand Down

0 comments on commit c255382

Please sign in to comment.