protected virtual MasterDataBO CopyToNewCalc(MasterDataBO oldData, PayRunBO payPeriod) { string json = JsonSerializer.Serialize(oldData); var result = JsonSerializer.Deserialize <MasterDataBO>(json); result.PlanYear = payPeriod.PlanYear; result.PayRunID = payPeriod.PayRunID; result.MasterEmployeeDeductions.ToList() .ForEach(a => { a.MasterEmployeeDeductionID = 0; a.PlanYear = payPeriod.PlanYear; a.PayRunID = payPeriod.PayRunID; }); result.MasterEmployeeEarnings.ToList() .ForEach(a => { a.MasterEmployeeEarningID = 0; a.PlanYear = payPeriod.PlanYear; a.PayRunID = payPeriod.PayRunID; }); return(result); }
protected BaseCalculationCommand(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, object reference) : base(processTracker) { m_OldMasterData = oldMasterData; m_NewMasterData = newMasterData; m_Reference = reference; }
public virtual void ComputeAsBiWeekly(MasterDataBO masterData, MasterEmployeeEarningBO basicPay) { decimal days = masterData.DaysFactor.GetValueOrDefault() / 12; masterData.BasicPayBasis = basicPay.AmountBasis; masterData.MonthlyRate = basicPay.Amount; masterData.DailyRate = basicPay.Amount / days; }
protected virtual void MarkOldCalcAsFrozen(MasterDataBO oldCalc) { var oldCalcData = p_DbContext.MasterEmployees .SingleOrDefault(a => a.ClientID == oldCalc.ClientID && a.CalcID == oldCalc.CalcID && a.EmployeeID == oldCalc.EmployeeID && a.PlanYear == oldCalc.PlanYear && a.PayRunID == oldCalc.PayRunID); if (oldCalcData != null) { oldCalcData.RecordStatus = RecordStatus.Frozen; } }
protected virtual bool HasChanges(MasterDataBO newMasterData, MasterEmployeeEarningBO oldEarn, MasterEmployeeEarningBO basicEarn) { if (oldEarn == null) { return(basicEarn != null); } if (newMasterData.MonthlyRate != basicEarn.Amount && basicEarn.Amount > 0) { return(true); } if (newMasterData.BasicPayBasis != basicEarn.AmountBasis) { return(true); } return(false); }
protected virtual MasterEmployeeLoanBO FindExistingLoan(MasterDataBO newMasterData, LoanBO loanReference) { return(newMasterData.MasterEmployeeLoans .SingleOrDefault(a => a.LoanID == loanReference.LoanID)); }
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 ContributionDeductionCmd(IProcessTracker processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, object reference) : base(processTracker, oldMasterData, newMasterData, reference) { }
public CalcDaysFactorCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData) : base(processTracker, oldMasterData, newMasterData, null) { }
public CalcRatesCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData) : base(processTracker, oldMasterData, newMasterData, null) { }
public OtherDeductionCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, DeductionBO reference) : base(processTracker, oldMasterData, newMasterData, reference) { p_Deduction = reference; }
public CalcEmployeeEarningCmd(IProcessTracker processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, EarningBO reference) : base(processTracker, oldMasterData, newMasterData, reference) { Earning = reference; }
public CalcBasicPayCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, EarningBO reference) : base(processTracker, oldMasterData, newMasterData, reference) { BasicPay = reference; }
public HMOPremiumPayableLoanCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, LoanBO reference) : base(processTracker, oldMasterData, newMasterData, reference) { Loan = reference; }