public void refreshPurchaseInvoices()
        {
            var saleDS         = new DataSet();
            var itemsDataTable = new DataTable("PurchaseOrders");

            itemsDataTable.Columns.Add("Pruchase Date");
            itemsDataTable.Columns.Add("Pruchase Amount");
            itemsDataTable.Columns.Add("Amount Paid");
            itemsDataTable.Columns.Add("Pruchase Status");
            itemsDataTable.Columns.Add("User Name");

            using (var db = new Model.posdbEntities())
            {
                var query = (from v in db.purchasesorders
                             orderby v.PurchaseDate descending
                             select v
                             ).ToList();


                foreach (var item in query)
                {
                    itemsDataTable.Rows.Add(item.PurchaseDate.Value.ToShortDateString(), item.PurchaseAmount, item.AmountPaid, item.PurchaseStatus, item.UserName);
                }

                saleDS.Tables.Add(itemsDataTable);
                PurchaseInvoices.DataSource = saleDS;
                PurchaseInvoices.DataMember = "PurchaseOrders";
                PurchaseInvoices.Refresh();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                Application oApp = null;
                if (args.Length < 1)
                {
                    oApp = new Application();
                }
                else
                {
                    oApp = new Application(args[0]);
                }

                LogService.Filename("AddOnFacturadeProveedor");
                DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany());
                PurchaseInvoices pObjpurchaseInvoices = new PurchaseInvoices();
                LogService.WriteInfo("Addon Iniciado");
                //Menu MyMenu = new Menu();
                //MyMenu.AddMenuItems();
                //oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent);
                Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent);
                oApp.Run();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void FilterInvoices(object sender = null)
        {
            if (sender != null && !(sender as RadioButton)?.Checked == true)
            {
                return;
            }
            PurchaseInvoicesList = PurchaseInvoices.Select(invoice => new PurchaseInvoiceVm
            {
                InvoiceId    = invoice.Id,
                Date         = invoice.Date,
                SupplierName = invoice.Supplier.Name,
                Total        = invoice.Total,
                Paid         = invoice.Paid,
                Discount     = invoice.Discount
            }).ToList();
            var txtSearch = txtSupplierName.Text.FullTrim();

            PurchaseInvoicesList = PurchaseInvoicesList.Where(invoiceVm => invoiceVm.SupplierName.Contains(txtSearch))
                                   .ToList();

            #region Filter by Invoide Date

            if (radThisDay.Checked)
            {
                PurchaseInvoicesList = PurchaseInvoicesList
                                       .Where(invoiceVm => invoiceVm.Date.Date == DateTime.Today.Date).ToList();
            }
            else if (radThisMonth.Checked)
            {
                PurchaseInvoicesList = PurchaseInvoicesList
                                       .Where(invoiceVm => invoiceVm.Date.Month == DateTime.Today.Month).ToList();
            }
            else if (radSpesificDate.Checked && dtInvoiceDate.Value != default)
            {
                PurchaseInvoicesList = PurchaseInvoicesList
                                       .Where(invoiceVm => invoiceVm.Date.Date == dtInvoiceDate.Value.Date).ToList();
            }

            #endregion

            #region Filter by Invoice State

            if (radPaidInvoices.Checked)
            {
                PurchaseInvoicesList = PurchaseInvoicesList.Where(invoiceVm => invoiceVm.IsPaid).ToList();
            }
            else if (radRemainingInvoices.Checked)
            {
                PurchaseInvoicesList = PurchaseInvoicesList.Where(invoiceVm => !invoiceVm.IsPaid).ToList();
            }

            #endregion

            FillGrid();
        }
        public void EditForPurchaseInvoice()
        {
            this.purchaseInvoiceListPage = this.Sidenav.NavigateToPurchaseInvoices();

            var purchaseInvoice = new PurchaseInvoices(this.Session).Extent().First;

            purchaseInvoice.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 = purchaseInvoice.OrderAdjustments.First();
            var id = surchargeAdjustment.Id;

            this.Session.Derive();

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

            this.purchaseInvoiceListPage.Table.DefaultAction(purchaseInvoice);
            var purchaseInvoiceOverview = new PurchaseInvoiceOverviewComponent(this.purchaseInvoiceListPage.Driver);
            var adjustmentOverviewPanel = purchaseInvoiceOverview.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);
        }
Exemplo n.º 5
0
        // Метод для учета поставки.
        public void AcountingSupply(PurchaseInvoice newSupply)
        {
            PurchaseInvoices.Add(newSupply);

            // Для добавления в магазин извлекаем продукты из поставки.
            List <Product> newProducts = newSupply.GetProductFromInvoice();

            // Мы могли бы просто добавить продукты, однако давайте подумаем о том, что определенный продукт может быть уже в магазине,
            // тогда нужно будет увеличить количество, а не иметь два разных продукта.
            foreach (Product newProduct in newProducts)
            {
                if (!newProduct.CheckProduct(Products))
                {
                    Products.Add(newProduct);
                }
            }
        }
Exemplo n.º 6
0
        public void CreatePercentageForPurchaseInvoice()
        {
            this.purchaseInvoiceListPage = this.Sidenav.NavigateToPurchaseInvoices();

            var purchaseInvoice = new PurchaseInvoices(this.Session).Extent().First;

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

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

            purchaseInvoice.AddOrderAdjustment(expected);

            this.Session.Derive();

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

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

            this.purchaseInvoiceListPage.Table.DefaultAction(purchaseInvoice);
            var miscellaneousChargeCreate = new PurchaseInvoiceOverviewComponent(this.purchaseInvoiceListPage.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);
        }
Exemplo n.º 7
0
        public void CreateAmountForPurchaseInvoice()
        {
            this.purchaseInvoiceListPage = this.Sidenav.NavigateToPurchaseInvoices();

            var purchaseInvoice = new PurchaseInvoices(this.Session).Extent().First;

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

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

            purchaseInvoice.AddOrderAdjustment(expected);

            this.Session.Derive();

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

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

            this.purchaseInvoiceListPage.Table.DefaultAction(purchaseInvoice);
            var surchargeAdjustmentCreate = new PurchaseInvoiceOverviewComponent(this.purchaseInvoiceListPage.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);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 设置发票核销
 /// </summary>
 protected virtual void SetInvoices(bool isStatus)
 {
     InvokeItemLoader("InvoiceinItems");
     if (InvoiceinItems == null)
     {
         return;
     }
     foreach (var invoiceinItem in InvoiceinItems)
     {
         var invoice = new PurchaseInvoiceEntity
         {
             Purchase = invoiceinItem.Purchase,
             Amount   = isStatus?invoiceinItem.Amount:0 - invoiceinItem.Amount,
             Number   = InvoiceNumber,
             Remark   = "",
             SaveType = SaveType.Add
         };
         PurchaseInvoices.Add(invoice);
     }
 }
Exemplo n.º 9
0
        private int PrintPurchaseInvoice()
        {
            using (var session = this.databaseService.Database.CreateSession())
            {
                this.logger.LogInformation("Begin");

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

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

                var invoice  = new PurchaseInvoices(session).Extent().Last();
                var template = invoice.BilledTo.PurchaseInvoiceTemplate;

                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 (invoice.ExistInvoiceNumber)
                {
                    var barcodeService = session.ServiceProvider.GetRequiredService <IBarcodeService>();
                    var barcode        = barcodeService.Generate(invoice.InvoiceNumber, BarcodeType.CODE_128, 320, 80);
                    images.Add("Barcode", barcode);
                }

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

                session.Derive();

                var result = invoice.PrintDocument;

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

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

            return(ExitCode.Success);
        }