public async Task <IActionResult> Edit(string id, [Bind("EmployeePaymentId,PaymentNumber,PaymentDate,PaymentTypeId,PaymentAmount,EmployeeId,CashRepositoryId,createdAt")] EmployeePayment employeePayment) { if (id != employeePayment.EmployeePaymentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employeePayment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeePaymentExists(employeePayment.EmployeePaymentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CashRepositoryId"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName", employeePayment.CashRepositoryId); ViewData["EmployeeId"] = new SelectList(_context.Employee, "EmployeeId", "DisplayName", employeePayment.EmployeeId); ViewData["PaymentTypeId"] = new SelectList(_context.PaymentType, "PaymentTypeId", "PaymentTypeName", employeePayment.PaymentTypeId); return(View(employeePayment)); }
private void OnRowEditEnded() { EmployeePaymentDetail detail = ListOfPaymentDetails.CurrentItem as EmployeePaymentDetail; if (detail == null) { return; } EmployeePayment payment = ListOfCurrentPayments.CurrentItem as EmployeePayment; // if Bonuspayment: set LastPayment = FirstPayment if (detail.PaymentType == PaymentType.Bonus) { detail.LastPayment = detail.FirstPayment; } if (detail.Id == 0) { detail = dbAccess.InsertEmployeePaymentDetail(detail); } else { dbAccess.UpdateEmployeePaymentDetail(detail); if (detail.PaymentType == PaymentType.CurrentSalary && payment.FirstPayment.Month == detail.FirstPayment.Month) { // update payment payment.LastPayment = detail.LastPayment; payment.MonthlySalary = detail.MonthlyAmount; payment.SocialSecurityPremium = detail.SocialSecurityPremium; dbAccess.UpdateEmployeePayment(payment); } } RefreshCurrentPayment(payment); }
private void PayButton_Click(object sender, RoutedEventArgs e) { var employee = (Employee)EmployeeDataGrid.SelectedItem; if (employee?.Id == null) { MessageBox.Show("Please Enter Payment Details", "GOLDLINE", MessageBoxButton.OK); return; } if (AmountTextBox.Text != "" && ReasonTextBox.Text != "") { decimal amount; if (decimal.TryParse(AmountTextBox.Text, out amount)) { var employeePayment = new EmployeePayment(employee.Id.Value, decimal.Parse(AmountTextBox.Text), ReasonTextBox.Text); _employeePaymentHandler.AddPayment(employeePayment); ReloadDataGrid(); AmountTextBox.Text = ""; ReasonTextBox.Text = "Salary"; MessageBox.Show("Payment Recorded Successfully", "GOLDLINE", MessageBoxButton.OK); } else { MessageBox.Show("Please Enter Valid Amount", "GOLDLINE", MessageBoxButton.OK); return; } } else { MessageBox.Show("Please Enter Payment Details", "GOLDLINE", MessageBoxButton.OK); } }
public override void OnNavigatedTo(NavigationContext navigationContext) { newEmployees = dbAccess.GetNewEmployeesForEmployeePayments(); if (newEmployees.Count > 0) { foreach (EmployeesForTravelExpenses employee in newEmployees) { EmployeePayment payment = new EmployeePayment(); payment.EmployeeId = employee.Id; payment = dbAccess.InsertEmployeePayment(payment); } } currentPayments = new ObservableCollection <EmployeePayment>(dbAccess.GetAllCurrentPayments()); ListOfCurrentPayments = CollectionViewSource.GetDefaultView(currentPayments); ListOfCurrentPayments.CurrentChanged -= ListOfCurrentPayments_CurrentChanged; ListOfCurrentPayments.CurrentChanged += ListOfCurrentPayments_CurrentChanged; if (ListOfCurrentPayments.CurrentItem != null) { EmployeePayment currentPayment = ListOfCurrentPayments.CurrentItem as EmployeePayment; RefreshCurrentPayment(currentPayment); } RaisePropertyChanged("ListOfCurrentPayments"); }
private void PostEanringToGL(Models.Accounting.LedgerGroup trLedger, EmployeePayment employeePayment) { foreach (var paymentItem in employeePayment.PaymentItems.Where(t => t.PaymentType.PayDirection == Models.Employees.PayDirection.Eanring).ToList()) { trLedger.AddDebit(paymentItem.PaymentType.Account, paymentItem.Amount); } }
public async Task <IActionResult> Edit(int id, [Bind("FuncID,PagID,Id")] EmployeePayment employeePayment) { if (id != employeePayment.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employeePayment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeePaymentExists(employeePayment.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(employeePayment)); }
public PensionViewModel(EmployeePayment employeePayment) { Facility = employeePayment?.Facility; MonthsWorked = employeePayment?.MonthsWorked; Deceased = employeePayment != null && employeePayment.Deceased; LastFiveYearSalaries = employeePayment?.LastFiveYearSalaries; }
// Factory Method public static IPayment GetPaymentObject(int objType) { IPayment _IPayment; if (objType == Constant.PaymentType.ProductDetails.GetHashCode()) { _IPayment = new ProductDetailsPayment(); } else if (objType == Constant.PaymentType.Employee.GetHashCode()) { _IPayment = new EmployeePayment(); } else if (objType == Constant.PaymentType.EmployeeActivate.GetHashCode()) { _IPayment = new EmployeeMemberActivatePayment(); } else if (objType == Constant.PaymentType.MembershipUpgrade.GetHashCode()) { _IPayment = new MembershipUpgradePayment(); } else if (objType == Constant.PaymentType.Video.GetHashCode()) { _IPayment = new VideoPayment(); } else { _IPayment = null; } return(_IPayment); }
/// <summary> /// Adds a new payment to employee /// </summary> /// <param name="payment"></param> public void AddPayment(EmployeePayment payment) { using (var connection = Connector.GetConnection()) { var employeePaymentDal = new EmployeePaymentDal(connection); employeePaymentDal.Insert(payment.EmployeeId, payment.Amount, payment.Reason); payment.Id = employeePaymentDal.GetLastInsertId(); } }
// GET: EmployeePayment/Create public IActionResult Create() { ViewData["StatusMessage"] = TempData["StatusMessage"]; ViewData["CashRepositoryId"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName"); ViewData["EmployeeId"] = new SelectList(_context.Employee, "EmployeeId", "DisplayName"); ViewData["PaymentTypeId"] = new SelectList(_context.PaymentType, "PaymentTypeId", "PaymentTypeName"); EmployeePayment ep = new EmployeePayment(); ep.PaymentDate = DateTime.UtcNow; return(View(ep)); }
private void PostDeductionToGL(Models.Accounting.LedgerGroup trLedger, EmployeePayment employeePayment) { var paymentDeductionItems = employeePayment.PaymentItems .Where(t => t.PaymentType.PayDirection == Models.Employees.PayDirection.Deduction) .ToList(); foreach (var paymentItem in paymentDeductionItems) { trLedger.AddCredit(paymentItem.PaymentType.Account, paymentItem.Amount); } }
public async Task <IActionResult> Create([Bind("FuncID,PagID,Id")] EmployeePayment employeePayment) { if (ModelState.IsValid) { _context.Add(employeePayment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employeePayment)); }
private void OnAddNewPaymentDetail() { EmployeePaymentDetail newDetail = new EmployeePaymentDetail(); newDetail.PaymentType = PaymentType.Salary; EmployeePayment currentPayment = ListOfCurrentPayments.CurrentItem as EmployeePayment; newDetail.EmployeeId = currentPayment.EmployeeId; employeePaymentDetails.Add(newDetail); ListOfPaymentDetails.MoveCurrentToLast(); }
/// <summary> /// Undo an erroneous employee payment /// </summary> /// <param name="payment"></param> public void DeletePayment(EmployeePayment payment) { // Exception handling if (payment.Id == null) { throw new ArgumentNullException(nameof(payment.Id), "Employee payment id is null"); } using (var connection = Connector.GetConnection()) { new EmployeePaymentDal(connection).Delete(payment.Id.Value); } }
public ActionResult EmployeeDeposit(long?id, decimal deposit) { try { DataSet dsbalance = new DataSet(); dsbalance = com.ReturnDataSet("SELECT ISNULL(SUM(Amount),0) AS Amount FROM EmployeePayments WHERE EmployeeID=" + id + ""); decimal balance = Convert.ToDecimal(dsbalance.Tables[0].Rows[0].ItemArray.GetValue(0).ToString()); DataSet dsMax = new DataSet(); dsMax = com.ReturnDataSet("SELECT ParamValue FROM Configurations WHERE(ParamName = 'MaxPayment')"); decimal maxVal = Convert.ToDecimal(dsMax.Tables[0].Rows[0].ItemArray.GetValue(0).ToString()); decimal totalBalance = deposit + balance; if (totalBalance <= maxVal) { EmployeePayment employeePayment = new EmployeePayment(); Employee employee = new Employee(); //Add deposit to Employee Payment Table employeePayment.EmployeeID = id; employeePayment.Amount = deposit; employeePayment.EffectiveDate = DateTime.Now; db.EmployeePayments.Add(employeePayment); db.SaveChanges(); //Update Employee Credit Balance var EmployeeSum = db.EmployeePayments.Where(e => e.EmployeeID == id).Sum(e => e.Amount); var DepositEmployee = db.Employees.Where(e => e.ID == id).FirstOrDefault(); DepositEmployee.CreditBalance = EmployeeSum; db.Entry(DepositEmployee).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); var message = "SAVED SUCCESSFULLY"; return(Json(new { message = message }, JsonRequestBehavior.AllowGet)); //TempData["success"] = "SAVED SUCCESSFULLY"; //return RedirectToAction("Index"); } else { var message = "PAYMENT EXCEEDS THE ALLOWED MAX PAYMENT"; return(Json(new { message = message }, JsonRequestBehavior.AllowGet)); //TempData["error"]= "PAYMENT EXCEEDS THE ALLOWED MAX PAYMENT"; //return RedirectToAction("Index"); } } catch (Exception ex) { ViewBag.Message = ex.Message.ToString(); com.RollbackTrans(); var message = ex.Message.ToString(); //return Json(new { message = message }, JsonRequestBehavior.AllowGet); } return(RedirectToAction("Index")); }
private void OnEditCurrentSalary() { NoRecordView = Visibility.Collapsed; CurrentSalaryView = Visibility.Visible; BonusView = Visibility.Collapsed; SalaryHistoryView = Visibility.Collapsed; FinalPaymentDateView = Visibility.Collapsed; CurrentPaymentDetail = new EmployeePaymentDetail(); CurrentPaymentDetail.PaymentType = PaymentType.CurrentSalary; EmployeePayment employeePayment = ListOfCurrentPayments.CurrentItem as EmployeePayment; CurrentPaymentDetail.EmployeeId = employeePayment.EmployeeId; }
private void OnAddingNewDetail(object obj) { Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e = obj as Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs; if (e == null) { return; } EmployeePaymentDetail newDetail = new EmployeePaymentDetail(); EmployeePayment currentPayment = ListOfCurrentPayments.CurrentItem as EmployeePayment; newDetail.EmployeeId = currentPayment.EmployeeId; e.NewObject = newDetail; }
public EmployeePayment Save(EmployeePayment employeePayment) { var existPayment = erpNodeDBContext.EmployeePayments.Find(employeePayment.Id); existPayment.FiscalYear = organization.FiscalYears.Find(existPayment.TransactionDate); existPayment.EmployeePaymentPeriodId = employeePayment.EmployeePaymentPeriodId; existPayment.TransactionDate = employeePayment.TransactionDate; existPayment.PayFromAccountGuid = employeePayment.PayFromAccountGuid ?? organization.SystemAccounts.Cash.Id; SaveChanges(); return(existPayment); }
public EmployeePayment CreateNew(Guid id) { var newEmployeePayment = new EmployeePayment() { Id = Guid.NewGuid(), EmployeeId = id, TransactionDate = DateTime.Today }; erpNodeDBContext.EmployeePayments.Add(newEmployeePayment); organization.SaveChanges(); return(newEmployeePayment); }
private void OnSetFinalPayment() { EmployeePayment employeePayment = ListOfCurrentPayments.CurrentItem as EmployeePayment; CurrentPaymentDetail = dbAccess.GetLatestSalary(employeePayment.EmployeeId); if (CurrentPaymentDetail == null) { return; } NoRecordView = Visibility.Collapsed; CurrentSalaryView = Visibility.Collapsed; BonusView = Visibility.Collapsed; SalaryHistoryView = Visibility.Collapsed; FinalPaymentDateView = Visibility.Visible; }
public PaymentDTO newPayment(PaymentDTO Payment) { var addedPayment = MapperFactory.CurrentMapper.Map <Payment>(Payment); uow.GetRepository <Payment>().Add(addedPayment); uow.SaveChanges(); var addedEmployeePayment = new EmployeePayment() { EmployeeId = Payment.EmployeeId, PaymentId = addedPayment.Id }; uow.GetRepository <EmployeePayment>().Add(addedEmployeePayment); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <PaymentDTO>(addedPayment)); }
private void OnCancel(string obj) { EmployeePayment employeePayment = ListOfCurrentPayments.CurrentItem as EmployeePayment; switch (obj) { case "Detail": { if (CurrentPaymentDetail.Id == 0) { employeePaymentDetails.Remove(CurrentPaymentDetail); RefreshCurrentPayment(employeePayment); } break; } } }
public EmployeePayment Copy(EmployeePayment originalEmployeePayment, DateTime trDate) { var cloneEmployeePayment = erpNodeDBContext.EmployeePayments .AsNoTracking() .Include(p => p.PaymentItems) .FirstOrDefault(x => x.Id == originalEmployeePayment.Id); cloneEmployeePayment.Id = Guid.NewGuid(); cloneEmployeePayment.TransactionDate = trDate; cloneEmployeePayment.No = organization.EmployeePayments.NextNumber; cloneEmployeePayment.PostStatus = LedgerPostStatus.ReadyToPost; cloneEmployeePayment.PaymentItems.ToList().ForEach(ci => ci.Id = Guid.NewGuid()); cloneEmployeePayment.EmployeePaymentPeriodId = null; erpNodeDBContext.EmployeePayments.Add(cloneEmployeePayment); erpNodeDBContext.SaveChanges(); return(cloneEmployeePayment); }
private void RefreshCurrentPayment(EmployeePayment currentPayment) { employeePaymentDetails = new ObservableCollection <EmployeePaymentDetail>(dbAccess.GetAllPaymentDetails(currentPayment.EmployeeId)); CurrentEmployeeFullname = currentPayment.Employee.FullName; ListOfPaymentDetails = CollectionViewSource.GetDefaultView(employeePaymentDetails); ListOfPaymentDetails.CurrentChanged -= ListOfPaymentDetails_CurrentChanged; ListOfPaymentDetails.CurrentChanged += ListOfPaymentDetails_CurrentChanged; if (employeePaymentDetails.Count == 0) { NoRecordView = Visibility.Visible; CurrentSalaryView = Visibility.Collapsed; BonusView = Visibility.Collapsed; SalaryHistoryView = Visibility.Collapsed; FinalPaymentDateView = Visibility.Collapsed; } else { NoRecordView = Visibility.Collapsed; CurrentSalaryView = Visibility.Collapsed; BonusView = Visibility.Collapsed; SalaryHistoryView = Visibility.Visible; FinalPaymentDateView = Visibility.Collapsed; // set Duration and Tooltip SetDurationAndTooltips(); } // set sort criteria ListOfPaymentDetails.SortDescriptions.Clear(); ListOfPaymentDetails.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "FirstPayment" }); ListOfPaymentDetails.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PaymentType" }); RaisePropertyChanged("ListOfPaymentDetails"); }
public bool PostLedger(EmployeePayment tr, bool SaveImmediately = true) { if (tr.PostStatus == LedgerPostStatus.Posted) { return(false); } var trLedger = new Models.Accounting.LedgerGroup() { Id = tr.Id, TransactionDate = tr.TransactionDate, TransactionName = tr.Name, TransactionNo = tr.No ?? 0, TransactionType = transactionType }; if (tr.PayFromAccount == null) { tr.PayFromAccount = organization.SystemAccounts.Cash; } trLedger.AddCredit(tr.PayFromAccount, tr.TotalPayment); PostEanringToGL(trLedger, tr); PostDeductionToGL(trLedger, tr); if (trLedger.FinalValidate()) { tr.PostStatus = LedgerPostStatus.Posted; erpNodeDBContext.LedgerGroups.Add(trLedger); } if (SaveImmediately) { erpNodeDBContext.SaveChanges(); } return(true); }
public async Task <IActionResult> Create([Bind("EmployeePaymentId,PaymentNumber,PaymentDate,PaymentTypeId,PaymentAmount,EmployeeId,CashRepositoryId,createdAt")] EmployeePayment employeePayment) { var username = HttpContext.User.Identity.Name; var cashrepository = await _context.CashRepository.Where(x => x.CashRepositoryId == employeePayment.CashRepositoryId).FirstOrDefaultAsync(); if (cashrepository.Balance < employeePayment.PaymentAmount) { TempData["StatusMessage"] = "Σφάλμα. Υπάρχει πρόβλημα στα ταμειακά διαθέσιμα. Το υπόλοιπο του ταμείου σας (" + cashrepository.Balance + "€), δεν επαρκεί για να καλύψει το ποσόν της πληρωμής(" + employeePayment.PaymentAmount + "€). Αλλάξτε ταμείο ή πληρώστε λιγότερα."; return(RedirectToAction(nameof(Create))); } if (ModelState.IsValid) { employeePayment.PaymentNumber = _numberSequence.GetNumberSequence("ΠΛΣ"); _context.Add(employeePayment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CashRepositoryId"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName", employeePayment.CashRepositoryId); ViewData["EmployeeId"] = new SelectList(_context.Employee, "EmployeeId", "DisplayName", employeePayment.EmployeeId); ViewData["PaymentTypeId"] = new SelectList(_context.PaymentType, "PaymentTypeId", "PaymentTypeName", employeePayment.PaymentTypeId); return(View(employeePayment)); }
public ActionResult EmployeeRecAdjustment(string date, int EmpId, int ItemId, decimal OldQty, decimal NewQty, string Remarks) { EmployeeAdjustment employeeAdjustment = new EmployeeAdjustment(); DateTime? EffDate = Convert.ToDateTime(date); var RecordInItemPurchase = db.ItemPurchases.Where(i => DbFunctions.TruncateTime(i.EffectiveDate) == DbFunctions.TruncateTime(EffDate) && i.EmployeeId == EmpId && i.ItemId == ItemId).FirstOrDefault(); int CurrentDate = DateTime.Now.Day; DateTime UserInputDate = Convert.ToDateTime(date); int EffectiveDate = UserInputDate.Day; if (CurrentDate == EffectiveDate) { employeeAdjustment.EmployeeId = EmpId; employeeAdjustment.ItemId = ItemId; employeeAdjustment.CashierId = RecordInItemPurchase.CashierId; employeeAdjustment.EnteredUserId = Convert.ToInt32(Session["UserId"].ToString()); employeeAdjustment.TransactionTypeId = 4; employeeAdjustment.FactoryId = RecordInItemPurchase.FactoryId; employeeAdjustment.UnitPrice = RecordInItemPurchase.UnitPrice; employeeAdjustment.Quantity = NewQty; employeeAdjustment.EffectiveDate = EffDate; employeeAdjustment.EnteredDate = DateTime.Now; employeeAdjustment.Remarks = Remarks; db.EmployeeAdjustments.Add(employeeAdjustment); db.SaveChanges(); EmployeePayment employeePayment = new EmployeePayment(); //Add a plus value for EmployeeID & Effective Date employeePayment.EmployeeID = EmpId; employeePayment.EffectiveDate = EffDate; employeePayment.Amount = (RecordInItemPurchase.UnitPrice * (NewQty * -1)); db.EmployeePayments.Add(employeePayment); db.SaveChanges(); ItemPurchase itemPurchase = new ItemPurchase();//Add minues value for Unit Price & Quantity for EmpId & EffDate itemPurchase.EffectiveDate = EffDate; itemPurchase.EmployeeId = EmpId; itemPurchase.ItemId = ItemId; itemPurchase.UnitPrice = (RecordInItemPurchase.UnitPrice * -1); itemPurchase.Quantity = NewQty; itemPurchase.FactoryId = RecordInItemPurchase.FactoryId; itemPurchase.CashierId = RecordInItemPurchase.CashierId; db.ItemPurchases.Add(itemPurchase); db.SaveChanges(); ItemTransaction itemTransaction1 = new ItemTransaction(); //If same date No plus value for transaction type 3, Add plus value for Trans Type 2 itemTransaction1.ItemID = ItemId; itemTransaction1.Quantity = (NewQty * -1); itemTransaction1.TransactionTypeId = 2; itemTransaction1.EffectiveDate = EffDate; db.ItemTransactions.Add(itemTransaction1); db.SaveChanges(); var EmployeeDetails = db.Employees.Where(e => e.ID == EmpId).FirstOrDefault();//Reduce Credit Balance EmployeeDetails.CreditBalance = (EmployeeDetails.CreditBalance + ((RecordInItemPurchase.UnitPrice * -1) * NewQty)); db.Entry(EmployeeDetails).State = EntityState.Modified; db.SaveChanges(); var daySesslingQty = db.Items.Where(i => i.ID == ItemId).FirstOrDefault(); decimal ReduceQty = (OldQty + NewQty);//If same date reduce Item Day Selling qty daySesslingQty.DaySellingQty = daySesslingQty.DaySellingQty + ReduceQty; db.Entry(daySesslingQty).State = EntityState.Modified; db.SaveChanges(); success = "Adjustment Entered Succfully."; } else if (CurrentDate > EffectiveDate) { employeeAdjustment.EmployeeId = EmpId; employeeAdjustment.ItemId = ItemId; employeeAdjustment.CashierId = RecordInItemPurchase.CashierId; employeeAdjustment.EnteredUserId = Convert.ToInt32(Session["UserId"].ToString()); employeeAdjustment.TransactionTypeId = 5; employeeAdjustment.FactoryId = RecordInItemPurchase.FactoryId; employeeAdjustment.UnitPrice = RecordInItemPurchase.UnitPrice; employeeAdjustment.Quantity = NewQty; employeeAdjustment.EffectiveDate = EffDate; employeeAdjustment.EnteredDate = DateTime.Now; employeeAdjustment.Remarks = Remarks; db.EmployeeAdjustments.Add(employeeAdjustment); db.SaveChanges(); //employeeAdjustment.EmployeeId = EmpId; //employeeAdjustment.ItemId = ItemId; //employeeAdjustment.CashierId = RecordInItemPurchase.CashierId; //employeeAdjustment.EnteredUserId = Convert.ToInt32(Session["UserId"].ToString()); //employeeAdjustment.TransactionTypeId = 3; //employeeAdjustment.FactoryId = RecordInItemPurchase.FactoryId; //employeeAdjustment.UnitPrice = RecordInItemPurchase.UnitPrice; //employeeAdjustment.Quantity = NewQty; //employeeAdjustment.EffectiveDate = EffDate; //employeeAdjustment.EnteredDate = DateTime.Now; //employeeAdjustment.Remarks = Remarks; //db.EmployeeAdjustments.Add(employeeAdjustment); //db.SaveChanges(); EmployeePayment employeePayment = new EmployeePayment(); employeePayment.EmployeeID = EmpId; employeePayment.EffectiveDate = EffDate; employeePayment.Amount = (RecordInItemPurchase.UnitPrice * (NewQty * -1)); db.EmployeePayments.Add(employeePayment); db.SaveChanges(); ItemPurchase itemPurchase = new ItemPurchase(); itemPurchase.EffectiveDate = EffDate; itemPurchase.EmployeeId = EmpId; itemPurchase.ItemId = ItemId; itemPurchase.UnitPrice = (RecordInItemPurchase.UnitPrice * -1); itemPurchase.Quantity = NewQty; itemPurchase.FactoryId = RecordInItemPurchase.FactoryId; itemPurchase.CashierId = RecordInItemPurchase.CashierId; db.ItemPurchases.Add(itemPurchase); db.SaveChanges(); ItemTransaction itemTransaction1 = new ItemTransaction();//If any other day- add plus value to transTyoe 2 and minus value to trans Type 3 itemTransaction1.ItemID = ItemId; itemTransaction1.Quantity = (NewQty * -1); itemTransaction1.TransactionTypeId = 2; itemTransaction1.EffectiveDate = EffDate; db.ItemTransactions.Add(itemTransaction1); db.SaveChanges(); ItemTransaction itemTransaction2 = new ItemTransaction(); itemTransaction2.ItemID = ItemId; itemTransaction2.Quantity = NewQty; itemTransaction2.TransactionTypeId = 3; itemTransaction2.EffectiveDate = EffDate; db.ItemTransactions.Add(itemTransaction2); db.SaveChanges(); var EmployeeDetails = db.Employees.Where(e => e.ID == EmpId).FirstOrDefault(); EmployeeDetails.CreditBalance = (EmployeeDetails.CreditBalance + ((RecordInItemPurchase.UnitPrice * -1) * NewQty)); db.Entry(EmployeeDetails).State = EntityState.Modified; db.SaveChanges(); success = "Adjustment Entered Succfully."; } else { error = "Error in Adjustment Entering. Please Start Again"; } return(Json(new { error, success }, JsonRequestBehavior.AllowGet)); }
public void UnPostLedger(EmployeePayment employeePayment) { organization.LedgersDal.RemoveTransaction(employeePayment.Id); employeePayment.PostStatus = LedgerPostStatus.ReadyToPost; organization.SaveChanges(); }
private void ListOfCurrentPayments_CurrentChanged(object sender, EventArgs e) { EmployeePayment currentPayment = ListOfCurrentPayments.CurrentItem as EmployeePayment; RefreshCurrentPayment(currentPayment); }
public ActionResult SavePurchasedItems() { ItemPurchase itemPurchase = new ItemPurchase(); ItemTransaction itemTransaction = new ItemTransaction(); EmployeePayment employeePayment = new EmployeePayment(); int employeeId = Convert.ToInt32(Session["EmployeeId"].ToString()); var employeeBalance = db.Employees.Where(e => e.ID == employeeId).FirstOrDefault(); decimal?OrderAmount = purchaseItems.Sum(i => (i.UnitPrice * i.ItemQty)); decimal?EmployeeBalanceAfterPurchase = (employeeBalance.CreditBalance - OrderAmount); string ParamValue = "0"; string commonThreshold = "CommonThreshold"; var confTbl = db.Configurations.Where(c => c.ParamName == commonThreshold).FirstOrDefault(); if (confTbl.ParamValue == "True") { string minPayment = "MinPayment"; var min = db.Configurations.Where(c => c.ParamName == minPayment).FirstOrDefault(); ParamValue = min.ParamValue; } else { ParamValue = Session["EmployeeMinValue"].ToString(); } if (EmployeeBalanceAfterPurchase > Convert.ToDecimal(ParamValue)) { foreach (var ItemsSelectedToPurchase in purchaseItems) { var itemBalance = db.Items.Where(i => i.ID == ItemsSelectedToPurchase.ItemId).FirstOrDefault(); var selectedItemQty = purchaseItems.Where(i => i.ItemId == ItemsSelectedToPurchase.ItemId).Sum(i => i.ItemQty); if (itemBalance.DaySellingQty >= selectedItemQty) { // Add record to Item Purchase Table itemPurchase.EffectiveDate = DateTime.Now; itemPurchase.EmployeeId = employeeId; itemPurchase.ItemId = ItemsSelectedToPurchase.ItemId; itemPurchase.UnitPrice = ItemsSelectedToPurchase.UnitPrice; itemPurchase.Quantity = ItemsSelectedToPurchase.ItemQty; itemPurchase.FactoryId = Convert.ToInt32(Session["factoryId"].ToString()); itemPurchase.CashierId = Convert.ToInt32(Session["UserId"].ToString()); db.ItemPurchases.Add(itemPurchase); db.SaveChanges(); // Add records to Item Transaction Table itemTransaction.ItemID = ItemsSelectedToPurchase.ItemId; itemTransaction.Quantity = ((ItemsSelectedToPurchase.ItemQty) * -1); itemTransaction.TransactionTypeId = 2; itemTransaction.EffectiveDate = DateTime.Now; db.ItemTransactions.Add(itemTransaction); db.SaveChanges(); //Add Records to Employee Payment Table employeePayment.EmployeeID = employeeId; employeePayment.EffectiveDate = DateTime.Now; employeePayment.Amount = ((ItemsSelectedToPurchase.UnitPrice * ItemsSelectedToPurchase.ItemQty) * -1); db.EmployeePayments.Add(employeePayment); db.SaveChanges(); //Update Day Selling Quantity in Items Table var changedRec = db.Items.Where(i => i.ID == ItemsSelectedToPurchase.ItemId).FirstOrDefault(); changedRec.DaySellingQty = changedRec.DaySellingQty - ItemsSelectedToPurchase.ItemQty; db.Entry(changedRec).State = EntityState.Modified; db.SaveChanges(); //Reduce Balance from Employee Table var reduceEmployeeBalance = db.Employees.Where(e => e.ID == employeeId).FirstOrDefault(); reduceEmployeeBalance.CreditBalance = reduceEmployeeBalance.CreditBalance - ((ItemsSelectedToPurchase.UnitPrice * ItemsSelectedToPurchase.ItemQty)); db.Entry(reduceEmployeeBalance).State = EntityState.Modified; db.SaveChanges(); } else { var userId = Convert.ToInt32(Session["UserId"].ToString()); var items = purchaseItems.Where(e => e.EmployeeID == userId).ToList(); items.Clear(); TempData["NoItems"] = "NOT ENOUGH " + ItemsSelectedToPurchase.ItemName + " FOR SALE"; Session["OrderPrice"] = purchaseItems.Where(p => p.EmployeeID == userId).Sum(p => p.ItemTotal); decimal existingBalance = Convert.ToDecimal(Session["EmployeeExistingBalance"].ToString()); decimal OrderPrice = Convert.ToDecimal(Session["OrderPrice"].ToString()); Session["EmployeeBalance"] = existingBalance - OrderPrice; ViewBag.SelectedItems = purchaseItems; return(PartialView("_getItemQtytoPurchase", ViewBag.SelectedItems)); } } purchaseItems.Clear(); return(RedirectToAction("MPOS")); } else { purchaseItems.Clear(); TempData["NoBalance"] = "BALANCE NOT ENOUGH TO PURCHASE THE ITEM"; ViewBag.SelectedItems = purchaseItems; return(PartialView("_getItemQtytoPurchase", ViewBag.SelectedItems)); } }