diff --git a/app/Http/Controllers/HealthCareSheetController.php b/app/Http/Controllers/HealthCareSheetController.php index fb01c85..728632e 100755 --- a/app/Http/Controllers/HealthCareSheetController.php +++ b/app/Http/Controllers/HealthCareSheetController.php @@ -1035,17 +1035,16 @@ class HealthCareSheetController extends Controller DB::rollback(); return $this->errorResponse(__('errors.prescription_already_invoiced', ['id' => $itemIndex + 1])); } - if (isset($prescriptions[$itemIndex]['quantity'])) { - $quantity_to_bill = $item->quantity - ($item->billed_quantity ?? 0); - if ($prescriptions[$itemIndex]['quantity'] > $quantity_to_bill) { - DB::rollback(); - return $this->errorResponse(__('errors.prescription_ordered_quantity_must_not_greater_than_ordered_quantity', - ['id' => $itemIndex + 1, 'quantity' => $quantity_to_bill])); - } - - $item->quantity = $prescriptions[$itemIndex]['quantity']; - $i->billed_quantity += $item->quantity; + $quantity = $prescriptions[$itemIndex]['quantity'] ?? $item->quantity; + $quantity_to_bill = $item->quantity - ($item->billed_quantity ?? 0); + if ($quantity > $quantity_to_bill) { + DB::rollback(); + return $this->errorResponse(__('errors.prescription_ordered_quantity_must_not_greater_than_ordered_quantity', + ['id' => $itemIndex + 1, 'quantity' => $quantity_to_bill])); } + $item->quantity = $quantity; + $i->billed_quantity += $item->quantity; + $item->unit_price = $prescriptions[$itemIndex]['unit_price']; $item->billed_quantity = null; } diff --git a/resources/lang/en/states.php b/resources/lang/en/states.php index fbe939a..e8215e8 100755 --- a/resources/lang/en/states.php +++ b/resources/lang/en/states.php @@ -35,5 +35,6 @@ return [ "ONE_TIME" => "ONCE", "DAILY" => "DAY", "MONTHLY" => "MONTH", - "MODIFIED" => "MODIFIED" + "MODIFIED" => "MODIFIED", + 'RENEWAL' => 'RENEWAL' ]; diff --git a/resources/lang/fr/states.php b/resources/lang/fr/states.php index 2f54405..dc74a4a 100755 --- a/resources/lang/fr/states.php +++ b/resources/lang/fr/states.php @@ -35,5 +35,6 @@ return [ "ONE_TIME" => "1 FOIS", "DAILY" => "JOUR", "MONTHLY" => "MOIS", - "MODIFIED" => "MODIFIÉE" + "MODIFIED" => "MODIFIÉE", + 'RENEWAL' => 'RENOUVELLEMENT' ];