public void EditForProductQuote()
        {
            this.quoteListPage = this.Sidenav.NavigateToProductQuotes();

            var quote = new ProductQuotes(this.Session).Extent().First;

            quote.AddOrderAdjustment(new SurchargeAdjustmentBuilder(this.Session).WithAmountDefaults().Build());

            this.Session.Derive();
            this.Session.Commit();

            var before = new OrderAdjustments(this.Session).Extent().ToArray();

            var expected = new SurchargeAdjustmentBuilder(this.Session).WithAmountDefaults().Build();

            var surchargeAdjustment = quote.OrderAdjustments.First();
            var id = surchargeAdjustment.Id;

            this.Session.Derive();

            var expectedAmount      = expected.Amount;
            var expectedDescription = expected.Description;

            this.quoteListPage.Table.DefaultAction(quote);
            var quoteOverview           = new ProductQuoteOverviewComponent(this.quoteListPage.Driver);
            var adjustmentOverviewPanel = quoteOverview.OrderadjustmentOverviewPanel.Click();

            adjustmentOverviewPanel.Table.DefaultAction(surchargeAdjustment);

            var adjustmentEdit = new OrderAdjustmentEditComponent(this.Driver);

            adjustmentEdit.Amount.Set(expected.Amount.ToString());
            adjustmentEdit.Description.Set(expected.Description);

            this.Session.Rollback();
            adjustmentEdit.SAVE.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new OrderAdjustments(this.Session).Extent().ToArray();

            var actual = (SurchargeAdjustment)this.Session.Instantiate(id);

            Assert.Equal(after.Length, before.Length);

            Assert.Equal(expectedAmount, actual.Amount);
            Assert.Equal(expectedDescription, actual.Description);
        }
Beispiel #2
0
        public void CreatePercentageForProductQuote()
        {
            this.quoteListPage = this.Sidenav.NavigateToProductQuotes();

            var quote = new ProductQuotes(this.Session).Extent().First;

            var before = new MiscellaneousCharges(this.Session).Extent().ToArray();

            var expected = new MiscellaneousChargeBuilder(this.Session).WithPercentageDefaults().Build();

            quote.AddOrderAdjustment(expected);

            this.Session.Derive();

            Assert.True(expected.ExistPercentage);
            Assert.True(expected.ExistDescription);

            var expectedPercentage  = expected.Percentage;
            var expectedDescription = expected.Description;

            this.quoteListPage.Table.DefaultAction(quote);
            var miscellaneousChargeCreate = new ProductQuoteOverviewComponent(this.quoteListPage.Driver).OrderadjustmentOverviewPanel.Click().CreateMiscellaneousCharge();

            miscellaneousChargeCreate
            .Percentage.Set(expectedPercentage.ToString())
            .Description.Set(expectedDescription);

            this.Session.Rollback();
            miscellaneousChargeCreate.SAVE.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new MiscellaneousCharges(this.Session).Extent().ToArray();

            Assert.Equal(after.Length, before.Length + 1);

            var actual = after.Except(before).First();

            Assert.Equal(expectedPercentage, actual.Percentage);
            Assert.Equal(expectedDescription, actual.Description);
        }
Beispiel #3
0
        public void CreateAmountForProductQuote()
        {
            this.quoteListPage = this.Sidenav.NavigateToProductQuotes();

            var quote = new ProductQuotes(this.Session).Extent().First;

            var before = new SurchargeAdjustments(this.Session).Extent().ToArray();

            var expected = new SurchargeAdjustmentBuilder(this.Session).WithAmountDefaults().Build();

            quote.AddOrderAdjustment(expected);

            this.Session.Derive();

            Assert.True(expected.ExistAmount);
            Assert.True(expected.ExistDescription);

            var expectedAmount      = expected.Amount;
            var expectedDescription = expected.Description;

            this.quoteListPage.Table.DefaultAction(quote);
            var surchargeAdjustmentCreate = new ProductQuoteOverviewComponent(this.quoteListPage.Driver).OrderadjustmentOverviewPanel.Click().CreateSurchargeAdjustment();

            surchargeAdjustmentCreate
            .Amount.Set(expectedAmount.ToString())
            .Description.Set(expectedDescription);

            this.Session.Rollback();
            surchargeAdjustmentCreate.SAVE.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new SurchargeAdjustments(this.Session).Extent().ToArray();

            Assert.Equal(after.Length, before.Length + 1);

            var actual = after.Except(before).First();

            Assert.Equal(expectedAmount, actual.Amount);
            Assert.Equal(expectedDescription, actual.Description);
        }
Beispiel #4
0
        private int PrintProductQuote()
        {
            using (var session = this.databaseService.Database.CreateSession())
            {
                this.logger.LogInformation("Begin");

                var scheduler = new AutomatedAgents(session).System;
                session.SetUser(scheduler);

                var templateFilePath = "domain/templates/ProductQuote.odt";
                var templateFileInfo = new FileInfo(templateFilePath);
                var prefix           = string.Empty;
                while (!templateFileInfo.Exists)
                {
                    prefix          += "../";
                    templateFileInfo = new FileInfo(prefix + templateFilePath);
                }

                var quote    = new ProductQuotes(session).Extent().Last();
                var template = quote.Issuer.ProductQuoteTemplate;

                using (var memoryStream = new MemoryStream())
                    using (var fileStream = new FileStream(
                               templateFileInfo.FullName,
                               FileMode.Open,
                               FileAccess.Read,
                               FileShare.ReadWrite))
                    {
                        fileStream.CopyTo(memoryStream);
                        template.Media.InData = memoryStream.ToArray();
                    }

                session.Derive();

                var images = new Dictionary <string, byte[]> {
                    { "Logo", session.GetSingleton().LogoImage.MediaContent.Data },
                };

                if (quote.ExistQuoteNumber)
                {
                    var barcodeService = session.ServiceProvider.GetRequiredService <IBarcodeService>();
                    var barcode        = barcodeService.Generate(quote.QuoteNumber, BarcodeType.CODE_128, 320, 80);
                    images.Add("Barcode", barcode);
                }

                var printModel = new Allors.Domain.Print.ProductQuoteModel.Model(quote, images);
                quote.RenderPrintDocument(template, printModel, images);

                session.Derive();

                var result = quote.PrintDocument;

                var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                var outputFile = File.Create(Path.Combine(desktopDir, "quote.odt"));
                using (var stream = new MemoryStream(result.Media.MediaContent.Data))
                {
                    stream.CopyTo(outputFile);
                }

                this.logger.LogInformation("End");
            }

            return(ExitCode.Success);
        }