Added create contact ednpoint
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
|
||||
func GetContracts(status string, companyName string, companyAddress string,
|
||||
func GetContracts(status []string, companyName string, companyAddress string,
|
||||
companyEmail string, companyPhone string, startTime *time.Time, endTime *time.Time,
|
||||
contractName string, deviceIDs []int64, contractID int, dateCreated *time.Time, limit, offset int) ([]models.Contract, int64, int, error) {
|
||||
|
||||
@@ -24,10 +24,10 @@ func GetContracts(status string, companyName string, companyAddress string,
|
||||
// Define custom fields to be selected, varies based on joined tables
|
||||
customFields := "contracts.*, array_length(contracts.device_ids, 1) as number_of_devices"
|
||||
|
||||
// Search by Status
|
||||
if status != "" {
|
||||
db = db.Where("contracts.status = ?", status)
|
||||
countDb = countDb.Where("contracts.status = ?", status)
|
||||
// Search by Statuses
|
||||
if len(status) > 0 {
|
||||
db = db.Where("contracts.status IN (?)", status)
|
||||
countDb = countDb.Where("contracts.status IN (?)", status)
|
||||
}
|
||||
|
||||
// Search by Company Fields
|
||||
|
||||
@@ -79,13 +79,14 @@ func GetDeviceInfoForContract (deviceID uint64, contract models.Contract) (model
|
||||
}
|
||||
}
|
||||
|
||||
deviceInfosResponse := models.ConvertDeviceInfoToResponse(deviceInfos)
|
||||
|
||||
// Loop through each deviceInfo to create GeoJSON features
|
||||
for _, info := range deviceInfos {
|
||||
for _, info := range deviceInfosResponse {
|
||||
info.RawJSON = ""
|
||||
feature := models.GeoJSONFeature{
|
||||
Type: "Feature",
|
||||
DeviceInfo: &info,
|
||||
DeviceInfoResponse: &info,
|
||||
Geometry: models.GeoJSONGeometry{
|
||||
Type: "Point",
|
||||
Coordinates: []float64{info.Lon, info.Lat},
|
||||
|
||||
@@ -47,13 +47,15 @@ func GetInvoices(buyerName string, sortBy string, limit int, offset int, id uint
|
||||
Find(&invoices).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
|
||||
for i := range invoices {
|
||||
var sum int64
|
||||
for _, item := range invoices[i].InvoiceItem {
|
||||
if invoices[i].InvoiceItem != nil {
|
||||
for _, item := range *invoices[i].InvoiceItem {
|
||||
sum += item.PriceCents * item.Quantity
|
||||
}
|
||||
invoices[i].PriceCents = sum
|
||||
}
|
||||
}
|
||||
|
||||
return invoices, total, nil
|
||||
|
||||
Reference in New Issue
Block a user