invoice create issue : GWM
This commit is contained in:
parent
5df47b9908
commit
6f9422f08c
@ -116,7 +116,7 @@ class InvoiceController extends ResourceController
|
||||
if (!$invoiceId) {
|
||||
|
||||
// Generate invoice number only for CREATE
|
||||
$invoiceData['invoice_no'] = $this->generateInvoiceNo();
|
||||
$invoiceData['invoice_no'] = $this->generateInvoiceNo($input['pos_id']);
|
||||
|
||||
$invoiceData['created_at'] = date('Y-m-d H:i:s');
|
||||
$invoiceData['created_by'] = $input['created_by'] ?? 0;
|
||||
@ -184,15 +184,16 @@ class InvoiceController extends ResourceController
|
||||
}
|
||||
}
|
||||
|
||||
private function generateInvoiceNo()
|
||||
private function generateInvoiceNo($pos_id)
|
||||
{
|
||||
$year = date('Y');
|
||||
$prefix = "INV/$year/";
|
||||
$prefix = "NIIB/$pos_id/$year/";
|
||||
|
||||
// Get last invoice of current year
|
||||
$lastInvoice = $this->InvoiceModel
|
||||
->select('invoice_no')
|
||||
->like('invoice_no', $prefix, 'after')
|
||||
->where('pos_id',$pos_id)
|
||||
->orderBy('id', 'DESC')
|
||||
->first();
|
||||
|
||||
@ -245,7 +246,7 @@ class InvoiceController extends ResourceController
|
||||
|
||||
// Build the main query
|
||||
$query = $this->PolicyModel
|
||||
->select('partner_policy.policy_number as policy_no, partner_policy.id as policy_id, partner_policy.issued_date, partner_policy.commission_amount, partner_policy.insured_name as customer_name, pe.agent_id, partner_policy.premium_amount, pi.id as invoice_id, pi.invoice_no')
|
||||
->select('partner_policy.policy_number as policy_no, partner_policy.id as policy_id, partner_policy.issued_date, partner_policy.commission_amount, partner_policy.insured_name as customer_name, pe.agent_id ,pa.name as agent_name, partner_policy.premium_amount, pi.id as invoice_id, pi.invoice_no')
|
||||
->join(
|
||||
'partner_enquiry pe',
|
||||
'pe.id = partner_policy.enquiry_id AND pe.broker_id = ' . (int)$input['broker_id'],
|
||||
@ -254,6 +255,7 @@ class InvoiceController extends ResourceController
|
||||
->join('partner_quotation pq', 'pq.id = partner_policy.quotation_id', 'left')
|
||||
->join('partner_invoice_items pii', 'pii.policy_id = partner_policy.id', 'left')
|
||||
->join('partner_invoice pi', 'pi.id = pii.invoice_id AND pi.is_active = 1', 'left')
|
||||
->join('partner_agent pa', 'pa.id = pe.agent_id', 'left')
|
||||
->where('partner_policy.is_active', 1)
|
||||
->where('partner_policy.commission_amount > 0')
|
||||
->where('partner_policy.is_data_accuracy_checked', 1);
|
||||
|
||||
@ -813,14 +813,12 @@ class PolicyController extends ResourceController
|
||||
|
||||
log_message('info', "Extracted and decoded final JSON data successfully.");
|
||||
|
||||
if($return == true)
|
||||
{
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $final_data ], 200);
|
||||
}else
|
||||
if($return == true)
|
||||
{
|
||||
return $this->respond(['status'=>"success", 'message'=> "Doc read sucess" , 'data'=>$final_data], 200);
|
||||
}else{
|
||||
return ['status'=>"success", 'message'=> "Doc read sucess" , 'data'=>$final_data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
@ -999,7 +997,69 @@ class PolicyController extends ResourceController
|
||||
|
||||
if($type == 'commission')
|
||||
{
|
||||
return $this->calculateCommission($policyId , true);
|
||||
$readDoc = $this->calculateCommission($policyId , false);
|
||||
if($readDoc['status'] == 'success')
|
||||
{
|
||||
|
||||
$data = $readDoc['data'];
|
||||
|
||||
$vehicleType = $data['vehicle']['vehicle_type'] ?? null;
|
||||
$fuelType = $data['vehicle']['fuel_type'] ?? null;
|
||||
if($vehicleType !== null)
|
||||
{
|
||||
$vehicleType = $this->postProcessGeminiData($vehicleType,$this->tier1VehicleTypeMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
$vehicleType = 'UN_IDEN_DOC';
|
||||
}
|
||||
if($fuelType !== null)
|
||||
{
|
||||
$fuelType = $this->postProcessGeminiData($fuelType,$this->fuelType);
|
||||
}
|
||||
else
|
||||
{
|
||||
$fuelType = 'UN_IDEN_DOC';
|
||||
}
|
||||
|
||||
//update data in to policy table
|
||||
$policyData['policy_number'] = $data['policy']['policy_number'] ?? null;
|
||||
$policyData['issued_date'] = $data['policy']['issue_date'] ?? null;
|
||||
$policyData['start_date'] = $data['policy']['period']['start'] ?? null;
|
||||
$policyData['end_date'] = $data['policy']['period']['end'] ?? null;
|
||||
$policyData['broker_name'] = $data['policy']['intermediary_name'] ?? null;
|
||||
$policyData['tp'] = $data['premium']['tp'] ?? null;
|
||||
$policyData['od'] = $data['premium']['od'] ?? null;
|
||||
$policyData['pa'] = $data['premium']['pa'] ?? null;
|
||||
$policyData['cgst'] = $data['premium']['taxes']['cgst'] ?? 0;
|
||||
$policyData['sgst'] = $data['premium']['taxes']['sgst'] ?? 0;
|
||||
$policyData['igst'] = $data['premium']['taxes']['igst'] ?? 0;
|
||||
$policyData['premium_amount'] = $data['premium']['total'] ?? null;
|
||||
$policyData['rto_state_code'] = $data['vehicle']['rto_state_code'] ?? null;
|
||||
$policyData['rto_city_code'] = $data['vehicle']['rto_city_code'] ?? null;
|
||||
$policyData['weight'] = $data['vehicle']['weight'] ?? null;
|
||||
$policyData['fuel_type'] = $fuelType;
|
||||
$policyData['date_of_registration'] = $data['vehicle']['date_of_registration'] ?? null;
|
||||
$policyData['year_of_manufacture'] = $data['vehicle']['year_of_manufacture'] ?? null;
|
||||
$policyData['engine_no'] = $data['vehicle']['engine_no'] ?? null;
|
||||
$policyData['chassis_no'] = $data['vehicle']['chassis_no'] ?? null;
|
||||
$policyData['make'] = $data['vehicle']['make'] ?? null;
|
||||
$policyData['model'] = $data['vehicle']['model'] ?? null;
|
||||
$policyData['cubic_capacity'] = $data['vehicle']['cubic_capacity'] ?? null;
|
||||
$policyData['vehicle_type'] = $vehicleType;
|
||||
$policyData['rc_no'] = $data['vehicle']['reg_no'] ?? null;
|
||||
$policyData['insured_name'] = $data['insured']['name'] ?? null;
|
||||
|
||||
log_message('debug', 'Policy Update Payload: ' . json_encode($policyData));
|
||||
|
||||
$updateStatus = $this->PolicyModel->update($policyId,$policyData);
|
||||
|
||||
} else {
|
||||
log_message('error', 'checkPolicyDoc returned failure: ' . json_encode($readDoc));
|
||||
}
|
||||
|
||||
return $this->respond(['status'=>$readDoc['status'], 'data'=> $readDoc ], 200);
|
||||
|
||||
|
||||
}else if($type == 'read')
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user