diff --git a/code/app/BookedProduct.php b/code/app/BookedProduct.php index 913e2320..2ac2e641 100644 --- a/code/app/BookedProduct.php +++ b/code/app/BookedProduct.php @@ -327,7 +327,7 @@ public function getValue($type) public function getFinalUnitPrice() { - if ($this->delivered) { + if ($this->delivered > 0) { return $this->final_price / $this->delivered; } else { diff --git a/code/app/Printers/Concerns/Shipping.php b/code/app/Printers/Concerns/Shipping.php index e7855768..3aab9656 100644 --- a/code/app/Printers/Concerns/Shipping.php +++ b/code/app/Printers/Concerns/Shipping.php @@ -94,6 +94,8 @@ public function formatShipping($order, $fields, $status, $shipping_place, $extra 'products' => [], 'totals' => [], 'notes' => !empty($booking->notes) ? [$booking->notes] : [], + + 'others' => $booking->user->morePendingBookings($order->aggregate), ]; foreach($booking->products_with_friends as $booked) { diff --git a/code/app/User.php b/code/app/User.php index 94bb432d..904f22dd 100644 --- a/code/app/User.php +++ b/code/app/User.php @@ -215,6 +215,33 @@ public function initialWelcome() } } + /* + Genera la notifica relativa ad altre prenotazioni (oltre a quella + dell'aggregato specificato) che devono essere ritirate dall'utente nel + corso della giornata. Viene aggiunta nel pannello delle consegne e nel + Dettaglio Consegne PDF + */ + public function morePendingBookings($aggregate) + { + $other_bookings = $this->bookings()->where('status', 'pending')->whereHas('order', function($query) use ($aggregate) { + $query->where('aggregate_id', '!=', $aggregate->id)->where('shipping', $aggregate->shipping); + })->get(); + + if ($other_bookings->isEmpty() == false) { + $notice = _i('Questa persona oggi deve ritirare anche altre prenotazioni:'); + $notice .= '