เสร็จงานอนุมัติ ปรับเลื่อนเงินเดือน และ โควต้า

This commit is contained in:
nakorn
2022-05-06 07:54:55 +07:00
parent bfb9c80fac
commit ccef30e588
15 changed files with 146 additions and 19 deletions

View File

@@ -23,6 +23,8 @@ namespace TodoAPI2.Models
rep_eva_savemessageReportRequestModel setModelFor_rep_eva_savemessageReport(rep_eva_savemessageReportRequestModel model);
DataContext GetContext();
void updateAllpostponement(int id);
}
}

View File

@@ -70,6 +70,39 @@ namespace TodoAPI2.Models
return GetDto(entity);
}
private string isStringNull(string a, string b)
{
if (!string.IsNullOrEmpty(a)) return a;
else return b;
}
private T isNull<T>(T a, T b)
{
if (a != null) return a;
else return b;
}
public void updateAllpostponement(int id)
{
var entity = _repository.Get(id);
var postponement = from x in _repository.Context.eva_adjust_postponement
where x.fiscal_year == entity.fiscal_year
&& x.theRound == entity.theRound
&& x.id != entity.id
select x;
foreach(var i in postponement)
{
//i.postponement_status = entity.postponement_status;
i.quota_status = entity.quota_status;
i.quota_final_status = entity.quota_final_status;
}
_repository.Context.SaveChanges();
}
public eva_adjust_postponement_quotaWithSelectionViewModel GetWithSelection(int id)
{
var entity = _repository.Get(id);
@@ -84,6 +117,19 @@ namespace TodoAPI2.Models
select new external_linkageViewModel { external_id = x.theRound, external_name = x.theRound.ToString() }
).Distinct().OrderByDescending(x => x.external_id).ToList();
var postponement = from x in _repository.Context.eva_adjust_postponement
join e in emp.GetAllEmployee() on isNull(x.managed_by, x.postponement_status_by) equals e.id
join v in ext.GetAgreeDisagree4() on isStringNull(x.postponement_status, "W") equals v.external_code
join c in _repository.Context.eva_create_evaluation on x.create_evaluation_id equals c.id
join d in _repository.Context.eva_evaluation_group on c.evaluation_group_id equals d.id
where x.fiscal_year == entity.fiscal_year
&& x.theRound == entity.theRound
&& x.id != entity.id
select d.thegroup + " โดย " + e.fullname + " " + v.external_name;
i.approve_status = postponement.ToList();
return i;
}
public eva_adjust_postponement_quotaWithSelectionViewModel GetBlankItem()

View File

@@ -10,5 +10,7 @@ namespace TodoAPI2.Models
public List<external_employeeViewModel> item_managed_by { get; set; }
public List<external_linkageViewModel> item_fiscal_year_search { get; set; }
public List<external_linkageViewModel> item_theRound_search { get; set; }
public List<string> approve_status { get; set; }
}
}
}

View File

@@ -23,18 +23,20 @@ namespace TodoAPI2.Models
private IMyDatabase db;
private Iexternal_linkageService ext;
private Iexternal_employeeService emp;
private Ieva_adjust_postponement_quotaService quotaStatus;
public eva_adjust_postponement_update_statusService(
IBaseRepository2<eva_adjust_postponementEntity, int> repository,
IMyDatabase mydb,
Iexternal_linkageService inext,
Iexternal_employeeService inemp
Iexternal_employeeService inemp,
Ieva_adjust_postponement_quotaService inquotaStatus
)
{
_repository = repository;
db = mydb;
ext = inext;
emp = inemp;
quotaStatus = inquotaStatus;
}
#region Private Functions
@@ -183,6 +185,9 @@ namespace TodoAPI2.Models
existingEntity.postponement_status_note = model.postponement_status_note;
var updated = _repository.Update(id, existingEntity);
//quotaStatus.updateAllpostponement(id);
return Get(updated.id);
}
else

View File

