Fix health care sheet execution
This commit is contained in:
parent
104e5d4f78
commit
1d5113ad26
|
@ -840,29 +840,22 @@ class HealthCareSheetController extends Controller
|
|||
if (!in_array($i->id, $prescriptionsIds)) {
|
||||
continue;
|
||||
}
|
||||
$itemIndex = array_search($i->id, $prescriptionsIds);
|
||||
if ($i->billed) {
|
||||
return $this->errorResponse(__('errors.prescription_already_invoiced', ['id' => array_search($i->id, $prescriptionsIds) + 1]));
|
||||
return $this->errorResponse(__('errors.prescription_already_invoiced', ['id' => $itemIndex + 1]));
|
||||
}
|
||||
|
||||
$itemId = $i->id;
|
||||
$item->unit_price = array_filter($prescriptions, function ($r) use ($itemId) {
|
||||
return $r['id'] == $itemId;
|
||||
})[0]['unit_price'];
|
||||
|
||||
$item->unit_price = $prescriptions[$itemIndex]['unit_price'];
|
||||
}
|
||||
|
||||
if ($relation == 'exams') {
|
||||
if (!in_array($i->id, $examsIds)) {
|
||||
continue;
|
||||
}
|
||||
$itemIndex = array_search($i->id, $examsIds);
|
||||
if ($i->billed) {
|
||||
return $this->errorResponse(__('errors.exam_already_invoiced', ['id' => array_search($i->id, $examsIds) + 1]));
|
||||
return $this->errorResponse(__('errors.exam_already_invoiced', ['id' => $itemIndex + 1]));
|
||||
}
|
||||
$itemId = $i->id;
|
||||
$item->unit_price = array_filter($exams, function ($r) use ($itemId) {
|
||||
return $r['id'] == $itemId;
|
||||
})[0]['unit_price'];
|
||||
|
||||
$item->unit_price = $exams[$itemIndex]['unit_price'];
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue