ปรับปรุงสูตรการคำนวณต่างๆ

This commit is contained in:
Nakorn Rientrakrunchai
2020-08-16 16:20:47 +07:00
parent 9df224d42d
commit a1ff729171
14 changed files with 171 additions and 24 deletions

View File

@@ -85,10 +85,46 @@ namespace TodoAPI2.Models
return GetListBySearch(model);
}
public List<eva_adjust_postponement_detail_normal_02ViewModel> GetListBySearch(eva_adjust_postponement_detail_normal_02SearchModel model)
public string GetWorkTimeText(DateTime? startDate, DateTime? endDate)
{
if (!endDate.HasValue || !startDate.HasValue)
return "";
int monthsApart = 12 * (startDate.Value.Year - endDate.Value.Year) + startDate.Value.Month - endDate.Value.Month;
if (Math.Abs(monthsApart) < 4)
{
return "ปฏิบัติงานไม่ครบ 4 เดือน";
}
return "";
}
public List<eva_adjust_postponement_detail_normal_02ViewModel> GetListBySearch(eva_adjust_postponement_detail_normal_02SearchModel model)
{
var all_emp = emp.GetListByemployee_type(null, null);
var endDate = (from m_eva_adjust_postponement_detail_normal_02 in _repository.Context.eva_adjust_postponement_detail
join fk_eva_adjust_postponement1 in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail_normal_02.adjust_postponement_id equals fk_eva_adjust_postponement1.id
into eva_adjust_postponementResult1
from fk_eva_adjust_postponementResult1 in eva_adjust_postponementResult1.DefaultIfEmpty()
join create_detail in _repository.Context.eva_create_evaluation_detail
on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_detail.create_evaluation_id
into create_detailResult
from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
join create_data in _repository.Context.eva_create_evaluation
on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_data.id
into create_dataResult
from fk_create_dataResult in create_dataResult.DefaultIfEmpty()
join i in _repository.Context.eva_performance_plan_detail
on fk_create_dataResult.performance_plan_id equals i.performance_plan_id
where m_eva_adjust_postponement_detail_normal_02.adjust_postponement_id == model.adjust_postponement_id
select i.end_date).Max();
var data = (
from m_eva_adjust_postponement_detail_normal_02 in _repository.Context.eva_adjust_postponement_detail
@@ -134,7 +170,7 @@ namespace TodoAPI2.Models
total_promote = m_eva_adjust_postponement_detail_normal_02.total_promote,
new_sarary = m_eva_adjust_postponement_detail_normal_02.new_sarary,
new_cost_living = m_eva_adjust_postponement_detail_normal_02.new_cost_living,
remark = m_eva_adjust_postponement_detail_normal_02.remark,
remark = GetWorkTimeText(fk_external_linkageResult2.packing_date, endDate),
emp_code = fk_external_linkageResult2.employee_no,
emp_fullname = fk_external_linkageResult2.fullname,
emp_position = fk_external_linkageResult2.position_name,
@@ -148,6 +184,9 @@ namespace TodoAPI2.Models
position_allowance = fk_external_linkageResult2.position_allowance,
other_money = fk_external_linkageResult2.other_money,
startDate = fk_external_linkageResult2.packing_date,
endDate = endDate,
isActive = m_eva_adjust_postponement_detail_normal_02.isActive,
Created = m_eva_adjust_postponement_detail_normal_02.created,
Updated = m_eva_adjust_postponement_detail_normal_02.updated

View File

@@ -53,5 +53,8 @@ namespace TodoAPI2.Models
public decimal? position_allowance { get; set; }
public decimal? other_money { get; set; }
public DateTime? startDate { get; set; }
public DateTime? endDate { get; set; }
}
}

View File