@@ -23,15 +23,18 @@ namespace TodoAPI2.Models
private IMyDatabase db;
private Iexternal_linkageService ext;
private Iexternal_employeeService emp;
private Ieva_adjust_postponement_quotaService quotaStatus;
public eva_adjust_quota_update_final_statusService(IBaseRepository2<eva_adjust_postponementEntity, int> repository,
IMyDatabase mydb, Iexternal_linkageService inext,
Iexternal_employeeService inemp)
Iexternal_employeeService inemp,
Ieva_adjust_postponement_quotaService inquotaStatus)
{
_repository = repository;
db = mydb;
ext = inext;
emp = inemp;
quotaStatus = inquotaStatus;
}
#region Private Functions
@@ -164,13 +167,18 @@ namespace TodoAPI2.Models
return newkey.Value;
}
public eva_adjust_quota_update_final_statusViewModel Update(int id,
eva_adjust_quota_update_final_statusInputModel model, bool is_force_save, int? updateby)
{
var existingEntity = _repository.Get(id);
if (existingEntity != null)
{
if(model.quota_final_status == "Y" && existingEntity.quota_status != "Y")
{
throw new Exception("ผู้อนุมัติวงเงินที่กันไว้ คนแรก, ยังไม่ได้อนุมัติ วงเงินที่กันไว้");
}
existingEntity.quota_final_status = model.quota_final_status;
existingEntity.quota_final_status_date = DateTime.Now;
existingEntity.quota_final_status_by = updateby;
@@ -183,6 +191,9 @@ namespace TodoAPI2.Models
}
var updated = _repository.Update(id, existingEntity);
quotaStatus.updateAllpostponement(id);
return Get(updated.id);
}
else

View File

@@ -23,16 +23,19 @@ namespace TodoAPI2.Models
private IMyDatabase db;
private Iexternal_linkageService ext;
private Iexternal_employeeService emp;
private Ieva_adjust_postponement_quotaService quotaStatus;
public eva_adjust_quota_update_statusService(IBaseRepository2<eva_adjust_postponementEntity, int> repository,
IMyDatabase mydb,
Iexternal_linkageService inext,
Iexternal_employeeService inemp)
Iexternal_employeeService inemp,
Ieva_adjust_postponement_quotaService inquotaStatus)
{
_repository = repository;
db = mydb;
ext = inext;
emp = inemp;
quotaStatus = inquotaStatus;
}
#region Private Functions
@@ -165,12 +168,26 @@ namespace TodoAPI2.Models
return newkey.Value;
}
public eva_adjust_quota_update_statusViewModel Update(int id, eva_adjust_quota_update_statusInputModel model, bool is_force_save, int? updateby)
{
var existingEntity = _repository.Get(id);
if (existingEntity != null)
{
if (model.quota_status == "Y")
{
var postponement = from x in _repository.Context.eva_adjust_postponement
where x.fiscal_year == existingEntity.fiscal_year
&& x.theRound == existingEntity.theRound
&& x.id != existingEntity.id
&& x.postponement_status != "Y"
select x;
if (postponement.Count() > 0)
{
throw new Exception("ยังมีบางหน่วยงาน ยังไม่ได้อนุมัติ ปรับเลื่อนค่าตอบแทน");
}
}
existingEntity.quota_status = model.quota_status;
existingEntity.quota_status_date = DateTime.Now;
existingEntity.quota_status_by = updateby;
@@ -184,6 +201,9 @@ namespace TodoAPI2.Models
}
var updated = _repository.Update(id, existingEntity);
quotaStatus.updateAllpostponement(id);
return Get(updated.id);
}
else

View File

@@ -454,6 +454,9 @@ namespace TodoAPI2.Models
|| ((m_eva_create_evaluation_detail_process.supervisor1_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor1_id : fk_eva_create_evaluationResult10.supervisor1_id).HasValue && emp_id == (m_eva_create_evaluation_detail_process.supervisor1_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor1_id : fk_eva_create_evaluationResult10.supervisor1_id))
|| ((m_eva_create_evaluation_detail_process.supervisor2_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor2_id : fk_eva_create_evaluationResult10.supervisor2_id).HasValue && emp_id == (m_eva_create_evaluation_detail_process.supervisor2_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor2_id : fk_eva_create_evaluationResult10.supervisor2_id))
|| ((int?[])special_person).Contains(emp_id)
|| ((m_eva_create_evaluation_detail_process.supervisor3_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor3_id : fk_eva_create_evaluationResult10.supervisor3_id).HasValue && emp_id == (m_eva_create_evaluation_detail_process.supervisor3_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor3_id : fk_eva_create_evaluationResult10.supervisor3_id))
)
&& (!model.employee_id.HasValue || m_eva_create_evaluation_detail_process.employee_id == model.employee_id)