예제 #1
0
 public IHttpActionResult AddNewEmployeeLoan(EmployeeLoan newemployeeloan)
 {
     newemployeeloan.employee = unitOfWork.employees.Get(newemployeeloan.Id);
     unitOfWork.employeeloans.Add(newemployeeloan);
     unitOfWork.Complete();
     return(Ok("One new Employee Loan Successfully Added"));
 }
예제 #2
0
        /// <summary>
        /// Verify Documents from the list
        /// </summary>
        /// <param name="eid"></param>
        /// <param name="lid"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult Verify(int eid, int lid, DocumentViewModel model)
        {
            string        cmd    = "SELECT * FROM Lookup";
            SqlDataReader reader = Database_Connection.get_instance().Getdata(cmd);

            while (reader.Read())
            {
                if (reader.GetString(1) == "Verified")
                {
                    model.Status = reader.GetInt32(0);
                }
            }
            EmployeeLoan  ob       = new EmployeeLoan();
            string        cmmd     = "SELECT * FROM Lookup";
            SqlDataReader readerrr = Database_Connection.get_instance().Getdata(cmmd);

            while (readerrr.Read())
            {
                if (readerrr.GetString(1) == "Approve")
                {
                    ob.Status = readerrr.GetInt32(0);
                }
            }

            string cmd3 = string.Format("UPDATE  Document SET Status = '{0}' WHERE  EmployeeId= '{1}' AND LoanId= '{2}'", model.Status, eid, lid);
            int    rows = Database_Connection.get_instance().Executequery(cmd3);
            string cmd4 = string.Format("UPDATE  EmployeeLoan SET Status = '{0}' WHERE  EmployeeId= '{1}' AND LoanId= '{2}'", ob.Status, eid, lid);
            int    row  = Database_Connection.get_instance().Executequery(cmd4);

            return(RedirectToAction("Listofdocuments", "Admin"));
        }
예제 #3
0
 public EmployeeLoan VHasStartDate(EmployeeLoan employeeLoan)
 {
     if (employeeLoan.StartDate == null || employeeLoan.StartDate.Equals(DateTime.FromBinary(0)))
     {
         employeeLoan.Errors.Add("StartDate", "Tidak valid");
     }
     return(employeeLoan);
 }
예제 #4
0
 public EmployeeLoan VIsValidInterest(EmployeeLoan employeeLoan)
 {
     if (employeeLoan.Interest < 0)
     {
         employeeLoan.Errors.Add("Interest", "Harus lebih besar atau sama dengan 0");
     }
     return(employeeLoan);
 }
예제 #5
0
 public EmployeeLoan VIsValidInstallmentTimes(EmployeeLoan employeeLoan)
 {
     if (employeeLoan.InstallmentTimes < 0)
     {
         employeeLoan.Errors.Add("InstallmentTimes", "Harus lebih besar atau sama dengan 0");
     }
     return(employeeLoan);
 }
예제 #6
0
        public IHttpActionResult UpdateOldEmployeeLoan(EmployeeLoan oldemployeeloan)
        {
            Expression <Func <EmployeeLoan, bool> > myfuncforemployeeloan = s => s.Id == oldemployeeloan.Id;

            unitOfWork.employeeloans.Update(myfuncforemployeeloan, oldemployeeloan);
            unitOfWork.Complete();
            return(Ok("Employee Loan Updated Successfully"));
        }
예제 #7
0
 public EmployeeLoan VHasRemark(EmployeeLoan employeeLoan)
 {
     if (String.IsNullOrEmpty(employeeLoan.Remark) || employeeLoan.Remark.Trim() == "")
     {
         employeeLoan.Errors.Add("Remark", "Tidak boleh kosong");
     }
     return(employeeLoan);
 }
예제 #8
0
 public EmployeeLoan VIsValidAmount(EmployeeLoan employeeLoan)
 {
     if (employeeLoan.Amount < 0)
     {
         employeeLoan.Errors.Add("Amount", "Harus lebih besar atau sama dengan 0");
     }
     return(employeeLoan);
 }
예제 #9
0
        public IHttpActionResult RemoveOldEmployeeLoan(EmployeeLoan oldemployeeloantoremove)
        {
            EmployeeLoan getemployeeloantoremove = unitOfWork.employeeloans.Get(oldemployeeloantoremove.Id);

            getemployeeloantoremove.IsTerminated = true;
            unitOfWork.employeeloans.Update(p => p.Id == getemployeeloantoremove.Id, getemployeeloantoremove);
            unitOfWork.Complete();
            return(Ok("Employee Loan removed Successfully"));
        }
