private void VerifyInvoiceTermsAreEqual(InvoiceTradingTerms terms1, InvoiceTradingTerms terms2) { if (terms1 == null || terms2 == null) { Assert.IsNull(terms1, "First Terms is not NULL"); Assert.IsNull(terms2, "Second terms is different"); return; } Assert.AreEqual(terms1.Type, terms2.Type, "Terms type is different"); Assert.AreEqual(terms1.Interval, terms2.Interval, "Terms Interval is different"); Assert.AreEqual(terms1.IntervalType, terms2.IntervalType, "Terms Interval type is different"); }
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); }
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 InsertInvoiceWithServiceItemsNoEmailToContact", 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; }