Esempio n. 1
0
 public void RecalculateTotal()
 {
     if (InvoiceLines != null)
     {
         Total = InvoiceLines.Sum(x => x.Total);
         if (Total > 0)
         {
             Discount  = Discount <= Total ? Discount : Total;
             BeforeTax = Total - Discount;
             if (Tax != null)
             {
                 TaxAmount = (Tax.TaxTariffPercentage / 100.0) * BeforeTax;
             }
             else
             {
                 TaxAmount = 0;
             }
             GrandTotal = BeforeTax + TaxAmount;
         }
         else if (Total == 0)
         {
             BeforeTax  = 0;
             Discount   = 0;
             TaxAmount  = 0;
             GrandTotal = 0;
         }
     }
 }
Esempio n. 2
0
        //protected readonly Func<string, SelectOption, bool> FilterOptionValue = FilterOption;

        //protected static bool FilterOption(string value, SelectOption option)
        //    => option.Children.ToUpperInvariant().Contains(value.ToLower(), StringComparison.OrdinalIgnoreCase);

        //protected void OnChange(OneOf<string, IEnumerable<string>, LabeledValue, IEnumerable<LabeledValue>> value,
        //    OneOf<SelectOption, IEnumerable<SelectOption>> option, InvoiceLine line)
        //{
        //    var product = GetProduct(value.Value.ToString());
        //    line.Product = product;
        //    line.Qty     = 1;
        //    line.IsEmpty = false;
        //    InvoiceLines.Add(GetEmptyLine());
        //    OnLineChanged.InvokeAsync(InvoiceLines.ToList());
        //}

        public void ClearLines()
        {
            InvoiceLines.RemoveAll(l => l.Index >= 0);
            //InvoiceLines.ForEach( l => l.CurrentSelect.ClearAll());
            UpdateEmptyLines();
            ((IJSInProcessRuntime)jSRuntime).InvokeVoid("removeLine");
            OnLineChanged.InvokeAsync(InvoiceLines.ToList());
        }
 public void AddLine()
 {
     InvoiceLines.Add(new InvoiceLine()
     {
         Number = "#",
         Title  = ""
     });
 }
Esempio n. 4
0
        public void AddInvoiceLine(Guid examId)
        {
            var ext = InvoiceLines.FirstOrDefault(c => c.InvoiceId == Id && c.ExamId == examId);

            if (ext == null)
            {
                InvoiceLines.Add(new InvoiceLine(Id, examId));
            }
        }
Esempio n. 5
0
 protected virtual void ClearNavigationProperties()
 {
     InvoiceFiles.Clear();
     InvoiceLines.Clear();
     TimeEntries.Clear();
     User = null;
     CustomerInvoiceGroup = null;
     CreditNote.Clear();
     InvoiceComments.Clear();
 }
