diff --git a/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php b/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php index 37517385..ab5034ab 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Country/AccessRoadReport.php @@ -43,7 +43,7 @@ class AccessRoadReport implements FromView, WithEvents, ShouldAutoSize, WithDraw } } - return view('v3.Reports.SafetyAndPrivacy.Country.AccessRoadReport', [ + return view('v3.Reports.SafetyAndPrivacy.Country.AccessRoadActivityReport', [ 'data' => $data, ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php b/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php index 3e64d0c8..52f57616 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Country/ConstructionReport.php @@ -44,7 +44,7 @@ class ConstructionReport implements FromView, WithEvents, ShouldAutoSize, WithDr } } - return view('v3.Reports.SafetyAndPrivacy.Country.ConstructionReport', [ + return view('v3.Reports.SafetyAndPrivacy.Country.ConstructionActivityReport', [ 'data' => $data, ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php b/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php index e44b14ac..1221ca07 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Country/UtilityPassingReport.php @@ -44,7 +44,7 @@ class UtilityPassingReport implements FromView, WithEvents, ShouldAutoSize, With } } - return view('v3.Reports.SafetyAndPrivacy.Country.UtilityPassingReport', [ + return view('v3.Reports.SafetyAndPrivacy.Country.UtilityPassingActivityReport', [ 'data' => $data, ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php b/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php index bc80b3a4..053de9b4 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Province/AccessRoadReport.php @@ -43,7 +43,7 @@ class AccessRoadReport implements FromView, WithEvents, ShouldAutoSize, WithDraw } } - return view('v3.Reports.SafetyAndPrivacy.Province.AccessRoadReport', [ + return view('v3.Reports.SafetyAndPrivacy.Province.AccessRoadActivityReport', [ 'data' => $data, ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php b/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php index e6492019..07e2d138 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Province/ConstructionReport.php @@ -43,7 +43,7 @@ class ConstructionReport implements FromView, WithEvents, ShouldAutoSize, WithDr } } - return view('v3.Reports.SafetyAndPrivacy.Province.ConstructionReport', [ + return view('v3.Reports.SafetyAndPrivacy.Province.ConstructionActivityReport', [ 'data' => $data, ]); } diff --git a/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php b/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php index d0f5f6a4..5c67b160 100644 --- a/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php +++ b/app/Exports/V3/SafetyAndPrivacy/Province/UtilityPassingReport.php @@ -43,7 +43,7 @@ class UtilityPassingReport implements FromView, WithEvents, ShouldAutoSize, With } } - return view('v3.Reports.SafetyAndPrivacy.Province.UtilityPassingReport', [ + return view('v3.Reports.SafetyAndPrivacy.Province.UtilityPassingActivityReport', [ 'data' => $data, ]); } diff --git a/app/Http/Controllers/HomeContentController.php b/app/Http/Controllers/HomeContentController.php index 9df4af59..a42efa07 100644 --- a/app/Http/Controllers/HomeContentController.php +++ b/app/Http/Controllers/HomeContentController.php @@ -64,7 +64,10 @@ class HomeContentController extends Controller public function getAllCitiesByProvince($id) { - $cities = \App\Models\City::where('province_id', $id)->where('type_id', 1)->get(); + $cities = \App\Models\City::query() + ->where('province_id', $id) + ->where('type_id', 1) + ->get(['id', 'name_fa', 'province_id','center_lat','center_lng']); // $cities = \App\Models\City::where('province_id', $id)->get(); return response()->json([ diff --git a/app/Http/Controllers/V3/Dashboard/Accident/AccidentReceiptController.php b/app/Http/Controllers/V3/Dashboard/Accident/AccidentReceiptController.php index f4a5900b..179c426b 100644 --- a/app/Http/Controllers/V3/Dashboard/Accident/AccidentReceiptController.php +++ b/app/Http/Controllers/V3/Dashboard/Accident/AccidentReceiptController.php @@ -23,9 +23,11 @@ use App\Services\PaymentService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; +use Illuminate\Validation\ValidationException; use Maatwebsite\Excel\Facades\Excel; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Throwable; +use function Laravel\Prompts\error; class AccidentReceiptController extends Controller { @@ -86,7 +88,7 @@ class AccidentReceiptController extends Controller 'status_fa' => AccidentStates::name(AccidentStates::BEDON_EGHDAM->value), ]; - $sum = 0; + $driver_share_amount = 0; $damageData = []; foreach ($request->damage_items as $key => $item) { @@ -96,14 +98,14 @@ class AccidentReceiptController extends Controller 'unit' => $damage->unit, 'amount' => $item['amount'], ]; - $sum += $item['amount']; + $driver_share_amount += $item['amount']; } - $ojrate_nasb = $sum/100*20; - $sum += $ojrate_nasb; + $ojrate_nasb = $driver_share_amount/100*20; + $driver_share_amount += $ojrate_nasb; $accidentData['ojrate_nasb'] = $ojrate_nasb; - $accidentData['sum'] = $sum; + $accidentData['driver_share_amount'] = $driver_share_amount; $accident = Accident::query()->create($accidentData); $accident->damage_picture1 = FileFacade::save($request->file('damage_picture1'), "receipts_files/{$accident->id}"); @@ -174,7 +176,7 @@ class AccidentReceiptController extends Controller $accidentData['damage_picture2'] = FileFacade::save($request->file('damage_picture2'), "receipts_files/{$accident->id}/"); } - $sum = 0; + $driver_share_amount = 0; $damageData = []; foreach ($request->damage_items as $key => $item) { @@ -184,14 +186,14 @@ class AccidentReceiptController extends Controller 'unit' => $damage->unit, 'amount' => $item['amount'], ]; - $sum += $item['amount']; + $driver_share_amount += $item['amount']; } - $ojrate_nasb = $sum/100*20; - $sum += $ojrate_nasb; + $ojrate_nasb = $driver_share_amount/100*20; + $driver_share_amount += $ojrate_nasb; $accidentData['ojrate_nasb'] = $ojrate_nasb; - $accidentData['sum'] = $sum; + $accidentData['driver_share_amount'] = $driver_share_amount; $accident->update($accidentData); @@ -246,14 +248,28 @@ class AccidentReceiptController extends Controller public function confirmPaymentInfo(ConfirmPaymentInfoRequest $request, Accident $accident): JsonResponse { DB::transaction(function () use ($request, $accident) { + $final_amount = $accident->driver_share_amount - ($request->deposit_insurance_amount + $request->deposit_daghi_amount); + if ($final_amount > 0) { + $status = AccidentStates::SABT_FISH->value; + $status_fa = AccidentStates::name($status); + } + elseif ($final_amount == 0) { + $status = AccidentStates::PARDAKHT_FACTOR->value; + $status_fa = AccidentStates::name($status); + } + else{ + throw ValidationException::withMessages([ + 'amounts' => 'مبالغ داغی و بیمه از مبلغ سهم راننده بیشتر است.', + ]); + } $accident->update([ 'deposit_insurance_image' => $request->has('deposit_insurance_image') ? FileFacade::save($request->deposit_insurance_image, "receipts_files/{$accident->id}/deposit_insurance") : null, 'deposit_insurance_amount' => $request->deposit_insurance_amount ?? 0, 'deposit_daghi_image' => $request->has('deposit_daghi_image') ? FileFacade::save($request->deposit_daghi_image, "receipts_files/{$accident->id}/deposit_daghi") : null, 'deposit_daghi_amount' => $request->deposit_daghi_amount ?? 0, - 'status' => AccidentStates::SABT_FISH->value, - 'status_fa' => AccidentStates::name(AccidentStates::SABT_FISH->value), + 'status' => $status, + 'status_fa' => $status_fa, ]); auth()->user()->addActivityComplete(1132); @@ -267,7 +283,7 @@ class AccidentReceiptController extends Controller */ public function submitInvoice(Accident $accident, PaymentService $paymentService): JsonResponse { - $final_amount = $accident->sum - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount); + $final_amount = $accident->driver_share_amount - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount); throw_if($final_amount < 0, new ProhibitedAction('مبالغ داغی و بیمه از مبلغ کل بیشتر می باشد.')); diff --git a/database/migrations/2025_08_30_110027_add_paid_driver_to_accidents_table.php b/database/migrations/2025_08_30_110027_add_paid_driver_to_accidents_table.php new file mode 100644 index 00000000..cb903027 --- /dev/null +++ b/database/migrations/2025_08_30_110027_add_paid_driver_to_accidents_table.php @@ -0,0 +1,30 @@ +unsignedBigInteger('driver_share_amount')->nullable(); + $table->unsignedBigInteger('driver_rate')->nullable(); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('accidents', function (Blueprint $table) { + $table->dropColumn('driver_share_amount', 'driver_rate'); + }); + } +};