示例#1
0
        private SSSContribution SSSCompute(double total)
        {
            SSSContribution sss = new SSSContribution();
            double          r   = 2250;

            sss.ER = 160;
            sss.EE = 80;
            double ec  = 10;
            double gap = 500;

            if (total < r)
            {
                sss.ER += ec;
                return(sss);
            }
            else
            {
                while (total >= r && total < (total + gap))
                {
                    r      += gap;
                    sss.ER += 40;
                    sss.EE += 20;
                    ec      = sss.ER >= 1500 ? 30 : 10;

                    //if (r > 16250) break;
                    //if (r > 30000) break;
                }

                sss.ER += ec;
            }

            return(sss);
        }
示例#2
0
        public List <PayrollObject> GetPayroll(string cutoff, string client)
        {
            List <PayrollObject> result = new List <PayrollObject>();

            DateTime dt1 = DateTime.Parse(cutoff.Split('-')[0]);
            DateTime dt2 = DateTime.Parse(cutoff.Split('-')[1]);

            _colaRate    = SettingManager.ColaRate;
            _reliever    = SettingManager.RelieverCheck;
            _pagibig     = SettingManager.Pagibig;
            _philHealth  = SettingManager.PhilHealth;
            _workingDays = SettingManager.WorkingDays(DateTime.Now.Year);

            using (SGSDBEntities db = new SGSDBEntities())
            {
                Client currClient = db.Clients.Where(x => x.ClientCode == client).FirstOrDefault();

                List <TimeSheet> ts = (from x in db.TimeSheets
                                       where x.Client == client && (x.WorkDate >= dt1 && x.WorkDate <= dt2)
                                       select x).ToList();

                List <TimeSheet> ts_prev = null;

                bool hasBenefitsDeductions = dt1.Day == int.Parse(currClient.GovtRemitDeductCutOff);

                if (hasBenefitsDeductions)
                {
                    string[] clientCutoffs = currClient.CutOffs.Split(',');
                    string   prev_day1     = currClient.GovtRemitDeductCutOff != clientCutoffs[0] ? clientCutoffs[0] : clientCutoffs[1];

                    DateTime prev_dt1 = dt1.Day < 16 ? new DateTime(dt1.AddMonths(-1).Year, dt1.AddMonths(-1).Month, int.Parse(prev_day1))
                                        : new DateTime(dt1.Year, dt1.Month, int.Parse(prev_day1));
                    DateTime prev_dt2 = dt1.AddDays(-1);

                    ts_prev = (from x in db.TimeSheets
                               where x.Client == client && (x.WorkDate >= prev_dt1 && x.WorkDate <= prev_dt2)
                               select x).ToList();
                }

                List <string> empIds = ts.Select(x => x.EmpId).Distinct().ToList();

                foreach (string empId in empIds)
                {
                    List <TimeSheet> empTS = ts.Where(x => x.EmpId == empId).ToList();
                    if (empTS.Count() > 0)
                    {
                        bool isReliever = empTS.First().Position.ToLower() == _reliever;

                        List <TimeSheet> empTS_prev     = null;
                        double           emp_prev_total = 0;

                        if (hasBenefitsDeductions && !isReliever)
                        {
                            empTS_prev = ts_prev.Where(x => x.EmpId == empId).ToList();
                            if (empTS_prev.Count > 0)
                            {
                                PayrollObject t = ComputePayroll(empTS_prev);

                                if (currClient.GovtRemitType == "BasicPayOnly")
                                {
                                    emp_prev_total = t.BasicPay;
                                }
                                else
                                {
                                    emp_prev_total = t.Total;
                                }
                            }
                            else
                            {
                                emp_prev_total = 0;
                            }
                        }

                        if (empTS != null)
                        {
                            PayrollObject t = ComputePayroll(empTS);
                            t.HasBenefitsDeductions = hasBenefitsDeductions;

                            if (hasBenefitsDeductions && !isReliever)
                            {
                                double total = 0;

                                if (currClient.GovtRemitType == "BasicPayOnly")
                                {
                                    total = t.BasicPay + emp_prev_total;
                                }
                                else
                                {
                                    total = t.Total + emp_prev_total;
                                }

                                SSSContribution sss = SSSCompute(total);
                                t.SSSER    = sss.ER;
                                t.SSSEE    = sss.EE;
                                t.SSSTotal = sss.ER + sss.EE;

                                t.PagibigER    = _pagibig;
                                t.PagibigEE    = _pagibig;
                                t.PagibigTotal = t.PagibigER + t.PagibigEE;

                                double phContri = PhilHealthContribution(total);
                                t.PhilHealthER    = phContri;
                                t.PhilHealthEE    = phContri;
                                t.PhilHealthTotal = phContri * 2;

                                t.TotalDeduction = t.SSSEE + t.PagibigEE + t.PhilHealthEE;
                            }
                            else
                            {
                                t.SSSLoan     = empTS.First().SSSLoan.Value;
                                t.PagibigLoan = empTS.First().PagibigLoan.Value;

                                t.TotalDeduction = t.SSSLoan + t.PagibigLoan;
                            }

                            if (t.Adjustment < 0)
                            {
                                t.TotalDeduction += t.Adjustment;
                            }
                            else
                            {
                                t.Total += t.Adjustment;
                            }

                            t.Total += t.Allowance;

                            t.NetPay = t.Total - t.TotalDeduction;

                            result.Add(t);
                        }
                    }
                }
            }

            return(result.Count() > 0? result : null);
        }
