public OrderPdfExport(Biller.UI.ViewModel.MainWindowViewModel MainWindowViewModel, Settings.ViewModel parentViewModel)
 {
     ParentViewModel = parentViewModel;
     this.MainWindowViewModel = MainWindowViewModel;
     PreviewElement = new MigraDoc.Rendering.Windows.DocumentPreview();
     PrintDialog = new System.Windows.Forms.PrintDialog();
     kgUnit = new Biller.Core.Utils.Unit() { DecimalDigits = 3, DecimalSeperator = ",", Name = "Kilogramm", ShortName = "kg", ThousandSeperator = "" };
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses <see cref="Customer"/> and <see cref="OrderedArticles"/>.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="data"></param>
        /// <param name="database"></param>
        /// <returns></returns>
        public bool ParseAdditionalData(ref Biller.Core.Document.Document document, XElement data, Biller.Core.Interfaces.IDatabase database)
        {
            if (document is Offer)
            {
                var result = database.GetCustomer(data.Element("CustomerID").Value);
                var customer = result.Result;
                (document as Offer).Customer = customer;

                var articles = data.Element("OrderedArticles").Elements();
                (document as Offer).OrderedArticles.Clear();
                foreach (XElement article in articles)
                {
                    var temp = new Biller.Core.Articles.OrderedArticle();

                    var task = database.ArticleUnits();
                    temp.ArticleUnit = task.Result.Where(x => x.Name == article.Element("ArticleUnit").Value).Single();

                    var taskTaxClass = database.TaxClasses();
                    temp.TaxClass = taskTaxClass.Result.Where(x => x.Name == article.Element("TaxClass").Value).Single();

                    temp.ParseFromXElement(article);
                    (document as Offer).OrderedArticles.Add(temp);
                }

                try
                {
                    (document as Offer).PaymentMethode.ParseFromXElement(data.Element((document as Offer).PaymentMethode.XElementName));
                    (document as Offer).OrderShipment.ParseFromXElement(data.Element((document as Offer).OrderShipment.XElementName));
                } catch { }
                try
                {
                    (document as Offer).SmallBusiness = Boolean.Parse(data.Element("SmallBusiness").Value);
                    if ((document as Offer).SmallBusiness)
                        (document as Offer).OrderCalculation = new Calculations.SmallBusinessCalculation(document as Order.Order, true);
                    else if (!((document as Offer).OrderCalculation is Calculations.DefaultOrderCalculation))
                        (document as Offer).OrderCalculation = new Calculations.DefaultOrderCalculation(document as Order.Order, true);
                } catch { }
                try
                {
                    if (data.Element("EAddress") != null)
                    {
                        (document as Offer).DeliveryAddress.ParseFromXElement(data.Element("EAddress"));
                    }       
                } catch {}
            }
            else
            {
                return false;
            }
            return true;
        }
        /// <summary>
        /// Works with the <see cref="source"/> when <see cref="target"/> is type of <see cref="Order"/>.
        /// </summary>
        /// <param name="source">When source is type of <see cref="Biller.Core.Customers.Customer"/> or <see cref="Biller.Core.Articles.Article"/> the data will be passed to the target <see cref="Order.Order"/>.</param>
        /// <param name="target"><see cref="source"/> will be passed to <see cref="target"/> if it's type of <see cref="Order.Order"/>.</param>
        public void ReceiveData(object source, Biller.Core.Document.Document target)
        {
            if (target is Order.Order)
            {
                if (source is Biller.Core.Customers.Customer)
                {
                    (target as Order.Order).Customer = (source as Biller.Core.Customers.Customer);
                    (target as Order.Order).PaymentMethode = (source as Biller.Core.Customers.Customer).DefaultPaymentMethode;
                }

                if (source is Biller.Core.Articles.Article)
                {
                    if (target is Order.Order)
                    {
                        if (!String.IsNullOrEmpty((target as Order.Order).Customer.MainAddress.OneLineString))
                        {
                            //Check pricegroup
                            var customer = (target as Order.Order).Customer;
                            var orderedArticle = new Biller.Core.Articles.OrderedArticle(source as Biller.Core.Articles.Article);
                            orderedArticle.OrderedAmount = 1;
                            orderedArticle.OrderPosition = (target as Order.Order).OrderedArticles.Count + 1;

                            switch (customer.Pricegroup)
                            {
                                case 0:
                                    orderedArticle.OrderPrice = orderedArticle.Price1;
                                    break;
                                case 1:
                                    orderedArticle.OrderPrice = orderedArticle.Price2;
                                    break;
                                case 2:
                                    orderedArticle.OrderPrice = orderedArticle.Price3;
                                    break;
                            }
                            (target as Order.Order).OrderedArticles.Add(orderedArticle);

                        }
                        else
                        {
                            var orderedArticle = new Biller.Core.Articles.OrderedArticle(source as Biller.Core.Articles.Article);
                            orderedArticle.OrderedAmount = 1;
                            orderedArticle.OrderPrice = orderedArticle.Price1;
                            orderedArticle.OrderPosition = (target as Order.Order).OrderedArticles.Count + 1;
                            (target as Order.Order).OrderedArticles.Add(orderedArticle);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public AnalyticsReporter(Biller biller, UnibillConfiguration config, IHTTPClient client, IStorage storage, IUtil util, ILevelLoadListener listener)
 {
     this.config = config;
     this.client = client;
     this.util = util;
     this.userId = getUserId (storage);
     biller.onPurchaseComplete += onSucceeded;
     biller.onPurchaseCancelled += (PurchasableItem obj) => onEvent(EventType.purchase_cancelled, obj, null);
     biller.onPurchaseRefunded += (PurchasableItem obj) => onEvent(EventType.purchase_refunded, obj, null);
     biller.onTransactionRestoreBegin += (bool obj) =>  restoreInProgress = true;
     biller.onTransactionsRestored += (bool obj) => restoreInProgress = false;
     listener.registerListener (() => onLevelLoad ());
     onEvent (EventType.new_session, null, null);
     this.levelName = util.loadedLevelName ();
     this.levelLoadTime = DateTime.UtcNow;
 }
 public void ReceiveRequestDocumentCommand(Biller.UI.Interface.ITabContentViewModel source)
 {
     ViewModelRequestingDocument = source;
     ParentViewModel.SelectedContent = TabContent;
 }
 public EntryPoint(Biller.UI.ViewModel.MainWindowViewModel parentViewModel)
 {
     vms = new List<Biller.UI.Interface.IViewModel>();
     this.parentViewModel = parentViewModel;            
 }
Ejemplo n.º 7
0
 public EntryPoint(Biller.UI.ViewModel.MainWindowViewModel parentViewModel)
 {
     this.ParentViewModel = parentViewModel;
     internalViewModels = new List<Biller.UI.Interface.IViewModel>();
 }
        private string ReplaceFooterPlaceHolder(string placeholder, Biller.Core.Models.CompanySettings companySettings)
        {
            if (String.IsNullOrEmpty(placeholder))
                return String.Empty;
            if (companySettings == null)
                return String.Empty;

            if (placeholder.Contains("{CompanyAddress}"))
            {
                var address = "";
                foreach (var line in companySettings.MainAddress.AddressStrings)
                    address += line + "\n";
                placeholder = placeholder.Replace("{CompanyAddress}", address);
            }
            placeholder = placeholder.Replace("{TaxID}", companySettings.TaxID);
            placeholder = placeholder.Replace("{SalesTaxID}", companySettings.SalesTaxID);
                
            return placeholder;
        }
Ejemplo n.º 9
0
 public void ReceiveArticleEditViewModel(Biller.UI.ArticleView.Contextual.ArticleEditViewModel articleEditViewModel)
 {
     //
 }
 public async void RenderDocumentPreview(Biller.Core.Document.Document document)
 {
     if (document is Order.Order)
         PreviewElement.Ddl = DdlWriter.WriteToString(await GetDocument(document as Order.Order));
 }
        private void CreateHeader(Section section, Biller.Core.Models.CompanySettings companySettings, Order.Order order)
        {
            Paragraph paragraph;
            Table table;
            Column column;
            Row row;

            if (!String.IsNullOrEmpty(ParentViewModel.SettingsController.DisplayedPath))
            {
                Image image = section.Headers.Primary.AddImage(ParentViewModel.SettingsController.DisplayedPath);
                image.LockAspectRatio = true;
                switch (ParentViewModel.SettingsController.RelativeVertical)
                {
                    case 0:
                        image.RelativeVertical = RelativeVertical.Margin;
                        break;
                    case 1:
                        image.RelativeVertical = RelativeVertical.Page;
                        break;
                    default:
                        image.RelativeVertical = RelativeVertical.Margin;
                        break;
                }
                switch (ParentViewModel.SettingsController.RelativeHorizontal)
                {
                    case 0:
                        image.RelativeHorizontal = RelativeHorizontal.Margin;
                        break;
                    case 1:
                        image.RelativeHorizontal = RelativeHorizontal.Page;
                        break;
                    default:
                        image.RelativeHorizontal = RelativeHorizontal.Margin;
                        break;
                }
                if (ParentViewModel.SettingsController.ImagePositionLeftIndex >= 0)
                {
                    switch (ParentViewModel.SettingsController.ImagePositionLeftIndex)
                    {
                        case 0:
                            image.Left = ShapePosition.Left;
                            break;
                        case 1:
                            image.Left = ShapePosition.Center;
                            break;
                        case 2:
                            image.Left = ShapePosition.Right;
                            break;
                        default:
                            image.Left = ShapePosition.Center;
                            break;
                    }
                }
                else
                {
                    image.Left = ParentViewModel.SettingsController.cmUnit.ValueToString(ParentViewModel.SettingsController.ImagePositionLeft);
                }
                image.Top = ParentViewModel.SettingsController.cmUnit.ValueToString(ParentViewModel.SettingsController.ImagePositionTop);
                image.WrapFormat.Style = WrapStyle.Through;
            }
            

            // Addresses
            table = section.Headers.Primary.AddTable();
            table.Style = "Table";
            table.Rows.Alignment = RowAlignment.Left;
            column = table.AddColumn("10cm");
            column.Format.Alignment = ParagraphAlignment.Left;
            row = table.AddRow();
            row.Format.SpaceBefore = Unit.FromCentimeter(ParentViewModel.SettingsController.AddressFrameTop);

            if (ParentViewModel.SettingsController.AddressFrameShowSender)
            {
                paragraph = row.Cells[0].AddParagraph(companySettings.MainAddress.OneLineString);
                paragraph.Format.Font.Size = 8;
            }

            row = table.AddRow();
            paragraph = row.Cells[0].AddParagraph();
            foreach (var line in order.Customer.MainAddress.AddressStrings)
                paragraph.AddText(line + "\n");

            table = section.Headers.Primary.AddTable();
            table.Style = "Table";
            table.Rows.Alignment = RowAlignment.Right;
            column = table.AddColumn("3cm");
            column.Format.Alignment = ParagraphAlignment.Left;
            column = table.AddColumn("3cm");
            column.Format.Alignment = ParagraphAlignment.Right;
            row = table.AddRow();
            row.Cells[0].AddParagraph("Rechnungsdatum:");
            row.Cells[1].AddParagraph(order.Date.ToString("dd.MM.yyyy"));
            row = table.AddRow();
            row.Cells[0].AddParagraph("Leistungsdatum:");
            row.Cells[1].AddParagraph(order.DateOfDelivery.ToString("dd.MM.yyyy"));
            if (ParentViewModel.SettingsController.OrderInfoShowCustomerID)
            {
                row = table.AddRow();
                row.Cells[0].AddParagraph("Kundennummer:");
                row.Cells[1].AddParagraph(order.Customer.CustomerID);
            }
            if (ParentViewModel.SettingsController.OrderInfoShowPageNumbers)
            {
                row = table.AddRow();
                row.Cells[0].AddParagraph("Seite");
                paragraph = row.Cells[1].AddParagraph();
                paragraph.AddPageField();
                paragraph.AddText(" von ");
                paragraph.AddNumPagesField();
            }
        }
        private void CreateFooter(Section section, Biller.Core.Models.CompanySettings companySettings)
        {
            var footer = section.Footers.Primary.AddTable();
            footer.Style = "Table";
            footer.Borders.Color = Color.Empty;
            footer.Borders.Visible = false;
            footer.Rows.LeftIndent = 0;
            footer.LeftPadding = "0cm";

            foreach (var footercolumn in ParentViewModel.SettingsController.FooterColumns)
            {
                var fcolumn = footer.AddColumn(Unit.FromCentimeter(footercolumn.ColumnWidth));
                fcolumn.Borders.Visible = false;
                fcolumn.Format.Alignment = footercolumn.Alignment;
            }

            if (ParentViewModel.SettingsController.FooterColumns.Count > 0)
            {
                Row footerrow = footer.AddRow();

                var index = 0;
                foreach (var footercolumn in ParentViewModel.SettingsController.FooterColumns)
                {
                    var content = ReplaceFooterPlaceHolder(footercolumn.Value, companySettings);
                    footerrow.Cells[index].AddParagraph(content);
                    index += 1;
                }
            }
        }
Ejemplo n.º 13
0
 public void ReceiveDocumentEditViewModel(Biller.UI.DocumentView.Contextual.DocumentEditViewModel documentEditViewModel)
 {
     documentEditViewModel.EditContentTabs.Add(new Control.EditTab());
 }
Ejemplo n.º 14
0
 public void ReceiveCustomerEditViewModel(Biller.UI.CustomerView.Contextual.CustomerEditViewModel customerEditViewModel)
 {
     //
 }
        public async void SaveDocument(Biller.Core.Document.Document document, string filename, bool OpenOnSuccess = true)
        {
            if (document is Order.Order)
            {
                PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
                renderer.Document = await GetDocument(document as Order.Order);

                renderer.RenderDocument();
                renderer.Save(filename);

                if (OpenOnSuccess)
                    Process.Start(filename);
            }
        }
Ejemplo n.º 16
0
 public EntryPoint(Biller.UI.ViewModel.MainWindowViewModel parentViewModel)
 {
     this.ParentViewModel = parentViewModel;
 }
        public void PrintDocument(Biller.Core.Document.Document document)
        {
            /*
            // Reuse the renderer from the preview
            RenderDocumentPreview(document);
            DocumentRenderer renderer = this.PreviewElement.Renderer;
            if (renderer != null)
            {
                int pageCount = renderer.FormattedDocument.PageCount;
                // Creates a PrintDocument that simplyfies printing of MigraDoc documents
                MigraDocPrintDocument printDocument = new MigraDocPrintDocument();

                if (PrintDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    // Attach the current printer settings
                    printDocument.PrinterSettings = this.PrintDialog.PrinterSettings;

                    if (this.PrintDialog.PrinterSettings.PrintRange == System.Drawing.Printing.PrintRange.Selection)
                        printDocument.SelectedPage = this.PreviewElement.Page;

                    renderer.PrepareDocument();

                    // Attach the current document renderer
                    printDocument.Renderer = renderer;
                    
                    // Print the document
                    printDocument.Print();
                }
            }
            */

            SaveDocument(document, document.DocumentType + document.DocumentID + ".pdf");
        }
Ejemplo n.º 18
0
 public Biller.Core.Document.PreviewDocument GetPreviewDocument(Biller.Core.Document.Document source)
 {
     return Order.Order.PreviewFromOrder(source as Order.Order);
 }
 private string ReplaceArticlePlaceHolder(string placeholder, Biller.Core.Articles.OrderedArticle article)
 {
     if (placeholder == "{Position}")
         return article.OrderPosition.ToString();
     if (placeholder == "{Amount}")
         return article.OrderedAmountString;
     if (placeholder == "{ArticleID}")
         return article.ArticleID;
     if (placeholder == "{ArticleID}")
         return article.ArticleID;
     if (placeholder == "{ArticleName}")
         return article.ArticleDescription;
     if (placeholder == "{ArticleText}")
         return article.ArticleText;
     if (placeholder == "{ArticleNameWithText}")
         return article.ArticleDescription + "\n" + article.OrderText;
     if (placeholder == "{SinglePriceGross}")
         return article.OrderPrice.Price1.ToString();
     if (placeholder == "{SinglePriceNet}")
         return article.OrderPrice.Price2.ToString();
     if (placeholder == "{TaxRate}")
         return article.TaxClass.TaxRate.PercentageString;
     if (placeholder == "{OrderedValueGross}")
         return article.RoundedGrossOrderValue.ToString();
     if (placeholder == "{OrderedValueNet}")
         return article.RoundedNetOrderValue.ToString();
     if (placeholder == "{Rebate}")
         return article.OrderRebate.PercentageString;
     if (placeholder == "{OrderedWeight}")
         return article.ArticleUnit.ValueToString(article.ArticleWeight * article.OrderedAmount);
     return placeholder;
 }
Ejemplo n.º 20
0
 public void Update(Models.UpdateModel app, Biller.Controls.Notification.UpdateNotification notification)
 {
     DownloadUpdateAsync(app, finished =>
     {
         if (finished)
             ApplyUpdate(app);
     }, progressPercent =>
     {
         notification.Progress = progressPercent;
     });
 }
Ejemplo n.º 21
0
 public ControlManager(Biller.UI.ViewModel.MainWindowViewModel mainWindowViewModel)
 {
     this.mainWindowViewModel = mainWindowViewModel;
     mainWindowViewModel.DocumentTabViewModel.RegisterObserver(this);
 }