示例#1
0
        private void CreateTestSaleInvoices()
        {
            var accountProxy    = new AccountsProxy();
            var accountResponse = accountProxy.GetAccounts(accountType: "Income");
            var incomeAccountId = accountResponse.DataObject.Accounts.Where(a => a.AccountType == "Income").Take(1).SingleOrDefault().Id;

            var invoice = new InvoiceTransactionDetail
            {
                LineItems = new List <InvoiceTransactionLineItem>
                {
                    new InvoiceTransactionLineItem
                    {
                        Description = "line item 1",
                        AccountId   = incomeAccountId,
                        TotalAmount = new decimal(10.00)
                    }
                },
                Currency        = "AUD",
                InvoiceType     = "Tax Invoice",
                TransactionType = "S",
                Layout          = "S",
                TotalAmount     = 10.00M,
                IsTaxInc        = true,
                TransactionDate = DateTime.Now.AddDays(-10),
                Tags            = new List <string> {
                    _testTag
                }
            };

            var invoiceProxy = new InvoiceProxy();
            var result       = invoiceProxy.InsertInvoice(invoice);

            _saleInvoiceTranId = result.DataObject.InsertedEntityId;

            var invoice2 = new InvoiceTransactionDetail
            {
                LineItems = new List <InvoiceTransactionLineItem>
                {
                    new InvoiceTransactionLineItem
                    {
                        Description = "line item 1",
                        AccountId   = incomeAccountId,
                        TotalAmount = new decimal(10.00)
                    }
                },
                Currency        = "AUD",
                InvoiceType     = "Tax Invoice",
                TransactionType = "S",
                Layout          = "S",
                TotalAmount     = 10.00M,
                IsTaxInc        = true,
                TransactionDate = DateTime.Now.AddDays(-10),
                Tags            = new List <string> {
                    _testTag
                }
            };

            result = invoiceProxy.InsertInvoice(invoice2);
            _saleInvoiceTranId2 = result.DataObject.InsertedEntityId;
        }
示例#2
0
        public void ShouldReturnPurchasesOnlyWhenTransactionEntityTypeSpecified()
        {
            var invoiceProxy = new InvoiceProxy();
            var saleInfo     = _searchHelper.GetSaleInvoiceFaker().Generate();
            var saleResponse = invoiceProxy.InsertInvoice(saleInfo);

            Assert.True(saleResponse != null && saleResponse.IsSuccessfull);

            var purchaseInfo     = _searchHelper.GetPurchaseInvoiceFaker(saleInfo.Summary).Generate();
            var purchaseResponse = invoiceProxy.InsertInvoice(purchaseInfo);

            Assert.True(purchaseResponse != null && purchaseResponse.IsSuccessfull);
            Thread.Sleep(5000); // Need to wait for entities to be indexed


            var searchProxy = new SearchProxy();
            var results     = searchProxy.Search(purchaseInfo.Summary, SearchScope.Transactions, 1, 25, "transactions.purchase");

            Assert.NotNull(results);
            Assert.NotNull(results.DataObject);
            Assert.True(results.DataObject.Transactions.TrueForAll(x => x.Type == "P"));
        }