public override void Run(HMOPremiumPayableLoanCmd request) { short planYear = request.m_NewMasterData.PlanYear; short payPeriodID = request.m_NewMasterData.PayRunID; var loan = p_Processor.Run(new GetLoanQr(LoanCodeConstants.HMOPremiumPayable)); var existingLoan = FindExistingLoan(request.m_NewMasterData, request.Loan); var employeeLoan = p_Processor.Run(new GetEmployeeLoanQr ( planYear, payPeriodID, request.m_NewMasterData.EmployeeID, LoanCodeConstants.HMOPremiumPayable )); MasterEmployeeLoanBO newComputedLoan = null; if (employeeLoan != null) { newComputedLoan = new MasterEmployeeLoanBO { LoanID = loan.LoanID, RecordStatus = RecordStatus.Active, ShortDesc = employeeLoan.N_EmployeeLoanRef.OvrdShortDesc ?? loan.ShortDesc, LongDesc = employeeLoan.N_EmployeeLoanRef.OvrdLongDesc ?? loan.LongDesc, AltDesc = employeeLoan.N_EmployeeLoanRef.OvrdAltDesc ?? loan.AltDesc, Amount = employeeLoan.Amount }; } if (HasChanges(existingLoan, newComputedLoan)) { request.m_NewMasterData.AddNewEmployeeLoan(newComputedLoan); } }
public override void Run(CalcBasicPayCmd request) { p_ProcessTracker.LogMessage("Calculate Basic Pay - Start"); var basicPayEarnRef = request.BasicPay; var basicPay = p_Processor.Run(new GetBasicPayQr ( request.m_NewMasterData.EmployeeID, request.m_NewMasterData.PlanYear, request.m_NewMasterData.PayRunID )); var earning = p_Processor.Run(new GetEarningQr(EarningCodeConstants.BasicPay)); var newCalcdEarning = new MasterEmployeeEarningBO { EarningID = earning.EarningID, Amount = basicPay.Amount, AmountBasis = basicPay.AmountBasis, IsAdjustIfAbsent = basicPayEarnRef.IsAdjustIfAbsent, IsComputed = basicPayEarnRef.IsComputed, IsDeMinimis = basicPayEarnRef.IsDeMinimis, IsNegativeComputation = basicPayEarnRef.IsNegativeComputation, IsPartOfBasicPay = basicPayEarnRef.IsPartOfBasicPay, IsReceivable = basicPayEarnRef.IsReceivable, IsTaxable = basicPayEarnRef.IsTaxable, ShortDesc = earning.ShortDesc, LongDesc = earning.LongDesc, AltDesc = earning.AltDesc }; var existingEarning = request.m_NewMasterData.MasterEmployeeEarnings .SingleOrDefault(a => a.EarningID == earning.EarningID); if (HasChanges(request.m_NewMasterData, existingEarning, newCalcdEarning)) { p_ProcessTracker.LogMessage("Calculate Basic Pay - Has Changes"); request.m_NewMasterData.AddNewEmployeeEarning(newCalcdEarning); } else { p_ProcessTracker.LogMessage("Calculate Basic Pay - No Change"); } p_ProcessTracker.LogMessage("Calculate Basic Pay - End"); }
public override PayRunBO Run(FindPayRunQr request) { var payRuns = p_TasqR.Run(new GetPayRunQr(request.PlanYear)); return(payRuns.Data .SingleOrDefault(a => a.PayRunID == request.PayRunID)); }
public override TableBO Run(GetSSSTableQr request) { CacheKey = $"SSSTable_{request.PlanYear}"; var table = p_MemoryCache.Get <TableBO>(CacheKey); var payRun = p_Processor.Run(new FindPayRunQr(request.PlanYear, request.PayRunID)); if (table == null) { var query = p_DbContext.Tables .AsNoTracking() .Include(a => a.N_Ranges) .ProjectTo <TableBO>(p_Mapper.ConfigurationProvider) .Where(a => a.Code == TableCodeConstants.SSS && (a.EffectiveStartOn < payRun.PayoutDate && payRun.PayoutDate < a.EffectiveEndOn)) .ToList(); if (query.Count > 1) { throw new AerishException("Multiple SSS table found"); } table = query.SingleOrDefault(); if (table == null) { throw new AerishException("SSS table not configured for this planyear"); } p_MemoryCache.Set(CacheKey, table); } return(table); }
public void CanHaveSameTasqRAndSameObjectInScope() { using (var serviceProvider = services.BuildServiceProvider()) { ITasqR tasqR1 = null; TrackMeInScope trackMe1 = null; ITasqR tasqR2 = null; TrackMeInScope trackMe2 = null; using (var scope = serviceProvider.CreateScope()) { var scopeSvc = scope.ServiceProvider; tasqR1 = scopeSvc.GetService <ITasqR>(); trackMe1 = scopeSvc.GetService <TrackMeInScope>(); var cmd = new DINestedCmd1(); var res = tasqR1.Run(cmd); Assert.AreEqual(tasqR1.ID, res[$"{nameof(DINestedCmd1Handler)}_{nameof(DINestedCmd1Handler.p_TasqR)}"]); Assert.AreEqual(tasqR1.ID, res[$"{nameof(DINestedCmd2Handler)}_{nameof(DINestedCmd2Handler.p_TasqR)}"]); Assert.AreEqual(tasqR1.ID, res[$"{nameof(DINestedCmd3Handler)}_{nameof(DINestedCmd3Handler.p_TasqR)}"]); Assert.AreEqual(trackMe1.ID, res[$"{nameof(DINestedCmd1Handler)}_{nameof(DINestedCmd1Handler.p_TrackMe)}"]); Assert.AreEqual(trackMe1.ID, res[$"{nameof(DINestedCmd2Handler)}_{nameof(DINestedCmd2Handler.p_TrackMe)}"]); Assert.AreEqual(trackMe1.ID, res[$"{nameof(DINestedCmd3Handler)}_{nameof(DINestedCmd3Handler.p_TrackMe)}"]); } using (var scope = serviceProvider.CreateScope()) { var scopeSvc = scope.ServiceProvider; tasqR2 = scopeSvc.GetService <ITasqR>(); trackMe2 = scopeSvc.GetService <TrackMeInScope>(); var cmd = new DINestedCmd1(); var res = tasqR2.Run(cmd); Assert.AreEqual(tasqR2.ID, res[$"{nameof(DINestedCmd1Handler)}_{nameof(DINestedCmd1Handler.p_TasqR)}"]); Assert.AreEqual(tasqR2.ID, res[$"{nameof(DINestedCmd2Handler)}_{nameof(DINestedCmd2Handler.p_TasqR)}"]); Assert.AreEqual(tasqR2.ID, res[$"{nameof(DINestedCmd3Handler)}_{nameof(DINestedCmd3Handler.p_TasqR)}"]); Assert.AreEqual(trackMe2.ID, res[$"{nameof(DINestedCmd1Handler)}_{nameof(DINestedCmd1Handler.p_TrackMe)}"]); Assert.AreEqual(trackMe2.ID, res[$"{nameof(DINestedCmd2Handler)}_{nameof(DINestedCmd2Handler.p_TrackMe)}"]); Assert.AreEqual(trackMe2.ID, res[$"{nameof(DINestedCmd3Handler)}_{nameof(DINestedCmd3Handler.p_TrackMe)}"]); } Assert.AreNotEqual(tasqR1.ID, tasqR2.ID); Assert.AreNotEqual(trackMe1.ID, trackMe2.ID); } }
public override void Run(ContributionDeductionCmd process) { short planYear = process.m_NewMasterData.PlanYear; short payRunID = process.m_NewMasterData.PayRunID; var ded = p_Processor.Run(new GetDeductionQr(DeductionCodeConstants.PhilHealth)); var existingPhilHealthDed = process.m_NewMasterData.MasterEmployeeDeductions .SingleOrDefault(a => a.DeductionID == ded.DeductionID); var philHealthTable = p_Processor.Run(new GetPhilHealthTableQr(planYear, payRunID)); var range = philHealthTable.Ranges .SingleOrDefault(a => a.Min < process.m_NewMasterData.MonthlyRate && process.m_NewMasterData.MonthlyRate < a.Max); var variables = new Dictionary <string, decimal> { ["Fixed"] = range.Fixed.GetValueOrDefault(), ["MonthlyBasicPay"] = process.m_NewMasterData.MonthlyRate.GetValueOrDefault(), ["Rate"] = range.Rate.GetValueOrDefault() }; var newComputedDeduction = new MasterEmployeeDeductionBO { DeductionID = ded.DeductionID, RecordStatus = RecordStatus.Active, EmployeeAmount = FormulaHelper.Calculate(range.EmployeeFormula, variables), EmployerAmount = FormulaHelper.Calculate(range.EmployerFormula, variables), ShortDesc = ded.ShortDesc, LongDesc = ded.LongDesc, AltDesc = ded.AltDesc }; if (HasChanges(existingPhilHealthDed, newComputedDeduction)) { process.m_NewMasterData.AddNewEmployeeDeduction(newComputedDeduction); } }
public override void Run(ContributionDeductionCmd request) { short planYear = request.m_NewMasterData.PlanYear; short payPeriodID = request.m_NewMasterData.PayRunID; var ded = p_Processor.Run(new GetDeductionQr(DeductionCodeConstants.SSS)); var existingSSSDed = request.m_NewMasterData.MasterEmployeeDeductions .SingleOrDefault(a => a.DeductionID == ded.DeductionID); var cmd = new GetSSSTableQr(request.m_NewMasterData.PlanYear, request.m_NewMasterData.PayRunID); var sssTable = p_Processor.Run(cmd); var range = sssTable.Ranges .SingleOrDefault(a => a.Min < request.m_NewMasterData.MonthlyRate && request.m_NewMasterData.MonthlyRate < a.Max); var variables = new Dictionary <string, decimal>(); variables["Fixed"] = range.Fixed.GetValueOrDefault(); variables["MonthlyBasicPay"] = request.m_NewMasterData.MonthlyRate.GetValueOrDefault(); variables["Rate"] = range.Rate.GetValueOrDefault(); var newComputedDeduction = new MasterEmployeeDeductionBO { DeductionID = ded.DeductionID, RecordStatus = RecordStatus.Active, EmployeeAmount = FormulaHelper.Calculate(range.EmployeeFormula, variables), EmployerAmount = FormulaHelper.Calculate(range.EmployerFormula, variables), ShortDesc = ded.ShortDesc, LongDesc = ded.LongDesc, AltDesc = ded.AltDesc }; if (HasChanges(existingSSSDed, newComputedDeduction)) { request.m_NewMasterData.AddNewEmployeeDeduction(newComputedDeduction); } }
public override EarningBO Run(GetEarningQr request) { var earnings = p_Processor.Run(new GetEarningListQr()); var earning = earnings .Where(a => a.Code == request.EarningCode && ( (a.ClientID == p_AppSession.ClientID && a.IsEnabled) || a.ClientID == ClientConstant.Default ) ) .OrderByDescending(a => a.ClientID); return(earning.FirstOrDefault()); }
public override Dictionary <string, Guid> Run(DINestedCmd2 request) { Dictionary <string, Guid> retVal = new Dictionary <string, Guid>(); var data = p_TasqR.Run(new DINestedCmd3()); retVal[$"{nameof(DINestedCmd2Handler)}_{nameof(p_TasqR)}"] = p_TasqR.ID; retVal[$"{nameof(DINestedCmd2Handler)}_{nameof(p_TrackMe)}"] = p_TrackMe.ID; foreach (var key in data.Keys) { retVal[key] = data[key]; } return(retVal); }
public override DeductionBO Run(GetDeductionQr process) { var deductions = p_Processor.Run(new GetDeductionListQr(process.ClientSpecific)); var deduction = deductions.Where(a => a.Code == process.DeductionCode); if (deduction.Count() > 1) { throw new AerishMultipleObjectFoundException <DeductionBO>(process.DeductionCode); } if (deduction.Count() == 0) { throw new AerishObjectNotFoundException <DeductionBO>(process.DeductionCode); } return(deduction.Single()); }
public override EmployeeLoan Run(GetEmployeeLoanQr process) { var loan = p_Processor.Run(new GetLoanQr(process.p_LoanCode)); var empLoan = p_DbContext.EmployeeLoans .Include(a => a.N_EmployeeLoanRef) .Where(a => a.EmployeeID == process.p_EmployeeID && a.LoanID == loan.LoanID && a.PlanYear == process.p_PlanYear && a.PayRunID == process.p_PayRunID); if (empLoan.Count() > 1) { throw new AerishMultipleObjectFoundException <EmployeeLoan>(process.p_LoanCode); } return(empLoan.SingleOrDefault()); }
public override LoanBO Run(GetLoanQr request) { var loans = p_Processor.Run(new GetLoanListQr(request.ClientSpecific)); var loan = loans.Where(a => a.Code == request.LoanCode); if (loan.Count() > 1) { throw new AerishMultipleObjectFoundException <Loan>(request.LoanCode); } if (loan.Count() == 0) { throw new AerishObjectNotFoundException <Loan>(request.LoanCode); } return(loan.Single()); }
public async override Task <LoginResultVM> RunAsync(ValidateUserLoginCmd process, CancellationToken cancellationToken = default) { try { string firebaseToken = p_TasqR.Run(new FindMyFirebaseTokenQr()); var loginRequest = new LoginRequestVM { Username = process.Username, Password = process.Password, FirebaseToken = firebaseToken }; var httpResponse = await p_HttpClient.PostAsync <UserSessionBO, LoginRequestVM>(APIUriConstants.AccessToken, loginRequest, cancellationToken); if (!httpResponse.IsSuccessStatusCode) { throw new LynxException(httpResponse.StringContent); } var dbUserSession = new UserSession { UserID = httpResponse.ObjectContent.UserData.ID, Token = httpResponse.ObjectContent.Token }; p_UserSessionDbSet.Add(dbUserSession); p_BaseDbContext.SaveChanges(); return(new LoginResultVM { IsSuccess = true }); } catch (Exception ex) { p_ExceptionHandler.LogError(ex); return(new LoginResultVM { IsSuccess = false, Error = ex.InnermostException() }); } }
public async override Task <UserSessionBO> RunAsync(GetActiveUserSessionQr request, CancellationToken cancellationToken = default) { string firebaseToken = p_TasqR.Run(new FindMyFirebaseTokenQr()); var verifResult = await p_LynxAPI.PostAsync <TokenVerificationResult, string> ( "/AccessToken/VerifyValidity", firebaseToken, cancellationToken ); if (verifResult.ObjectContent.TokenStatus != TokenStatus.Active) { return(null); } var token = await p_TasqR.RunAsync(new GetTokenCmd(p_AppUser.UserID)); return(token); }
public override void Run(ContributionDeductionCmd request) { var ded = p_Processor.Run(new GetDeductionQr(DeductionCodeConstants.PagIBIG)); var existingDeduction = request.m_NewMasterData.MasterEmployeeDeductions .SingleOrDefault(a => a.DeductionID == ded.DeductionID); var newComputedDeduction = new MasterEmployeeDeductionBO { DeductionID = ded.DeductionID, RecordStatus = RecordStatus.Active, EmployeeAmount = 100, ShortDesc = ded.ShortDesc, LongDesc = ded.LongDesc, AltDesc = ded.AltDesc }; if (HasChanges(existingDeduction, newComputedDeduction)) { request.m_NewMasterData.AddNewEmployeeDeduction(newComputedDeduction); } }
public override void Run(OtherDeductionCmd process) { var ded = p_Processor.Run(new GetDeductionQr(DeductionCodeConstants.Others)); var empDeduction = p_DbContext.EmployeeDeductionRefs .AsNoTracking() .Include(a => a.N_EmployeeDeductions.Where(b => b.PlanYear == process.m_NewMasterData.PlanYear && b.PayRunID == process.m_NewMasterData.PayRunID)) .Include(a => a.N_Deduction) .SingleOrDefault(a => a.DeductionID == ded.DeductionID && a.ClientID == p_AppSession.ClientID && a.EmployeeID == process.m_NewMasterData.EmployeeID); if (empDeduction == null) { return; } var deduction = empDeduction.N_EmployeeDeductions .Select(a => new MasterEmployeeDeductionBO { DeductionID = empDeduction.DeductionID, ShortDesc = empDeduction.OvrdShortDesc ?? empDeduction.N_Deduction.ShortDesc, LongDesc = empDeduction.OvrdLongDesc ?? empDeduction.N_Deduction.LongDesc, AltDesc = empDeduction.OvrdAltDesc ?? empDeduction.N_Deduction.AltDesc, EmployeeAmount = a.Amount, RecordStatus = RecordStatus.Active }) .SingleOrDefault(); var existingDeduction = process.m_NewMasterData.MasterEmployeeDeductions .SingleOrDefault(a => a.DeductionID == ded.DeductionID); if (HasChanges(existingDeduction, deduction)) { process.m_NewMasterData.AddNewEmployeeDeduction(deduction); } }
public override void Run(CalcRatesCmd request) { var earning = p_Processor.Run(new GetEarningQr(EarningCodeConstants.BasicPay)); var basicPay = request.m_NewMasterData.MasterEmployeeEarnings .SingleOrDefault(a => a.EarningID == earning.EarningID); if (basicPay == null) { throw new AerishException("No basic pay configured?"); } switch (basicPay.AmountBasis) { case AmountBasis.Monthly: ComputeAsMonthly(request.m_NewMasterData, basicPay); break; case AmountBasis.SemiMontly: break; case AmountBasis.BiWeekly: ComputeAsBiWeekly(request.m_NewMasterData, basicPay); break; case AmountBasis.Weekly: break; case AmountBasis.Daily: break; case AmountBasis.Hourly: break; default: break; } }
public override bool Run(int key, MainCalcCmd request) { short planYear = p_ProcessTracker.PlanYear.GetValueOrDefault(); short payPeriodID = p_ProcessTracker.PayRunID.GetValueOrDefault(); bool isSuccess = false; try { p_PayPeriod = p_Processor.Run(new FindPayRunQr(planYear, payPeriodID)); if (p_PayPeriod == null) { throw new AerishException($"Invalid pay period ({planYear} - {payPeriodID}) for client: {p_AppSession.ClientID}"); } p_OldMasterData = p_Processor.Run(new GetPreviousMasterDataQr(p_PayPeriod.PlanYear, p_PayPeriod.PayRunID, key)); if (p_OldMasterData != null) { p_NewMasterData = CopyToNewCalc(p_OldMasterData, p_PayPeriod); } else { p_ProcessTracker.LogMessage("No existing records"); p_NewMasterData = new MasterDataBO { EmployeeID = key, ClientID = p_AppSession.ClientID, RecordStatus = RecordStatus.ModelledActive, }; } p_NewMasterData.ClearTracker(); p_NewMasterData.PlanYear = p_PayPeriod.PlanYear; p_NewMasterData.PayRunID = p_PayPeriod.PayRunID; CalcLastCalcID(); CalcBasicPay(); CalcDaysFactor(); CalcRates(); ValidateParameters(); CalcDeductions(); CalcLoans(); CalcEarnings(); CalcTotalTaxableIncome(); CalcTotalNonTaxableIncome(); CalcNetTaxableIncome(); CalcWitholdingTax(); CalcTotalDeduction(); CalcNetSalary(); if (p_NewMasterData.HasChanges()) { if (p_OldMasterData != null) { MarkOldCalcAsFrozen(p_OldMasterData); } p_NewMasterData.RecordStatus = RecordStatus.Active; var newMasterData = p_Mapper.Map <MasterDataBO, MasterEmployee>(p_NewMasterData); p_DbContext.MasterEmployees.Add(newMasterData); p_ProcessTracker.SaveContext = true; } else { p_ProcessTracker.SaveContext = false; } isSuccess = true; } catch (Exception ex) { p_ProcessTracker.LogError(ex); isSuccess = false; } return(isSuccess); }
public override JobBO Run(FindJobQr request) { var jobs = processor.Run(new GetJobsQr()); return(jobs.SingleOrDefault(a => a.JobID == request.JobID)); }
public override IProcessTrackerBase Run(MasterProcessCmd request) { var jobTracker = p_Processor.Run(new GetNewJobInstanceCmd()); var job = p_Processor.Run(new FindJobQr(request.JobID)); if (job == null) { throw new AerishNullReferenceException("Job", request.JobID); } foreach (var jobParams in job.JobParameters) { var paramDic = request.Parameters[jobParams.Name]; if (paramDic != null) { paramDic.DataType = jobParams.DataType; paramDic.IsRequired = jobParams.IsRequired; paramDic.MaxLength = jobParams.MaxLength; } } jobTracker.AttachJob(job, request.Parameters); jobTracker.JobStarted(); try { var handlerProvider = job.TaskHandlerProvider; var assembly = Assembly.Load(assemblyString: handlerProvider.TaskAssembly); var type = assembly.GetType(handlerProvider.TaskClass); var instance = (ITasq)Activator.CreateInstance(type, args: new object[] { jobTracker }); if (handlerProvider.IsDefaultHandler) { p_Processor.Run(instance); } else { var assemblyH = Assembly.Load(assemblyString: handlerProvider.HandlerAssembly); var typeH = assemblyH.GetType(name: handlerProvider.HandlerClass); p_Processor.UsingAsHandler(typeH).Run(instance); } if (jobTracker.SaveContext == true) { p_BaseDbContext.SaveChanges(); } } catch (Exception ex) { jobTracker.LogError(ex.InnermostException()); } jobTracker.JobEnded(); return(jobTracker); }
public override int Run(NestedCommandWithReturn process) { int firstResult = process.StartNumber + 1; return(p_TasqR.Run(new CommandWithReturn(firstResult))); }