예제 #10
0
        public EmployeeLoan VHasSalaryItem(EmployeeLoan employeeLoan, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectById(employeeLoan.SalaryItemId);

            if (salaryItem == null)
            {
                employeeLoan.Errors.Add("SalaryItem", "Tidak ada");
            }
            return(employeeLoan);
        }
예제 #11
0
        public EmployeeLoan VHasEmployee(EmployeeLoan employeeLoan, IEmployeeService _employeeService)
        {
            Employee employee = _employeeService.GetObjectById(employeeLoan.EmployeeId);

            if (employee == null)
            {
                employeeLoan.Errors.Add("Employee", "Tidak ada");
            }
            return(employeeLoan);
        }
예제 #12
0
        public EmployeeLoanDetail VHasEmployeeLoan(EmployeeLoanDetail employeeLoanDetail, IEmployeeLoanService _employeeLoanService)
        {
            EmployeeLoan employeeLoan = _employeeLoanService.GetObjectById(employeeLoanDetail.EmployeeLoanId);

            if (employeeLoan == null)
            {
                employeeLoanDetail.Errors.Add("EmployeeLoan", "Tidak ada");
            }
            return(employeeLoanDetail);
        }
예제 #13
0
 public EmployeeLoan VHasEndDate(EmployeeLoan employeeLoan)
 {
     if (employeeLoan.EndDate == null || employeeLoan.EndDate.Equals(DateTime.FromBinary(0)))
     {
         employeeLoan.Errors.Add("EndDate", "Tidak valid");
     }
     else if (employeeLoan.EndDate.Date < employeeLoan.StartDate.Date)
     {
         employeeLoan.Errors.Add("EndDate", "Harus lebih besar atau sama dengan Start Date");
     }
     return(employeeLoan);
 }
예제 #14
0
        public string PrintError(EmployeeLoan obj)
        {
            string erroroutput = "";
            KeyValuePair <string, string> first = obj.Errors.ElementAt(0);

            erroroutput += first.Key + "," + first.Value;
            foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1))
            {
                erroroutput += Environment.NewLine;
                erroroutput += pair.Key + "," + pair.Value;
            }
            return(erroroutput);
        }
