Warenwirtschaft: Review-Fix — API-Protokoll markiert verworfene Positionen korrekt
recordTransfer() löste die SKU erneut auf und markierte nur unbekannte Artikel als Fehler — Zeilen mit gültiger SKU aber fehlender Menge/Preis wurden verworfen und trotzdem grün protokolliert. prepareOrder() reicht jetzt included/product_id/product_name durch; failed = Position nicht übernommen. Entfernt zugleich die N+1-Produkt-Queries je Position. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1b9b6adc44
commit
8ad0f65947
4 changed files with 50 additions and 8 deletions
|
|
@ -700,6 +700,12 @@ class ShoppingUserController extends Controller
|
|||
// $object = json_decode(json_encode($order), FALSE);
|
||||
$order = (object) $order;
|
||||
$error = [];
|
||||
// AP-13 (Review 20.07.2026): Zuordnung + Übernahme-Status hier mitliefern,
|
||||
// damit das Protokoll (ApiOrderLog::recordTransfer) exakt dieselbe Wahrheit
|
||||
// loggt und die SKU nicht erneut auflösen muss.
|
||||
$order->product_id = null;
|
||||
$order->product_name = null;
|
||||
$order->included = false;
|
||||
if (! isset($order->article) || ! isset($order->qty) || ! isset($order->price)) {
|
||||
$error[] = 'article parameter is missing';
|
||||
} else {
|
||||
|
|
@ -708,11 +714,14 @@ class ShoppingUserController extends Controller
|
|||
if (! $product) {
|
||||
$error[] = 'article not found';
|
||||
} else {
|
||||
$order->product_id = $product->id;
|
||||
$order->product_name = $product->name;
|
||||
if ($order->price != ($product->price * 100)) {
|
||||
$error[] = 'different price: '.($product->price * 100);
|
||||
}
|
||||
|
||||
Yard::instance('shopping')->add($product->id, $product->name, (int) $order->qty, $product->price, $product->tax, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
$order->included = true;
|
||||
}
|
||||
}
|
||||
$order->message = $error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue