This commit is contained in:
Djery-Tom 2022-04-13 17:46:47 +01:00
parent c12ef5ea18
commit 0ce46df5a9
3 changed files with 13 additions and 12 deletions

View File

@ -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;
}

View File

@ -35,5 +35,6 @@ return [
"ONE_TIME" => "ONCE",
"DAILY" => "DAY",
"MONTHLY" => "MONTH",
"MODIFIED" => "MODIFIED"
"MODIFIED" => "MODIFIED",
'RENEWAL' => 'RENEWAL'
];

View File

@ -35,5 +35,6 @@ return [
"ONE_TIME" => "1 FOIS",
"DAILY" => "JOUR",
"MONTHLY" => "MOIS",
"MODIFIED" => "MODIFIÉE"
"MODIFIED" => "MODIFIÉE",
'RENEWAL' => 'RENOUVELLEMENT'
];