Rollback failed charge creation
This commit is contained in:
1 parent
764b6fa886
commit
6c1e840c97
1 file changed
+2
@@ -112,6 +112,7 @@ try {
|
|||||||
$purchaseDate = trim((string) ($data['purchaseDate'] ?? ''));
|
$purchaseDate = trim((string) ($data['purchaseDate'] ?? ''));
|
||||||
$receiptQty = isset($data['receiptQty']) && $data['receiptQty'] !== '' ? (float) $data['receiptQty'] : 0.0;
|
$receiptQty = isset($data['receiptQty']) && $data['receiptQty'] !== '' ? (float) $data['receiptQty'] : 0.0;
|
||||||
$targetQty = isset($data['targetQty']) && $data['targetQty'] !== '' ? (float) $data['targetQty'] : null;
|
$targetQty = isset($data['targetQty']) && $data['targetQty'] !== '' ? (float) $data['targetQty'] : null;
|
||||||
|
$pdo->beginTransaction();
|
||||||
if ($lotId > 0) {
|
if ($lotId > 0) {
|
||||||
$lotStmt = $pdo->prepare(
|
$lotStmt = $pdo->prepare(
|
||||||
"SELECT id
|
"SELECT id
|
||||||
@@ -152,6 +153,7 @@ try {
|
|||||||
}
|
}
|
||||||
refresh_lager_stock_lot_forecast_for_product($pdo, $productId);
|
refresh_lager_stock_lot_forecast_for_product($pdo, $productId);
|
||||||
$forecast = get_lager_product_forecast($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]);
|
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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user