debug accident controller
This commit is contained in:
@@ -80,11 +80,8 @@ class AccidentReceiptController extends Controller
|
|||||||
'accident_type_fa' => DailyAccidentSettings::query()->where('type', 'accident_type')->where('name', $request->accident_type)->first()->value,
|
'accident_type_fa' => DailyAccidentSettings::query()->where('type', 'accident_type')->where('name', $request->accident_type)->first()->value,
|
||||||
'way_id' => $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng),
|
'way_id' => $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng),
|
||||||
'report_base' => $request->report_base,
|
'report_base' => $request->report_base,
|
||||||
'police_file' => $request->report_base ? null : FileFacade::save($request->file('police_file'), 'receipts_files/'),
|
|
||||||
'police_serial' => $request->police_serial ?? null,
|
'police_serial' => $request->police_serial ?? null,
|
||||||
'police_file_date' => $request->police_file_date ?? null,
|
'police_file_date' => $request->police_file_date ?? null,
|
||||||
'damage_picture1' => FileFacade::save($request->file('damage_picture1'), 'receipts_files/'),
|
|
||||||
'damage_picture2' => FileFacade::save($request->file('damage_picture2'), 'receipts_files/'),
|
|
||||||
'status' => AccidentStates::BEDON_EGHDAM->value,
|
'status' => AccidentStates::BEDON_EGHDAM->value,
|
||||||
'status_fa' => AccidentStates::name(AccidentStates::BEDON_EGHDAM->value),
|
'status_fa' => AccidentStates::name(AccidentStates::BEDON_EGHDAM->value),
|
||||||
];
|
];
|
||||||
@@ -109,6 +106,10 @@ class AccidentReceiptController extends Controller
|
|||||||
$accidentData['sum'] = $sum;
|
$accidentData['sum'] = $sum;
|
||||||
|
|
||||||
$accident = Accident::query()->create($accidentData);
|
$accident = Accident::query()->create($accidentData);
|
||||||
|
$accident->damage_picture1 = FileFacade::save($request->file('damage_picture1'), "receipts_files/{$accident->id}");
|
||||||
|
$accident->damage_picture2 = FileFacade::save($request->file('damage_picture2'), "receipts_files/{$accident->id}");
|
||||||
|
$accident->police_file = $request->report_base ? null : FileFacade::save($request->file('police_file'), "receipts_files/{$accident->id}");
|
||||||
|
$accident->save();
|
||||||
|
|
||||||
$accident->damages()->attach($damageData);
|
$accident->damages()->attach($damageData);
|
||||||
|
|
||||||
@@ -207,10 +208,9 @@ class AccidentReceiptController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(Accident $accident): JsonResponse
|
public function destroy(Accident $accident): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
throw_if($accident->status != AccidentStates::BEDON_EGHDAM->value, new ProhibitedAction('قابلیت حذف در این مرحله وجود ندارد'));
|
throw_if($accident->status != AccidentStates::BEDON_EGHDAM->value, new ProhibitedAction('قابلیت حذف در این مرحله وجود ندارد'));
|
||||||
|
|
||||||
FileFacade::deleteDirectory('receipts_files/' . $accident->id);
|
FileFacade::deleteDirectory("receipts_files/{$accident->id}");
|
||||||
|
|
||||||
DB::transaction(function () use ($accident) {
|
DB::transaction(function () use ($accident) {
|
||||||
|
|
||||||
@@ -262,13 +262,14 @@ class AccidentReceiptController extends Controller
|
|||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
public function submitInvoice(Accident $accident, PaymentService $paymentService): JsonResponse
|
public function submitInvoice(Accident $accident, PaymentService $paymentService): JsonResponse
|
||||||
{
|
{
|
||||||
$final_amount = $accident->sum - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount);
|
$final_amount = $accident->sum - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount);
|
||||||
|
|
||||||
if ($final_amount < 0) {
|
throw_if($final_amount < 0, new ProhibitedAction('مبالغ داغی و بیمه از مبلغ کل بیشتر می باشد.'));
|
||||||
return $this->errorResponse('error');
|
|
||||||
}
|
|
||||||
|
|
||||||
$bill_code = $paymentService->invoiceBillApi($accident->driver_national_code, $final_amount);
|
$bill_code = $paymentService->invoiceBillApi($accident->driver_national_code, $final_amount);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user