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

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

View File

@@ -78,7 +78,7 @@
<div class='row'>
<div class="form-group col-md-6">
<label id="lab_eva_adjust_postponement_normal_percentage" for="eva_adjust_postponement_normal_percentage">ร้อยละที่ได้เลื่อน</label>
<input class="form-control" type="number" onchange="Oneva_adjust_postponement_normal_percentageChange();" id="eva_adjust_postponement_normal_percentage" iLabel="ร้อยละที่ได้เลื่อน" iRequire="true" iGroup="eva_adjust_postponement_normal" />
<input class="form-control" type="number" onchange="Oneva_adjust_postponement_normal_percentageChange();" id="eva_adjust_postponement_normal_percentage" iLabel="ร้อยละที่ได้เลื่อน" iRequire="false" iGroup="eva_adjust_postponement_normal" />
</div>
<div class="form-group col-md-6">
<label for="eva_adjust_postponement_normal_percentage">จำนวนเงินที่ใช้เลื่อนคงเหลือ</label>

View File

@@ -57,7 +57,7 @@
<div class='row'>
<div class="form-group col-md-6">
<label id="lab_eva_adjust_postponement_quota_limit_frame_quota" for="eva_adjust_postponement_quota_limit_frame_quota">กรอบโควต้าพิเศษร้อยละ</label>
<input onchange="Oneva_adjust_postponement_quota_limit_frame_quotaChange();" placeholder="0.00" class="form-control money mask_plugin" type="text" id="eva_adjust_postponement_quota_limit_frame_quota" iLabel="กรอบโควต้าพิเศษร้อยละ" iRequire="true" iGroup="eva_adjust_postponement_quota" />
<input onchange="Oneva_adjust_postponement_quota_limit_frame_quotaChange();" placeholder="0.00" class="form-control money mask_plugin" type="number" id="eva_adjust_postponement_quota_limit_frame_quota" iLabel="กรอบโควต้าพิเศษร้อยละ" iRequire="true" iGroup="eva_adjust_postponement_quota" />
</div>
<div class="form-group col-md-6">
@@ -136,7 +136,7 @@
var id = getUrlParameter("id");
if (id) {
eva_adjust_postponement_quota_SetEditForm(id);
eva_adjust_postponement_detail_quota_02_InitialForm(id);
setTimeout(function(){ eva_adjust_postponement_detail_quota_02_InitialForm(getUrlParameter("id")) }, 800);
} else {
eva_adjust_postponement_quota_SetCreateForm();

View File

@@ -99,7 +99,12 @@ var cur_dep = "";
var successFunc = function (response) {
console.log(response);
var sum_current_salary = 0;
$.each(response, function (i, data) {
sum_current_salary += data.sarary;
var tag = "";
if(cur_dep !== data.emp_department_name){
tag += '<tr><td colspan="16">'+data.emp_department_name+'</td></tr>';
@@ -176,8 +181,14 @@ if(cur_dep !== data.emp_department_name){
$('#eva_adjust_postponement_detail_quota_02Body').append($(tag));
eva_adjust_postponement_detail_quota_02_FeedDataToForm(data, (i + 1), blankItem);
});
CalculateRemainQuota();
$("#eva_adjust_postponement_quota_limit").val(sum_current_salary);
Oneva_adjust_postponement_quota_limit_frame_quotaChange();
//CalculateRemainQuota();
endLoad();
};
startLoad();

View File

@@ -129,8 +129,8 @@ function Oneva_adjust_postponement_normal_limit_frameChange(){
var limit_frame = $("#eva_adjust_postponement_normal_limit_frame").val();
limit_frame = Math.round(limit_frame*100)/100;
$("#eva_adjust_postponement_normal_limit_frame").val(limit_frame);
// $("#eva_adjust_postponement_normal_limit_quota").val(Math.round( Math.ceil(limit*limit_frame)/1000)*10 );
$("#eva_adjust_postponement_normal_limit_quota").maskMoney('mask',Math.round( Math.ceil(limit*limit_frame)/1000)*10 );
//$("#eva_adjust_postponement_normal_limit_quota").val(Math.ceil((limit*limit_frame/1000))*10);
$("#eva_adjust_postponement_normal_limit_quota").maskMoney('mask',Math.ceil((limit*limit_frame/1000))*10);
}
@@ -148,7 +148,6 @@ function Oneva_adjust_postponement_normal_percentageChange(){
function Oneva_adjust_postponement_detail_normal_02_promoted_percentageChanged(){
var current_quota = $("#eva_adjust_postponement_normal_limit_quota").val().replace(/[,-]/g,'');
console.log("yy");
var sum_postpone = 0;
$('#eva_adjust_postponement_detail_normal_02Body tr').each(function () {

View File

@@ -4,6 +4,7 @@ var eva_adjust_postponement_quota_API = "/api/eva_adjust_postponement_quota/";
//================= Form Data Customizaiton =========================================
function eva_adjust_postponement_quota_FeedDataToForm(data) {
console.log(data.limit);
$("#eva_adjust_postponement_quota_id").val(data.id);
$("#eva_adjust_postponement_quota_fiscal_year").val(data.fiscal_year);
$("#eva_adjust_postponement_quota_theDate").val(formatDate(data.theDate));
@@ -133,13 +134,13 @@ function Oneva_adjust_postponement_quota_limit_frame_quotaChange() {
//$("#eva_adjust_postponement_quota_limit").maskMoney('mask', limit);
limit_quota = limit_frame_quota * limit / 100;
$("#eva_adjust_postponement_quota_limit_quota").val(limit_quota);
//$("#eva_adjust_postponement_quota_limit_quota").maskMoney('mask', limit_quota);
//$("#eva_adjust_postponement_quota_limit_quota").val(Math.ceil(limit_quota/10)*10);
$("#eva_adjust_postponement_quota_limit_quota").maskMoney('mask', Math.ceil(limit_quota/10)*10);
CalculateRemainQuota();
}
function CalculateRemainQuota() {
console.log("xx");
//console.log("xx");
var sum_receive_quota = 0;
var limit_quota = parseFloat($("#eva_adjust_postponement_quota_limit_quota").val().replace(/[,-]/g,''));
@@ -170,8 +171,8 @@ console.log("xx");
var remain_quota = limit_quota - sum_receive_quota;
$("#remain_quota").val(remain_quota);
//$("#remain_quota").maskMoney('mask', remain_quota);
//$("#remain_quota").val(remain_quota);
$("#remain_quota").maskMoney('mask', remain_quota);
}

View File

@@ -16,7 +16,7 @@ $("#eva_create_evaluation_detail_agreement_chief_fullname").text(data.chief_full
$("#eva_create_evaluation_detail_agreement_chief_position").text(data.chief_position);
$("#eva_create_evaluation_detail_agreement_create_evaluation_id").val(data.create_evaluation_id);
$("#remark_hrm_work_record").val(data.remark_hrm_work_record);
$("#remark_hrm_work_record").text(data.remark_hrm_work_record);
status_self = data.status_self;
CheckPermission();

View File

@@ -50,7 +50,7 @@ DropDownClearFormAndFeedWithData($("#eva_create_evaluation_detail_process_org_id
$("#eva_create_evaluation_detail_process_search_employee_code").val(data.search_employee_code);
$("#eva_create_evaluation_detail_process_search_employee_fullname").val(data.search_employee_fullname);
$("#remark_hrm_work_record").val(data.remark_hrm_work_record);
$("#remark_hrm_work_record").text(data.remark_hrm_work_record);
searchVacation();

View File

@@ -28,6 +28,8 @@ var item_level_score;
function eva_create_evaluation_detail_process_FeedDataToForm(data) {
console.log(data);
$("#date_from").val(formatDate(data.start_date));
$("#date_to").val(formatDate(data.end_date));
@@ -47,7 +49,7 @@ DropDownClearFormAndFeedWithData($("#eva_create_evaluation_detail_process_org_id
$("#eva_create_evaluation_detail_process_search_employee_code").val(data.search_employee_code);
$("#eva_create_evaluation_detail_process_search_employee_fullname").val(data.search_employee_fullname);
$("#remark_hrm_work_record").val(data.remark_hrm_work_record);
$("#remark_hrm_work_record").text(data.remark_hrm_work_record);
searchVacation();
@@ -99,7 +101,7 @@ function eva_create_evaluation_detail_process_SetEditForm(a) {
endLoad();
};
startLoad();
console.log(apisite + eva_create_evaluation_detail_process_API + a+"/d2");
AjaxGetRequest(apisite + eva_create_evaluation_detail_process_API + a+"/d2", successFunc, AlertDanger);
}