Merge charge save error fix
This commit is contained in:
commit
185dfcdb38
2 files changed
+5
-3
No files matched your search
@@ -112,6 +112,7 @@ try {
|
||||
$purchaseDate = trim((string) ($data['purchaseDate'] ?? ''));
|
||||
$receiptQty = isset($data['receiptQty']) && $data['receiptQty'] !== '' ? (float) $data['receiptQty'] : 0.0;
|
||||
$targetQty = isset($data['targetQty']) && $data['targetQty'] !== '' ? (float) $data['targetQty'] : null;
|
||||
$pdo->beginTransaction();
|
||||
if ($lotId > 0) {
|
||||
$lotStmt = $pdo->prepare(
|
||||
"SELECT id
|
||||
@@ -152,6 +153,7 @@ try {
|
||||
}
|
||||
refresh_lager_stock_lot_forecast_for_product($pdo, $productId);
|
||||
$forecast = get_lager_product_forecast($pdo, $productId);
|
||||
$pdo->commit();
|
||||
json_response(200, ['ok' => true, 'productId' => $productId, 'lot' => $preparedLot, 'balance' => get_stock_lot_balance($pdo, $lotId), 'availableQty' => get_lager_product_available_qty($pdo, $productId), 'forecast' => $forecast]);
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ function get_lager_product_available_qty(PDO $pdo, int $productId): float
|
||||
function get_lager_product_forecast(PDO $pdo, int $productId): array
|
||||
{
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT sellout_date, sellout_forecast_status, expiry_date,
|
||||
"SELECT stock_lot.sellout_date, stock_lot.sellout_forecast_status, stock_lot.expiry_date,
|
||||
next_lot.sellout_date AS next_sellout_date,
|
||||
next_lot.sellout_forecast_status AS next_sellout_forecast_status,
|
||||
next_lot.expiry_date AS next_expiry_date
|
||||
@@ -296,8 +296,8 @@ function get_lager_product_forecast(PDO $pdo, int $productId): array
|
||||
AND v.qty_net > 0
|
||||
LIMIT 1
|
||||
) next_lot ON TRUE
|
||||
WHERE product_id = :product_id
|
||||
AND status = 'current'
|
||||
WHERE stock_lot.product_id = :product_id
|
||||
AND stock_lot.status = 'current'
|
||||
LIMIT 1"
|
||||
);
|
||||
$stmt->execute([':product_id' => $productId]);
|
||||
|
||||
Reference in new issue
Block a user