public ActionResult _AddInvoice(AddInvoice addInvoice)
        {
            if (this.ModelState.IsValid)
            {
                addInvoice.ExecuteNonQuery();
                return(Redirect(string.Format("/Invoice/{0}", addInvoice.Id)));
            }

            return(View("FormPage", addInvoice));
        }
        public ActionResult _AddInvoice(AddInvoice addInvoice)
        {
            if (this.ModelState.IsValid)
            {
                addInvoice.ExecuteNonQuery();
                return(Redirect($"/Providers/Invoices/Invoice/View/{addInvoice.Id}"));
            }

            return(View("FormPage", addInvoice));
        }
示例#3
0
        //add method. First one will be to show the add page only. This page requires the list of customers.
        public ActionResult Add()
        {
            List <Customer>    customers    = db.Customers.SqlQuery("select * from customers").ToList();
            List <InvoiceItem> invoiceItems = db.InvoiceItems.SqlQuery("select * from invoiceitems").ToList();
            AddInvoice         viewmodel    = new AddInvoice();

            viewmodel.customers    = customers;
            viewmodel.invoiceItems = invoiceItems;
            return(View(viewmodel));
        }
示例#4
0
 private void InvoicesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         AddInvoice?.Invoke(this, new EventArgs());
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         DeleteInvoice?.Invoke(this, new EventArgs());
     }
 }
        public ActionResult Add()
        {
            string userID = User.Identity.GetUserId();

            if (string.IsNullOrEmpty(userID))
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                AddInvoice viewmodel = new AddInvoice();
                viewmodel.Patients = db.Patients.ToList();
                viewmodel.Services = db.Services.ToList();
                return(View(viewmodel));
            }
        }
示例#6
0
        public void InvoiceSmokeTest()
        {
            // Step 1. Create invoice
            AddInvoice addInvoice = new AddInvoice()
            {
                Id = _InvoiceId, OwnerId = ProviderTestData.Wag_Weber_OwnerId, ProviderId = ProviderTestData.Wag_RedwoodCity_ProviderId
            };

            addInvoice.ExecuteNonQuery();

            // Step 2. Get sku from manager

            // Step 3. Add line items

            // Step 4. Fill out the questionaire

            // Step 5.
        }
示例#7
0
        public async Task <HttpResult <bool> > AddInvoice(Invoice invoice, CancellationToken token = default(CancellationToken))
        {
            var result = new HttpResult <bool>();

            var model = new AddInvoice
            {
                DocumentId     = invoice.DocumentId,
                CompletionDate = invoice.CompletionDate,
                Counterparty   = new Common.DTO.Counterparty
                {
                    Id   = invoice.Counterparty.Id,
                    Name = invoice.Counterparty.Name,
                    NIP  = invoice.Counterparty.NIP,
                },
                City = new Common.DTO.City
                {
                    Id   = invoice.City.Id,
                    Name = invoice.City.Name
                },
                InvoiceType   = invoice.InvoiceType,
                PaymentMethod = invoice.PaymentMethod,
                IssueDate     = invoice.IssueDate,
                Products      = invoice.Products.Select(inv => new Data_Access_Layer.Entry
                {
                    Name  = inv.Name,
                    Price = inv.Price,
                    Count = inv.Count,
                    VAT   = inv.VAT
                })
                                .ToList()
            };

            await _unitOfWork.CreateInvoice(model);

            return(result);
        }
        public async Task CreateInvoice(AddInvoice model)
        {
            await RunTaskInTransaction(async() =>
            {
                Data_Access_Layer.Invoice invoice = null;
                Data_Access_Layer.City city       = null;

                if (model.City != null)
                {
                    city = GetOrCreateCity(model.City);
                }

                var entries  = new List <Data_Access_Layer.Entry>();
                var totalVAT = 0m;
                var total    = 0m;

                invoice = new Data_Access_Layer.Invoice
                {
                    CounterpartyId = model.Counterparty.Id,
                    CityId         = model.City.Id,
                    CompletionDate = model.CompletionDate,
                    IssueDate      = model.IssueDate,
                    DocumentId     = model.DocumentId,
                    Total          = total,
                    VAT            = totalVAT,
                    InvoiceType    = model.InvoiceType,
                    PaymentMethod  = model.PaymentMethod,
                    CanEdit        = model.CanEdit
                };

                if (city != null)
                {
                    invoice.CityId = city.Id;
                }

                await InvoiceRepository.Add(invoice);

                foreach (var product in model.Products)
                {
                    var entry = new Data_Access_Layer.Entry
                    {
                        Name      = product.Name,
                        Price     = product.Price,
                        Count     = product.Count,
                        VAT       = product.VAT,
                        InvoiceId = invoice.Id
                    };

                    var amount = entry.Count *entry.Price;
                    totalVAT  += amount *entry.VAT;
                    total     += amount;
                    entries.Add(entry);
                }

                await EntryRepository.AddRange(entries);

                invoice.Total = total;
                invoice.VAT   = totalVAT;

                InvoiceRepository.Update(invoice);

                return(string.Empty);
            });
        }
        public async Task CreateInvoice(AddInvoice model)
        {
            var transaction = _dbContext.Database.BeginTransaction();

            try
            {
                Data_Access_Layer.Invoice invoice = null;
                Data_Access_Layer.City    city    = null;

                if (model.City != null)
                {
                    city = await GetOrAddCity(model.City);
                }

                var entries  = new List <Data_Access_Layer.Entry>();
                var totalVAT = 0m;
                var total    = 0m;

                invoice = new Data_Access_Layer.Invoice
                {
                    CounterpartyId = model.Counterparty.Id,
                    CityId         = model.City.Id,
                    CompletionDate = model.CompletionDate,
                    IssueDate      = model.IssueDate,
                    DocumentId     = model.DocumentId,
                    Total          = total,
                    VAT            = totalVAT,
                    InvoiceType    = model.InvoiceType,
                    PaymentMethod  = model.PaymentMethod,
                    CanEdit        = model.CanEdit
                };

                if (city != null)
                {
                    invoice.CityId = city.Id;
                }

                await InvoiceRepository.Add(invoice);

                Save();

                foreach (var product in model.Products)
                {
                    var entry = new Data_Access_Layer.Entry
                    {
                        Name      = product.Name,
                        Price     = product.Price,
                        Count     = product.Count,
                        VAT       = product.VAT,
                        InvoiceId = invoice.Id
                    };

                    var amount = entry.Count * entry.Price;
                    totalVAT += amount * entry.VAT;
                    total    += amount;
                    entries.Add(entry);
                }

                await EntryRepository.AddRange(entries);

                Save();

                invoice.Total = total;
                invoice.VAT   = totalVAT;

                InvoiceRepository.Update(invoice);
                Save();

                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw;
            }
        }