Esempio n. 6
0
    public Invoices viewInvoiceForCustomer(DateTime startDate, DateTime endDate, int selectedCustomer)
    {
        string sqlStartDate = startDate.ToString("yyyy-MM-dd");
        string sqlEndtDate  = endDate.ToString("yyyy-MM-dd");
        //string orderQuery = "select OrderDate,ServiceID,ShipFromID,ShipToID,TotalPrice,c.CustomerID,c.CustomerName,OrderID from Orders o inner join Customers c on c.CustomerID=o.CustomerID where 1=1 and CustomerID=" + selectedCustomer + " and OrderDate>='" + sqlStartDate + "' and OrderDate<='" + sqlEndtDate + "' and OrderStatusID=6";

        string orderQuery = "select o.OrderID, o.OrderName, o.OrderDate, o.OrderStatusID, os.Status, o.CustomerID, c.CustomerName, o.ServiceID, s.Service, o.TotalPrice,o.ShipFromID,orig.AddressName 'ShipFrom',o.ShipToID,dest.AddressName 'ShipTo' from Orders o inner join OrderStatus os on o.OrderStatusID=os.StatusID inner join Customers c on c.CustomerID=o.CustomerID inner join Services s on s.ServiceID=o.ServiceID inner join Addresses orig on orig.AddressID = o.ShipFromID inner join Addresses dest on dest.AddressID = o.ShipToID where 1=1 and c.CustomerID=" + selectedCustomer + " and OrderDate>='" + sqlStartDate + "' and OrderDate<='" + sqlEndtDate + "' and OrderStatusID=6";


        DbService dbGetOrder = new DbService();
        DataSet   dsGetOrder = dbGetOrder.GetDataSetByQuery(orderQuery);


        List <InvoiceLines> list = new List <InvoiceLines>();

        Invoices inv = new Invoices();


        foreach (DataRow dr in dsGetOrder.Tables[0].Rows)
        {
            Customers c = new Customers();
            c.CustomerName = dr["CustomerName"].ToString();
            c.CustomerID   = (int)dr["CustomerID"];

            inv.InvoiceCustomer = c;

            InvoiceLines tmp = new InvoiceLines();
            tmp.OrderID   = (int)dr["OrderID"];
            tmp.OrderName = dr["OrderName"].ToString();
            tmp.OrderDate = (DateTime)dr["OrderDate"];

            Services s = new Services();
            s.Service        = dr["Service"].ToString();
            s.ServiceID      = (int)dr["ServiceID"];
            tmp.OrderService = s;

            Addresses sf = new Addresses();
            sf.AddressID   = (int)dr["ShipFromID"];
            sf.AddressName = dr["ShipFrom"].ToString();
            tmp.ShipFrom   = sf;

            Addresses st = new Addresses();
            st.AddressID   = (int)dr["ShipToID"];
            st.AddressName = dr["ShipTo"].ToString();
            tmp.ShipTo     = st;

            tmp.TotalPrice = Convert.ToSingle(dr["TotalPrice"]);

            list.Add(tmp);
        }

        inv.InvoiceLines = list;

        return(inv);
    }
        private void ExecuteCreateNewInvoiceLine(object obj)
        {
            var invoiceLine = new InvoiceLine {
                InvoiceID = _invoice.ID, UnitType = (int)UnitTypes.Other, Text = string.Empty
            };

            _invoice.InvoiceLines.Add(invoiceLine);
            InvoiceLines.Add(new InvoiceLineListItemViewModel(invoiceLine));
            ApplyChangesCommand.RaiseCanExecuteChanged();
            //SaveAndCloseCommand.RaiseCanExecuteChanged();
        }
Esempio n. 8
0
 protected void Remove(InvoiceLine line)
 {
     if (line.IsEmpty)
     {
         return;
     }
     line.IsDelete = true;
     //line.CurrentSelect.ClearAll();
     ((IJSInProcessRuntime)jSRuntime).InvokeVoid("removeLine");
     OnLineChanged.InvokeAsync(InvoiceLines.ToList());
 }
 private void OnAddInvoiceLineCommand()
 {
     if (CurrentInvoiceLine.Quantity == 0)
     {
         MessageBox.Show("Quantity can not be 0!");
         return;
     }
     InvoiceLines.Add(CurrentInvoiceLine);
     CalculateInvoiceLine(CurrentInvoiceLine);
     CurrentInvoiceLine = new InvoiceLine();
 }
Esempio n. 10
0
        void UpdateEmptyLines()
        {
            var shouldAddLines = InvoiceLines.Count - InvoiceLines.Count(i => i.Product?.Id != 0) == 1;

            if (shouldAddLines)
            {
                return;
            }

            var line = GetEmptyLine();

            InvoiceLines.Add(line);
        }
Esempio n. 11
0
 public void AddDummyInvoiceLines()
 {
     if (SelectedInvoice.InvoiceID == "Draft")
     {
         var test = new InvoiceLineListItemViewModel(new InvoiceLine {
             InvoiceID = (int)SelectedInvoice.Id
         },
                                                     _dataService)
         {
             IsTemp = true, UnitType = 1
         };
         InvoiceLines.Add(test);
     }
 }
Esempio n. 12
0
        public void GroupByWithSelectorSelectManyTest()
        {
            var result = Session.Query.All <InvoiceLine>()
                         .GroupBy(c => c.Track.Name,
                                  (trackName, invoiceLines) => invoiceLines.Where(k => k.Invoice.Customer.FirstName.Substring(0, 1) == trackName.Substring(0, 1)))
                         .SelectMany(k => k);
            var expected = InvoiceLines
                           .GroupBy(c => c.Track.Name,
                                    (trackName, invoiceLines) => invoiceLines.Where(k => k.Invoice.Customer.FirstName.Substring(0, 1) == trackName.Substring(0, 1)))
                           .SelectMany(k => k);

            Assert.AreEqual(0, expected.Except(result).Count());
            QueryDumper.Dump(result);
        }
        /// <summary>
        /// Prints the order list items.
        /// </summary>
        /// <returns></returns>
        protected override string PrintOrderListItems()
        {
            var orderListItems = InvoiceLines
                                 .SelectMany(L => new List <string>
            {
                $"{L.Quantity} x {L.Description} = {L.TotalAmount.ToCurrencyPrecision()}",
                $"  [{nameof(L.Price)}]: {L.Price.ToCurrencyPrecision()};" +
                $"{(L.Discount > 0 ? $"[{nameof(L.Discount)}]: {L.Discount * 100}%" : string.Empty)}"
            });

            var result = string.Join(Environment.NewLine, orderListItems);

            return(result);
        }
