示例#1
0
        public async Task <IActionResult> Edit(string id, [Bind("customerInvoiceLineId,itemId,description,quantity,price,taxId,taxAmount,amount,totalAmount,customerInvoiceId,createdAt")] CustomerInvoiceLine customerInvoiceLine)
        {
            if (id != customerInvoiceLine.customerInvoiceLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerInvoiceLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerInvoiceLineExists(customerInvoiceLine.customerInvoiceLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["customerInvoiceId"] = new SelectList(_context.CustomerInvoice, "customerInvoiceId", "invoiceNumber", customerInvoiceLine.customerInvoiceId);
            ViewData["itemId"]            = new SelectList(_context.Item, "itemId", "itemName", customerInvoiceLine.itemId);
            return(View(customerInvoiceLine));
        }
示例#2
0
        public JsonResult AddInvoiceLine(int Prod, int Qty, double Price, double Total)
        {
            CustomerInvoiceLine SIL = new CustomerInvoiceLine();

            SIL.ProductId = Prod;
            SIL.Qty       = Qty;
            SIL.Price     = Price;
            SIL.Total     = Total;
            return(SIL.Add().DataInJSON);
        }
        public async Task <IActionResult> PostCustomerInvoiceLine([FromBody] CustomerInvoiceLine customerInvoiceLine)
        {
            Item item = await _context.Item.Include(x => x.tax).SingleOrDefaultAsync(x => x.itemId.Equals(customerInvoiceLine.itemId));

            customerInvoiceLine.taxId = item.taxId;



            if (customerInvoiceLine.customerInvoiceLineId == string.Empty)
            {
                customerInvoiceLine.customerInvoiceLineId = Guid.NewGuid().ToString();

                if (customerInvoiceLine.price.Equals(0m))
                {
                    customerInvoiceLine.price = item.price;
                }
                customerInvoiceLine.amount      = (decimal)customerInvoiceLine.quantity * customerInvoiceLine.price;
                customerInvoiceLine.taxAmount   = (decimal)(item.tax.taxRate / 100.0) * customerInvoiceLine.amount;
                customerInvoiceLine.totalAmount = customerInvoiceLine.amount + customerInvoiceLine.taxAmount;
                _context.CustomerInvoiceLine.Add(customerInvoiceLine);

                CustomerInvoice ci = await _context.CustomerInvoice.Include(x => x.customerInvoiceLine).SingleOrDefaultAsync(x => x.customerInvoiceId.Equals(customerInvoiceLine.customerInvoiceId));

                ci.subTotal   = ci.customerInvoiceLine.Sum(x => x.amount);
                ci.taxAmount  = ci.customerInvoiceLine.Sum(x => x.taxAmount);
                ci.grandTotal = ci.subTotal + ci.taxAmount - ci.discount + ci.shipping;
                _context.CustomerInvoice.Update(ci);

                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Add new data success." }));
            }
            else
            {
                if (customerInvoiceLine.price.Equals(0m))
                {
                    customerInvoiceLine.price = item.price;
                }
                customerInvoiceLine.amount      = (decimal)customerInvoiceLine.quantity * customerInvoiceLine.price;
                customerInvoiceLine.taxAmount   = (decimal)(item.tax.taxRate / 100.0) * customerInvoiceLine.amount;
                customerInvoiceLine.totalAmount = customerInvoiceLine.amount + customerInvoiceLine.taxAmount;
                _context.Update(customerInvoiceLine);

                CustomerInvoice ci = await _context.CustomerInvoice.Include(x => x.customerInvoiceLine).SingleOrDefaultAsync(x => x.customerInvoiceId.Equals(customerInvoiceLine.customerInvoiceId));

                ci.subTotal   = ci.customerInvoiceLine.Sum(x => x.amount);
                ci.taxAmount  = ci.customerInvoiceLine.Sum(x => x.taxAmount);
                ci.grandTotal = ci.subTotal + ci.taxAmount - ci.discount + ci.shipping;
                _context.CustomerInvoice.Update(ci);

                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Edit data success." }));
            }
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("customerInvoiceLineId,itemId,description,quantity,price,taxId,taxAmount,amount,totalAmount,customerInvoiceId,createdAt")] CustomerInvoiceLine customerInvoiceLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerInvoiceLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["customerInvoiceId"] = new SelectList(_context.CustomerInvoice, "customerInvoiceId", "invoiceNumber", customerInvoiceLine.customerInvoiceId);
            ViewData["itemId"]            = new SelectList(_context.Item, "itemId", "itemName", customerInvoiceLine.itemId);
            return(View(customerInvoiceLine));
        }
示例#5
0
        public string RemoveInvoiceLine(int id)
        {
            CustomerInvoiceLine SIL = new CustomerInvoiceLine {
                Id = id
            };

            if (SIL.Remove().Message == Message.Invoice_Line_Removed_Successfully)
            {
                return("true");
            }
            else
            {
                return("false");
            }
        }
示例#6
0
        // GET: CustomerInvoiceLine/Create
        public IActionResult Create(string masterid, string id)
        {
            var check    = _context.CustomerInvoiceLine.SingleOrDefault(m => m.customerInvoiceLineId == id);
            var selected = _context.CustomerInvoice.SingleOrDefault(m => m.customerInvoiceId == masterid);

            ViewData["customerInvoiceId"] = new SelectList(_context.CustomerInvoice, "customerInvoiceId", "invoiceNumber");
            ViewData["itemId"]            = new SelectList(_context.Item, "itemId", "itemName");
            if (check == null)
            {
                CustomerInvoiceLine objline = new CustomerInvoiceLine();
                objline.customerInvoice   = selected;
                objline.customerInvoiceId = masterid;
                return(View(objline));
            }
            else
            {
                return(View(check));
            }
        }
示例#7
0
        public string EditFullInvoice(int ISup, DateTime IDate, int ToAcc, int projId, double IDis, double ITotal, double INet, string LineIds)
        {
            CustomerInvoice SI = new CustomerInvoice();

            SI.Id              = (int)TempData["IID"];
            SI.Departed        = false;
            SI.InvoiceDate     = IDate;
            SI.InvoiceDiscount = IDis;
            SI.InvoiceNet      = INet;
            SI.InvoiceAccount  = ToAcc;
            SI.InvoiceTotal    = ITotal;
            SI.LastEditBy      = (Session["User"] as User).ID;
            SI.CustomerID      = ISup;
            SI.ProjectID       = projId;
            string[]      LOSIL = LineIds.Split(',');
            List <string> AIL   = new List <string>(LOSIL);

            AIL.Remove("");
            List <CustomerInvoiceLine> LOCILTS = new List <CustomerInvoiceLine>();
            int Skip         = 0;
            int ObjectsCount = AIL.Count / 5;

            for (int i = 1; i <= ObjectsCount; i++)
            {
                List <string> CurrentObject = new List <string>();
                CurrentObject = AIL.Skip(Skip).Take(5).ToList();
                CustomerInvoiceLine CILTS = new CustomerInvoiceLine();
                CILTS.Id        = Convert.ToInt32(CurrentObject[0]);
                CILTS.ProductId = Convert.ToInt32(CurrentObject[1]);
                CILTS.Qty       = Convert.ToDouble(CurrentObject[2]);
                CILTS.Price     = Convert.ToDouble(CurrentObject[3]);
                CILTS.Total     = Convert.ToDouble(CurrentObject[4]);
                LOCILTS.Add(CILTS);
                Skip += 5;
            }
            TempData.Keep();
            SI.Edit(LOCILTS);
            return("true");
        }
示例#8
0
        public void SaveWorkOrder(DateTime Date, int Acc, int ProjId, string Notes, double Total, string LineIds)
        {
            string[]      LOSIL = LineIds.Split(',');
            List <string> AIL   = new List <string>(LOSIL);

            AIL.Remove("");
            List <CustomerInvoiceLine> LOCILTS = new List <CustomerInvoiceLine>();
            int Skip         = 0;
            int ObjectsCount = AIL.Count / 4;

            for (int i = 1; i <= ObjectsCount; i++)
            {
                List <string> CurrentObject = new List <string>();
                CurrentObject = AIL.Skip(Skip).Take(4).ToList();
                CustomerInvoiceLine CILTS = new CustomerInvoiceLine();
                CILTS.ProductId = Convert.ToInt32(CurrentObject[0]);
                CILTS.Qty       = Convert.ToDouble(CurrentObject[1]);
                CILTS.Price     = Convert.ToDouble(CurrentObject[2]);
                CILTS.Total     = Convert.ToDouble(CurrentObject[3]);
                LOCILTS.Add(CILTS);
                Skip += 4;
            }
            new AccountingTree().SaveWorkOrder(LOCILTS, Date, ProjId, Acc, Notes, Total, (Session["User"] as User).ID);
        }