From 792277e83bc7d0892c1fb5a12156b6ca3598e246 Mon Sep 17 00:00:00 2001 From: chapal Date: Thu, 9 Jan 2025 12:03:52 +0600 Subject: [PATCH] Prod validation --- HRM.BO/Salary/SalaryProcess.cs | 2 +- HRM.DA/DA/Salary/SalaryProcessDA.cs | 11 +++- HRM.DA/Service/Salary/SalaryProcessService.cs | 25 ++++++++ .../app/_services/payroll/salary.service.ts | 4 +- ...production-bonus-attendance.component.html | 4 +- .../production-bonus-attendance.component.ts | 51 ++++++++++++++-- .../production-bonus-setup.component.html | 2 +- .../production-bonus-setup.component.ts | 58 +++++++++++++++++-- .../Controllers/Payroll/SalaryController.cs | 21 +++++++ 9 files changed, 162 insertions(+), 16 deletions(-) diff --git a/HRM.BO/Salary/SalaryProcess.cs b/HRM.BO/Salary/SalaryProcess.cs index f9c7f68..ee1525c 100644 --- a/HRM.BO/Salary/SalaryProcess.cs +++ b/HRM.BO/Salary/SalaryProcess.cs @@ -383,7 +383,7 @@ namespace HRM.BO List SalaryProcess(SalaryProcess item, List employees); int Save(SalaryProcess item); void Delete(int id); - + bool IsSalaryprocessed(DateTime salarymonth, int payrollTypeID); void UndoSalary(int id); void UndoMonthlySalaryByIDs(string ids); void UndoMonthlySalaryByEmpIDs(string ids, DateTime salaryMonth); diff --git a/HRM.DA/DA/Salary/SalaryProcessDA.cs b/HRM.DA/DA/Salary/SalaryProcessDA.cs index 398aaad..271602f 100644 --- a/HRM.DA/DA/Salary/SalaryProcessDA.cs +++ b/HRM.DA/DA/Salary/SalaryProcessDA.cs @@ -114,7 +114,16 @@ namespace HRM.DA return bShowInDesktop; } - + internal static bool IsSalaryprocessed(TransactionContext tc, DateTime dSMonth, int payrollTypeID) + { + bool bShowInDesktop = false; + object obj = + tc.ExecuteScalar("Select SALARYPROCESSID from SALARYPROCESS where SALARYMONTH=%d AND PAYROLLTYPEID=%n", + dSMonth, payrollTypeID); + if (obj == DBNull.Value) return false; + else bShowInDesktop=true; + return bShowInDesktop; + } #endregion #region Delete function diff --git a/HRM.DA/Service/Salary/SalaryProcessService.cs b/HRM.DA/Service/Salary/SalaryProcessService.cs index 138a883..2f3eddd 100644 --- a/HRM.DA/Service/Salary/SalaryProcessService.cs +++ b/HRM.DA/Service/Salary/SalaryProcessService.cs @@ -978,6 +978,31 @@ namespace HRM.DA return bShowInDesktop; } + public bool IsSalaryprocessed(DateTime dSalaryMonth, int payrollTypeID) + { + TransactionContext tc = null; + bool isSalaryprocessed; + try + { + tc = TransactionContext.Begin(); + isSalaryprocessed = SalaryProcessDA.IsSalaryprocessed(tc, dSalaryMonth, payrollTypeID); + tc.End(); + } + catch (Exception e) + { + #region Handle Exception + + if (tc != null) + tc.HandleError(); + ExceptionLog.Write(e); + throw new ServiceException(e.Message, e); + + #endregion + } + + return isSalaryprocessed; + } + public List GetAllProcess(int payrollTypeID, DateTime nextPayProcessDate) { List salaryProcesss = new List(); diff --git a/HRM.UI/ClientApp/src/app/_services/payroll/salary.service.ts b/HRM.UI/ClientApp/src/app/_services/payroll/salary.service.ts index 75b15b2..6719ec3 100644 --- a/HRM.UI/ClientApp/src/app/_services/payroll/salary.service.ts +++ b/HRM.UI/ClientApp/src/app/_services/payroll/salary.service.ts @@ -238,5 +238,7 @@ export class SalaryService { DownloadPayslipForMultiple(param: any): Observable> { return this.apiService.httpPost('/salary/DownloadPayslipForMultiple', param); } - + IsSalaryProcessed(salaryMonth: Date) { + return this.apiService.httpGet('/salary' + '/IsSalaryprocessedMonthly' + '/' + salaryMonth.toDateString()); + } } diff --git a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-attendance/production-bonus-attendance.component.html b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-attendance/production-bonus-attendance.component.html index f53ca56..8a3c105 100644 --- a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-attendance/production-bonus-attendance.component.html +++ b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-attendance/production-bonus-attendance.component.html @@ -136,6 +136,6 @@
- +
- \ No newline at end of file + diff --git a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-attendance/production-bonus-attendance.component.ts b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-attendance/production-bonus-attendance.component.ts index af4613f..d7f0f6d 100644 --- a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-attendance/production-bonus-attendance.component.ts +++ b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-attendance/production-bonus-attendance.component.ts @@ -20,6 +20,9 @@ import { EnumBonusItemType, EnumProductionBonusType } from 'src/app/_models/enum import { ProdBonusParameter } from 'src/app/_models/Payroll/ProductionBonus/prodBonusParameter'; import { error } from 'console'; import { GridComponent } from '@progress/kendo-angular-grid'; +import { AuthService } from '../../_services/auth/auth.service'; +import { SalaryService } from '../../_services/payroll/salary.service'; +import { PayrollType } from '../../_models/Authentication/payrollType'; @Component({ @@ -63,7 +66,11 @@ export class ProductionBonusAttendanceComponent implements OnInit { employeeSelection: string = 'commonEmployee'; employeeList: Employee[] = []; - allEmps: any[] = []; + allEmps: any[] = []; + isprevious: boolean = false; + iSalaryProcesed: boolean = false; + salaryMonth: Date = new Date(); + payrollType: PayrollType; value: ''; @@ -72,7 +79,9 @@ export class ProductionBonusAttendanceComponent implements OnInit { public dataTransferService: DataTransferService, public WindowPopUp: AppWindowPopUp, public loadingPanelService: loadingPanelService, - public employeeService: EmployeeServices, + public employeeService: EmployeeServices, + public authservice: AuthService, + public salaryService: SalaryService, public bonusService: BonusService) { this.apiService.selectedMenuName = 'Production Bonus Attendance'; this._departmentPicker = new DynamicPicker(EnumDynamicpickerType.Department, false); @@ -80,7 +89,17 @@ export class ProductionBonusAttendanceComponent implements OnInit { ngOnInit(): void { - // this.Loadlayout(); + // this.Loadlayout(); + this.authservice.GetPayrollTypeByLoginID().subscribe( + (resp: any) => { + this.payrollType = resp; + }, + (err: any) => { + }, + () => { + this.salaryMonth = new Date(this.payrollType.nextPayProcessDate); + } + ); this.GetAllEmployees(); this.productionBonusSetup = new ProductionBonusSetup(); this.showScheduleDate = false; @@ -117,7 +136,31 @@ export class ProductionBonusAttendanceComponent implements OnInit { } Loadlayout() { this.clear(); - debugger; + debugger; + this.loadingPanelService.ShowLoadingPanel = true; + this.salaryService.IsSalaryProcessed(new Date(this.payrollType.nextPayProcessDate)).subscribe( + (resp: any) => { + this.iSalaryProcesed = resp; + }, + (err: any) => { + this.loadingPanelService.ShowLoadingPanel = false; + this.notificationService.showError(err.error); + + }, + () => { + + this.loadingPanelService.ShowLoadingPanel = false; + + if (new Date(this.selectedSalaryDate) <= new Date(this.payrollType.lastPayProcessDate) || + (new Date(this.selectedSalaryDate) > new Date(this.payrollType.lastPayProcessDate) && + new Date(this.payrollType.nextPayProcessDate) >= new Date(this.selectedSalaryDate) && this.iSalaryProcesed)) { + this.isprevious = true; + } + else { + this.isprevious = false; + } + + }); const data = { createdDate: this.selectedSalaryDate } diff --git a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html index 005413c..8792721 100644 --- a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html +++ b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html @@ -130,7 +130,7 @@
- +
diff --git a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.ts b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.ts index dc856d9..d031d1d 100644 --- a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.ts +++ b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.ts @@ -29,6 +29,9 @@ import { process, State } from '@progress/kendo-data-query'; import { DataStateChangeEvent } from '@progress/kendo-angular-grid'; import { noUndefined } from '@angular/compiler/src/util'; import { EnumStatus } from '../../_models/enums'; +import { AuthService } from '../../_services/auth/auth.service'; +import { PayrollType } from '../../_models/Authentication/payrollType'; +import { SalaryService } from '../../_services/payroll/salary.service'; @@ -46,7 +49,9 @@ export class ProductionBonusSetupComponent implements OnInit { public WindowPopUp: AppWindowPopUp, public loadingPanelService: loadingPanelService, public employeeService: EmployeeServices, - public bonusService: BonusService, + public bonusService: BonusService, + public authservice: AuthService, + public salaryService: SalaryService, public datePipe: DatePipe) { this.apiService.selectedMenuName = 'Production Bonus Setup'; this._departmentPicker = new DynamicPicker(EnumDynamicpickerType.Department, false); @@ -69,7 +74,11 @@ export class ProductionBonusSetupComponent implements OnInit { prodBonusWork: ProdBonusWorkSchedule; //Child-level 2 prodBonusSupervisor: ProdBonusSupervisor; - prodBonusParameter: ProdBonusParameter; + prodBonusParameter: ProdBonusParameter; + isprevious: boolean = false; + iSalaryProcesed: boolean = false; + salaryMonth: Date = new Date(); + payrollType: PayrollType; prodBonusAttn: ProdBonusAttn[]; depts: Department[] = []; @@ -119,12 +128,23 @@ export class ProductionBonusSetupComponent implements OnInit { // { text: "Large", value: 3 }, // ]; - ngOnInit(): void { + ngOnInit(): void { + this.productionBonusSetup = new ProductionBonusSetup(); this.prodBonusLine = new ProdBonusLine(); this.prodBonusSupervisor = new ProdBonusSupervisor(); this.prodBonusParameter = new ProdBonusParameter(); - this.prodBonusWork = new ProdBonusWorkSchedule(); + this.prodBonusWork = new ProdBonusWorkSchedule(); + this.authservice.GetPayrollTypeByLoginID().subscribe( + (resp: any) => { + this.payrollType = resp; + }, + (err: any) => { + }, + () => { + this.salaryMonth = new Date(this.payrollType.nextPayProcessDate); + } + ); this.getBonusType(); @@ -174,8 +194,34 @@ export class ProductionBonusSetupComponent implements OnInit { Loadlayout() { this.selectedProdBSdata = undefined; - debugger; - const data = { + debugger; + this.loadingPanelService.ShowLoadingPanel = true; + this.salaryService.IsSalaryProcessed(new Date(this.payrollType.nextPayProcessDate)).subscribe( + (resp: any) => { + this.iSalaryProcesed = resp; + }, + (err: any) => { + this.loadingPanelService.ShowLoadingPanel = false; + this.notificationService.showError(err.error); + + }, + () => { + + this.loadingPanelService.ShowLoadingPanel = false; + + if (new Date(this.selectedSalaryDate) <= new Date(this.payrollType.lastPayProcessDate) || + (new Date(this.selectedSalaryDate) > new Date(this.payrollType.lastPayProcessDate) && + new Date(this.payrollType.nextPayProcessDate) >= new Date(this.selectedSalaryDate) && this.iSalaryProcesed)) { + this.isprevious = true; + } + else { + this.isprevious = false; + } + + }); + + + const data = { createdDate: this.selectedSalaryDate } this.loadingPanelService.ShowLoadingPanel = true; diff --git a/HRM.UI/Controllers/Payroll/SalaryController.cs b/HRM.UI/Controllers/Payroll/SalaryController.cs index 3574339..8ea3698 100644 --- a/HRM.UI/Controllers/Payroll/SalaryController.cs +++ b/HRM.UI/Controllers/Payroll/SalaryController.cs @@ -956,6 +956,27 @@ namespace HRM.UI.Controllers.Payroll return Ok(); } + [HttpGet] + [Route("IsSalaryprocessedMonthly/{salarymonth}")] + public ActionResult IsSalaryprocessedMonthly(string salarymonth) + { + bool isSalaryprocessed = false; + DateTime month=Convert.ToDateTime(salarymonth); + + CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); + try + { + + isSalaryprocessed= _salaryProcessService.IsSalaryprocessed(month, (int)currentUser.PayrollTypeID); + } + catch (Exception e) + { + return StatusCode(StatusCodes.Status500InternalServerError, e.Message); + } + + return Ok(isSalaryprocessed); + } + [HttpPost] [Route("salaryProcessApprove")] public ActionResult SalaryProcessApprove(SalaryProcess process)