public ActionResult SetRecipient(int id, string value) { var entity = SalesOrder.Find(id); string val = (value ?? string.Empty).Trim(); if (entity.IsCompleted || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } var item = entity.Customer.Taxpayers.Single(x => x.Id == val); entity.Recipient = item.Id; entity.RecipientName = item.Name; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } return(Json(new { id = id, value = item.Name })); }
public ActionResult SetCustomerShipTo(int id, string value) { var entity = SalesOrder.Find(id); string val = (value ?? string.Empty).Trim(); if (entity.IsPaid || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } entity.CustomerShipTo = string.IsNullOrEmpty(val) ? null : val; entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; if (string.IsNullOrEmpty(entity.CustomerShipTo)) { foreach (var payment in entity.Payments) { payment.Delete(); } } using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } return(Json(new { id = id, value = value })); }
public ActionResult SetShipTo(int id, int value) { var entity = SalesOrder.Find(id); var item = Address.TryFind(value); if (entity.IsCompleted || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } if (item != null) { entity.ShipTo = item; entity.CustomerShipTo = item.ToString(); entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } } return(Json(new { id = id, value = entity.ShipTo.ToString() })); }
public ActionResult Cancel(int id) { var entity = SalesOrder.Find(id); if (!entity.IsCompleted || entity.IsCancelled || entity.IsPaid) { return(RedirectToAction("Index")); } entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; entity.IsCancelled = true; using (var scope = new TransactionScope()) { foreach (var item in entity.Payments) { var payment = PaymentOnDelivery.Find(item.Id); if (payment != null) { payment.DeleteAndFlush(); } item.Delete(); } entity.UpdateAndFlush(); } return(RedirectToAction("Index")); }
public ActionResult SetPromiseDate(int id, DateTime?value) { var entity = SalesOrder.Find(id); if (entity.IsCompleted || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } if (value != null) { entity.PromiseDate = value.Value; entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } } return(Json(new { id = id, value = entity.FormattedValueFor(x => x.PromiseDate) })); }
public ActionResult GetSalesOrderBalance(int id) { var item = SalesOrder.Find(id); item.Details.ToList(); item.Payments.ToList(); return(PartialView("_SalesOrderBalance", item)); }
public ActionResult Print(int id) { var model = SalesOrder.Find(id); if (model.IsPaid) { return(PdfTicketView("Print", model)); } return(RedirectToAction("Index")); }
public ActionResult PrintDeliveryTicket(int id) { var model = SalesOrder.Find(id); if (model.IsPaid && model.ShipTo == null) { return(PdfTicketView("DeliveryTicket", model)); } return(RedirectToAction("Index")); }
public ActionResult Confirm(int id) { var item = SalesOrder.Find(id); item.Updater = CurrentUser.Employee; item.ModificationTime = DateTime.Now; item.IsDelivered = true; using (var scope = new TransactionScope()) { item.UpdateAndFlush(); } return(RedirectToAction("Index")); }
public ActionResult ConfirmPayment(int id) { var item = SalesOrder.Find(id); item.IsPaid = true; item.ModificationTime = DateTime.Now; item.Updater = CurrentUser.Employee; using (var scope = new TransactionScope()) { item.UpdateAndFlush(); } return(PartialView("_DetailsView", item)); }
public ActionResult SetExchangeRate(int id, string value) { var entity = SalesOrder.Find(id); bool success; decimal val; if (entity.IsCompleted || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } success = decimal.TryParse(value.Trim(), out val); if (success) { if (entity.Currency == WebConfig.BaseCurrency) { Response.StatusCode = 400; return(Content(Resources.Message_InvalidBaseExchangeRate)); } if (val <= 0m) { Response.StatusCode = 400; return(Content(Resources.Message_InvalidExchangeRate)); } entity.ExchangeRate = val; entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; using (var scope = new TransactionScope()) { foreach (var item in entity.Details) { item.ExchangeRate = val; item.Update(); } entity.UpdateAndFlush(); } } return(Json(new { id = entity.Id, value = entity.FormattedValueFor(x => x.ExchangeRate), itemsChanged = success })); }
public ActionResult SetTerms(int id, string value) { bool success; PaymentTerms val; var entity = SalesOrder.Find(id); if (entity.IsCompleted || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } success = Enum.TryParse(value.Trim(), out val); if (success) { if (val == PaymentTerms.NetD && !entity.Customer.HasCredit) { Response.StatusCode = 400; return(Content(Resources.CreditLimitIsNotSet)); } entity.Terms = val; entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; switch (entity.Terms) { case PaymentTerms.Immediate: entity.DueDate = entity.Date; break; case PaymentTerms.NetD: entity.DueDate = entity.Date.AddDays(entity.Customer.CreditDays); break; } using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } } return(Json(new { id = id, value = entity.Terms, dueDate = entity.FormattedValueFor(x => x.DueDate), totalsChanged = success })); }
public ActionResult Edit(int id) { var item = SalesOrder.Find(id); if (item.IsCompleted || item.IsCancelled) { return(RedirectToAction("View", new { id = item.Id })); } if (!CashHelpers.ValidateExchangeRate()) { return(View("InvalidExchangeRate")); } return(View(item)); }
public ActionResult PayOrder(int id) { var drawer = WebConfig.CashDrawer; var session = GetSession(); if (drawer == null) { return(View("InvalidCashDrawer")); } if (session == null) { return(RedirectToAction("OpenSession")); } var item = SalesOrder.Find(id); return(View(item)); }
public ActionResult Cancel(int id) { var entity = SalesOrder.Find(id); if (entity.IsCancelled || entity.IsPaid) { return(RedirectToAction("Index")); } entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; entity.IsCancelled = true; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } return(RedirectToAction("Index")); }
public ActionResult SetCustomer(int id, int value) { var entity = SalesOrder.Find(id); var customer = Customer.TryFind(value); if (entity.IsCancelled || entity.IsPaid) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } if (customer == null) { Response.StatusCode = 400; return(Content(Resources.CustomerNotFound)); } foreach (var payment in entity.Payments) { payment.Delete(); } if (entity.Customer.Id != WebConfig.DefaultCustomer) { entity.CustomerName = string.Empty; } entity.ShipTo = null; entity.CustomerShipTo = null; entity.Customer = customer; entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } return(Json(new { id = id, value = entity.FormattedValueFor(x => x.Customer) })); }
public ActionResult SetCustomerName(int id, string value) { var entity = SalesOrder.Find(id); string val = (value ?? string.Empty).Trim(); if (entity.IsPaid || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } entity.CustomerName = (value.Length == 0) ? null : val; entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } return(Json(new { id = id, value = value })); }
public ViewResult Print(int id) { var item = SalesOrder.Find(id); return(View(item)); }
public override ActionResult Pdf(int id) { var model = SalesOrder.Find(id); return(PdfTicketView("Print", model)); }
public ActionResult Totals(int id) { var entity = SalesOrder.Find(id); return(PartialView("_Totals", entity)); }
public ActionResult GetPayments(int id) { var item = SalesOrder.Find(id); return(PartialView("_Payments", item)); }
public JsonResult AddPayment(int id, int type, decimal amount, string reference, int?fee, bool ondelivery) { var dt = DateTime.Now; var session = GetSession(); var store = session.CashDrawer.Store; var sales_order = SalesOrder.Find(id); var employee = CurrentUser.Employee; var item = new SalesOrderPayment { SalesOrder = sales_order, Payment = new CustomerPayment { Creator = employee, CreationTime = dt, Updater = employee, ModificationTime = dt, CashSession = session, /* SalesOrder = sales_order, */ Customer = sales_order.Customer, Method = (PaymentMethod)type, Amount = amount, Date = DateTime.Now, Reference = reference, Currency = sales_order.Currency }, Amount = amount }; if (fee.HasValue) { item.Payment.ExtraFee = PaymentMethodOption.Find(fee.Value); item.Payment.Commission = item.Payment.ExtraFee.CommissionByManage; } // Store and Serial item.Payment.Store = store; try { item.Payment.Serial = (from x in CustomerPayment.Queryable where x.Store.Id == store.Id select x.Serial).Max() + 1; } catch { item.Payment.Serial = 1; } if (item.Amount > item.SalesOrder.Balance) { if (item.Payment.Method == PaymentMethod.Cash) { item.Change = item.Amount - item.SalesOrder.Balance; } else { item.Payment.Amount = item.SalesOrder.Balance; } item.Amount = item.SalesOrder.Balance; } if (ondelivery && !string.IsNullOrEmpty(sales_order.CustomerShipTo)) { item.Payment.CashSession = null; } using (var scope = new TransactionScope()) { item.Payment.Create(); item.CreateAndFlush(); } return(Json(new { id = item.Id })); }
public ViewResult Print(int id) { var model = SalesOrder.Find(id); return(View(model)); }
public virtual ActionResult Pdf(int id) { var model = SalesOrder.Find(id); return(PdfView("Print", model)); }
public ActionResult Items(int id) { var entity = SalesOrder.Find(id); return(PartialView("_Items", entity.Details)); }
public ActionResult GetCustomerName(int id) { return(PartialView("_CustomerName", SalesOrder.Find(id))); }
public ActionResult SetCustomer(int id, int value) { var entity = SalesOrder.Find(id); var item = Customer.TryFind(value); if (entity.IsCompleted || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } if (item != null) { entity.Customer = item; entity.Contact = null; entity.ShipTo = null; entity.CustomerShipTo = null; entity.CustomerName = null; if (item.SalesPerson == null) { entity.SalesPerson = CurrentUser.Employee; } else { entity.SalesPerson = item.SalesPerson; } if (entity.Terms == PaymentTerms.NetD && !entity.Customer.HasCredit) { entity.Terms = PaymentTerms.Immediate; } switch (entity.Terms) { case PaymentTerms.Immediate: entity.DueDate = entity.Date; break; case PaymentTerms.NetD: entity.DueDate = entity.Date.AddDays(entity.Customer.CreditDays); break; } entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; entity.Recipient = string.Empty; entity.RecipientName = string.Empty; entity.RecipientAddress = null; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } } return(Json(new { id = id, value = entity.FormattedValueFor(x => x.Customer), terms = entity.Terms, termsText = entity.Terms.GetDisplayName(), dueDate = entity.FormattedValueFor(x => x.DueDate), salesPerson = entity.SalesPerson.Id, salesPersonName = entity.SalesPerson.Name })); }