예제 #15
0
        /// <summary>
        /// Saves the employee loan information.
        /// </summary>
        /// <param name="employeeLoan">The employee loan.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">employeeLoan</exception>
        public string SaveEmployeeLoanInfo(IEmployeeLoanView employeeLoan)
        {
            if (employeeLoan == null)
            {
                throw new ArgumentNullException(nameof(employeeLoan));
            }

            string result = string.Empty;

            var newReocord = new EmployeeLoan
            {
                EmployeeId   = employeeLoan.EmployeeId,
                CompanyId    = employeeLoan.CompanyId,
                Tenure       = employeeLoan.Tenure,
                LoanTypeId   = employeeLoan.LoanId,
                Reason       = employeeLoan.Reason,
                DateCreated  = DateTime.UtcNow,
                IsActive     = true,
                AgreedDate   = null,
                Amount       = employeeLoan.LoanAmount,
                IsApproved   = null,
                HRComment    = null,
                DateDisburst = employeeLoan.DisburstDate,
                ExpectedDate = employeeLoan.ExpectedDate,
                PeriodRemain = employeeLoan.Tenure,
            };

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    dbContext.EmployeeLoans.Add(newReocord);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("Save Employee loan info - {0}, {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            return(result);
        }
예제 #16
0
 public bool ValidCreateObject(EmployeeLoan employeeLoan, IEmployeeService _employeeService, ISalaryItemService _salaryItemService)
 {
     VHasEmployee(employeeLoan, _employeeService);
     if (!isValid(employeeLoan))
     {
         return(false);
     }
     VHasRemark(employeeLoan);
     if (!isValid(employeeLoan))
     {
         return(false);
     }
     VHasSalaryItem(employeeLoan, _salaryItemService);
     if (!isValid(employeeLoan))
     {
         return(false);
     }
     VIsValidAmount(employeeLoan);
     if (!isValid(employeeLoan))
     {
         return(false);
     }
     VIsValidInterest(employeeLoan);
     if (!isValid(employeeLoan))
     {
         return(false);
     }
     VIsValidInstallmentTimes(employeeLoan);
     if (!isValid(employeeLoan))
     {
         return(false);
     }
     VHasStartDate(employeeLoan);
     if (!isValid(employeeLoan))
     {
         return(false);
     }
     VHasEndDate(employeeLoan);
     return(isValid(employeeLoan));
 }
예제 #17
0
 public bool ValidUpdateObject(EmployeeLoan employeeLoan, IEmployeeService _employeeService, ISalaryItemService _salaryItemService)
 {
     employeeLoan.Errors.Clear();
     ValidCreateObject(employeeLoan, _employeeService, _salaryItemService);
     return(isValid(employeeLoan));
 }
예제 #18
0
 public EmployeeLoan SoftDeleteObject(EmployeeLoan employeeLoan)
 {
     return(employeeLoan = _validator.ValidDeleteObject(employeeLoan) ?
                           _repository.SoftDeleteObject(employeeLoan) : employeeLoan);
 }
예제 #19
0
 public EmployeeLoan UpdateObject(EmployeeLoan employeeLoan, IEmployeeService _employeeService, ISalaryItemService _salaryItemService)
 {
     return(employeeLoan = _validator.ValidUpdateObject(employeeLoan, _employeeService, _salaryItemService) ? _repository.UpdateObject(employeeLoan) : employeeLoan);
 }
예제 #20
0
 public EmployeeLoan CreateObject(EmployeeLoan employeeLoan, IEmployeeService _employeeService, ISalaryItemService _salaryItemService)
 {
     employeeLoan.Errors = new Dictionary <String, String>();
     return(_validator.ValidCreateObject(employeeLoan, _employeeService, _salaryItemService) ? _repository.CreateObject(employeeLoan) : employeeLoan);
 }
예제 #21
0
        protected override void Seed(PlutoContext context)
        {
            AppUser appuser1 = new AppUser
            {
                username = "******",
                password = "******",
                email    = "*****@*****.**",
                alterEgo = "Admin"
            };


            Department department1 = new Department()
            {
                Id   = 1,
                name = "Business"
            };

            Department department2 = new Department()
            {
                Id   = 2,
                name = "Science"
            };

            StudentClass studentclass1 = new StudentClass()
            {
                Id               = 1,
                name             = "One",
                classamounttopay = 20,
                IsTerminated     = false
            };

            StudentClass studentclass2 = new StudentClass()
            {
                Id               = 2,
                name             = "Two",
                classamounttopay = 30,
                IsTerminated     = false
            };

            StudentStatus studentstatus1 = new StudentStatus()
            {
                Id   = 1,
                name = "Full Payment"
            };

            StudentStatus studentstatus2 = new StudentStatus()
            {
                Id   = 2,
                name = "Partial Payment"
            };

            Region region1 = new Region()
            {
                Id   = 1,
                name = "Ashanti"
            };

            Region region2 = new Region()
            {
                Id   = 2,
                name = "Grater Accra"
            };

            EmployeeCategory employeecategory1 = new EmployeeCategory()
            {
                Id   = 1,
                name = "Fixed",
                allowancepercentage = 70
            };

            EmployeeCategory employeecategory2 = new EmployeeCategory()
            {
                Id   = 2,
                name = "Variable",
                allowancepercentage = 50
            };
            EmployeeLevelOfEducation employeelevelofeducation1 = new EmployeeLevelOfEducation()
            {
                Id   = 1,
                name = "BSC"
            };

            EmployeeLevelOfEducation employeelevelofeducation2 = new EmployeeLevelOfEducation()
            {
                Id   = 2,
                name = "MBS"
            };

            PayrollRate payrollrate = new PayrollRate()
            {
                workday = 100, workdayovertime = 120, saturday = 140, saturdayovertime = 150, sunday = 160, sundayovertime = 160, holiday = 170, holidayovertime = 180
            };

            TaxRate taxrate1 = new TaxRate()
            {
                Id = 1, name = "first", amount = 300, rate = 2
            };
            TaxRate taxrate2 = new TaxRate()
            {
                Id = 2, name = "second", amount = 300, rate = 5
            };

            SSNITRate ssnitrate = new SSNITRate()
            {
                Id = 1, name = "SSNIT", Rate = 3
            };

            StudentSubject subject1 = new StudentSubject()
            {
                Id             = 1,
                name           = "Maths",
                studentclassid = 1
            };

            StudentSubject subject2 = new StudentSubject()
            {
                Id             = 2,
                name           = "English",
                studentclassid = 2
            };


            EmployeeType employeetype1 = new EmployeeType()
            {
                Id   = 1,
                name = "Regular"
            };

            EmployeeType employeetype2 = new EmployeeType()
            {
                Id   = 2,
                name = "Staff"
            };


            Student student1 = new Student
            {
                Id                 = 1,
                gender             = "female",
                firstname          = "Dede",
                lastname           = "Ansah",
                placeofbirth       = "Tema",
                dateofbirth        = DateTime.Now,
                studentclassId     = 2,
                departmentId       = 1,
                mothername         = "Joyce",
                fathername         = "Ankrah",
                regionId           = 2,
                city               = "Tema",
                address            = "P.O.Box 23332",
                email              = "*****@*****.**",
                phone              = "2323323",
                studentstatusId    = 1,
                scholarshippercent = 0,
                imagesrc           = "../../assets/images/default.png"
            };
            Student student2 = new Student
            {
                Id                 = 2,
                gender             = "Male",
                firstname          = "Ansah",
                lastname           = "Phillip",
                placeofbirth       = "Tema",
                dateofbirth        = DateTime.Now,
                studentclassId     = 1,
                departmentId       = 1,
                mothername         = "Joyce",
                fathername         = "Ankrah",
                regionId           = 2,
                city               = "Tema",
                address            = "P.O.Box 23332",
                email              = "*****@*****.**",
                phone              = "2323323",
                studentstatusId    = 2,
                scholarshippercent = 0,
                imagesrc           = "../../assets/images/default.png"
            };

            Payment payment1 = new Payment
            {
                Id          = 1,
                amounttopay = 50,
                amountpaid  = 20,
                amountowing = 30,
                studentId   = 1
            };

            PaymentHistory paymenthistory1 = new PaymentHistory
            {
                Id            = 1,
                amount        = 50,
                amountinwords = "Fifty Ghana Cedis",
                paymentdate   = DateTime.Now,
                studentId     = 1
            };

            Employee employee1 = new Employee()
            {
                Id              = 1, gender = "Male", firstname = "Emmanuel", lastname = "Atiapa", fullname = "Emmanuel Atiapa", placeofbirth = "Kpone", dateofbirth = DateTime.Now, categoryId = 1, departmentId = 1,
                classtoteachId  = 1, mothername = "Joyce", fathername = "Frank", regionId = 1, city = "Tema", address = "P.O.Box 233", email = "*****@*****.**", phone = "233254443",
                areaofexpertise = "Teaching", levelofeducationId = 1, yearsofexperience = 2, salary = 233, workinghours = 22, imagesrc = "../../assets/images/default.png",
                employeetypeId  = 1
            };

            Employee employee2 = new Employee()
            {
                Id          = 2, gender = "Female", firstname = "Kenneth", lastname = "Atsekpor", fullname = "Kenneth Atsekpor", placeofbirth = "Kpone",
                dateofbirth = DateTime.Now, categoryId = 2, departmentId = 2, classtoteachId = 2, mothername = "Joyce",
                fathername  = "Frank", regionId = 2, city = "Tema", address = "P.O.Box 233", email = "*****@*****.**",
                phone       = "233254443", areaofexpertise = "Accounting", levelofeducationId = 2, yearsofexperience = 4,
                salary      = 233, workinghours = 8, imagesrc = "../../assets/images/default.png", employeetypeId = 2
            };



            PayrollAllowance payrollallowance1 = new PayrollAllowance()
            {
                Id     = 1,
                name   = "Medical",
                amount = 200
            };

            PayrollAllowance payrollallowance2 = new PayrollAllowance()
            {
                Id     = 2,
                name   = "Leave",
                amount = 300
            };

            Allowance allowance1 = new Allowance()
            {
                Id = 1,
                payrollamountId = 1, payrollallowanceId = 1,
                amount          = 30
            };

            Allowance allowance2 = new Allowance()
            {
                Id = 2,
                payrollamountId    = 1,
                payrollallowanceId = 2,
                amount             = 40
            };


            //PayrollAmount payrollamount1 = new PayrollAmount()
            //{
            //    Id = 1,
            //    employeeId = 1,
            //    enddate = DateTime.Now,
            //    startdate = DateTime.Now,
            //    expectedworkhours = 23,
            //    grosssalary = 500,
            //    netsalary = 450,
            //    holiday = 23,
            //    loan = 34,
            //    payee = 3,
            //    saturday = 3,
            //    ssnit = 3,
            //    totalallowance = 45,
            //    workday = 34,
            //    workdayovertime = 2,
            //    sunday = 43,
            //    saturdayovertime = 3,
            //    sundayovertime = 3,
            //    totalworkdays = 3,
            //    holidayovertime = 4,
            //    allowances = new List<Allowance>()
            //    {
            //        allowance1,allowance2
            //    }
            //};


            EmployeeLoan employeeloan1 = new EmployeeLoan()
            {
                Id = 1, amount = 200, amountowing = 180, amountpaid = 20, interestrate = 5, interestamount = 20, monthlypayment = 200, loandate = DateTime.Now, employeeId = 1
            };

            EmployeeLoanHistory employeeloanhistory1 = new EmployeeLoanHistory()
            {
                Id = 1, amount = 20, employeeloanId = 1, paymentdate = DateTime.Now
            };

            Mark mark1 = new Mark()
            {
                Id               = 1,
                examId           = 1,
                mark             = 10,
                studentsubjectId = 1
            };

            Exam exam1 = new Exam()
            {
                Id        = 1,
                studentId = 1,
                marks     = new List <Mark>()
                {
                    mark1
                }
            };

            IncomeCategory incomecategory1 = new IncomeCategory()
            {
                Id   = 1,
                name = "First Income"
            };

            IncomeCategory incomecategory2 = new IncomeCategory()
            {
                Id   = 2,
                name = "Second Income"
            };

            ExpenseCategory expensecategory1 = new ExpenseCategory()
            {
                Id   = 1,
                name = "First Expense"
            };

            ExpenseCategory expensecategory2 = new ExpenseCategory()
            {
                Id   = 2,
                name = "Second Expense"
            };



            context.appusers.Add(appuser1);
            context.employeetypes.Add(employeetype1);
            context.employeetypes.Add(employeetype2);
            context.studentsubjects.Add(subject1);
            context.studentsubjects.Add(subject2);
            context.departments.Add(department1);
            context.departments.Add(department2);
            context.studentclasses.Add(studentclass1);
            context.studentclasses.Add(studentclass2);
            context.studentstatuses.Add(studentstatus1);
            context.studentstatuses.Add(studentstatus2);
            context.regions.Add(region1);
            context.regions.Add(region2);
            context.employeecategories.Add(employeecategory1);
            context.employeecategories.Add(employeecategory2);
            context.employeelevelsofeducation.Add(employeelevelofeducation1);
            context.employeelevelsofeducation.Add(employeelevelofeducation2);
            context.employees.Add(employee1);
            context.employees.Add(employee2);
            context.students.Add(student1);
            context.students.Add(student2);
            context.payrollallowances.Add(payrollallowance1);
            context.payrollallowances.Add(payrollallowance2);
            //context.payrollamounts.Add(payrollamount1);
            //context.allowances.Add(allowance1);
            //context.allowances.Add(allowance2);
            context.payrollrates.Add(payrollrate);
            context.taxrates.Add(taxrate1);
            context.taxrates.Add(taxrate2);
            context.ssnitrates.Add(ssnitrate);
            context.payments.Add(payment1);
            context.paymenthistories.Add(paymenthistory1);
            context.employeeloans.Add(employeeloan1);
            context.employeeloanhistories.Add(employeeloanhistory1);
            context.exams.Add(exam1);
            context.marks.Add(mark1);
            context.incomecategories.Add(incomecategory1);
            context.incomecategories.Add(incomecategory2);
            context.expensecategories.Add(expensecategory1);
            context.expensecategories.Add(expensecategory2);
            base.Seed(context);
        }
예제 #22
0
 public bool ValidDeleteObject(EmployeeLoan employeeLoan)
 {
     employeeLoan.Errors.Clear();
     return(isValid(employeeLoan));
 }
예제 #23
0
        public bool isValid(EmployeeLoan obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }