product on shelf
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"nearle/models"
|
||||
"nearle/repositories"
|
||||
)
|
||||
@@ -23,6 +25,7 @@ type CatalogueUploadService interface {
|
||||
List(tenantID, locationID, pageNo, pageSize int) ([]models.CatalogueUpload, error)
|
||||
UpdateStatus(upload *models.CatalogueUpload) error
|
||||
MarkShelved(batchID string, shelved, skipped int) error
|
||||
AttachSheet(batchID, sheetRows string) error
|
||||
}
|
||||
|
||||
type catalogueUploadService struct {
|
||||
@@ -40,6 +43,13 @@ func (s *catalogueUploadService) Record(upload *models.CatalogueUpload) error {
|
||||
// the pipeline had it when it is in fact waiting for a person.
|
||||
upload.Laststatus = "pending"
|
||||
}
|
||||
if strings.TrimSpace(upload.Sheetrows) == "" {
|
||||
// `sheetrows` is jsonb, and Postgres rejects an empty string for it —
|
||||
// "invalid input syntax for type json" — which would fail the whole
|
||||
// receipt over a field nobody supplied. An empty ARRAY is the honest
|
||||
// value: no rows were sent, so there is nothing to shelve from later.
|
||||
upload.Sheetrows = "[]"
|
||||
}
|
||||
return s.repo.Record(upload)
|
||||
}
|
||||
|
||||
@@ -54,3 +64,7 @@ func (s *catalogueUploadService) UpdateStatus(upload *models.CatalogueUpload) er
|
||||
func (s *catalogueUploadService) MarkShelved(batchID string, shelved, skipped int) error {
|
||||
return s.repo.MarkShelved(batchID, shelved, skipped)
|
||||
}
|
||||
|
||||
func (s *catalogueUploadService) AttachSheet(batchID, sheetRows string) error {
|
||||
return s.repo.AttachSheet(batchID, sheetRows)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user