示例#1
0
        public void DoNotSyncMailedOrInvoicedItemsFromEbay()
        {
            using (MyDataContext.Default = new MyDataContext(Effort.EntityConnectionFactory.CreateTransient("name=MyDataContext")))
            {
                this.InitializeDatabase();

                TransactionType ebaySale = CreateEbaySale();

                var ebaySyncer = new EbaySalesSyncer();
                ebaySyncer.SyncToSale(ebaySale);

                var sale = MyDataContext.Default.Sales.First();

                // Items which are shipped shouldn't be synced again
                sale.DateOfPayment = DateTime.Now;
                MyDataContext.Default.SaveChanges();
                Mailing.CreateFromUnsentSales();
                ebaySale.Buyer.BuyerInfo.ShippingAddress.Name = "New Name";
                ebaySyncer.SyncToSale(ebaySale);

                Assert.AreNotSame("New Name", sale.InvoiceName);

                // Items which are invoiced shouldn't be synced again
                Invoice.CreateFromUnbilledSales();
                ebaySale.Buyer.BuyerInfo.ShippingAddress.Name = "New Name";
                ebaySyncer.SyncToSale(ebaySale);

                Assert.AreNotSame("New Name", sale.InvoiceName);
            }
        }
示例#2
0
        public void TestEbayShippingCosts()
        {
            using (MyDataContext.Default = new MyDataContext(Effort.EntityConnectionFactory.CreateTransient("name=MyDataContext")))
            {
                this.InitializeDatabase();

                var ebaySale   = CreateEbaySale();
                var ebaySyncer = new EbaySalesSyncer();

                // Without containing order
                ebaySyncer.SyncToSale(ebaySale);

                var sale = MyDataContext.Default.Sales.FirstOrDefault();
                Assert.AreEqual(5, sale.ShippingPrice);

                // Add another sale without containing order and without converted amount
                ebaySale.ShippingDetails.SellingManagerSalesRecordNumber = 1910;
                ebaySale.ConvertedAmountPaid.Value = 0;
                ebaySyncer.SyncToSale(ebaySale);

                sale = MyDataContext.Default.Sales.Where(runner => runner.SourceId == "1910").FirstOrDefault();
                Assert.AreEqual(10, sale.ShippingPrice);

                // With containing order
                ebaySale.ShippingDetails.SellingManagerSalesRecordNumber = 1895;
                ebaySale.ContainingOrder = CreateOrderType();

                ebaySyncer.SyncToSale(ebaySale);

                sale = MyDataContext.Default.Sales.Where(runner => runner.SourceId == "1911").FirstOrDefault();
                Assert.AreEqual(4, sale.ShippingPrice);
            }
        }
示例#3
0
        public void DoNotSyncCanceldOrChangedItemsFromEbay()
        {
            using (MyDataContext.Default = new MyDataContext(Effort.EntityConnectionFactory.CreateTransient("name=MyDataContext")))
            {
                this.InitializeDatabase();

                TransactionType ebaySale = CreateEbaySale();

                var ebaySyncer = new EbaySalesSyncer();
                ebaySyncer.SyncToSale(ebaySale);

                var sale = MyDataContext.Default.Sales.First();

                // Canceled items shouldn't be synced
                sale         = MyDataContext.Default.Sales.First();
                sale.Invoice = null;
                sale.Mailing = null;
                foreach (var item in sale.SaleItems)
                {
                    item.CancelDate = DateTime.Now;
                }
                MyDataContext.Default.SaveChanges();
                ebaySale.Buyer.BuyerInfo.ShippingAddress.Name = "New Name";
                ebaySyncer.SyncToSale(ebaySale);

                Assert.AreNotSame("New Name", sale.InvoiceName);
                foreach (var item in sale.SaleItems)
                {
                    item.CancelDate = null;
                }

                // Items which have been changed manually shouldn't be synced either
                sale = MyDataContext.Default.Sales.First();
                sale.ManuallyChanged = true;
                MyDataContext.Default.SaveChanges();
                ebaySale.Buyer.BuyerInfo.ShippingAddress.Name = "New Name";
                ebaySyncer.SyncToSale(ebaySale);

                Assert.AreNotSame("New Name", sale.InvoiceName);
            }
        }
示例#4
0
        public void DoNotChangeStockAmountWhenSaleItemWasAlreadySyncedBefore()
        {
            using (MyDataContext.Default = new MyDataContext(Effort.EntityConnectionFactory.CreateTransient("name=MyDataContext")))
            {
                this.InitializeDatabase();

                TransactionType ebaySale = CreateEbaySale();

                var ebaySyncer = new EbaySalesSyncer();
                ebaySyncer.SyncToSale(ebaySale);
                Assert.AreEqual(90, MyDataContext.Default.Articles.First().AmountOnStock);

                // Sync existing sale item but in another sale,
                TransactionType anotherEbaySale = CreateEbaySale();
                anotherEbaySale.ContainingOrder = CreateOrderType();

                ebaySyncer.SyncToSale(anotherEbaySale);

                Assert.AreEqual(90, MyDataContext.Default.Articles.First().AmountOnStock);
            }
        }
