예제 #1
0
        public async Task <IActionResult> Create([Bind("SalaryPaymentId,CourierId,StartPeriodDate,EndPeriodDate,DeliveriesCount,PaymentForDeliveries,Premium,FineAmt,PaymentAmt,CreatedDateTime,LastModifiedDateTime")] SalaryPayment salaryPayment)
        {
            if (ModelState.IsValid)
            {
                salaryPayment.CreatedDateTime      = DateTime.Now;
                salaryPayment.LastModifiedDateTime = DateTime.Now;
                var deliveriesCount = _context
                                      .Delivery
                                      .Include(d => d.Courier)
                                      .ThenInclude(d => d.CourierType)
                                      .Where(
                    d => d.CourierId == salaryPayment.CourierId &&
                    d.StartTime >= salaryPayment.StartPeriodDate &&
                    d.StartTime <= salaryPayment.EndPeriodDate &&
                    d.EndTime >= salaryPayment.StartPeriodDate &&
                    d.EndTime <= salaryPayment.EndPeriodDate)
                                      .Count();

                var courier = _context.Courier
                              .Include(c => c.CourierType)
                              .First(c => c.CourierId == salaryPayment.CourierId);

                salaryPayment.DeliveriesCount      = deliveriesCount;
                salaryPayment.PaymentForDeliveries = deliveriesCount * courier.CourierType.Rate;
                salaryPayment.PaymentAmt           = salaryPayment.PaymentForDeliveries +
                                                     salaryPayment.Premium.GetValueOrDefault(0) -
                                                     salaryPayment.FineAmt.GetValueOrDefault(0);
                _context.Add(salaryPayment);
                await _context.SaveChangesAsync();

                return(RedirectToRoute(new { controller = "SalaryPayments", action = "Details", id = salaryPayment.SalaryPaymentId }));
            }
            ViewData["CourierId"] = new SelectList(_context.Courier, "CourierId", "Name", salaryPayment.CourierId);
            return(View(salaryPayment));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("SalaryPaymentId,CourierId,StartPeriodDate,EndPeriodDate,DeliveriesCount,PaymentForDeliveries,Premium,FineAmt,PaymentAmt,CreatedDateTime,LastModifiedDateTime")] SalaryPayment salaryPayment)
        {
            if (id != salaryPayment.SalaryPaymentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (salaryPayment.CreatedDateTime.Year < 2000)
                    {
                        salaryPayment.CreatedDateTime = DateTime.Now;
                    }
                    salaryPayment.LastModifiedDateTime = DateTime.Now;
                    _context.Update(salaryPayment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SalaryPaymentExists(salaryPayment.SalaryPaymentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourierId"] = new SelectList(_context.Courier, "CourierId", "Name", salaryPayment.CourierId);
            return(View(salaryPayment));
        }
예제 #3
0
        public async Task <IActionResult> PutSalaryPayment(int id, SalaryPayment salaryPayment)
        {
            if (id != salaryPayment.SalaryPaymentId)
            {
                return(BadRequest());
            }

            _context.Entry(salaryPayment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SalaryPaymentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #4
0
        public IHttpActionResult Put(int id, SalaryPayment salaryPayement)
        {
            var           context         = new ClipperDBEntities();
            SalaryPayment salaryPayStatus = context.SalaryPayments.Find(id);

            if (salaryPayStatus == null)
            {
                return(NotFound());
            }
            else if (salaryPayement == null)
            {
                ArgumentNullException argumentNullException = new ArgumentNullException();
                return(InternalServerError(argumentNullException));
            }
            else
            {
                if (salaryPayement.EmpID == 0)
                {
                    context.SalaryPayments.Add(salaryPayement);
                }
                else
                {
                    Employee employeeUpdate = context.Employees
                                              .Where(e => e.EmpID == salaryPayement.EmpID).FirstOrDefault();

                    if (employeeUpdate != null)
                    {
                        context.Entry(employeeUpdate).CurrentValues.SetValues(salaryPayement);
                    }
                }

                context.SaveChanges();
                return(Ok());
            }
        }
예제 #5
0
        public bool SaveSalaryPayment(SalaryPayment salaryPayment)
        {
            //throw new NotImplementedException();

            ISalaryPaymentDAL dAL = new SalaryPaymentDAL();

            if (dAL.QueryById(salaryPayment.Id) != null)
            {
                if (dAL.Update(salaryPayment) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (dAL.Add(salaryPayment) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
예제 #6
0
        public IHttpActionResult Post(List <SalaryPayment> SalaryPaymentReceived)
        {
            SalaryPayment userAccount = new SalaryPayment();
            var           context     = new ClipperDBEntities();

            foreach (SalaryPayment payment in SalaryPaymentReceived)
            {
                context.SalaryPayments.Add(payment);
            }
            try
            {
                context.SaveChanges();
                return(Ok());
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
        }
예제 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("SalaryPaymentId,MonthNumber,Year,TransactionNumber,Amount,WorkerId,CreatedDateTime,LastModifiedDateTime")] SalaryPayment salaryPayment)
        {
            if (id != salaryPayment.SalaryPaymentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(salaryPayment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SalaryPaymentExists(salaryPayment.SalaryPaymentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["WorkerId"] = new SelectList(_context.Workers, "WorkerId", "Address", salaryPayment.WorkerId);
            return(View(salaryPayment));
        }
        public IHttpActionResult PutSalaryPayment(int id, SalaryPayment salaryPayment)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            if (id != salaryPayment.SalaryPaymentId)
            {
                return(BadRequest());
            }

            db.Entry(salaryPayment).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SalaryPaymentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #9
0
        public ActionResult EmpSalarySave(List <SalaryPayment> salaryPayment, List <LedgerPosting> ledgerPosting)
        {
            foreach (var item in ledgerPosting)
            {
                LedgerPosting ledgersave = new LedgerPosting();
                ledgersave.VoucherTypeId = 6;
                ledgersave.LedgerId      = item.LedgerId;
                ledgersave.Debit         = item.Credit;
                ledgersave.Credit        = 0;
                ledgersave.ChequeNo      = item.ChequeNo;
                ledgersave.ChequeDate    = item.ChequeDate;
                lps.Save(ledgersave);
            }

            foreach (var i in salaryPayment)
            {
                SalaryPayment sp = new SalaryPayment();
                sp.EmployeeId   = i.EmployeeId;
                sp.SalaryAmount = i.SalaryAmount;
                sp.Bonus        = i.TotalAmount - i.SalaryAmount;
                sp.TotalAmount  = i.TotalAmount;
                sp.Date         = i.Date;
                sp.Month        = i.Month;
                salaryPaymentService.Save(sp);
            }

            return(Json("", JsonRequestBehavior.AllowGet));
        }
예제 #10
0
        public async Task <ActionResult <SalaryPayment> > PostSalaryPayment(SalaryPayment salaryPayment)
        {
            _context.SalaryPayments.Add(salaryPayment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSalaryPayment", new { id = salaryPayment.SalaryPaymentId }, salaryPayment));
        }
예제 #11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Year,EmployeeId,CalculatedTax")] SalaryPayment salaryPayment)
        {
            if (id != salaryPayment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(salaryPayment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SalaryPaymentExists(salaryPayment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employee, "Id", "Id", salaryPayment.EmployeeId);
            return(View(salaryPayment));
        }
예제 #12
0
        public ActionResult Create([Bind(Include = "Payment, Department, Balance")] SalaryPayment salaryPayment)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    SalaryPaymentServices.Insert(CurrentUser.Id, salaryPayment, db);
                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                    return(RedirectToAction("Index"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

            ViewBag.PaymentList    = new SelectList(PaymentServices.List(db), "Id", "Notes");
            ViewBag.DepartmentList = new SelectList(DepartmentServices.List(db), "Id", "Name");
            return(View(salaryPayment));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SalaryPayment salaryPayment = db.SalaryPayments.Find(id);

            db.SalaryPayments.Remove(salaryPayment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #14
0
        //public void OnDelete(eStoreDbContext db, StaffAdvancePayment salPayment)
        //{
        //    UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, true);
        //}

        public void OnUpdate(eStoreDbContext db, SalaryPayment salPayment)
        {
            //    var old = db.SalaryPayments.Where(c => c.SalaryPaymentId == salPayment.SalaryPaymentId).Select(d => new { d.Amount, d.PaymentDate, d.PayMode }).FirstOrDefault();
            //    if (old != null)
            //    {
            //        UpdateOutAmount(db, old.Amount, old.PayMode, old.PaymentDate, true);
            //    }
            //    UpdateOutAmount(db, salPayment.Amount, salPayment.PayMode, salPayment.PaymentDate, false);
            //    HRMBot.NotifyStaffPayment(db, "", salPayment.EmployeeId, salPayment.Amount, "Salary payment for month of " + salPayment.SalaryMonth + "  details: " + salPayment.Details);
        }
 public ActionResult Edit([Bind(Include = "SalaryPaymId,EmployeeCode,SalaryAmount,Month,Year,DeductionAmount,AllowanceAmount,OtherDeduction,OtherAllowance,PaymentDate,IsPaid,IsSalarySlipPrint,IsDeleted,CreatedDate")] SalaryPayment salaryPayment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(salaryPayment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(salaryPayment));
 }
예제 #16
0
 public ActionResult Edit([Bind(Include = "SalaryPaymentId,Amount,EmployeeId,PaidDate,Remark")] SalaryPayment salaryPayment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(salaryPayment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(salaryPayment));
 }
예제 #17
0
        public IHttpActionResult GetSalaryPayment(int id)
        {
            SalaryPayment salaryPayment = db.SalaryPayments.Find(id);

            if (salaryPayment == null)
            {
                return(NotFound());
            }

            return(Ok(salaryPayment));
        }
예제 #18
0
        public ActionResult Create([Bind(Include = "SalaryPaymentId,Amount,EmployeeId,PaidDate,Remark")] SalaryPayment salaryPayment)
        {
            if (ModelState.IsValid)
            {
                db.SalaryPayments.Add(salaryPayment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(salaryPayment));
        }
예제 #19
0
 public ActionResult Edit([Bind(Include = "SalaryPaymentId,EmployeeId,SalaryMonth,SalaryComponet,PaymentDate,Amount,PayMode,Details")] SalaryPayment salaryPayment)
 {
     if (ModelState.IsValid)
     {
         ProcessAccounts(salaryPayment);
         db.Entry(salaryPayment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "StaffName", salaryPayment.EmployeeId);
     return(View(salaryPayment));
 }
예제 #20
0
 private void ProcessAccounts(SalaryPayment salary)
 {
     if (salary.PayMode == PayModes.Cash)
     {
         Utils.UpDateCashOutHand(db, salary.PaymentDate, salary.Amount);
     }
     //TODO: in future make it more robust
     if (salary.PayMode != PayModes.Cash && salary.PayMode != PayModes.Coupons && salary.PayMode != PayModes.Points)
     {
         Utils.UpDateCashOutBank(db, salary.PaymentDate, salary.Amount);
     }
 }
예제 #21
0
        public IHttpActionResult AddSalaryPayment(SalaryPayment salaryPayment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SalaryPayments.Add(salaryPayment);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = salaryPayment.SalaryPaymentId }, salaryPayment));
        }
예제 #22
0
 public List <SalaryPayment> GetEmpSal(SalaryPayment salary)
 {
     try
     {
         var result = context.SalaryPayments.Where(ss => ss.empId == salary.empId && ss.month == salary.month && ss.year == salary.year).ToList();
         return(result);
     }
     catch (Exception exc)
     {
         throw exc;
     }
 }
예제 #23
0
        public async Task <IActionResult> Create([Bind("Id,Year,EmployeeId,CalculatedTax")] SalaryPayment salaryPayment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(salaryPayment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employee, "Id", "Id", salaryPayment.EmployeeId);
            return(View(salaryPayment));
        }
예제 #24
0
 public async Task <IHttpActionResult> SalaryPayment([FromBody] SalaryPayment payment)
 {
     try
     {
         SalaryPaymentService client = new SalaryPaymentService();
         r = await client.MakeSalaryPayment(payment);
     }
     catch (Exception)
     {
         return(StatusCode(HttpStatusCode.BadRequest));
     }
     return(Ok(r));
 }
예제 #25
0
        public async Task <IActionResult> Create([Bind("SalaryPaymentId,EmployeeId,SalaryMonth,SalaryComponet,PaymentDate,Amount,PayMode,Details")] SalaryPayment salaryPayment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(salaryPayment);
                new PayRollManager().OnInsert(_context, salaryPayment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "StaffName", salaryPayment.EmployeeId);
            return(PartialView(salaryPayment));
        }
        public void UpdateSalarypayment(SalaryPayment salaryPayment)
        {
            var salaryPaymentFromDb = salaryPaymentRepositroy.Get(salaryPayment.Id);

            if (salaryPaymentFromDb != null)
            {
                _util.CopyProperties(salaryPayment, salaryPaymentFromDb);
                salaryPaymentRepositroy.Update(salaryPaymentFromDb);
            }
            else
            {
                throw new Exception("This salary payment record does not exist");
            }
        }
        // GET: SalaryPayments/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SalaryPayment salaryPayment = db.SalaryPayments.Find(id);

            if (salaryPayment == null)
            {
                return(HttpNotFound());
            }
            return(View(salaryPayment));
        }
예제 #28
0
        public IHttpActionResult DeleteSalaryPayment(int id)
        {
            SalaryPayment salaryPayment = db.SalaryPayments.Find(id);

            if (salaryPayment == null)
            {
                return(NotFound());
            }

            db.SalaryPayments.Remove(salaryPayment);
            db.SaveChanges();

            return(Ok(salaryPayment));
        }
예제 #29
0
        public SalaryPayment EditSalary(SalaryPayment salary)
        {
            var orgSal = context.SalaryPayments.Where(ss => ss.ID == salary.ID).FirstOrDefault();

            #region edit employee
            orgSal.empId      = salary.empId;
            orgSal.month      = salary.month;
            orgSal.year       = salary.year;
            orgSal.paidAmount = salary.paidAmount;
            orgSal.date       = salary.date;
            #endregion

            return(context.SaveChanges() > 0 ? salary : null);
        }
예제 #30
0
        // GET: SalaryPayments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SalaryPayment salaryPayment = db.Salaries.Find(id);

            if (salaryPayment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "StaffName", salaryPayment.EmployeeId);
            return(View(salaryPayment));
        }