CHNAGE_BDS_STMT_UPLOAD&OUTSTANDING
This commit is contained in:
parent
9feff96826
commit
928bc61171
@ -362,6 +362,8 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1");
|
||||
$routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement");
|
||||
$routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1");
|
||||
$routes->get("getInsurerStatementMonth", "PolicyTransactionController::getInsurerStatementMonth");
|
||||
$routes->get("deleteStatement/(:any)", "PolicyTransactionController::deleteStatement/$1");
|
||||
});
|
||||
|
||||
});
|
||||
@ -375,6 +377,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
||||
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
|
||||
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
|
||||
|
||||
});
|
||||
|
||||
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
@ -1328,7 +1328,7 @@ class EmployeeServiceController extends AdminController
|
||||
// }
|
||||
// dd($row[4]);
|
||||
//for emp table
|
||||
$this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
|
||||
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
|
||||
// dd( $this->empEndorsementModel->getLastQuery());
|
||||
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']);
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ use App\Models\InsurerStatements;
|
||||
use App\Models\InvPaymentDetailsModel;
|
||||
use App\Models\BatchFileModel;
|
||||
use App\Models\FileModel;
|
||||
use App\Models\COShareStmtDetailsModel;
|
||||
use Kint;
|
||||
|
||||
class PolicyTransactionController extends BaseController
|
||||
@ -62,6 +63,7 @@ class PolicyTransactionController extends BaseController
|
||||
protected $invPaymentDetailsModel;
|
||||
protected $batchFileModel;
|
||||
protected $filesModel;
|
||||
protected $coShareStmtDetailsModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -91,11 +93,12 @@ class PolicyTransactionController extends BaseController
|
||||
$this->invPaymentDetailsModel = new InvPaymentDetailsModel();
|
||||
$this->batchFileModel = new BatchFileModel();
|
||||
$this->filesModel = new FileModel();
|
||||
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
|
||||
$this->invoiceStatus = [
|
||||
'pending' => 'Pending',
|
||||
'generated' => 'Generated',
|
||||
'sent' => 'Sent',
|
||||
'payment_received' => 'Payment Received',
|
||||
'payment_received' => 'Payment<br> Received',
|
||||
];
|
||||
}
|
||||
|
||||
@ -1531,20 +1534,17 @@ class PolicyTransactionController extends BaseController
|
||||
$end_date = $this->request->getGet('end_date');
|
||||
$client_id = $this->request->getGet('client_id');
|
||||
$insurer_id = $this->request->getGet('insurer_id');
|
||||
$policy_type_id = $this->request->getGet('policy_type_id');
|
||||
$date_type = $this->request->getGet('date_type');
|
||||
$issuer = $this->request->getGet('issuer');
|
||||
$insurer_branch_id = $this->request->getGet('insurer_branch_id');
|
||||
|
||||
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
|
||||
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
|
||||
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : change_date_format($start_date,'d-m-Y','Y-m-01');
|
||||
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : change_date_format($end_date,'d-m-Y','Y-m-31');
|
||||
// dd([$start_date,$end_date]);
|
||||
|
||||
$client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
|
||||
$insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
|
||||
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
|
||||
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
|
||||
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
|
||||
$insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id;
|
||||
|
||||
|
||||
$data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer);
|
||||
$data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date,$insurer_id, $insurer_branch_id);
|
||||
// dd($this->policyTransactionModel->getLastQuery());
|
||||
// dd($data);
|
||||
$this->loadLayout('outstanding_report_list', $data);
|
||||
@ -1556,7 +1556,7 @@ class PolicyTransactionController extends BaseController
|
||||
//insurer statement list page
|
||||
public function statementList()
|
||||
{
|
||||
// dd($this->validateInsurerStatement(['file_id' => 30]));
|
||||
// dd($this->updateInsurerStatement(['file_id' => 59]));
|
||||
// $data['insurers'] = $this->insurerModel->where('is_active',1)->findAll();
|
||||
$today = date('Y-m-d');
|
||||
$fromday = $from_date = date('Y-m-d', strtotime('-60 days', strtotime($today)));
|
||||
@ -1576,7 +1576,7 @@ class PolicyTransactionController extends BaseController
|
||||
WHERE pt_co_share_details.is_active = 1
|
||||
AND pt_co_share_details.statement_id = insurer_statements.id
|
||||
) AS exp_inv_amt,
|
||||
(SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds)
|
||||
(SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds) + SUM(inv_payment_details.gst)
|
||||
FROM inv_payment_details
|
||||
WHERE inv_payment_details.is_active = 1
|
||||
AND inv_payment_details.statement_id = insurer_statements.id
|
||||
@ -1649,9 +1649,10 @@ class PolicyTransactionController extends BaseController
|
||||
$month = $month.'-01';
|
||||
// print_r($month);die;
|
||||
$month = change_date_format($month,'Y-M-d','Y-m-d');
|
||||
$stmt_sno = $this->request->getPost('statement_no');
|
||||
// print_r($month);die;
|
||||
|
||||
$file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID]); //here field policy_id have client_policy_id and not policy id from policy master
|
||||
$file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID,'stmt_sno' => $stmt_sno]); //here field policy_id have client_policy_id and not policy id from policy master
|
||||
$this->myLogger->logme("error", '{file_id} statement uploaded success', ['file_id' => $file_id]);
|
||||
|
||||
//validate file
|
||||
@ -1739,11 +1740,11 @@ class PolicyTransactionController extends BaseController
|
||||
unset($excel_data[0]);
|
||||
// Kint::dump($excel_data);
|
||||
//get no of line items and update in DB
|
||||
$line_items = count($excel_data);
|
||||
$line_items = 0;
|
||||
// get uploaded month transactions data
|
||||
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
|
||||
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
|
||||
// var_dump($source_data);die();
|
||||
// Kint::dump($source_data);//die();
|
||||
// print_rr($this->db->getLastQuery()->getQuery);die();
|
||||
|
||||
|
||||
// check policy no,insurer and etc in DB for this month
|
||||
@ -1765,7 +1766,9 @@ class PolicyTransactionController extends BaseController
|
||||
$source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : "";
|
||||
if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
|
||||
{
|
||||
|
||||
$is_source_found = 1;
|
||||
$line_items = $line_items + 1;
|
||||
unset($source_data[$source_key]);
|
||||
continue 2;
|
||||
}
|
||||
@ -1842,7 +1845,7 @@ class PolicyTransactionController extends BaseController
|
||||
//get no of line items and update in DB
|
||||
$line_items = count($excel_data);
|
||||
// get uploaded month transactions data
|
||||
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
|
||||
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
|
||||
// Kint::dump($source_data);die;
|
||||
// Kint::dump($excel_data);
|
||||
|
||||
@ -1934,7 +1937,7 @@ class PolicyTransactionController extends BaseController
|
||||
//find variance
|
||||
$variance_amt = $source_row['exp_amt'] - $total_amt;
|
||||
|
||||
$data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
|
||||
$data_to_update[] = ['co_share_id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
|
||||
|
||||
unset($source_data[$source_key]);
|
||||
continue 2;
|
||||
@ -1944,7 +1947,7 @@ class PolicyTransactionController extends BaseController
|
||||
}
|
||||
}
|
||||
// dd($data_to_update);
|
||||
$this->PTCOShareDetailsModel->updateBatch($data_to_update, 'id');
|
||||
$this->coShareStmtDetailsModel->insertBatch($data_to_update, 'id');
|
||||
// dd($data_to_update);
|
||||
// if($error_data['error_code'])
|
||||
// {
|
||||
@ -1966,8 +1969,25 @@ class PolicyTransactionController extends BaseController
|
||||
->where('is_active',1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
if(!$inv_details['invoice_value'])
|
||||
{
|
||||
$stmt_level_value = $this->coShareStmtDetailsModel->select('sum(actual_tep_brokerage_amt) + sum(actual_tp_brokerage_amt) + sum(actual_bp_brokerage_amt) + sum(reward) as invoice_value')
|
||||
->where('statement_id',$statement_id)
|
||||
->groupBy('statement_id')
|
||||
->get()
|
||||
->getResultArray();
|
||||
// print_r($stmt_level_value);
|
||||
if($stmt_level_value && count($stmt_level_value) && isset($stmt_level_value[0]))
|
||||
{
|
||||
$inv_details['invoice_value'] = $stmt_level_value[0]['invoice_value'];
|
||||
}
|
||||
}
|
||||
// ~dd($inv_details);
|
||||
$data = [ 'invoice_status' => $inv_details['invoice_status'],
|
||||
'gst_per' => $inv_details['gst_per'],
|
||||
'invoice_value' => $inv_details['invoice_value'],
|
||||
'gst_value' => $inv_details['gst_value'],
|
||||
'invoice_no' => $inv_details['invoice_no'],
|
||||
'invoice_amount' => $inv_details['invoice_amount'],
|
||||
'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'],'Y-m-d','d/m/Y') : null ];
|
||||
@ -1989,6 +2009,9 @@ class PolicyTransactionController extends BaseController
|
||||
$invoiceNo = $jsonData['invoice_no'];
|
||||
$invoiceDate = change_date_format($jsonData['invoice_date'],'d/m/Y','Y-m-d');
|
||||
$invoice_amount = $jsonData['invoice_amount'];
|
||||
$invoice_value = $jsonData['invoice_value'];
|
||||
$gst_per = $jsonData['invoice_gst_per'];
|
||||
$gst_value = $jsonData['invoice_gst'];
|
||||
|
||||
//Update statement table
|
||||
$parentData = [
|
||||
@ -1996,6 +2019,9 @@ class PolicyTransactionController extends BaseController
|
||||
'invoice_no' => $invoiceNo,
|
||||
'invoice_date' => $invoiceDate,
|
||||
'invoice_amount' => $invoice_amount,
|
||||
'gst_per' => $gst_per,
|
||||
'gst_value' => $gst_value,
|
||||
'invoice_value' => $invoice_value,
|
||||
'updated_by' => get_session_userid()
|
||||
];
|
||||
|
||||
@ -2007,6 +2033,7 @@ class PolicyTransactionController extends BaseController
|
||||
$receivedAmounts = $jsonData['received_amount'];
|
||||
$utrNos = $jsonData['utr_no'];
|
||||
$tdsTotal = $jsonData['tds'];
|
||||
$gstTotal = $jsonData['gst_amount'];
|
||||
$paymentDates = $jsonData['payment_date'];
|
||||
$pks = $jsonData['pk'];
|
||||
|
||||
@ -2014,6 +2041,7 @@ class PolicyTransactionController extends BaseController
|
||||
$pk = $pks[$index]; // Get the pk for the current record
|
||||
$utrNo = $utrNos[$index];
|
||||
$tds = $tdsTotal[$index];
|
||||
$gst = $gstTotal[$index];
|
||||
$paymentDate = $paymentDates[$index];
|
||||
|
||||
// Prepare data for insert/update
|
||||
@ -2021,6 +2049,7 @@ class PolicyTransactionController extends BaseController
|
||||
'inv_amt' => $receivedAmount,
|
||||
'utr_no' => $utrNo,
|
||||
'tds' => $tds,
|
||||
'gst' => $gst,
|
||||
'received_date' => change_date_format($paymentDate,'d/m/Y','Y-m-d'),
|
||||
'statement_id' => $hiddenStatementId
|
||||
];
|
||||
@ -2120,5 +2149,45 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getInsurerStatementMonth()
|
||||
{
|
||||
$insurer_id = $this->request->getGet('insurer_id');
|
||||
$month = $this->request->getGet('month');
|
||||
// echo $month;
|
||||
$insurer_branch_id = explode('-',$insurer_id)[1];
|
||||
$insurer_id = explode('-',$insurer_id)[0];
|
||||
$month = $month.'-01';
|
||||
$month = change_date_format($month,'Y-M-d','Y-m-d');
|
||||
// echo $month;
|
||||
|
||||
$res_data = $this->insurerStatements
|
||||
->where('insurer_id',$insurer_id)
|
||||
->where('branch_id',$insurer_branch_id)
|
||||
->where('month', $month)
|
||||
->where('is_active', 1)
|
||||
->where('file_status', 'success')
|
||||
->findAll();
|
||||
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200,'data' => $res_data], 200);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function deleteStatement($id)
|
||||
{
|
||||
// echo $id;die();
|
||||
$this->coShareStmtDetailsModel->where('statement_id',$id)
|
||||
->set(['is_active' => 0])
|
||||
->update();
|
||||
$this->invPaymentDetailsModel->where('statement_id',$id)
|
||||
->set(['is_active' => 0])
|
||||
->update();
|
||||
$this->insurerStatements->where('id',$id)
|
||||
->set(['is_active' => 0])
|
||||
->update();
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200], 200);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
38
app/Models/COShareStmtDetailsModel.php
Normal file
38
app/Models/COShareStmtDetailsModel.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class COShareStmtDetailsModel extends Model
|
||||
{
|
||||
protected $table = 'co_share_stmt_details';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'co_share_id',
|
||||
'statement_id',
|
||||
'actual_bp_amt',
|
||||
'actual_tp_amt',
|
||||
'actual_tep_amt',
|
||||
'actual_bp_per',
|
||||
'actual_tp_per',
|
||||
'actual_tep_per',
|
||||
'actual_bp_brokerage_amt',
|
||||
'actual_tp_brokerage_amt',
|
||||
'actual_tep_brokerage_amt',
|
||||
'reward',
|
||||
'exp_amt',
|
||||
'variance',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -23,7 +23,11 @@ class InsurerStatements extends Model
|
||||
"invoice_no",
|
||||
"invoice_amount",
|
||||
"invoice_date",
|
||||
"updated_by"
|
||||
"updated_by",
|
||||
"stmt_sno",
|
||||
"gst_per",
|
||||
"gst_value",
|
||||
"invoice_value"
|
||||
|
||||
];
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ class InvPaymentDetailsModel extends Model
|
||||
'inv_amt',
|
||||
'utr_no',
|
||||
'tds',
|
||||
'gst',
|
||||
'received_date',
|
||||
'created_by',
|
||||
'is_active',
|
||||
|
||||
@ -66,8 +66,11 @@ class PTCOShareDetailsModel extends Model
|
||||
'statement_id'
|
||||
];
|
||||
|
||||
public function getNonReconcileredPolicyTransactions(string $month,string $year,string $insurer_id,string $insurer_branch_id)
|
||||
public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id)
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
$sixMonthsAgo = date('Y-m-01', strtotime('-6 months'));
|
||||
|
||||
return $this->db->table('pt_co_share_details pt_co')
|
||||
->select('
|
||||
pt_co.id,
|
||||
@ -93,12 +96,15 @@ class PTCOShareDetailsModel extends Model
|
||||
->join('policy_transaction pt', 'pt_co.pt_id = pt.id')
|
||||
->join('clients c', 'pt.client_id = c.id')
|
||||
->where('pt_co.is_active', 1)
|
||||
->where('MONTH(pt.month)', $month)
|
||||
->where('YEAR(pt.month)', $year)
|
||||
->where('pt.is_active', 1)
|
||||
// ->where('MONTH(pt.month)', $month)
|
||||
// ->where('YEAR(pt.month)', $year)
|
||||
->where('pt_co.insurer_id', $insurer_id)
|
||||
->where('pt_co.insurer_branch_id', $insurer_branch_id)
|
||||
->where('pt_co.statement_id is null')
|
||||
// ->where('pt_co.statement_id is null')
|
||||
->where('pt.status','completed')
|
||||
->where('DATE(pt.created_at) >=', $sixMonthsAgo)
|
||||
->where('DATE(pt.created_at) <=', $currentDate)
|
||||
// ->where('pt_co.exp_amt', 0.00)
|
||||
// ->orWhere('pt_co.exp_amt is null')
|
||||
->get()
|
||||
|
||||
@ -694,7 +694,7 @@ class PolicyTransactionModel extends Model
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getOutstandingReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
public function getOutstandingReportList_OLD($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
{
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select("
|
||||
@ -791,5 +791,53 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0,$insurer_branch_id = 0)
|
||||
{
|
||||
$builder = $this->db->table('insurer_statements s')
|
||||
->select('
|
||||
s.id,
|
||||
s.insurer_id,
|
||||
s.branch_id,
|
||||
ins.short_name,
|
||||
ib.branch_name,
|
||||
s.month,
|
||||
s.line_items,
|
||||
s.stmt_sno,
|
||||
s.invoice_status,
|
||||
s.invoice_date,
|
||||
s.invoice_no,
|
||||
s.invoice_amount,
|
||||
COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0) AS total_paid,
|
||||
(s.invoice_amount - COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0)) AS outstanding_amount
|
||||
')
|
||||
->join('inv_payment_details p', 's.id = p.statement_id', 'left')
|
||||
->join('insurers ins', 's.insurer_id = ins.id')
|
||||
->join('insurer_branch ib', 's.branch_id = ib.id')
|
||||
->where('s.is_active', 1)
|
||||
->where('p.is_active', 1)
|
||||
->groupBy('s.id, s.invoice_no, s.invoice_date, s.invoice_amount')
|
||||
->having('outstanding_amount >', 0);
|
||||
// ->get();
|
||||
|
||||
|
||||
// Date range filtering
|
||||
if ($start_date != 0 && $end_date != 0) {
|
||||
|
||||
$builder->where('s.month >=', $start_date)
|
||||
->where('s.month <=', $end_date);
|
||||
}
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('s.insurer_id', $insurer_id);
|
||||
}
|
||||
if ($insurer_branch_id != 0) {
|
||||
$builder->where('s.branch_id', $insurer_branch_id);
|
||||
}
|
||||
|
||||
$builder->orderBy('s.id', 'desc');
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -103,6 +103,10 @@ table.dataTable tbody td {
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.disabled-option {
|
||||
color: gray;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row" id="inception_list">
|
||||
@ -125,6 +129,7 @@ table.dataTable tbody td {
|
||||
<th></th>
|
||||
<th><div class="column-header">Insurer</div></th>
|
||||
<th><div class="column-header">Month</div></th>
|
||||
<th><div class="column-header">Statement<br>sno</div></th>
|
||||
<th><div class="column-header">Filename</div></th>
|
||||
<th><div class="column-header">Line<br>items</div></th>
|
||||
<th><div class="column-header">File<br>status</div></th>
|
||||
@ -140,6 +145,7 @@ table.dataTable tbody td {
|
||||
<td><input type="hidden" class="row-select" data-id="<?= $row['id']; ?>"></td>
|
||||
<td><?php echo $row['short_name'].'-'.$row['branch_code']; ?></td>
|
||||
<td><?php echo change_date_format($row['month'],'Y-m-d','M-Y'); ?></td>
|
||||
<td><?php echo $row['stmt_sno'] ?> </td>
|
||||
<td><?php echo $row['file_name'] ?> </td>
|
||||
<td><?php echo $row['line_items'] ?></td>
|
||||
<td><?php echo $row['file_status'];
|
||||
@ -172,6 +178,9 @@ table.dataTable tbody td {
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-exp-amt="<?= $row['exp_inv_amt'];?>" data-received-amt="<?= $row['received_inv_amt'];?>" onclick="showInvoiceStatusModal(event)">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Invoice status
|
||||
</a>
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>"onclick="deleteStatement(<?= $row['id'];?>)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
@ -218,8 +227,24 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
<div class="form-group col-md-10">
|
||||
<label for="statement_month">Statement month</label>
|
||||
<input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly>
|
||||
<input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly onchange="getStatementNo()">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-10">
|
||||
<label for="statement_no">Statement no</label>
|
||||
<select class="form-control" id="statement_no" name="statement_no" required >
|
||||
<option value="" selected>Select statement no</option>
|
||||
<?php
|
||||
$stmt_no = [1,2,3,4,5,6,7];
|
||||
if (isset($stmt_no) && count($stmt_no)) {
|
||||
foreach ($stmt_no as $key => $value) {
|
||||
echo "<option value=" . $value . ">" . $value . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-10" >
|
||||
<label for="statment">Statement </label> <span><a href="downloadSampleInsurerStatement" id="download_sample_file" style="font-size: small;">Download sample file</a></span>
|
||||
<input type="file" class="form-control" name="statement" required accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
|
||||
@ -255,7 +280,7 @@ table.dataTable tbody td {
|
||||
|
||||
<!-- Invoice status content modal-->
|
||||
<div class="modal fade" id="invoice_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-dialog modal-lg" style="max-width:1000px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="title">Update Invoice Status</h4>
|
||||
@ -286,32 +311,65 @@ table.dataTable tbody td {
|
||||
<label for="addon_policy">Exp Amount</label>
|
||||
<input type="text" class="form-control" id="modal_exp_amt" placeholder="" disabled>
|
||||
</div> -->
|
||||
<div class="form-group col-md-4" id="modal_received_amt_div">
|
||||
<label for="addon_policy">Total Received Amount</label>
|
||||
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Invoice Number and Invoice Date in same row -->
|
||||
<div class="row" id="invoice_no_div_modal" style="display: none;">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
|
||||
<!-- <div id="invoice_no_div_modal" style="display: none;"> -->
|
||||
<div class="row" id="invoice_no_div_modal" style="display: none;">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_date">Invoice Date</label>
|
||||
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_value_modal">Invoice value<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="invoice_value_modal" name="invoice_value" placeholder="Enter Invoice Value" readonly>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required>
|
||||
<div class="row" id="invoice_no_div_modal2" style="display: none;">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gst_value_modal">GST %<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="gst_per_modal" name="invoice_gst_per" placeholder="Enter GST %" required onchange="calcGSTValue()">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gst_value_modal">GST Value<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="gst_value_modal" name="invoice_gst" placeholder="Enter Invoice Value" required readonly step="0.01">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required readonly step="0.01">
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group col-md-3" id="modal_received_amt_div">
|
||||
<label for="addon_policy">Total Received Amount</label>
|
||||
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_date">Invoice Date</label>
|
||||
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="modal_received_amt_div">
|
||||
<div class="form-group col-md-4" >
|
||||
<label for="addon_policy">Total Received Amount</label>
|
||||
<input type="number" class="form-control" id="modal_received_amt" placeholder="" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Payment Received Table -->
|
||||
<div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal">
|
||||
<div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal" style="max-width: 800px;">
|
||||
<button type="button" id="add_row_btn" class="btn btn-secondary float-right"><i class="fa fa-plus"></i></button>
|
||||
|
||||
|
||||
@ -319,7 +377,8 @@ table.dataTable tbody td {
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="display: none;">pk</th>
|
||||
<th>Received Amount</th>
|
||||
<th>Invoice value</th>
|
||||
<th>GST</th>
|
||||
<th>TDS</th>
|
||||
<th>UTR Number</th>
|
||||
<th>Date</th>
|
||||
@ -330,6 +389,7 @@ table.dataTable tbody td {
|
||||
<tr>
|
||||
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
|
||||
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" required onchange="checkInvAmont(event)"></td>
|
||||
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" required step="0.01" onchange="checkInvAmont(event)"></td>
|
||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
|
||||
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="<?php echo date('d/m/Y'); ?>" placeholder="dd/mm/yyyy" required readonly></td>
|
||||
@ -358,12 +418,14 @@ table.dataTable tbody td {
|
||||
const invoiceStatus = this.value;
|
||||
console.log(invoiceStatus);
|
||||
const invoiceNoDiv = document.getElementById('invoice_no_div_modal');
|
||||
const invoiceNoDiv2 = document.getElementById('invoice_no_div_modal2');
|
||||
// const invoiceDateDiv = document.getElementById('invoice_date_div_modal');
|
||||
const paymentTableDiv = document.getElementById('payment_table_div_modal');
|
||||
const totalReceivedAmtDiv = document.getElementById('modal_received_amt_div');
|
||||
|
||||
// Hide everything initially
|
||||
invoiceNoDiv.style.display = 'none';
|
||||
invoiceNoDiv2.style.display = 'none';
|
||||
// invoiceDateDiv.style.display = 'none';
|
||||
paymentTableDiv.style.display = 'none';
|
||||
totalReceivedAmtDiv.style.display = 'none';
|
||||
@ -371,6 +433,7 @@ table.dataTable tbody td {
|
||||
// Show fields based on selected status
|
||||
if (invoiceStatus === 'generated' || invoiceStatus === 'sent') {
|
||||
invoiceNoDiv.style.display = 'flex';
|
||||
invoiceNoDiv2.style.display = 'flex';
|
||||
totalReceivedAmtDiv.style.display = 'none';
|
||||
switchRequired('invoice_no_modal',true);
|
||||
switchRequired('invoice_date_modal',true);
|
||||
@ -384,6 +447,7 @@ table.dataTable tbody td {
|
||||
// invoiceDateDiv.style.display = 'block';
|
||||
} else if (invoiceStatus === 'payment_received') {
|
||||
invoiceNoDiv.style.display = 'flex';
|
||||
invoiceNoDiv2.style.display = 'flex';
|
||||
paymentTableDiv.style.display = 'block';
|
||||
totalReceivedAmtDiv.style.display = 'block';
|
||||
switchRequired('invoice_no_modal',true);
|
||||
@ -399,6 +463,7 @@ table.dataTable tbody td {
|
||||
}else if(invoiceStatus === 'pending')
|
||||
{
|
||||
invoiceNoDiv.style.display = 'none';
|
||||
invoiceNoDiv2.style.display = 'none';
|
||||
paymentTableDiv.style.display = 'none';
|
||||
totalReceivedAmtDiv.style.display = 'none';
|
||||
// switchRequired('modal_received_amt_div',false);
|
||||
@ -435,6 +500,13 @@ table.dataTable tbody td {
|
||||
|
||||
$('#invoiceForm').on('submit', function (e) {
|
||||
e.preventDefault(); // Prevent default form submission
|
||||
|
||||
var res = checkInvAmont();
|
||||
if(!res)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var form = document.getElementById('invoiceForm');
|
||||
// alert(form.checkValidity());
|
||||
// alert($('#invoice_date_modal').val());
|
||||
@ -487,7 +559,7 @@ table.dataTable tbody td {
|
||||
|
||||
$('.close').click()
|
||||
// Reset the form data
|
||||
$('#invoiceForm')[0].reset();
|
||||
// $('#invoiceForm')[0].reset();
|
||||
|
||||
alert('Invoice updated successfully!');
|
||||
location.reload();
|
||||
@ -513,6 +585,7 @@ table.dataTable tbody td {
|
||||
newRow.innerHTML = `
|
||||
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
|
||||
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
|
||||
<td><input type="text" class="form-control payment_date" value="<?php echo date('d/m/Y'); ?>" name="payment_date[]" placeholder="dd/mm/yyyy" required readonly></td>
|
||||
@ -627,6 +700,10 @@ function showInvoiceStatusModal(event)
|
||||
document.getElementById('invoice_no_modal').value = response.data.invoice_no;
|
||||
document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? <?php echo date('d-m-Y')?> : response.data.invoice_date;
|
||||
document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount;
|
||||
|
||||
document.getElementById('invoice_value_modal').value = response.data.invoice_value;
|
||||
document.getElementById('gst_per_modal').value = response.data.gst_per;
|
||||
document.getElementById('gst_value_modal').value = response.data.gst_value;
|
||||
|
||||
if (!$('#invoice_date_modal').val()) {
|
||||
// alert('nope');
|
||||
@ -646,6 +723,7 @@ function showInvoiceStatusModal(event)
|
||||
row.innerHTML = `
|
||||
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" value="${payment.id}"></td>
|
||||
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter Amount" value="${payment.gst}" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter Amount" value="${payment.tds}" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td>
|
||||
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" required readonly></td>
|
||||
@ -727,7 +805,8 @@ maxDate.setDate(today.getDate() + 180);
|
||||
alert('choose all fileds');
|
||||
return;
|
||||
}
|
||||
|
||||
// var myModal = new bootstrap.Modal(document.getElementById('file_upload'));
|
||||
|
||||
// Create FormData object
|
||||
var formData = new FormData($(this)[0]);
|
||||
for (var pair of formData.entries()) {
|
||||
@ -769,6 +848,9 @@ maxDate.setDate(today.getDate() + 180);
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
window.location.reload(true);
|
||||
}
|
||||
$('.close').click()
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
@ -776,11 +858,13 @@ maxDate.setDate(today.getDate() + 180);
|
||||
console.error("Request failed:", status, error);
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
$('#uploadForm')[0].reset();
|
||||
$('.close').click()
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
|
||||
});
|
||||
|
||||
function fetchFileError(file_id) {
|
||||
@ -804,7 +888,7 @@ maxDate.setDate(today.getDate() + 180);
|
||||
var file_error_html = "";
|
||||
|
||||
if (file_error_data['error_code'] == 1) {
|
||||
file_error_html += 'The following row no(s) from excel are <span style="font-weight:bold">either already mapped / not found with policy transactions / duplicates.</span>';
|
||||
file_error_html += 'The following row no(s) from excel are <span style="font-weight:bold">not found with policy transactions / duplicates.</span>';
|
||||
file_error_html += ' : ' + '<span style="font-weight:bolder">' + file_error_data['error_data'].join(',') + '</span>';
|
||||
}
|
||||
|
||||
@ -829,19 +913,21 @@ maxDate.setDate(today.getDate() + 180);
|
||||
}
|
||||
|
||||
|
||||
function checkInvAmont(event) {
|
||||
function checkInvAmont(event = null) {
|
||||
var total = 0;
|
||||
var receivedAmounts = document.querySelectorAll('input[name="received_amount[]"]');
|
||||
var receivedGST = document.querySelectorAll('input[name="gst_amount[]"]');
|
||||
var tdsAmounts = document.querySelectorAll('input[name="tds[]"]');
|
||||
// console.log();
|
||||
receivedAmounts.forEach(function(el, index) {
|
||||
// Get the received amount
|
||||
let receivedVal = parseFloat(el.value) || 0;
|
||||
// Get the corresponding tds amount (paired with the received amount)
|
||||
let gstVal = parseFloat(receivedGST[index].value) || 0;
|
||||
let tdsVal = parseFloat(tdsAmounts[index].value) || 0;
|
||||
// Add received amount and tds amount
|
||||
// console.log();
|
||||
total += (receivedVal + tdsVal);
|
||||
total += (receivedVal + tdsVal + gstVal);
|
||||
});
|
||||
// console.log(total);
|
||||
// Get the expected invoice amount
|
||||
@ -849,9 +935,16 @@ function checkInvAmont(event) {
|
||||
|
||||
// Check if the total exceeds the expected amount
|
||||
if (exp_amt < total) {
|
||||
alert('Exceeds Invoice amount');
|
||||
event.target.value = ''; // Reset the value of the element that triggered the event
|
||||
alert('Exceeds Invoice amount...Plz adjust numbers');
|
||||
if(event != null)
|
||||
{
|
||||
event.target.value = '';
|
||||
|
||||
}
|
||||
return false; // Reset the value of the element that triggered the event
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -883,5 +976,186 @@ function switchRequired(elementId, isRequired, type = 'id') {
|
||||
}
|
||||
}
|
||||
|
||||
function getStatementNo()
|
||||
{
|
||||
var insurer_id = $('#insurer').val();
|
||||
var statement_month = $('#statement_month').val();
|
||||
|
||||
console.log(insurer_id+' / '+statement_month);
|
||||
if(insurer_id == "")
|
||||
{
|
||||
alert('Choose insurer...!');
|
||||
$('#statement_month').val('');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
var apiURL = 'getInsurerStatementMonth?insurer_id=' +insurer_id+'&month='+statement_month ;
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
type: "GET",
|
||||
headers: {
|
||||
// "Content-Type":"multipart/form-data",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
console.log(response);
|
||||
// $('#insurer_statement_upload_form')[0].reset();
|
||||
|
||||
if (response.code === 200 && response.dataStatus === true && response
|
||||
.data !== "") {
|
||||
|
||||
disableStatementNo(response.data)
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
} else if (response.code === 404 && response.dataStatus === false) {
|
||||
console.error('no data found', response);
|
||||
// alert(response.message);
|
||||
// toastr.error(response.message, 'Failed');
|
||||
// window.location.reload(true);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
// alert('Something went wrong! Try later');
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
// window.location.reload(true);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Request failed, handle error
|
||||
console.error("Request failed:", status, error);
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
// $('#uploadForm')[0].reset();
|
||||
// window.location.reload(true);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(10).fadeOut('slow');
|
||||
|
||||
|
||||
}
|
||||
|
||||
function calcGSTValue()
|
||||
{
|
||||
// alert('calcGSTValue');
|
||||
var gst_per = document.getElementById('gst_per_modal').value;
|
||||
|
||||
var invoice_value_dom_obj = document.getElementById('invoice_value_modal');
|
||||
var invoice_value = invoice_value_dom_obj.value;
|
||||
|
||||
var gst_value_dom_obj = document.getElementById('gst_value_modal');
|
||||
var gst_value = gst_value_dom_obj.value;
|
||||
|
||||
var invoice_amount_dom_obj = document.getElementById('invoice_amount_no_modal');
|
||||
// var invoice_amount = invoice_amount_dom_obj.value();
|
||||
|
||||
gst_value_dom_obj.value = (parseFloat(gst_per) / 100 ) * invoice_value;
|
||||
invoice_amount_dom_obj.value = parseFloat(invoice_value_dom_obj.value) + parseFloat(gst_value_dom_obj.value);
|
||||
checkInvAmont();
|
||||
|
||||
|
||||
}
|
||||
|
||||
function disableStatementNo(arr)
|
||||
{
|
||||
// JavaScript array with values to disable
|
||||
// const disableValues = arr;
|
||||
const disableIds = arr.map(item => item.stmt_sno);
|
||||
console.log(disableIds);
|
||||
|
||||
// Get the select element
|
||||
const selectElement = document.getElementById("statement_no");
|
||||
// Variable to track if the first enabled option is selected
|
||||
let firstEnabledOptionSelected = false;
|
||||
// Iterate over the options in the select element
|
||||
Array.from(selectElement.options).forEach(option => {
|
||||
// If the option value is in the disableIds array, disable it
|
||||
console.log(option.value);
|
||||
option.disabled = false;
|
||||
option.style.backgroundColor = "";
|
||||
if (disableIds.includes((option.value))) {
|
||||
option.disabled = true;
|
||||
option.style.backgroundColor = "lightgray";
|
||||
}
|
||||
else if (!firstEnabledOptionSelected && option.value !== "") {
|
||||
// Automatically select the first enabled option
|
||||
option.selected = true;
|
||||
firstEnabledOptionSelected = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteStatement(id)
|
||||
{
|
||||
//alert(id);
|
||||
Swal.fire({
|
||||
title: "Do you want to delete statement & it's invoice data if any?",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "Delete",
|
||||
confirmButtonColor: "#ff3333",
|
||||
}).then((result) => {
|
||||
|
||||
console.log(result);
|
||||
|
||||
if (result.isConfirmed) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
var apiURL = 'deleteStatement/' + id;
|
||||
// console.log('Truncate API URL : ', apiURL);
|
||||
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log('Truncate Response', response)
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
if (response.code === 200 && response.dataStatus === true) {
|
||||
Swal.fire({
|
||||
title: "Deleted!",
|
||||
icon: "success"
|
||||
});
|
||||
window.location.reload(true);
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: "Failed!",
|
||||
text: 'Something went wrong! Try later',
|
||||
icon: "error"
|
||||
});
|
||||
|
||||
window.location.reload(true);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
console.error('Error fetching data from API:', error);
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@ -41,7 +41,7 @@ table.dataTable tbody td {
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="client_branch">Client<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="client_id" name="client_id">
|
||||
<option value="0">Select Client</option>
|
||||
@ -53,7 +53,7 @@ table.dataTable tbody td {
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="addon_policy"> Insurer <span id="base_danger"
|
||||
@ -69,6 +69,19 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="addon_policy"> Insurer Branch<span id="base_danger"
|
||||
class="text-danger"></span></label>
|
||||
<select class="form-control" id="insurer_id" name="insurer_id">
|
||||
<option value="0" selected>Select Insurer</option>
|
||||
<?php if(isset($insurer) && count($insurer)){ ?>
|
||||
<?php foreach ($insurer as $value) { ?>
|
||||
<option value="<?= $value['id']?>"><?= $value['name']?></option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="email"> Policy Type <span class="text-danger"></span></label>
|
||||
<select class="form-control" id="policy_type_id" name="policy_type_id">
|
||||
<option value="0">Select Policy Type</option>
|
||||
@ -80,9 +93,9 @@ table.dataTable tbody td {
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="issuer" name="issuer" required>
|
||||
<option value="0">Select Issure</option>
|
||||
@ -94,13 +107,13 @@ table.dataTable tbody td {
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
<!-- </div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-row"> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label>Date Type<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="date_type" name="date_type"
|
||||
onchange="hideDateField()">
|
||||
@ -113,10 +126,10 @@ table.dataTable tbody td {
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3" style="display: none;" id="date_div">
|
||||
<label>Date<span class="text-danger"></span></label>
|
||||
<div class="form-group col-md-3" style="display: true;" id="date_div">
|
||||
<label>Statement Month<span class="text-danger"></span></label>
|
||||
<div id="reportrange" class="form-control"
|
||||
style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
|
||||
<i class="fa fa-calendar"></i>
|
||||
@ -158,28 +171,36 @@ table.dataTable tbody td {
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>S.No</th>
|
||||
<th>Client Name</th>
|
||||
<!-- <th>Client Name</th> -->
|
||||
<th>Insurer</th>
|
||||
<th>Policy</th>
|
||||
<th>Endorsement No</th>
|
||||
<th>Insurer<br> Branch</th>
|
||||
<th>Statement<br> Month</th>
|
||||
<th>Statement<br> No</th>
|
||||
<th>Invoice No</th>
|
||||
<th>Invoice Status</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>Invoice Amount</th>
|
||||
<th>Realization Amount</th>
|
||||
<th>Outstanding Amount</th>
|
||||
<th>Realization <br>Amount</th>
|
||||
<th>Outstanding <br>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (isset($outstanding_list)) { ?>
|
||||
<?php foreach($outstanding_list as $index => $row){ ?>
|
||||
<?php
|
||||
|
||||
// dd($outstanting_list);
|
||||
if (isset($outstanting_list)) { ?>
|
||||
<?php foreach($outstanting_list as $index => $row){ ?>
|
||||
<tr>
|
||||
<td><?= $index + 1 ?></td>
|
||||
<td><?php echo $row['client_name']; ?></td>
|
||||
<td><?php echo $row['insurer_name']; ?></td>
|
||||
<td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td>
|
||||
<td><?php echo $row['endorsement_no']; ?></td>
|
||||
<td><?php echo $row['short_name']; ?></td>
|
||||
<td><?php echo $row['branch_name']; ?></td>
|
||||
<td><?php echo change_date_format($row['month'],'Y-m-d','Y-m') ?></td>
|
||||
<td><?php echo $row['stmt_sno']; ?></td>
|
||||
<td><?php echo $row['invoice_no']; ?></td>
|
||||
<td class="center-align-input"><?php echo isset($row['invoice_status']) ? $row['invoice_status'] : ' - '; ?></td>
|
||||
<td><?php echo change_date_format($row['invoice_date'],'Y-m-d','d-M-Y'); ?></td>
|
||||
<td class="right-align-input"><?php echo isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo isset($row['realization_amount']) ? $row['realization_amount'] : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo isset($row['total_paid']) ? $row['total_paid'] : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo isset($row['outstanding_amount']) ? $row['outstanding_amount'] : '0.00'; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@ -364,10 +385,6 @@ $(function() {
|
||||
startDate: start,
|
||||
endDate: end,
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
|
||||
.endOf('month')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user