Fix timestamps, delete requests, invoice dates and GR quantities
Apply the configured timezone to PHP and both DB connections, wrap unwrapped ajax payloads so delete buttons reach their engines, normalise and validate invoice due dates, reject stock quantities below the stored 4dp scale, and list stock movements across all warehouses.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/DocumentNumberManager.php';
|
||||
require_once __DIR__ . '/WarehouseManager.php';
|
||||
require_once __DIR__ . '/StockManager.php';
|
||||
require_once __DIR__ . '/../classes_ac/PostingWindowGuard.php';
|
||||
|
||||
/**
|
||||
@@ -575,7 +576,16 @@ class PurchaseOrderManager {
|
||||
$warehouse_id = (int)($recv['warehouse_id'] ?? $po['warehouse_id']);
|
||||
$quantity = (float)($recv['quantity'] ?? 0);
|
||||
|
||||
if ($quantity <= 0) continue;
|
||||
// A blank line is a line the user chose not to receive — skip it.
|
||||
if ($quantity == 0) continue;
|
||||
|
||||
// Anything positive has to survive the decimal(18,4) columns it is
|
||||
// about to be written to. Without this, 0.0000001 was accepted, was
|
||||
// stored as 0.0000, produced a stock movement of nothing, and still
|
||||
// advanced received_qty enough to leave the PO stuck on "Partial".
|
||||
$name = $po_items[$po_items_by_id[$item_id] ?? -1]['product_name'] ?? $product_sku;
|
||||
$quantity = StockManager::normaliseQuantity($quantity, "Receiving quantity for \"{$name}\"");
|
||||
|
||||
if (!$product_sku) throw new Exception("Item #{$j}: missing product_sku.");
|
||||
if (!$warehouse_id) throw new Exception("Item #{$j}: missing warehouse_id.");
|
||||
|
||||
@@ -600,6 +610,16 @@ class PurchaseOrderManager {
|
||||
$zone = $recv['zone'] ?? '';
|
||||
$aisle = $recv['aisle'] ?? '';
|
||||
|
||||
// Expiry dates live on md_lot, keyed by lot number, so an expiry
|
||||
// entered without one is silently dropped and the received stock
|
||||
// shows no expiry at all. Say so instead of discarding it.
|
||||
if (trim((string)($recv['expiry_date'] ?? '')) !== ''
|
||||
&& trim((string)($recv['lot_number'] ?? '')) === '') {
|
||||
throw new Exception(
|
||||
"Enter a lot number for \"{$name}\" — an expiry date is recorded against its lot."
|
||||
);
|
||||
}
|
||||
|
||||
// Simple location mode: zone and aisle must mirror the bin value
|
||||
// (same convention as manage_stock_in.php).
|
||||
// occupyBin() looks up md_bin WHERE zone=:zone AND aisle=:aisle AND bin=:bin,
|
||||
|
||||
Reference in New Issue
Block a user