@@ -85,10 +85,50 @@ namespace TodoAPI2.Models
return GetListBySearch(model);
}
public string GetWorkTimeText(DateTime? startDate, DateTime? endDate)
{
if (!endDate.HasValue || !startDate.HasValue)
return "";
int monthsApart = 12 * (startDate.Value.Year - endDate.Value.Year) + startDate.Value.Month - endDate.Value.Month;
if (Math.Abs(monthsApart) < 4)
{
return "ปฏิบัติงานไม่ครบ 4 เดือน";
}
return "";
}
public List<eva_adjust_postponement_detail_quota_02ViewModel> GetListBySearch(eva_adjust_postponement_detail_quota_02SearchModel model)
{
var all_emp = emp.GetListByemployee_type(null, null);
var endDate = (from m_eva_adjust_postponement_detail_quota_02 in _repository.Context.eva_adjust_postponement_detail
join fk_eva_adjust_postponement1 in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail_quota_02.adjust_postponement_quota_id equals fk_eva_adjust_postponement1.id
into eva_adjust_postponementResult1
from fk_eva_adjust_postponementResult1 in eva_adjust_postponementResult1.DefaultIfEmpty()
join fk_eva_adjust_postponement1A in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail_quota_02.adjust_postponement_id equals fk_eva_adjust_postponement1A.id
into eva_adjust_postponementResult1A
from fk_eva_adjust_postponementResult1A in eva_adjust_postponementResult1A.DefaultIfEmpty()
join create_detail in _repository.Context.eva_create_evaluation_detail
on fk_eva_adjust_postponementResult1A.create_evaluation_id equals create_detail.create_evaluation_id
into create_detailResult
from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
join create_data in _repository.Context.eva_create_evaluation
on fk_eva_adjust_postponementResult1A.create_evaluation_id equals create_data.id
into create_dataResult
from fk_create_dataResult in create_dataResult.DefaultIfEmpty()
join i in _repository.Context.eva_performance_plan_detail
on fk_create_dataResult.performance_plan_id equals i.performance_plan_id
where m_eva_adjust_postponement_detail_quota_02.adjust_postponement_quota_id == model.adjust_postponement_quota_id
select i.end_date).Max();
var data = (
from m_eva_adjust_postponement_detail_quota_02 in _repository.Context.eva_adjust_postponement_detail
@@ -113,6 +153,11 @@ namespace TodoAPI2.Models
into create_detailResult
from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
join create_data in _repository.Context.eva_create_evaluation
on fk_eva_adjust_postponementResult1A.create_evaluation_id equals create_data.id
into create_dataResult
from fk_create_dataResult in create_dataResult.DefaultIfEmpty()
where 1==1
//&& (m_eva_adjust_postponement_detail_quota_02.id == model.id || !model.id.HasValue)
&& (m_eva_adjust_postponement_detail_quota_02.adjust_postponement_quota_id == model.adjust_postponement_quota_id || !model.adjust_postponement_quota_id.HasValue)
@@ -131,14 +176,14 @@ namespace TodoAPI2.Models
adjust_postponement_quota_id = m_eva_adjust_postponement_detail_quota_02.adjust_postponement_quota_id,
employee_id = m_eva_adjust_postponement_detail_quota_02.employee_id,
sarary = m_eva_adjust_postponement_detail_quota_02.sarary,
// cost_living = m_eva_adjust_postponement_detail_quota_02.cost_living,
//cost_living = m_eva_adjust_postponement_detail_quota_02.cost_living,
cost_living = fk_external_linkageResult2.cost_of_living,
middle = m_eva_adjust_postponement_detail_quota_02.middle,
promoted_percentage = m_eva_adjust_postponement_detail_quota_02.promoted_percentage,
total_promote = m_eva_adjust_postponement_detail_quota_02.total_promote,
new_sarary = m_eva_adjust_postponement_detail_quota_02.new_sarary,
new_cost_living = m_eva_adjust_postponement_detail_quota_02.new_cost_living,
remark = m_eva_adjust_postponement_detail_quota_02.remark,
remark = GetWorkTimeText(fk_external_linkageResult2.packing_date, endDate),
receive_quota = m_eva_adjust_postponement_detail_quota_02.receive_quota,
new_sarary_with_quota = m_eva_adjust_postponement_detail_quota_02.new_sarary_with_quota,
emp_code = fk_external_linkageResult2.employee_no,
@@ -153,6 +198,9 @@ namespace TodoAPI2.Models
position_allowance = fk_external_linkageResult2.position_allowance,
other_money = fk_external_linkageResult2.other_money,
startDate = fk_external_linkageResult2.packing_date,
endDate = endDate,
isActive = m_eva_adjust_postponement_detail_quota_02.isActive,
Created = m_eva_adjust_postponement_detail_quota_02.created,
Updated = m_eva_adjust_postponement_detail_quota_02.updated

View File

@@ -57,5 +57,8 @@ namespace TodoAPI2.Models
public decimal? position_allowance { get; set; }
public decimal? other_money { get; set; }
public DateTime? startDate { get; set; }
public DateTime? endDate { get; set; }
}
}

