public RedirectResult AddProductLineItem(int invoiceId)
        {
            InvoiceItem lineItem = new InvoiceItem();
            lineItem.Invoice = new InvoiceRepository().Get(invoiceId);
            lineItem.IsActive = true;
            lineItem.Product = new ProductRepository().Get(1);
            lineItem.Quantity = 1;

            new InvoiceRepository().AddLineItem(lineItem);
            return new RedirectResult("/Billing/Edit/" + invoiceId);
        }
Beispiel #2
0
 /// <summary>
 /// Remove an invoice item from the list of items on this invoice
 /// </summary>
 /// <param name="item">Invoice item to remove from the list</param>
 public virtual void RemoveLineItem(InvoiceItem item)
 {
     Items.Remove(item);
 }
Beispiel #3
0
 /// <summary>
 /// Add new invoice item to the list of items on this invoice
 /// </summary>
 /// <param name="item">Invoice item that contains details for the invoice</param>
 public virtual void AddLineItem(InvoiceItem item)
 {
     Items.Add(item);
 }
        /// <summary>
        /// Add an item to the patient's invoice.
        /// </summary>
        /// <returns>The Jason object so it can be immediately displayed.</returns>
        public JsonResult AddInvoiceItem()
        {
            try
            {
                //Build Line Item objects
                InvoiceItem lineItem = new InvoiceItem();

                //Get patient object
                int patientID = int.Parse(Request.Form["patientID"]);
                PatientRepository patientRepo = new PatientRepository();
                var patient = patientRepo.Get(patientID);

                //Get current open patient checkin
                var query = from checkin in patient.PatientCheckIns
                            where checkin.CheckOutTime == DateTime.MinValue
                            select checkin;
                PatientCheckIn openCheckIn = query.First<PatientCheckIn>();

                //Invoice Repository
                InvoiceRepository invoiceRepo = new InvoiceRepository();

                //Product Repository
                ProductRepository productRepo = new ProductRepository();

                //Service Repository
                ServiceRepository serviceRepo = new ServiceRepository();

                //Quantity
                if (Request.Form["quantity"] != "")
                {
                    lineItem.Quantity = int.Parse(Request.Form["quantity"]);
                    lineItem.Invoice = openCheckIn.Invoice;
                    lineItem.IsActive = true;

                    //Product
                    if (Request.Form["product"] != "")
                    {
                        lineItem.Product = productRepo.Get(int.Parse(Request.Form["product"]));
                        lineItem.Service = null;
                        invoiceRepo.AddLineItem(lineItem);
                        UnitOfWork.CurrentSession.Flush();
                        return Json(new
                        {
                            error = "false",
                            lineItem.Product.Name,
                            lineItem.Quantity

                        });
                    } //Service
                    else if (Request.Form["service"] != "")
                    {
                        lineItem.Service = serviceRepo.Get(int.Parse(Request.Form["service"]));
                        lineItem.Product = null;
                        invoiceRepo.AddLineItem(lineItem);
                        UnitOfWork.CurrentSession.Flush();
                        return Json(new
                        {
                            error = "false",
                            lineItem.Service.Name,
                            lineItem.Quantity
                        });
                    }
                }

                return Json(new
                {
                    error = "false"
                });
            }
            catch (Exception e)
            {
                return Json(new
                {
                    error = "true",
                    status = e.Message
                });
            }
        }
 public ActionResult Service(InvoiceItem lineItem)
 {
     //add save code here?
     try
     {
         BillingEditViewModel invoice = new BillingEditViewModel(lineItem.Invoice.Id);
         invoice.Save();
         return RedirectToAction("Edit");
     }
     catch
     {
         return RedirectToAction("Index");
     }
 }
        public ActionResult Service(int invoiceId)
        {
            var lineItem = new InvoiceItem();
            var repo = new InvoiceRepository();
            lineItem.Service = new ServiceRepository().Get(1);
            lineItem.Invoice = repo.Get(invoiceId);
            lineItem.IsActive = true;
            repo.AddLineItem(lineItem);

            return View(lineItem);
        }
Beispiel #7
0
 /// <summary>
 /// Remove an invoice item from the list of items on this invoice
 /// </summary>
 /// <param name="item">Invoice item to remove from the list</param>
 public virtual void RemoveLineItem(InvoiceItem item)
 {
     Items.Remove(item);
 }
Beispiel #8
0
 /// <summary>
 /// Add new invoice item to the list of items on this invoice
 /// </summary>
 /// <param name="item">Invoice item that contains details for the invoice</param>
 public virtual void AddLineItem(InvoiceItem item)
 {
     Items.Add(item);
 }
 /// <summary>
 /// Adds an InvoiceItem to the database.
 /// </summary>
 /// <param name="lineItem">The item to be added.</param>
 public void AddLineItem(InvoiceItem lineItem)
 {
     Session.SaveOrUpdate(lineItem);
 }
 /// <summary>
 /// Removes an InvoiceItem from the database.
 /// </summary>
 /// <param name="lineItem">the InvoiceItem to be removed.</param>
 public void RemoveLineItem(InvoiceItem lineItem)
 {
     Session.Delete(lineItem);
 }