示例#5
0
        public void SyncEbayWithSpecialEbayArticleNumber()
        {
            using (MyDataContext.Default = new MyDataContext(Effort.EntityConnectionFactory.CreateTransient("name=MyDataContext")))
            {
                String ebayArticleNumber = "wi_131843106366_0";

                this.InitializeDatabase();
                MyDataContext.Default.Articles.First().EbayArticleNumber = ebayArticleNumber;
                MyDataContext.Default.SaveChanges();

                TransactionType ebaySale = CreateEbaySale();
                ebaySale.Item.SKU = ebayArticleNumber;

                var ebaySyncer = new EbaySalesSyncer();
                ebaySyncer.SyncToSale(ebaySale);

                var sale = MyDataContext.Default.Sales.First();
                Assert.AreEqual(MyDataContext.Default.Articles.First(), sale.SaleItems.First().Article);
            }
        }
示例#6
0
        public void SyncEbayTransactionToSale()
        {
            using (MyDataContext.Default = new MyDataContext(Effort.EntityConnectionFactory.CreateTransient("name=MyDataContext")))
            {
                this.InitializeDatabase();

                TransactionType ebaySale = CreateEbaySale();

                var ebaySyncer = new EbaySalesSyncer();
                ebaySyncer.SyncToSale(ebaySale);

                var sale = MyDataContext.Default.Sales.First();

                Assert.AreEqual("1239817", sale.SourceId);
                Assert.AreEqual("komakommander", sale.EbayName);
                Assert.AreEqual("Tobias Mundt", sale.NameOfBuyer);
                Assert.AreEqual("0049 171 1234567", sale.PhoneNumber);
                Assert.AreEqual("*****@*****.**", sale.EMailAddress);
                Assert.AreEqual(new DateTime(2015, 08, 25, 14, 59, 00), sale.DateOfSale);

                Assert.AreEqual("Tobias Mundt", sale.InvoiceName);
                Assert.AreEqual("street1", sale.InvoiceStreet1);
                Assert.AreEqual("street2", sale.InvoiceStreet2);
                Assert.AreEqual("city", sale.InvoiceCity);
                Assert.AreEqual("stateOrProvince", sale.InvoiceRegion);
                Assert.AreEqual("postalCode", sale.InvoicePostcode);
                Assert.AreEqual("countryName", sale.InvoiceCountry);

                Assert.AreEqual("Tobias Mundt", sale.ShippingName);
                Assert.AreEqual("street1", sale.ShippingStreet1);
                Assert.AreEqual("street2", sale.ShippingStreet2);
                Assert.AreEqual("city", sale.ShippingCity);
                Assert.AreEqual("stateOrProvince", sale.ShippingRegion);
                Assert.AreEqual("postalCode", sale.ShippingPostcode);
                Assert.AreEqual("countryName", sale.ShippingCountry);
                Assert.AreEqual(5, sale.ShippingPrice);

                var saleItem = sale.SaleItems.First();
                Assert.AreEqual(1239817, saleItem.EbaySalesRecordNumber);
                Assert.AreEqual("descDe", saleItem.ExternalArticleName);
                Assert.AreEqual("external", saleItem.ExternalArticleNumber);
                Assert.AreEqual("art001", saleItem.InternalArticleNumber);
                Assert.AreEqual(10.0m, saleItem.Amount);
                Assert.AreEqual(19.0m, saleItem.TaxRate);
                Assert.AreEqual(13.0m, saleItem.SinglePriceGross);
                Assert.AreEqual("TestOrderLine", saleItem.EbayOrderLineItemID);

                Assert.AreEqual(90, MyDataContext.Default.Articles.First().AmountOnStock);

                // Item is already synced, so no new entry should be create
                ebaySyncer.SyncToSale(ebaySale);

                var noOfSales     = MyDataContext.Default.Sales.Count();
                var noOfSaleItems = MyDataContext.Default.SaleItems.Count();
                Assert.AreEqual(noOfSales, MyDataContext.Default.Sales.Count());
                Assert.AreEqual(noOfSaleItems, MyDataContext.Default.SaleItems.Count());

                // Add another sale, also private method GetStringFromTransaction is tested here
                ebaySale.Buyer.BuyerInfo.ShippingAddress.Phone           = "invalid request";
                ebaySale.ShippingDetails.SellingManagerSalesRecordNumber = 1910;

                ebaySyncer.SyncToSale(ebaySale);

                sale = MyDataContext.Default.Sales.Where(runner => runner.SourceId == "1910").FirstOrDefault();

                Assert.AreEqual("1910", sale.SourceId);
                Assert.AreEqual(String.Empty, sale.PhoneNumber);
                Assert.AreEqual(80, MyDataContext.Default.Articles.First().AmountOnStock);
            }
        }