PROD AI ISSUE RESOLVED
This commit is contained in:
parent
9656a42f0c
commit
e37fc31877
@ -4152,7 +4152,7 @@ public function getPDFormDetailsJSON_post()
|
||||
|
||||
$overall_summary_report = array();
|
||||
$overall_summary_report['sales_calculated_by_itemwise'] = null;
|
||||
//$overall_summary_report['sales_calculated_by_monthwise'] = null;
|
||||
|
||||
$overall_summary_report['sales_declared_by_customer'] = null;
|
||||
|
||||
$sales_declared_by_customer = array();
|
||||
@ -4161,10 +4161,7 @@ public function getPDFormDetailsJSON_post()
|
||||
$sales_calculated_by_itemwise = array();
|
||||
$sales_calculated_by_itemwise_flag = 0;
|
||||
|
||||
// $sales_by_item_monthwise = array();
|
||||
// $sales_by_item_monthwise_flag = 0;
|
||||
// $margin_value_from_monthwise_data = array();
|
||||
|
||||
|
||||
$purchases = array();
|
||||
$purchases_flag = 0;
|
||||
|
||||
@ -4189,13 +4186,13 @@ public function getPDFormDetailsJSON_post()
|
||||
|
||||
//Get all Master Details
|
||||
$result_array = $this->PD_Model->getAssessedIncome($pd_id,$company_id);
|
||||
//print_r($result_array);
|
||||
|
||||
$sales_declared_by_customer = $result_array['sales_declared_by_customer'];
|
||||
$sales_calculated_by_itemwise = $result_array['sales_calculated_by_itemwise'];
|
||||
//$sales_by_item_monthwise = $result_array['sales_items_by_monthwise'];
|
||||
|
||||
$purchases = $result_array['purchase_details'];
|
||||
$purchase_declared_by_customer = $result_array['purchase_declared_by_customer'];
|
||||
//$purchase_billwise = $result_array['purchase_billwise'];
|
||||
|
||||
$business_expenses = $result_array['business_expenses'];
|
||||
$other_business_income = $result_array['othre_business_income'];
|
||||
$household_expenses = $result_array['house_hold_expenses'];
|
||||
@ -4203,15 +4200,18 @@ public function getPDFormDetailsJSON_post()
|
||||
$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;}
|
||||
|
||||
|
||||
if(count($purchases)){ $purchases_flag = 1;}
|
||||
//echo $sales_calculated_by_itemwise_flag.$purchases_flag;
|
||||
if(count($purchase_declared_by_customer)){$purchase_declared_by_customer_flag = 1;}
|
||||
if(count($business_expenses)){$business_expenses_flag = 1;}
|
||||
if(count($household_expenses)){$household_expenses_flag = 1;}
|
||||
if(count($other_business_income)){$other_business_income_flag = 1;}
|
||||
|
||||
|
||||
if(($business_expenses_flag == 1) && ($sales_declared_by_customer_flag == 1 || $purchase_declared_by_customer_flag) || ($sales_calculated_by_itemwise_flag == 1 || $purchases_flag = 1))
|
||||
// if(($business_expenses_flag == 1) && ($sales_declared_by_customer_flag == 1 || $purchase_declared_by_customer_flag) || ($sales_calculated_by_itemwise_flag == 1 || $purchases_flag == 1))
|
||||
if($gross_profit_calculation_type[0]['is_completed'])
|
||||
{
|
||||
$total_sales_itemwise = 0;
|
||||
$sales_monthwise = array();
|
||||
@ -4239,223 +4239,76 @@ public function getPDFormDetailsJSON_post()
|
||||
if($purchases_flag != 0)
|
||||
{
|
||||
|
||||
// if($gross_profit_calculation_type[0]['mode'] == 1 && $gross_profit_calculation_type[0]['purchase_type'] == 1)//purchase item wise
|
||||
// {
|
||||
|
||||
foreach($purchases as $purchase_key => $purchase)
|
||||
{
|
||||
|
||||
$overall_purchase_total += $purchase['annual_purchase_value'];
|
||||
}
|
||||
// }
|
||||
// else if($gross_profit_calculation_type[0]['mode'] == 1 && $gross_profit_calculation_type[0]['purchase_type'] == 2)////purchase bill wise
|
||||
// {
|
||||
|
||||
// foreach($purchase_billwise as $purchase_billwise_key => $bill)
|
||||
// {
|
||||
|
||||
// $overall_purchase_total = $overall_purchase_total + ($bill['annual_purchase_value'] * (12/ count($bill['items'])) );
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($sales_calculated_by_itemwise_flag == 1 || $purchases_flag == 1)
|
||||
if($sales_calculated_by_itemwise_flag == 1 )
|
||||
{
|
||||
|
||||
|
||||
$temp_purchases = 0;
|
||||
$temp_netprofit = 0;
|
||||
$temp_grossprofit = 0;
|
||||
$temp_netmargin = 0;
|
||||
$month_total = 0;
|
||||
$i = 0;
|
||||
foreach($sales_calculated_by_itemwise as $itemwise_key => $item)
|
||||
{
|
||||
|
||||
//print_r($item);die();
|
||||
// if($item['sales_type'] != 3)
|
||||
// {
|
||||
$total_sales_itemwise = $total_sales_itemwise + $item['annual_sale_value'];
|
||||
$temp_netprofit = $temp_netprofit + $item['margin_final_value'];
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //*****************************
|
||||
// // foreach($sales_by_item_monthwise as $monthwise_key => $sales_by_item_month)
|
||||
// // {
|
||||
// //print_r($sales_by_item_month['items']);
|
||||
// //echo isset($sales_by_item_month['items']);die();
|
||||
|
||||
// $temp_netprofit = $temp_netprofit + $item['margin_final_value'];
|
||||
// if(isset($item['items']))
|
||||
// {
|
||||
// //echo 'insdie if';
|
||||
// foreach($item['items'] as $month_key => $month)
|
||||
// {
|
||||
// $temp = 0;
|
||||
|
||||
// $i++;
|
||||
// foreach($month as $key => $m)
|
||||
// {
|
||||
// $temp = $temp + $m['sales_value'];
|
||||
// }
|
||||
// $month_total = $month_total + $temp;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //die();
|
||||
// $sales_monthwise[] = array('total' => $month_total,'no_of_months' => $i,'sales_type' => $item['sales_type']);
|
||||
// //}
|
||||
|
||||
|
||||
// //print_r($sales_monthwise);die();
|
||||
// $total_sales_monthwise = 0;
|
||||
// foreach($sales_monthwise as $sale)
|
||||
// {
|
||||
|
||||
|
||||
// $annual_multuplier = 12 / ( $sale['no_of_months'] ? $sale['no_of_months'] : 1);
|
||||
|
||||
// if($sale['sales_type'] == 1)
|
||||
// {
|
||||
// $total_sales_monthwise = $total_sales_monthwise + ($sale['total'] * $annual_multuplier);
|
||||
// }
|
||||
// else if($sale['sales_type'] == 2)
|
||||
// {
|
||||
// $total_sales_monthwise = $total_sales_monthwise + $sale['total'];
|
||||
// }
|
||||
// }
|
||||
// //*****************************
|
||||
// }
|
||||
|
||||
}
|
||||
$total_sales_monthwise = 0;
|
||||
|
||||
|
||||
//calculatin part
|
||||
if($gross_profit_calculation_type[0]['mode'] == 1)
|
||||
{
|
||||
|
||||
$temp_purchases = $overall_purchase_total;
|
||||
$temp_grossprofit = ($total_sales_itemwise + $total_sales_monthwise) - $temp_purchases;
|
||||
$temp_netprofit = $temp_grossprofit - $overall_business_expenses_total;
|
||||
|
||||
if($temp_netprofit != 0 && ($total_sales_itemwise + $total_sales_monthwise) != 0)
|
||||
{
|
||||
$temp_netmargin = ($temp_netprofit/ ($total_sales_itemwise + $total_sales_monthwise)) * 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp_netmargin = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// This one changes as per 15/03/2019 Excel Review changes
|
||||
$temp_grossprofit = $temp_netprofit;// + $overall_business_expenses_total;
|
||||
$temp_netprofit = $temp_grossprofit - $overall_business_expenses_total;
|
||||
$temp_purchases = ($total_sales_itemwise + $total_sales_monthwise) - $temp_grossprofit;
|
||||
if($temp_netprofit != 0 && ( $total_sales_itemwise + $total_sales_monthwise) != 0 ){
|
||||
$temp_netmargin = ($temp_netprofit/( $total_sales_itemwise + $total_sales_monthwise) * 100);
|
||||
}
|
||||
else { $temp_netmargin = 0;}
|
||||
}
|
||||
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'] = round($total_sales_itemwise + $total_sales_monthwise);
|
||||
($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_calculated_by_itemwise']['purchases'] = round($temp_purchases,2) : $overall_summary_report['sales_calculated_by_itemwise']['cost_of_goods_sold'] = round($temp_purchases);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['grossprofit'] = round($temp_grossprofit);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['business_expenses'] = round($overall_business_expenses_total);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['netprofit'] = round($temp_netprofit);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['house_hold_expenses'] = round($overall_household_total);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['disposable_income'] = round($temp_netprofit - $overall_household_total);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['netmargin'] = round($temp_netmargin,2);
|
||||
$temp_purchases = 0;
|
||||
$temp_netprofit = 0;
|
||||
$temp_grossprofit = 0;
|
||||
$temp_netmargin = 0;
|
||||
$month_total = 0;
|
||||
$i = 0;
|
||||
foreach($sales_calculated_by_itemwise as $itemwise_key => $item)
|
||||
{
|
||||
|
||||
$total_sales_itemwise = $total_sales_itemwise + $item['annual_sale_value'];
|
||||
$temp_netprofit = $temp_netprofit + $item['margin_final_value'];
|
||||
|
||||
}
|
||||
$total_sales_monthwise = 0;
|
||||
|
||||
|
||||
//calculatin part
|
||||
if($gross_profit_calculation_type[0]['mode'] == 1)
|
||||
{
|
||||
|
||||
$temp_purchases = $overall_purchase_total;
|
||||
$temp_grossprofit = ($total_sales_itemwise + $total_sales_monthwise) - $temp_purchases;
|
||||
$temp_netprofit = $temp_grossprofit - $overall_business_expenses_total;
|
||||
|
||||
if($temp_netprofit != 0 && ($total_sales_itemwise + $total_sales_monthwise) != 0)
|
||||
{
|
||||
$temp_netmargin = ($temp_netprofit/ ($total_sales_itemwise + $total_sales_monthwise)) * 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp_netmargin = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// This one changes as per 15/03/2019 Excel Review changes
|
||||
$temp_grossprofit = $temp_netprofit;// + $overall_business_expenses_total;
|
||||
$temp_netprofit = $temp_grossprofit - $overall_business_expenses_total;
|
||||
$temp_purchases = ($total_sales_itemwise + $total_sales_monthwise) - $temp_grossprofit;
|
||||
if($temp_netprofit != 0 && ( $total_sales_itemwise + $total_sales_monthwise) != 0 ){
|
||||
$temp_netmargin = ($temp_netprofit/( $total_sales_itemwise + $total_sales_monthwise) * 100);
|
||||
}
|
||||
else { $temp_netmargin = 0;}
|
||||
}
|
||||
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'] = round($total_sales_itemwise + $total_sales_monthwise);
|
||||
($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_calculated_by_itemwise']['purchases'] = round($temp_purchases,2) : $overall_summary_report['sales_calculated_by_itemwise']['cost_of_goods_sold'] = round($temp_purchases);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['grossprofit'] = round($temp_grossprofit);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['business_expenses'] = round($overall_business_expenses_total);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['netprofit'] = round($temp_netprofit);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['house_hold_expenses'] = round($overall_household_total);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['disposable_income'] = round($temp_netprofit - $overall_household_total);
|
||||
$overall_summary_report['sales_calculated_by_itemwise']['netmargin'] = round($temp_netmargin,2);
|
||||
}
|
||||
|
||||
// if($sales_by_item_monthwise_flag == 1)
|
||||
// {
|
||||
// $temp_purchases = 0;
|
||||
// $temp_netprofit = 0;
|
||||
// $temp_grossprofit = 0;
|
||||
// $temp_netmargin = 0;
|
||||
// //print_r($sales_by_item_monthwise);die();
|
||||
// foreach($sales_by_item_monthwise as $monthwise_key => $sales_by_item_month)
|
||||
// {
|
||||
// //print_r($sales_by_item_month['items']);
|
||||
// //echo isset($sales_by_item_month['items']);die();
|
||||
// $month_total = 0;
|
||||
// $i = 0;
|
||||
// $temp_netprofit = $temp_netprofit + $sales_by_item_month['margin_value'];
|
||||
// if(isset($sales_by_item_month['items']))
|
||||
// {
|
||||
// //echo 'insdie if';
|
||||
// foreach($sales_by_item_month['items'] as $month_key => $month)
|
||||
// {
|
||||
// $temp = 0;
|
||||
|
||||
// $i++;
|
||||
// foreach($month as $key => $m)
|
||||
// {
|
||||
// $temp = $temp + $m['sales_value'];
|
||||
// }
|
||||
// $month_total = $month_total + $temp;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //die();
|
||||
// $sales_monthwise[] = array('total' => $month_total,'no_of_months' => $i,'sales_type' => $sales_by_item_month['sales_type']);
|
||||
// }
|
||||
|
||||
|
||||
// //print_r($sales_monthwise);die();
|
||||
// foreach($sales_monthwise as $sale)
|
||||
// {
|
||||
|
||||
|
||||
// $annual_multuplier = 12 / ( $sale['no_of_months'] ? $sale['no_of_months'] : 1);
|
||||
|
||||
// if($sale['sales_type'] == 1)
|
||||
// {
|
||||
// $total_sales_monthwise = $total_sales_monthwise + ($sale['total'] * $annual_multuplier);
|
||||
// }
|
||||
// else if($sale['sales_type'] == 2)
|
||||
// {
|
||||
// $total_sales_monthwise = $total_sales_monthwise + $sale['total'];
|
||||
// }
|
||||
// }
|
||||
|
||||
// //calculation part
|
||||
// //calculatin part
|
||||
// if($gross_profit_calculation_type[0]['mode'] == 1)
|
||||
// {
|
||||
// $temp_purchases = $overall_purchase_total;
|
||||
// $temp_grossprofit = $total_sales_monthwise - $temp_purchases;
|
||||
// $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total;
|
||||
// $temp_netmargin = ($temp_netprofit/ ($total_sales_monthwise?$total_sales_monthwise:1) ) * 100;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $temp_grossprofit = $temp_netprofit ;//+ $overall_business_expenses_total;
|
||||
// $temp_purchases = $total_sales_monthwise - $temp_grossprofit;
|
||||
// $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total;
|
||||
// //echo $temp_netprofit.'-'.$total_sales_monthwise;die();
|
||||
// $temp_netmargin = ($temp_netprofit/ ($total_sales_monthwise?$total_sales_monthwise:1) ) * 100;
|
||||
// }
|
||||
|
||||
// $overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'] = round($total_sales_monthwise);
|
||||
// ($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_calculated_by_monthwise']['purchases'] = round($temp_purchases) : $overall_summary_report['sales_calculated_by_monthwise']['cost_of_goods_sold'] = round($temp_purchases);
|
||||
// $overall_summary_report['sales_calculated_by_monthwise']['grossprofit'] = round($temp_grossprofit);
|
||||
// $overall_summary_report['sales_calculated_by_monthwise']['business_expenses'] = round($overall_business_expenses_total);
|
||||
// $overall_summary_report['sales_calculated_by_monthwise']['netprofit'] = round($temp_netprofit);
|
||||
// $overall_summary_report['sales_calculated_by_monthwise']['house_hold_expenses'] = round($overall_household_total);
|
||||
// $overall_summary_report['sales_calculated_by_monthwise']['disposable_income'] = round($temp_netprofit - $overall_household_total);
|
||||
// $overall_summary_report['sales_calculated_by_monthwise']['netmargin'] = round($temp_netmargin,2);
|
||||
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
if($sales_declared_by_customer_flag == 1)
|
||||
{
|
||||
|
||||
@ -4526,10 +4379,7 @@ public function getPDFormDetailsJSON_post()
|
||||
}
|
||||
else
|
||||
{
|
||||
// $data['dataStatus'] = false;
|
||||
// $data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
||||
// $data['msg'] = 'Not enough Data to Calculate Assessed Income';
|
||||
// $this->response($data,REST_Controller::HTTP_OK);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -1465,7 +1465,7 @@ class PD_Model extends SPARQ_Model {
|
||||
$purchase_declared_by_customer = $this->selectCustomRecords($fields,$where_condition_array,PURCHASEDECLAREDBYCUSTOMER);
|
||||
|
||||
//get Gross Profit calculatio Mode details
|
||||
$fields = array('calc_type_id','mode','margin','purchase_type');
|
||||
$fields = array('calc_type_id','mode','margin','purchase_type','is_completed');
|
||||
$where_condition_array = array('fk_pd_id'=>$pdid,'company_id'=>$company_id);
|
||||
$gross_profit_calculation_type = $this->selectCustomRecords($fields,$where_condition_array,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE);
|
||||
//print_r($gross_profit_calculation_type);die();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user