Exemple #1
0
        public IActionResult CreateInvoice()
        {
            Users user = new Users {
                Id = long.Parse(HttpContext.User.FindFirst(ClaimTypes.Actor).Value)
            };
            Invoice invoice = BillingModel.Invoice;

            invoice.CreatedBy = user;
            invoice.Flag      = new BillingFlag {
                Id = Constants.FLAG_PROCESS
            };
            invoice.Save();

            foreach (var itd in BillingModel.Items)
            {
                if (itd.Checked)
                {
                    itd.Invoice   = invoice;
                    itd.CreatedBy = user;
                    itd.Save();
                }
                else
                {
                    itd.Remove();
                }

                Bills bill = itd.Item.Bill;
                bill.SetAutoFlag();
            }

            return(LocalRedirect("/billing/invoice/?qp=" + invoice.Id));
        }
Exemple #2
0
        public bool CancelBillItems(int idnt, string items, string notes)
        {
            Bills bill = new Bills {
                Id = idnt
            };
            Users user = new Users {
                Id = long.Parse(HttpContext.User.FindFirst(ClaimTypes.Actor).Value)
            };

            List <string> Items = items.Split(new string[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries).ToList();

            foreach (var id in Items)
            {
                BillsItem item = new BillsItem {
                    Id           = Convert.ToInt64(id),
                    Bill         = bill,
                    VoidedBy     = user,
                    VoidedReason = notes
                };

                item.Void();
            }

            bill.ProcessedBy = user;
            bill.SetAutoFlag();

            return(true);
        }