diff --git a/app/Services/BillDetailService.php b/app/Services/BillDetailService.php index c1b2d3b..3a57047 100644 --- a/app/Services/BillDetailService.php +++ b/app/Services/BillDetailService.php @@ -22,6 +22,7 @@ class BillDetailService { $items = StoreOrderItemModel::query() ->where('bill_id', $bill->id) + ->where('quantity', '>', 0) ->orderBy('id') ->get(); @@ -39,6 +40,7 @@ class BillDetailService { $items = StoreOrderItemModel::query() ->whereIn('bill_id', $billIds) + ->where('quantity', '>', 0) ->orderBy('id') ->get(); @@ -73,15 +75,14 @@ class BillDetailService $weight = bcadd($weight, (string) $item->weight, 3); $amount = bcadd($amount, (string) $item->amount, 2); } + $price = bcdiv($amount, (string) $quantity, 2); $rows[] = [ 'product_id' => (int) $productId, 'product_name' => $first->product_name, 'product_spec' => $first->product_spec, 'unit' => $first->unit, - 'price' => $quantity > 0 - ? bcdiv($amount, (string) $quantity, 2) - : (string) $first->price, + 'price' => $price, 'quantity' => $quantity, 'weight' => $weight, 'amount' => $amount,