Esempio n. 14
0
        public void SubqueryCalculableColumnTest()
        {
            Require.ProviderIsNot(StorageProvider.SqlServerCe);
            var result = Session.Query.All <Invoice>()
                         .Select(invoice => Session.Query.All <InvoiceLine>()
                                 .Where(p => p.Invoice == invoice)
                                 .Count());
            var expectedResult = Invoices
                                 .Select(invoice => InvoiceLines
                                         .Where(p => p.Invoice == invoice)
                                         .Count());

            Assert.AreEqual(0, expectedResult.Except(result).Count());
            QueryDumper.Dump(result);
        }
Esempio n. 15
0
        protected override Task OnInitializedAsync()
        {
            Console.WriteLine("On initialized async invoice lines");
            ProductDataSource = ProductDataSource.Length > 0
                ? ProductDataSource
                : System.Array.Empty <Product>();

            InvoiceLines = (InvoiceLines?.Count(l => l.Id > 0)) >= 1
                ? InvoiceLines
                : new List <InvoiceLine> {
                GetEmptyLine()
            };

            return(Task.CompletedTask);
        }
        /// <summary>
        /// Prints the order list items.
        /// </summary>
        /// <returns></returns>
        protected override string PrintOrderListItems()
        {
            var orderListItems = string.Join(string.Empty, InvoiceLines
                                             .Select(L =>
                                                     $"<li style='margin-top:.75em;'><span style='font-size:medium;'>" +
                                                     $"{L.Quantity} x {L.Description} = {L.TotalAmount.ToCurrencyPrecision()}</span>" +
                                                     $"<br/><span style='font-size:smaller;'>" +
                                                     $"<strong>[{nameof(L.Price)}]:</strong> {L.Price.ToCurrencyPrecision()};" +
                                                     $"{(L.Discount > 0 ? $" <strong>[{nameof(L.Discount)}]:</strong> {L.Discount * 100}%" : "")}" +
                                                     $"</span></li>"));

            var result = $"<ul>{orderListItems}</ul>";

            return(result);
        }
Esempio n. 17
0
        public void OrderByAnonymousEntityTest()
        {
            var result = Session.Query.All <InvoiceLine>()
                         .Select(il => new { InvoiceLine = il, Invoice = il.Invoice })
                         .OrderBy(x => new { x, x.Invoice.Customer })
                         .Select(x => new { x, x.Invoice.Customer });

            var expected = InvoiceLines
                           .Select(il => new { InvoiceLine = il, Invoice = il.Invoice })
                           .OrderBy(x => x.InvoiceLine.InvoiceLineId)
                           .ThenBy(x => x.Invoice.InvoiceId)
                           .ThenBy(x => x.Invoice.Customer.CustomerId)
                           .Select(x => new { x, x.Invoice.Customer });

            Assert.That(result, Is.Not.Empty);
            Assert.IsTrue(expected.SequenceEqual(result));
        }
