Пример #1
0
        public ActionResult FinalisePayroll(SetupEmployeeMasterModel model)
        {
            SetupEmployeeMasterProviders pro = new SetupEmployeeMasterProviders();
            int     i = 0;
            decimal SalaryExpenses = 0, PfDR = 0, Festival = 0, Dress = 0, Dearness = 0, OtherAllowance = 0, InsuranceDr = 0;
            decimal SalaryPayable = 0, InsuranceCR = 0, Advance = 0, PfCR = 0, CIT = 0, Fund = 0, SST = 0, Tax = 0, LoanDeduct = 0, LoanInterest = 0, LeaveDeduct = 0, TotalDeduct = 0;
            decimal TotalDebit = 0, TotalCredit = 0;

            model.SetupEmployeeMasterModelList       = pro.GeneratePayroll(model.MonthId, model.YearId);
            model.ObjAddMoreParticularsEmployeeModel = new AddMoreParticularsEmployeeModel();
            foreach (var item in model.SetupEmployeeMasterModelList)
            {
                #region DR
                if (item.TotalDebit > 0)
                {
                    TotalDebit += item.TotalDebit;
                }
                if (item.BasicSalary > 0)
                {
                    SalaryExpenses += item.BasicSalary;
                }
                if (item.GradeAmount > 0)
                {
                    SalaryExpenses += item.GradeAmount;
                }
                if (item.OverTimeAmount > 0)
                {
                    SalaryExpenses += item.OverTimeAmount;
                }
                if (item.PFAmount > 0)
                {
                    PfDR += item.PFAmount;
                }
                if (item.FestivalAmount > 0)
                {
                    Festival += item.FestivalAmount;
                }
                if (item.DressAllowance > 0)
                {
                    Dress += item.DressAllowance;
                }
                if (item.DearnessAllowance > 0)
                {
                    Dearness += item.DearnessAllowance;
                }
                if (item.TotalAllowance > 0)
                {
                    OtherAllowance += item.TotalAllowance;
                }
                if (item.InsuranceAmount > 0)
                {
                    InsuranceDr += item.InsuranceAmount;
                }
                #endregion
                #region CR
                if (item.CITAmount > 0)
                {
                    CIT += item.CITAmount;
                }
                if (item.AdvanceDeduction > 0)
                {
                    Advance += item.AdvanceDeduction;
                }
                if (item.InsuranceDeductAmount > 0)
                {
                    InsuranceCR += item.InsuranceDeductAmount;
                }
                if (item.PFDeductAmount > 0)
                {
                    PfCR += item.PFDeductAmount;
                }
                if (item.FundAmount > 0)
                {
                    Fund += item.FundAmount;
                }
                if (item.SSTAmount > 0)
                {
                    SST += item.SSTAmount;
                }
                if (item.TaxAmount > 0)
                {
                    Tax += item.TaxAmount;
                }
                if (item.LoanDeduction > 0)
                {
                    LoanDeduct += item.LoanDeduction;
                }
                if (item.LoanInterest > 0)
                {
                    LoanInterest += item.LoanInterest;
                }
                if (item.LeaveDeduction > 0)
                {
                    LeaveDeduct += item.LeaveDeduction;
                }
                if (item.TotalDeduction > 0)
                {
                    TotalDeduct += item.TotalDeduction;
                }
                if (item.TotalCredit > 0)
                {
                    TotalCredit += item.TotalCredit;
                }
                if (item.SalaryPayable > 0)
                {
                    SalaryPayable += item.SalaryPayable;
                }
                #endregion
            }
            model.ObjAddMoreParticularsEmployeeModel.DrAmountTotal = TotalDebit;
            model.ObjAddMoreParticularsEmployeeModel.CrAmountTotal = TotalCredit;
            model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList = new List <AddMoreParticularsEmployeeModel>();
            #region AssignToListDR
            if (SalaryExpenses > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    CrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    DrAmount       = SalaryExpenses,
                    DrOrCr         = 1,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("Salary Expenses"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (PfDR > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    CrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    DrAmount       = PfDR,
                    DrOrCr         = 1,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("PFAddition"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (Festival > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    CrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    DrAmount       = Festival,
                    DrOrCr         = 1,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("FestivalAmount"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (Dress > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    CrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    DrAmount       = Dress,
                    DrOrCr         = 1,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("Dress Allowance"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (Dearness > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    CrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    DrAmount       = Dearness,
                    DrOrCr         = 1,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("Dearness Allowance"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (InsuranceDr > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    CrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    DrAmount       = InsuranceDr,
                    DrOrCr         = 1,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("InsuranceDR"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            #endregion
            #region AssignToListCR
            if (SalaryPayable > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = SalaryPayable,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = model.BankAccHeadID,
                    SubParticulars = model.BankSubAccHeadID,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (Advance > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount      = 0,
                    DrAmountTotal = TotalDebit,
                    CrAmountTotal = TotalCredit,
                    CrAmount      = Advance,
                    DrOrCr        = 0,
                    JvType        = "JV",
                    Narration     = "",
                    Particulars   = Utility.GetAccHeadIDFromDescription("Staff Advance"),
                    DrOrCrName    = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (InsuranceCR > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = InsuranceCR,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("InsuranceCR"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (PfCR > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = PfCR,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("PFDeduction"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (CIT > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = CIT,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("CIT"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (Fund > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = Fund,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("Proverty Alivation Fund"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (SST > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = SST,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("SST"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (Tax > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = Tax,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("Tax"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (LoanDeduct > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = LoanDeduct,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("LoanDeduction"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (LoanInterest > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = LoanInterest,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("LoanInterest"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            if (LeaveDeduct > 0)
            {
                var ObjModel = new AddMoreParticularsEmployeeModel()
                {
                    DrAmount       = 0,
                    DrAmountTotal  = TotalDebit,
                    CrAmountTotal  = TotalCredit,
                    CrAmount       = LeaveDeduct,
                    DrOrCr         = 0,
                    JvType         = "JV",
                    Narration      = "",
                    Particulars    = Utility.GetAccHeadIDFromDescription("LeaveDeduction"),
                    SubParticulars = 0,
                    DrOrCrName     = ""
                };
                model.ObjAddMoreParticularsEmployeeModel.AddMoreParticularsEmployeeModelList.Add(ObjModel);
            }
            #endregion
            if (model.ObjAddMoreParticularsEmployeeModel.DrAmountTotal != 0)
            {
                if (model.ObjAddMoreParticularsEmployeeModel.DrAmountTotal == model.ObjAddMoreParticularsEmployeeModel.CrAmountTotal)
                {
                    i = pro.CreateNewJv(model);
                    return(RedirectToAction("ShowJournalVoucher", "JVMaster", new { id = i }));
                }
                else
                {
                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }