Lot, Serial, ExpiryDate

This commit is contained in:
Thanakorn S
2026-04-25 14:37:00 +07:00
parent 92d116fd21
commit 3cc5baba3f
35 changed files with 3518 additions and 1890 deletions
+23 -5
View File
@@ -117,7 +117,21 @@
);
}
$quantity = (int) $source_stock['in'];
// Defensive lot/serial checks
if (!empty($data["lot_number"]) && $source_stock['lot_number'] !== $data["lot_number"]) {
throw new Exception(
"Source rack holds lot '{$source_stock['lot_number']}', not '{$data['lot_number']}'."
);
}
if (!empty($data["serial_number"]) && $source_stock['serial_number'] !== $data["serial_number"]) {
throw new Exception(
"Source rack holds serial '{$source_stock['serial_number']}', not '{$data['serial_number']}'."
);
}
$quantity = (int) $source_stock['in'];
$lot_number = $source_stock['lot_number'] ?? null;
$serial_number = $source_stock['serial_number'] ?? null;
// Resolve both td_stock_<wh> tables
$from_ctx = $whMgmt->getStockContext($from_warehouse, 0);
@@ -134,11 +148,11 @@
$sql = "INSERT INTO `$from_table`
(uuid, company_id, `date`, product_sku, `out`,
ref_warehouse, zone, aisle, rack,
contact_id, `description`, `log`, `type`)
contact_id, `description`, `log`, `type`, lot_number, serial_number)
VALUES
(:uuid, :company_id, :date, :product_sku, :quantity,
:ref_warehouse, :zone, :aisle, :rack,
:contact_id, :description, :log, 'transfer')";
:contact_id, :description, :log, 'transfer', :lot_number, :serial_number)";
$pdo->prepare($sql)->execute([
":uuid" => $transfer_uuid,
":company_id" => $company_id,
@@ -152,6 +166,8 @@
":contact_id" => $contact_id,
":description" => $description,
":log" => json_encode($table_log),
":lot_number" => $lot_number,
":serial_number" => $serial_number,
]);
$from_stock_id = (int) $pdo->lastInsertId();
@@ -159,11 +175,11 @@
$sql = "INSERT INTO `$to_table`
(uuid, company_id, `date`, product_sku, `in`,
ref_warehouse, ref_id, zone, aisle, rack,
contact_id, `description`, `log`, `type`)
contact_id, `description`, `log`, `type`, lot_number, serial_number)
VALUES
(:uuid, :company_id, :date, :product_sku, :quantity,
:ref_warehouse, :ref_id, :zone, :aisle, :rack,
:contact_id, :description, :log, 'transfer')";
:contact_id, :description, :log, 'transfer', :lot_number, :serial_number)";
$pdo->prepare($sql)->execute([
":uuid" => $transfer_uuid,
":company_id" => $company_id,
@@ -178,6 +194,8 @@
":contact_id" => $contact_id,
":description" => $description,
":log" => json_encode($table_log),
":lot_number" => $lot_number,
":serial_number" => $serial_number,
]);
$to_stock_id = (int) $pdo->lastInsertId();