Esempio n. 18
0
        private void ExecuteGetInvoicesFromMany(ObservableCollection <CustomersInvoiceView> t)
        {
            try
            {
                var tmp = new ObservableCollection <int>();
                foreach (var customerInvoiceView in t)
                {
                    tmp.Add(customerInvoiceView.CustomerID);
                }

                _dataService.GetInvoicesByCustomerId(tmp).Subscribe(i =>
                {
                    if (i != null)
                    {
                        Invoices = SeeAll == true ? TakeAll(i) : TakeOnlyNoneClosed(i);

                        if (_lastInvoiceSelectedId != null &&
                            Invoices.Select(id => id.Id).Contains(_lastInvoiceSelectedId))
                        {
                            SelectedInvoice = Invoices.First(x => x.Id == _lastInvoiceSelectedId);
                        }

                        if (SelectedInvoice != null && _lastInvoiceSelectedId != null)
                        {
                            LoadInvoiceLines(SelectedInvoice);
                            LoadTimeEntries(SelectedInvoice);
                        }
                        else
                        {
                            TimeEntries.Clear();
                            InvoiceLines.Clear();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Something went wrong in a call on the server", "Error", MessageBoxButton.OK);
                    }
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                throw;
            }
        }
Esempio n. 19
0
 public InvoiceEntity(Invoice Invoice, params object[] args) : base(Invoice)
 {
     foreach (object arg in args)
     {
         if (arg is Order Order)
         {
             OrderEntity = new OrderEntity(Order);
         }
         if (arg is ICollection <InvoiceLine> InvoiceLines)
         {
             InvoiceLineEntities = InvoiceLines.Select(model => new InvoiceLineEntity(model)).ToList();
         }
         if (arg is ICollection <IssueNote> IssueNotes)
         {
             IssueNoteEntities = IssueNotes.Select(model => new IssueNoteEntity(model, model.Customer, model.WareHouse)).ToList();
         }
     }
 }
        /// <summary>
        /// Prints this instance.
        /// </summary>
        /// <returns></returns>
        public override string Print()
        {
            var strBuilder = new StringBuilder();

            strBuilder.AppendLine($"Order Receipt for {CompanyName}");

            if (!InvoiceLines?.Any() ?? true)
            {
                return(strBuilder.ToString());
            }

            strBuilder.AppendLine(PrintOrderListItems());
            strBuilder.AppendLine(PrintSubTotals());
            strBuilder.AppendLine(PrintTotalDiscount());
            strBuilder.AppendLine(PrintTotalTax());
            strBuilder.Append(PrintGrandTotals());

            var result = strBuilder.ToString();

            return(result);
        }
        private void ExecuteDeleteInvoiceLine(object obj)
        {
            _selectedInvoiceLine.InvoiceLine.MarkAsDeleted();

            InvoiceLines.Remove(_selectedInvoiceLine);
            ApplyChangesCommand.RaiseCanExecuteChanged();
            //SaveAndCloseCommand.RaiseCanExecuteChanged();
            //_dataService.SaveInvoice(_invoice).Subscribe(
            //    result =>
            //    {
            //        _invoice = result;

            //        _invoice.MarkAsUnchanged();
            //        _invoice.AcceptChanges();
            //        this.Update();
            //        LoadInvoiceLines();
            //        LoadTimeEntries();
            //    }

            //    );
        }
Esempio n. 22
0
        public void LoadInvoiceLines(InvoiceListItemViewModel invoice)
        {
            if (invoice == null)
            {
                invoice = SelectedInvoice;
            }

            _dataService.GetInvoiceLinesByInvoiceID((int)invoice.Id).Subscribe(
                re =>
            {
                if (InvoiceLines.Count > 0)
                {
                    InvoiceLines.Clear();
                }
                foreach (var invoiceLine in re)
                {
                    invoiceLine.AcceptChanges();
                    InvoiceLines.Add(new InvoiceLineListItemViewModel(invoiceLine, _dataService));
                }
                AddDummyInvoiceLines();
            });
        }
        /// <summary>
        /// Prints this instance.
        /// </summary>
        /// <returns></returns>
        public override string Print()
        {
            var htmlStrBuilder = new StringBuilder();

            htmlStrBuilder.Append($"<html><body><h1>Order Receipt for {CompanyName}</h1>");

            if (!InvoiceLines?.Any() ?? true)
            {
                htmlStrBuilder.Append("</body></html>");
                return(htmlStrBuilder.ToString());
            }

            htmlStrBuilder.Append(PrintOrderListItems());
            htmlStrBuilder.Append(PrintSubTotals());
            htmlStrBuilder.Append(PrintTotalDiscount());
            htmlStrBuilder.Append(PrintTotalTax());
            htmlStrBuilder.Append(PrintGrandTotals());
            htmlStrBuilder.Append($"</body></html>");

            var result = htmlStrBuilder.ToString();

            return(result);
        }
Esempio n. 24
0
 public InvoiceBuilder WithInvoiceLines()
 {
     this.lines = new InvoiceLinesBuilder().Build();
     return(this);
 }
Esempio n. 25
0
 public void AddInvoiceLine(CreateInvoice_InvoiceLine invoiceLine)
 {
     InvoiceLines.Add(invoiceLine);
 }
Esempio n. 26
0
 public void InvoiceLinesChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     TotalAmount = InvoiceLines.Sum(c => c.Amount);
 }
 public void RemoveLine(InvoiceLine line)
 {
     InvoiceLines.Remove(line);
 }
Esempio n. 28
0
 public void AddLine(InvoiceLine line)
 {
     InvoiceLines.Add(line);
 }
 private void OnDeleteInvoiceLineCommand()
 {
     InvoiceLines.Remove(SelectedInvoiceLine);
 }
Esempio n. 30
0
 public void CalculateTotalAmount()
 {
     TotalAmount = InvoiceLines.Sum(l => l.UnitPrice * l.Volume);
 }