GET COMPANY DETAILS FROM GENERAL FORM
This commit is contained in:
parent
a9a27ff538
commit
f5811c38db
@ -189,6 +189,7 @@ $route['getPDFormDetails'] = 'PD_Controller/getPDFormDetailsJSON';
|
||||
$route['savePDFormDetails'] = 'PD_Controller/savePDFormDetailsJSON';
|
||||
$route['getFinalPDReportQuestions'] = 'PD_Controller/getFinalPDReportQuestions';
|
||||
$route['getTypeOfActivetyFromBusinessForm'] = 'PD_Controller/getTypeOfActivetyFromBusinessJSON';
|
||||
$route['getCompaniesListsForBusiness'] = 'PD_Controller/getCompaniesListsFromGeneralFormRawJSON';
|
||||
//$route['getTypeOfActivetyFromBusinessJSON'] = 'PD_Controller/getTypeOfActivetyFromBusinessJSON';
|
||||
|
||||
//Dashboard and Reports Related routes
|
||||
|
||||
@ -2041,6 +2041,11 @@ class PD_Controller extends REST_Controller {
|
||||
$where_condition_array = array('fk_form_id'=>$formid,'fk_pd_id'=>$pdid);
|
||||
$id = $this->PD_Model->updateRecords($fields,PDFORMDETAILSJSON,$where_condition_array);
|
||||
|
||||
//Save Any New Applicants Details From General Form
|
||||
if($records['formid'] == 18)
|
||||
{
|
||||
$this->saveCoApplicantsFromGeneralInfoForm($records);
|
||||
}
|
||||
unset($records['pdid']);
|
||||
unset($records['formid']);
|
||||
unset($records['fk_createdby']);
|
||||
@ -2666,7 +2671,7 @@ class PD_Controller extends REST_Controller {
|
||||
$overall_business_total = 0;
|
||||
$overall_household_total = 0;
|
||||
$net_profit = 0;
|
||||
$final_purchase_avg_value = 0;
|
||||
$final_sales_avg_value = 0;
|
||||
|
||||
//Get all Master Details
|
||||
$result_array = $this->PD_Model->getAssessedIncome($pd_id);
|
||||
@ -2678,6 +2683,7 @@ class PD_Controller extends REST_Controller {
|
||||
$business_expenses = $result_array['business_expenses'];
|
||||
$household_expenses = $result_array['house_hold_expenses'];
|
||||
$gross_profit_calculation_type = $result_array['gross_profit_calculation_type'];
|
||||
$othre_business_income = $result_array['othre_business_income'];
|
||||
if(count($sales_declared_by_customer)){$sales_declared_by_customer_flag = 1;}
|
||||
if(count($sales_calculated_by_itemwise)){$sales_calculated_by_itemwise_flag = 1;}
|
||||
if(count($sales_by_item_monthwise)){$sales_by_item_monthwise_flag = 1;}
|
||||
@ -2777,18 +2783,18 @@ class PD_Controller extends REST_Controller {
|
||||
$diff = $height_value - $lowest_vaule;
|
||||
if($diff > ($lowest_vaule * 0.5))
|
||||
{
|
||||
$final_purchase_avg_value = $lowest_vaule * 1.25;
|
||||
$final_sales_avg_value = $lowest_vaule * 1.25;
|
||||
}
|
||||
|
||||
}
|
||||
else //case 2 - (a) ref doc - Normally Average of the above 3 sales estimates is considered. There may be situations where sales information is available only from a or b or c or any
|
||||
{
|
||||
$average = array_sum($temp_array)/count($temp_array);
|
||||
$final_purchase_avg_value = $average;
|
||||
$final_sales_avg_value = $average;
|
||||
|
||||
}
|
||||
|
||||
//echo "\n\n".$final_purchase_avg_value;
|
||||
//echo "\n\n".$final_sales_avg_value;
|
||||
|
||||
/**************End of Purchase Calculations************************/
|
||||
|
||||
@ -2799,7 +2805,7 @@ class PD_Controller extends REST_Controller {
|
||||
{
|
||||
if($gross_profit_calculation_type[0]['mode'] == 1)
|
||||
{
|
||||
$estimation_of_gross_profit = $final_purchase_avg_value - $overall_purchase_total;
|
||||
$estimation_of_gross_profit = $final_sales_avg_value - $overall_purchase_total;
|
||||
$net_profit = $estimation_of_gross_profit - $overall_business_total;
|
||||
}
|
||||
else
|
||||
@ -2851,12 +2857,12 @@ class PD_Controller extends REST_Controller {
|
||||
|
||||
}
|
||||
|
||||
$overall_purchase_total = $final_purchase_avg_value - ($overall_business_total+$net_profit);
|
||||
$overall_purchase_total = $final_sales_avg_value - ($overall_business_total+$net_profit);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**************************Gross Profit calculation end***************/
|
||||
$calculated_data['income']['sales_revenue'] = $final_purchase_avg_value;
|
||||
$calculated_data['income']['sales_revenue'] = $final_sales_avg_value;
|
||||
$calculated_data['expense']['purchase'] = $overall_purchase_total;
|
||||
if(isset($gross_profit_calculation_type[0]))
|
||||
{
|
||||
@ -2871,7 +2877,7 @@ class PD_Controller extends REST_Controller {
|
||||
}
|
||||
$calculated_data['expense']['business_expense'] = $overall_business_total;
|
||||
$calculated_data['expense']['net_profit'] = $net_profit;
|
||||
$calculated_data['net_margin'] = $net_profit / $final_purchase_avg_value;
|
||||
$calculated_data['net_margin'] = $net_profit / $final_sales_avg_value;
|
||||
|
||||
|
||||
|
||||
@ -3824,6 +3830,50 @@ class PD_Controller extends REST_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function getCompaniesListsFromGeneralFormRawJSON_post()
|
||||
{
|
||||
$records = $this->post('records');
|
||||
$pd_id = $records['pd_id'];
|
||||
// $pd_form_id = $records['pd_form_id'];
|
||||
$final_array = array();
|
||||
$fields = array('json');
|
||||
$where_condition_array = array('isactive' => 1,'fk_form_id'=>18,'fk_pd_id'=>$pd_id);
|
||||
$rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
|
||||
//print_r($this->db->last_query());
|
||||
//print_r($rec);
|
||||
if(count($rec))
|
||||
{
|
||||
$temp_data = json_decode($rec[0]['json'],true);
|
||||
$company_list = array();
|
||||
foreach($temp_data['companies'] as $company)
|
||||
{
|
||||
$company_list = array_merge($company_list,array($company['company_name']));
|
||||
}
|
||||
if(count($company_list))
|
||||
{
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['records'] = $company_list;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{ $data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'No Comapany Details Found!';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'Kindy Fill General Form First!';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1163,10 +1163,20 @@ class PD_Model extends SPARQ_Model {
|
||||
$joins = array(
|
||||
array('table'=>FREQUENCY.' as FREQUENCY','condition'=>'PDHOUSEHOLDEXPENSES.fk_frequency_id = FREQUENCY.frequency_id','jointype'=>'INNER JOIN'));
|
||||
$house_hold_expenses = $this->getJoinRecords($fields,$table,$joins,$where_condition_array);
|
||||
|
||||
|
||||
//get Other Business Income details
|
||||
$fields = array('PDBUSINESSINCOME.pd_business_income_id', 'PDBUSINESSINCOME.fk_pd_id', 'PDBUSINESSINCOME.business_income_id', 'PDBUSINESSINCOME.income_value', 'PDBUSINESSINCOME.fk_frequency_id', 'PDBUSINESSINCOME.annual_income_value','PDBUSINESSINCOME.fk_createdby','PDBUSINESSINCOME.other_income_item','PDBUSINESSINCOME.other_frequncy_item','FREQUENCY.name as frequency_name','BUSINESSINCOME.business_income_item');
|
||||
$table = PDBUSINESSINCOME.' as PDBUSINESSINCOME';
|
||||
$where_condition_array = array('fk_pd_id'=>$pdid,'PDBUSINESSINCOME.isactive'=>1);
|
||||
$joins = array(
|
||||
array('table'=>FREQUENCY.' as FREQUENCY','condition'=>'PDBUSINESSINCOME.fk_frequency_id = FREQUENCY.frequency_id','jointype'=>'INNER JOIN'),
|
||||
array('table'=>BUSINESSINCOME.' as BUSINESSINCOME','condition'=>'PDBUSINESSINCOME.business_income_id = BUSINESSINCOME.business_income_id','jointype'=>'INNER JOIN'));
|
||||
$other_business_income = $this->getJoinRecords($fields,$table,$joins,$where_condition_array);
|
||||
|
||||
/*********************************End of Assessd Income Sections *****************************************/
|
||||
|
||||
$assessed_income= array('sales_declared_by_customer'=>$sales_declared_by_customer,'sales_calculated_by_itemwise'=>$sales_calculated_by_itemwise,'sales_items_by_monthwise'=>$sales_items_by_monthwise,'purchase_details'=>$purchase_details,'business_expenses'=>$business_expenses,'house_hold_expenses'=>$house_hold_expenses,'gross_profit_calculation_type' => $gross_profit_calculation_type);
|
||||
$assessed_income= array('sales_declared_by_customer'=>$sales_declared_by_customer,'sales_calculated_by_itemwise'=>$sales_calculated_by_itemwise,'sales_items_by_monthwise'=>$sales_items_by_monthwise,'purchase_details'=>$purchase_details,'business_expenses'=>$business_expenses,'house_hold_expenses'=>$house_hold_expenses,'gross_profit_calculation_type' => $gross_profit_calculation_type,'othre_business_income' => $other_business_income);
|
||||
|
||||
return $assessed_income;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user