View File

@@ -51,16 +51,42 @@ namespace TodoAPI2.Models
{
return Mapper.Map<List<eva_create_evaluation_detail_agreementViewModel>>(entities);
}
#endregion
#region Public Functions
#region Query Functions
public string GetWorkTimeText(DateTime? startDate, DateTime? endDate)
{
if (!endDate.HasValue || !startDate.HasValue)
return "";
int monthsApart = 12 * (startDate.Value.Year - endDate.Value.Year) + startDate.Value.Month - endDate.Value.Month;
if (Math.Abs(monthsApart) < 4)
{
return "ปฏิบัติงานไม่ครบ 4 เดือน";
}
return "";
}
public eva_create_evaluation_detail_agreementWithSelectionViewModel Get(int id)
{
var allemp = emp.GetListByemployee_type(null, null);
var endDate = (from m_eva_create_evaluation_detail_agreement in _repository.Context.eva_create_evaluation_detail
join fk_eva_create_evaluation10 in _repository.Context.eva_create_evaluation on m_eva_create_evaluation_detail_agreement.create_evaluation_id equals fk_eva_create_evaluation10.id
into eva_create_evaluationResult10
from fk_eva_create_evaluationResult10 in eva_create_evaluationResult10.DefaultIfEmpty()
join i in _repository.Context.eva_performance_plan_detail
on fk_eva_create_evaluationResult10.performance_plan_id equals i.performance_plan_id
where m_eva_create_evaluation_detail_agreement.id == id
select i.end_date).Max();
var data = (
from m_eva_create_evaluation_detail_agreement in _repository.Context.eva_create_evaluation_detail
@@ -101,7 +127,8 @@ namespace TodoAPI2.Models
org_id_external_linkage_external_name = fk_external_employee.department_name,
remark_hrm_work_record = fk_external_employee.remark_hrm_work_record,
remark_hrm_work_record = fk_external_employee.remark_hrm_work_record
+ GetWorkTimeText(fk_external_employee.packing_date, endDate),
isActive = m_eva_create_evaluation_detail_agreement.isActive,
Created = m_eva_create_evaluation_detail_agreement.created,

View File

@@ -149,7 +149,8 @@ namespace TodoAPI2.Models
fk_eva_create_evaluationResult10.supervisor1_id,
fk_eva_create_evaluationResult10.supervisor2_id, path),
remark_hrm_work_record = fk_external_employee.remark_hrm_work_record,
remark_hrm_work_record = fk_external_employee.remark_hrm_work_record
+ GetWorkTimeText(fk_external_employee.packing_date, end_date),
start_date = start_date,
end_date = end_date,
@@ -183,6 +184,19 @@ namespace TodoAPI2.Models
return i;
}
public string GetWorkTimeText(DateTime? startDate, DateTime? endDate)
{
if (!endDate.HasValue || !startDate.HasValue)
return "";
int monthsApart = 12 * (startDate.Value.Year - endDate.Value.Year) + startDate.Value.Month - endDate.Value.Month;
if (Math.Abs(monthsApart) < 4)
{
return "ปฏิบัติงานไม่ครบ 4 เดือน";
}
return "";
}
public List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id, string path)
{
var model = new eva_create_evaluation_detail_processSearchModel();
@@ -193,7 +207,7 @@ namespace TodoAPI2.Models
public List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model, int? emp_id, string path)
{
var allemp = emp.GetListByemployee_type(null, null);
var all_org_id = from i in ext.GetAllChildInDep(model.org_id) select i.external_id;
var all_org_id = from i in ext.GetAllChildInDep(model.org_id) select i.external_id;
var data = (
from m_eva_create_evaluation_detail_process in _repository.Context.eva_create_evaluation_detail