CHNAGE_COMMISSION_FILE_FORMAT
This commit is contained in:
parent
d3e155819d
commit
d359327c3e
@ -63,6 +63,19 @@ class RuleImportController extends AdminController
|
||||
|
||||
public function commissionFileUploadList()
|
||||
{
|
||||
|
||||
// print_rr($this->ruleImportService->processUpload([
|
||||
// 'id' => 60,
|
||||
// 'file_name' => 'Sample_commission_file-New.xlsx',
|
||||
// 'insurer_id' => 77,
|
||||
// 'department' => 'motor',
|
||||
// 'commission_month' => '2025-11-10',
|
||||
// 'created_by' => 10
|
||||
// ]));
|
||||
// die();
|
||||
|
||||
|
||||
|
||||
$data['page_name'] = "Commision File Upload";
|
||||
$data['departments'] = $this->departments;
|
||||
$data['insurers'] = $this->insurerModel->where('is_active', 1)->findAll();
|
||||
|
||||
@ -10,11 +10,19 @@ class CommissionApiFilter implements FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
return null;
|
||||
// return null;
|
||||
// Read API key from header
|
||||
// $authHeader = $request->getHeaderLine('X');
|
||||
$authHeader = $request->getHeaderLine('AUTHORIZATION');
|
||||
if(empty($authHeader))
|
||||
{
|
||||
$authHeader = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
|
||||
// echo $authHeader;die();
|
||||
}
|
||||
|
||||
// $requestHeaders = getallheaders();
|
||||
// // $authHeader = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
|
||||
// // $authHeader = $_SERVER['Authorization'];
|
||||
// print_r($authHeader);
|
||||
// print_r($_SERVER);die();
|
||||
if (empty($authHeader)) {
|
||||
return service('response')->setJSON([
|
||||
'success' => false,
|
||||
|
||||
@ -36,6 +36,7 @@ class RuleImportService
|
||||
];
|
||||
|
||||
// Column name constants
|
||||
private const COL_SNO = 'S.No';
|
||||
private const COL_RULE_NAME = 'Rule Name';
|
||||
private const COL_POLICY_BUSINESS_TYPE = 'Policy Business Type';
|
||||
private const COL_POLICY_NAME = 'Policy Name';
|
||||
@ -52,12 +53,17 @@ class RuleImportService
|
||||
private const COL_VEHICLE_WEIGHT_MIN = 'Vehicle Weight Min';
|
||||
private const COL_VEHICLE_WEIGHT_MAX = 'Vehicle Weight Max';
|
||||
private const COL_RTO_STATE = 'RTO State';
|
||||
private const COL_RTO_CITY = 'RTO City';
|
||||
private const COL_RTO_CITY = 'RTO Code';
|
||||
private const COL_RENEWAL_TYPE = 'Renewal Type';
|
||||
private const COL_RENEWAL_SUB_TYPE = 'Renewal Sub Type';
|
||||
private const COL_COMMISSION_TYPE = 'Commission Type';
|
||||
private const COL_COMMISSION_VALUE = 'Commission Value';
|
||||
private const COL_COMMISSION_PARAMS = 'Commission Params(TP:OD:PA)';
|
||||
|
||||
private const COL_COMMISSION_PARAMS_OD = 'Commission Params (OD)';
|
||||
private const COL_COMMISSION_PARAMS_PA = 'Commission Params (PA)';
|
||||
private const COL_COMMISSION_PARAMS_TP = 'Commission Params (TP)';
|
||||
|
||||
private const COL_NOTES = 'Notes';
|
||||
|
||||
protected array $expectedColumns;
|
||||
@ -82,9 +88,10 @@ class RuleImportService
|
||||
private function initializeExpectedColumns(): void
|
||||
{
|
||||
$this->expectedColumns = [
|
||||
self::COL_RULE_NAME,
|
||||
self::COL_POLICY_BUSINESS_TYPE,
|
||||
self::COL_POLICY_NAME,
|
||||
// self::COL_RULE_NAME,
|
||||
// self::COL_POLICY_BUSINESS_TYPE,
|
||||
// self::COL_POLICY_NAME,
|
||||
self::COL_SNO,
|
||||
self::COL_PREMIUM_TYPE,
|
||||
self::COL_VEHICLE_TYPE,
|
||||
self::COL_VEHICLE_SUB_TYPE,
|
||||
@ -100,11 +107,13 @@ class RuleImportService
|
||||
self::COL_RTO_STATE,
|
||||
self::COL_RTO_CITY,
|
||||
self::COL_RENEWAL_TYPE,
|
||||
self::COL_RENEWAL_SUB_TYPE,
|
||||
// self::COL_RENEWAL_SUB_TYPE,
|
||||
self::COL_COMMISSION_TYPE,
|
||||
self::COL_COMMISSION_VALUE,
|
||||
self::COL_COMMISSION_PARAMS,
|
||||
self::COL_NOTES
|
||||
self::COL_COMMISSION_PARAMS_TP,
|
||||
self::COL_COMMISSION_PARAMS_OD,
|
||||
self::COL_COMMISSION_PARAMS_PA,
|
||||
// self::COL_NOTES
|
||||
];
|
||||
}
|
||||
|
||||
@ -123,7 +132,7 @@ class RuleImportService
|
||||
self::COL_FUEL_TYPE => 'validateCommaList',
|
||||
self::COL_COMMISSION_TYPE => 'validateCommissionType',
|
||||
self::COL_COMMISSION_VALUE => 'validateNumeric',
|
||||
self::COL_COMMISSION_PARAMS => 'validateCompositeParams',
|
||||
// self::COL_COMMISSION_PARAMS => 'validateCompositeParams',
|
||||
];
|
||||
}
|
||||
|
||||
@ -402,13 +411,16 @@ class RuleImportService
|
||||
{
|
||||
$commissionType = strtolower($rowData[self::COL_COMMISSION_TYPE] ?? '');
|
||||
$commissionValue = $rowData[self::COL_COMMISSION_VALUE] ?? '';
|
||||
$commissionParams = $rowData[self::COL_COMMISSION_PARAMS] ?? '';
|
||||
// $commissionParams = $rowData[self::COL_COMMISSION_PARAMS] ?? '';
|
||||
$commissionParams_od = $rowData[self::COL_COMMISSION_PARAMS_OD] ?? '';
|
||||
$commissionParams_pa = $rowData[self::COL_COMMISSION_PARAMS_PA] ?? '';
|
||||
$commissionParams_tp = $rowData[self::COL_COMMISSION_PARAMS_TP] ?? '';
|
||||
|
||||
// Composite commission requires params
|
||||
if ($commissionType === self::COMMISSION_COMPOSITE && empty($commissionParams)) {
|
||||
if ($commissionType === self::COMMISSION_COMPOSITE && empty($commissionParams_od) && empty($commissionParams_pa) && empty($commissionParams_tp)) {
|
||||
$this->validationResult->addError(
|
||||
$rowNum,
|
||||
self::COL_COMMISSION_PARAMS,
|
||||
self::COL_COMMISSION_PARAMS_OD,
|
||||
"Required when commission type is composite"
|
||||
);
|
||||
}
|
||||
@ -1255,10 +1267,14 @@ class RuleImportService
|
||||
$commissionType = strtolower(trim($rowData[self::COL_COMMISSION_TYPE] ?? ''));
|
||||
$commissionValue = $rowData[self::COL_COMMISSION_VALUE] ?? '';
|
||||
$commissionParams = $rowData[self::COL_COMMISSION_PARAMS] ?? '';
|
||||
$commissionParams_od = $rowData[self::COL_COMMISSION_PARAMS_OD] ?? '';
|
||||
$commissionParams_pa = $rowData[self::COL_COMMISSION_PARAMS_PA] ?? '';
|
||||
$commissionParams_tp = $rowData[self::COL_COMMISSION_PARAMS_TP] ?? '';
|
||||
$commission = $commissionParams_tp.':'.$commissionParams_od.':'. $commissionParams_pa;
|
||||
|
||||
switch ($commissionType) {
|
||||
case 'composite':
|
||||
return $this->buildCompositeCalculation($commissionParams);
|
||||
return $this->buildCompositeCalculation($commission);
|
||||
|
||||
case 'percentage':
|
||||
return $this->buildPercentageCalculation($commissionValue);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
Rule Name,Policy Business Type,Policy Name,Premium Type,Vehicle Type,Vehicle Sub Type,Make,Model,CC Min,CC Max,Fuel Type,Vehicle Age Min,Vehicle Age Max,Vehicle Weight Min,Vehicle Weight Max,RTO State,RTO City,Renewal Type,Renewal Sub Type,Commission Type,Commission Value,Commission Params(TP:OD:PA),Notes
|
||||
Motor sample 1,Retail,,,Two Wheeler,,,,100,100,,,,,,,,,,composite,,10:25:0,"id: rule_68bc096e6d7df; conditions: vehicle_type == Two Wheeler; cubic_capcity == 100; calculation: composite 10% on tp_premium, 25% on od_premium"
|
||||
Motor sample 2,Retail,,,Four Wheeler,,,,1000,1000,,5,5,,,,,,,percentage,10,,id: rule_68fb5ad42f3c4; conditions: vehicle_type == Four Wheeler; cubic_capcity >= 1000; vehicle_age <= 5; calculation: 10% on premium
|
||||
Sample 2,Retail,,TP,Four Wheeler,,,,1000,1000,,,,,,,,,,composite,,10:0:0,id: rule_691438a7cb08b; conditions: vehicle_type == Four Wheeler; policy_type == TP; is_new_vehicle == true; cubic_capcity > 1000; calculation: composite 10% on tp_premium
|
||||
Sample 2 test,Retail,,,"Two Wheeler,Four Wheeler",,,,2500,2500,,,,,,,,,,flat,500,,"id: rule_6916ad2837807; conditions: vehicle_type in [Two Wheeler, Four Wheeler]; cubic_capcity == 2500; calculation: fixed 500 on premium"
|
||||
S.No,Premium Type,Vehicle Type,Vehicle Sub Type,Make,Model,CC Min,CC Max,Fuel Type,Vehicle Age Min,Vehicle Age Max,Vehicle Weight Min,Vehicle Weight Max,RTO State,RTO Code,Renewal Type,Commission Type,Commission Value,Commission Params (TP),Commission Params (OD),Commission Params (PA)
|
||||
1,OD,Car,Honda i10,Honda,2014,1000,3000,Petrol,5,10,2000,3000,RJ,41,Online,percentage,15,,,
|
||||
2,TP,Two Wheeler,Passion Pro,Hero,2019,100,150,Petrol,1,5,100,150,RJ,57,Cash,composite,,18,10,
|
||||
3,COM,PCV,Toyota,Toyota,2020,2000,8000,Diesel,5,20,3000,5000,GJ,33,Card,percentage,25,,,
|
||||
4,COM,GCV,Tata,Tata,2023,2000,8000,Diesel,5,20,5000,10000,PB,19,Cash,composite,,,10,
|
||||
|
||||
|
5
public/sample_excel/sample_commission_old.csv
Normal file
5
public/sample_excel/sample_commission_old.csv
Normal file
@ -0,0 +1,5 @@
|
||||
Rule Name,Policy Business Type,Policy Name,Premium Type,Vehicle Type,Vehicle Sub Type,Make,Model,CC Min,CC Max,Fuel Type,Vehicle Age Min,Vehicle Age Max,Vehicle Weight Min,Vehicle Weight Max,RTO State,RTO City,Renewal Type,Renewal Sub Type,Commission Type,Commission Value,Commission Params(TP:OD:PA),Notes
|
||||
Motor sample 1,Retail,,,Two Wheeler,,,,100,100,,,,,,,,,,composite,,10:25:0,"id: rule_68bc096e6d7df; conditions: vehicle_type == Two Wheeler; cubic_capcity == 100; calculation: composite 10% on tp_premium, 25% on od_premium"
|
||||
Motor sample 2,Retail,,,Four Wheeler,,,,1000,1000,,5,5,,,,,,,percentage,10,,id: rule_68fb5ad42f3c4; conditions: vehicle_type == Four Wheeler; cubic_capcity >= 1000; vehicle_age <= 5; calculation: 10% on premium
|
||||
Sample 2,Retail,,TP,Four Wheeler,,,,1000,1000,,,,,,,,,,composite,,10:0:0,id: rule_691438a7cb08b; conditions: vehicle_type == Four Wheeler; policy_type == TP; is_new_vehicle == true; cubic_capcity > 1000; calculation: composite 10% on tp_premium
|
||||
Sample 2 test,Retail,,,"Two Wheeler,Four Wheeler",,,,2500,2500,,,,,,,,,,flat,500,,"id: rule_6916ad2837807; conditions: vehicle_type in [Two Wheeler, Four Wheeler]; cubic_capcity == 2500; calculation: fixed 500 on premium"
|
||||
|
Loading…
Reference in New Issue
Block a user