示例#3
0
        public List <BillingObject> GetBilling(string cutoff, string client)
        {
            List <BillingObject> result = new List <BillingObject>();

            DateTime dt1 = DateTime.Parse(cutoff.Split('-')[0]);
            DateTime dt2 = DateTime.Parse(cutoff.Split('-')[1]);

            _colaRate    = SettingManager.ColaRate;
            _reliever    = SettingManager.RelieverCheck;
            _pagibig     = SettingManager.Pagibig;
            _philHealth  = SettingManager.PhilHealth;
            _workingDays = SettingManager.WorkingDays(DateTime.Now.Year);

            using (SGSDBEntities db = new SGSDBEntities())
            {
                Client currClient = db.Clients.Where(x => x.ClientCode == client).FirstOrDefault();
                _separationPayRate = currClient.SeparationPay == null? 0 : currClient.SeparationPay.Value;

                double agencyFee = currClient.AgencyFee / 100;

                List <TimeSheet> ts = (from x in db.TimeSheets
                                       where x.Client == client && (x.WorkDate >= dt1 && x.WorkDate <= dt2)
                                       select x).ToList();

                List <TimeSheet> ts_prev = null;

                bool hasBenefitsDeductions = dt1.Day == int.Parse(currClient.GovtRemitDeductCutOff);

                if (hasBenefitsDeductions)
                {
                    string[] clientCutoffs = currClient.CutOffs.Split(',');
                    string   prev_day1     = currClient.GovtRemitDeductCutOff != clientCutoffs[0] ? clientCutoffs[0] : clientCutoffs[1];

                    DateTime prev_dt1 = dt1.Day < 16 ? new DateTime(dt1.AddMonths(-1).Year, dt1.AddMonths(-1).Month, int.Parse(prev_day1))
                                        : new DateTime(dt1.Year, dt1.Month, int.Parse(prev_day1));
                    DateTime prev_dt2 = dt1.AddDays(-1);

                    ts_prev = (from x in db.TimeSheets
                               where x.Client == client && (x.WorkDate >= prev_dt1 && x.WorkDate <= prev_dt2)
                               select x).ToList();
                }

                List <string> empIds = ts.Where(x => x.Client == client).Select(x => x.EmpId).Distinct().ToList();

                foreach (string empId in empIds)
                {
                    List <TimeSheet> empTS = ts.Where(x => x.EmpId == empId).ToList();
                    if (empTS.Count() > 0)
                    {
                        bool isReliever = empTS.First().Position.ToLower() == _reliever;

                        List <TimeSheet> empTS_prev     = null;
                        double           emp_prev_total = 0;

                        if (hasBenefitsDeductions && !isReliever)
                        {
                            empTS_prev = ts_prev.Where(x => x.EmpId == empId).ToList();

                            if (empTS_prev.Count > 0)
                            {
                                BillingObject t = ComputeBilling(empTS_prev);

                                if (currClient.GovtRemitType == "BasicPayOnly")
                                {
                                    emp_prev_total = t.BasicPay;
                                }
                                else
                                {
                                    emp_prev_total = t.Total - (t.IncentiveLeavePay + t.ThirteenthMonthPay + t.SeparationPay);
                                }
                            }
                            else
                            {
                                emp_prev_total = 0;
                            }
                        }

                        if (empTS != null)
                        {
                            BillingObject t = ComputeBilling(empTS);
                            t.HasSeparationPay      = currClient.SeparationPay.Value > 0;
                            t.HasBenefitsDeductions = hasBenefitsDeductions;

                            if (hasBenefitsDeductions && !isReliever)
                            {
                                double total = 0;

                                if (currClient.GovtRemitType == "BasicPayOnly")
                                {
                                    total = t.BasicPay + emp_prev_total;
                                }
                                else
                                {
                                    total = (t.Total + emp_prev_total) - (t.IncentiveLeavePay + t.ThirteenthMonthPay + t.SeparationPay);
                                }

                                SSSContribution sss = SSSCompute(total);
                                t.SSS = sss.ER;

                                t.Pagibig = _pagibig;

                                double phContri = PhilHealthContribution(total);
                                t.PhilHealth = phContri;

                                t.TotalGovRemitance = t.SSS + t.Pagibig + t.PhilHealth;
                            }

                            t.TotalReimbursableCost = t.Total + t.TotalGovRemitance;
                            t.AgencyFee             = t.TotalReimbursableCost * agencyFee;
                            t.TotalWithFee          = t.TotalReimbursableCost + t.AgencyFee;
                            t.VAT         = t.TotalWithFee * 0.12;
                            t.TotalAmount = t.TotalWithFee + t.VAT + t.Allowance + t.Adjustment;

                            result.Add(t);
                        }
                    }
                }
            }

            return(result.Count() > 0 ? result : null);
        }