e2e changes
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"nearle/models"
|
||||
"nearle/repositories"
|
||||
"time"
|
||||
@@ -22,6 +24,21 @@ func NewStockRequestService(repo repositories.StockRequestRepository, productSer
|
||||
}
|
||||
|
||||
func (s *stockRequestService) CreateStockRequest(req *models.StockRequest) error {
|
||||
// A request for nothing is not a request.
|
||||
//
|
||||
// Nothing downstream rejected it, so a branch could raise a request for
|
||||
// zero units and it sat in the admin's queue looking exactly like a real
|
||||
// one — and approving it moved no stock, which reads as the ledger being
|
||||
// broken rather than the request being empty. A negative would move stock
|
||||
// the wrong way on receipt, since UpdateStockRequest writes Qty straight
|
||||
// into the ledger as an 'in'.
|
||||
//
|
||||
// Returned as an ordinary error: the controller already reports per-item
|
||||
// reasons, so one bad row in a batch is named and the rest still land.
|
||||
if req.Qty <= 0 {
|
||||
return errors.New("quantity must be more than zero")
|
||||
}
|
||||
|
||||
return s.repo.CreateStockRequest(req)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user