nhance/app/Models/PTCOShareDetailsModel.php

119 lines
3.2 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
class PTCOShareDetailsModel extends Model
{
protected $table = 'pt_co_share_details';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = [
'id',
'pt_id',
'insurer_id',
'insurer_branch_id',
'co_share_type',
'co_share_per',
'bp_amt',
'bp_gst_amt',
'bp_igst',
'bp_sgst',
'bp_cgst',
'tp_amt',
'tp_gst_amt',
'tp_igst',
'tp_sgst',
'tp_cgst',
'tep_amt',
'tep_gst_amt',
'tep_igst',
'tep_sgst',
'tep_cgst',
'agreed_amt',
'agreed_bp_per',
'agreed_tp_per',
'agreed_tep_per',
'standerd_bp_per',
'standerd_tp_per',
'standerd_tep_per',
'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',
'remark',
'created_at',
'created_by',
'updated_at',
'updated_by',
'is_active',
'cd_ac_no',
'amount',
'stamp_duty',
'cop_amt',
'statement_id',
'follower_policy_no',
'non_comm_per_amt',
'cotp_amt',
'cotep_amt',
];
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,
pt_co.pt_id,
pt_co.exp_amt,
pt.id AS policy_transaction_id,
pt.endorsement_no,
c.client_name,
pt.created_at,
pt_co.insurer_id,
pt_co.insurer_branch_id,
pt.policy_no,
pt.policy_issue_date,
pt.policy_start_date,
pt.policy_end_date,
pt.status,
pt_co.bp_amt,
pt_co.tp_amt,
pt_co.tep_amt,
pt_co.exp_amt,
pt_co.statement_id
')
->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('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.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()
->getResultArray();
}
}