コード例 #1
0
        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);
        }
コード例 #2
0
 protected BaseCalculationCommand(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, object reference)
     : base(processTracker)
 {
     m_OldMasterData = oldMasterData;
     m_NewMasterData = newMasterData;
     m_Reference     = reference;
 }
コード例 #3
0
            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;
            }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 protected virtual MasterEmployeeLoanBO FindExistingLoan(MasterDataBO newMasterData, LoanBO loanReference)
 {
     return(newMasterData.MasterEmployeeLoans
            .SingleOrDefault(a => a.LoanID == loanReference.LoanID));
 }
コード例 #7
0
        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);
        }
コード例 #8
0
 public ContributionDeductionCmd(IProcessTracker processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, object reference)
     : base(processTracker, oldMasterData, newMasterData, reference)
 {
 }
コード例 #9
0
 public CalcDaysFactorCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData)
     : base(processTracker, oldMasterData, newMasterData, null)
 {
 }
コード例 #10
0
 public CalcRatesCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData)
     : base(processTracker, oldMasterData, newMasterData, null)
 {
 }
コード例 #11
0
ファイル: OtherDeductionCmd.cs プロジェクト: vgdagpin/Aerish
 public OtherDeductionCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, DeductionBO reference)
     : base(processTracker, oldMasterData, newMasterData, reference)
 {
     p_Deduction = reference;
 }
コード例 #12
0
 public CalcEmployeeEarningCmd(IProcessTracker processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, EarningBO reference)
     : base(processTracker, oldMasterData, newMasterData, reference)
 {
     Earning = reference;
 }
コード例 #13
0
 public CalcBasicPayCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, EarningBO reference)
     : base(processTracker, oldMasterData, newMasterData, reference)
 {
     BasicPay = reference;
 }
コード例 #14
0
 public HMOPremiumPayableLoanCmd(IProcessTrackerBase processTracker, MasterDataBO oldMasterData, MasterDataBO newMasterData, LoanBO reference)
     : base(processTracker, oldMasterData, newMasterData, reference)
 {
     Loan = reference;
 }