Lot, Serial, ExpiryDate
This commit is contained in:
@@ -6,6 +6,27 @@
|
||||
|
||||
$id = (int)$data['id'];
|
||||
|
||||
// ── Business rule: min_stock < reorder_point ──────────────────────────
|
||||
// The warning tier (balance between min_stock and reorder_point) only
|
||||
// exists when min_stock is strictly less than reorder_point. Enforcing
|
||||
// this invariant keeps the low-stock report meaningful.
|
||||
$min_stock = (float) ($data['min_stock'] ?? 0);
|
||||
$reorder_point = (float) ($data['reorder_point'] ?? 0);
|
||||
|
||||
if ($min_stock < 0 || $reorder_point < 0) {
|
||||
$answer["success"] = 0;
|
||||
$answer["message"] = "Min stock and reorder point cannot be negative.";
|
||||
http_response_code(400);
|
||||
exit(json_encode($answer));
|
||||
}
|
||||
|
||||
if ($min_stock >= $reorder_point) {
|
||||
$answer["success"] = 0;
|
||||
$answer["message"] = "Min stock ({$min_stock}) must be less than reorder point ({$reorder_point}).";
|
||||
http_response_code(400);
|
||||
exit(json_encode($answer));
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
/** 1. FILE HANDLING **/
|
||||
|
||||
Reference in New Issue
Block a user