@extends('layouts.admin') @section('title', 'Commission Settings') @php $currencySymbol = App\Models\AppSetting::getValue('currency_symbol', '?'); $currencyDecimals = App\Models\AppSetting::currencyDecimals(); $restaurantSetting = $settings->where('type', 'restaurant')->first(); $driverSetting = $settings->where('type', 'driver')->first(); $posSetting = $settings->where('type', 'pos')->first(); $gstOnCommissionRate = (float) App\Models\AppSetting::getValue('gst_rate'); $gatewayFeeRate = (float) App\Models\AppSetting::getValue('gateway_fee_rate', 2); $commissionLabels = [ 'restaurant' => 'Store Earning Commission', 'driver' => 'Driver Earning Commission', 'pos' => 'POS Commission', ]; $formatCommission = fn ($setting, $fallback) => ($setting?->calculation_type ?? 'percentage') === 'fixed' ? $currencySymbol . number_format((float) ($setting?->rate ?? $fallback), $currencyDecimals) : number_format((float) ($setting?->rate ?? $fallback), 2) . '%'; $commissionAmount = fn ($setting, $base, $fallback) => min($base, ($setting?->calculation_type ?? 'percentage') === 'fixed' ? (float) ($setting?->rate ?? $fallback) : $base * ((float) ($setting?->rate ?? $fallback) / 100)); $sampleSubtotal = 500; $sampleRestaurantCommission = $commissionAmount($restaurantSetting, $sampleSubtotal, 15); $sampleGst = $sampleRestaurantCommission * ($gstOnCommissionRate / 100); $sampleDeliveryFee = 40; $samplePlatformFee = App\Models\DeliveryChargeSetting::getPlatformFee(); $sampleCustomerTax = App\Models\TaxSetting::calculateTax($sampleSubtotal, $sampleDeliveryFee); $sampleCustomerTotal = $sampleSubtotal + $sampleDeliveryFee + $samplePlatformFee + $sampleCustomerTax; $sampleGatewayFee = $sampleCustomerTotal * ($gatewayFeeRate / 100); $sampleRestaurantPayout = $sampleSubtotal - $sampleRestaurantCommission - $sampleGst - $sampleGatewayFee; $sampleDriverCommission = $commissionAmount($driverSetting, $sampleDeliveryFee, 5); @endphp @section('content')
Configure platform commission rates
| Type | Value | Calculation Type | Last Updated | Status |
|---|---|---|---|---|
| {{ $commissionLabels[$setting->type] ?? ucfirst(str_replace('_', ' ', $setting->type)) }} | {{ $formatCommission($setting, 0) }} | {{ ucfirst($setting->calculation_type) }} | {{ $setting->updated_at->format('d M Y, h:i A') }} | {{ $setting->is_active ? 'Active' : 'Inactive' }} |