예제 #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 ProxyResponse <UpdateInvoiceResult> UpdateInvoice(int invoiceId, InvoiceTransactionDetail invoiceDetail)
        {
            OperationMethod = HttpMethod.Put;
            _requestPrefix  = ResourceNames.Invoice;
            var uri = base.GetRequestUri(invoiceId.ToString());

            return(base.GetResponse <InvoiceTransactionDetail, UpdateInvoiceResult>(uri, invoiceDetail));
        }
예제 #3
0
        public ProxyResponse <InsertInvoiceResult> InsertInvoice(InvoiceTransactionDetail invoiceDetail)
        {
            _requestPrefix  = ResourceNames.Invoice;
            OperationMethod = HttpMethod.Post;
            var uri = base.GetRequestUri(null);

            return(base.GetResponse <InvoiceTransactionDetail, InsertInvoiceResult>(uri, invoiceDetail));
        }
예제 #4
0
        private InvoiceTransactionDetail GetTestInsertInvoice(string invoiceLayout, List <InvoiceTransactionLineItem> lineItems = null, string notesInternal = null,
                                                              string notesExternal = null, InvoiceTradingTerms terms = null, List <FileAttachmentInfo> attachments = null, int?templateId       = null,
                                                              bool emailContact    = false, Saasu.API.Core.Models.Email emailMessage = null, string currency       = null, string invoiceNumber = null, string purchaseOrderNumber = null,
                                                              string invoiceType   = null, string transactionType = null, string summary     = null, decimal?totalAmountInclTax = null, bool requiresFollowUp = false, DateTime?transactionDate = null,
                                                              int?billingContactId = null, int?shippingContactId  = null, List <string> tags = null, decimal?fxRate             = null, string invoiceStatus  = null,
                                                              bool actuallyInsertAndVerifyResponse = false, bool autoPopulateFxRate = false)
        {
            var tranType = transactionType ?? "S";

            var invDetail = new InvoiceTransactionDetail
            {
                LineItems           = lineItems ?? GetInsertItems(invoiceLayout, tranType),
                NotesInternal       = notesInternal ?? "Test internal note",
                NotesExternal       = notesExternal ?? "Test external note",
                Terms               = terms ?? GetTradingTerms(),
                Attachments         = attachments ?? GetAttachments(),
                TemplateId          = templateId ?? GetTemplateUid(),
                SendEmailToContact  = emailContact,
                EmailMessage        = emailMessage ?? GetEmailMessage(),
                Currency            = currency ?? "AUD",
                InvoiceNumber       = invoiceNumber ?? AutoNumber,
                PurchaseOrderNumber = purchaseOrderNumber ?? AutoNumber,
                InvoiceType         = invoiceType ?? "Tax Invoice",
                TransactionType     = tranType,
                Layout              = invoiceLayout,
                Summary             = summary ?? "Summary " + Guid.NewGuid(),
                TotalAmount         = totalAmountInclTax ?? new decimal(20.00),
                IsTaxInc            = true,
                RequiresFollowUp    = requiresFollowUp,
                TransactionDate     = transactionDate ?? DateTime.Now.AddDays(-10),
                BillingContactId    = billingContactId ?? _BillingContactId,
                ShippingContactId   = shippingContactId ?? _ShippingContactId,
                FxRate              = fxRate,
                AutoPopulateFxRate  = autoPopulateFxRate,
                InvoiceStatus       = invoiceStatus,
                Tags = tags ?? new List <string> {
                    "invoice header tag 1", "invoice header tag 2"
                }
            };

            if (actuallyInsertAndVerifyResponse)
            {
                var response = new InvoiceProxy().InsertInvoice(invDetail);

                Assert.IsNotNull(response, "Inserting an invoice did not return a response");
                Assert.IsTrue(response.IsSuccessfull, "Inserting an invoice was not successfull. Status code: " + ((int)response.StatusCode).ToString());
                Assert.IsNotNull(response.RawResponse, "No raw response returned as part of inserting an invoice");

                var serialized = response.DataObject;

                Assert.IsTrue(serialized.InsertedEntityId > 0, "Invoice insert did not return an InsertedEntityId > 0");

                invDetail.TransactionId = serialized.InsertedEntityId;
            }

            return(invDetail);
        }
예제 #5
0
        private InvoiceTransactionDetail GetInvoiceTransaction02()
        {
            var invDetail = new InvoiceTransactionDetail
            {
                LineItems = new List <InvoiceTransactionLineItem>
                {
                    new InvoiceTransactionLineItem
                    {
                        AccountId   = IncomeHardwareSales,
                        TotalAmount = 150M
                    }
                },
                InvoiceNumber   = "<Auto Number>",
                InvoiceType     = "Tax Invoice",
                TransactionType = "S",
                Layout          = "S",
                Summary         = "Test Invoice For Payment",
                TransactionDate = DateTime.Now
            };

            return(invDetail);
        }