product on shelf
This commit is contained in:
@@ -15,6 +15,7 @@ type CatalogueUploadRepository 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 catalogueUploadRepository struct {
|
||||
@@ -148,3 +149,29 @@ func (r *catalogueUploadRepository) MarkShelved(batchID string, shelved, skipped
|
||||
"shelvedat": gorm.Expr("CURRENT_TIMESTAMP"),
|
||||
}).Error
|
||||
}
|
||||
|
||||
// AttachSheet stores the sheet's rows against a receipt that has none.
|
||||
//
|
||||
// The rescue path for a receipt filed before the rows were kept, and for one
|
||||
// whose upload predates this column. The prices and opening stock exist only in
|
||||
// the spreadsheet; if the receipt was written without them, the only way back is
|
||||
// for somebody to hand the file over again.
|
||||
//
|
||||
// Deliberately not part of UpdateStatus. That call is made by any browser
|
||||
// polling the ingest service and must never touch what the console owns; this
|
||||
// one is a person supplying missing data, and the two should not be able to
|
||||
// happen by accident in each other's place.
|
||||
func (r *catalogueUploadRepository) AttachSheet(batchID, sheetRows string) error {
|
||||
if strings.TrimSpace(batchID) == "" {
|
||||
return errors.New("batchid is required")
|
||||
}
|
||||
if strings.TrimSpace(sheetRows) == "" {
|
||||
// Empty would be stored as `[]` and read back as "this sheet had no
|
||||
// rows", which is a different claim from "nobody has supplied them
|
||||
// yet" — and the second is what makes the shelve button appear.
|
||||
return errors.New("sheetrows is required")
|
||||
}
|
||||
return r.db.Model(&models.CatalogueUpload{}).
|
||||
Where("batchid = ?", batchID).
|
||||
Update("sheetrows", sheetRows).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user