public void InsertAndGetInvoicePaymentForMultiCcyInvoice() { var invoice = GetInvoiceTransaction01(); invoice.Currency = "USD"; invoice.AutoPopulateFxRate = true; var invoiceProxy = new InvoiceProxy(); var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the invoice for payment test."); var insertedInvoiceFromDb = invoiceProxy.GetInvoice(insertInvoiceResult.DataObject.InsertedEntityId); var insertedInvoiceAutoPopulatedFxRate = insertedInvoiceFromDb.DataObject.FxRate; var invoicePayment = new PaymentTransaction { TransactionDate = DateTime.Now, TransactionType = "SP", Currency = "USD", AutoPopulateFxRate = true, Summary = string.Format("Test Payment insert for Inv# {0}", insertInvoiceResult.DataObject.GeneratedInvoiceNumber), PaymentAccountId = _bankAccount01Id, PaymentItems = new List <PaymentItem> { new PaymentItem { InvoiceTransactionId = insertInvoiceResult.DataObject.InsertedEntityId, AmountPaid = 110.00M } } }; var invoicePaymentProxy = new PaymentProxy(); var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment); Assert.IsNotNull(insertInvoicePaymentResponse); Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull); Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse); var insertInvoicePaymentResult = insertInvoicePaymentResponse.DataObject; Assert.IsTrue(insertInvoicePaymentResult.InsertedEntityId > 0, string.Format("There was an error creating the invoice payment for Invoice Id {0}", insertInvoiceResult.DataObject.InsertedEntityId)); var getInvoicePaymentResponse = invoicePaymentProxy.GetPayment(insertInvoicePaymentResult.InsertedEntityId); var getInvoicePaymentResult = getInvoicePaymentResponse.DataObject; Assert.IsNotNull(getInvoicePaymentResult); Assert.IsTrue(getInvoicePaymentResult.TransactionId == insertInvoicePaymentResult.InsertedEntityId, "Incorrect payment transaction ID"); Assert.AreEqual(110M, getInvoicePaymentResult.TotalAmount, "Incorrect payment amount."); Assert.IsTrue(getInvoicePaymentResult.AutoPopulateFxRate, "Incorrect auto populate Fx Rate status."); Assert.AreEqual(insertedInvoiceAutoPopulatedFxRate, getInvoicePaymentResult.FxRate, "Incorrect Auto Populated FX Rate"); Assert.IsTrue(getInvoicePaymentResult.PaymentItems.Count == 1, "Incorrect number of payment items."); }
public void CannotApplyPaymentToIncorrectInvoiceTransactionType() { var invoice = GetInvoiceTransaction01(); var invoiceProxy = new InvoiceProxy(); var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the invoice for payment test."); var invoicePayment = new PaymentTransaction { TransactionDate = DateTime.Now, TransactionType = "PP", Currency = "AUD", Summary = string.Format("Test Incorrect Payment Type for Inv# {0}", insertInvoiceResult.DataObject.GeneratedInvoiceNumber), PaymentAccountId = _bankAccount01Id, PaymentItems = new List <PaymentItem> { new PaymentItem { InvoiceTransactionId = insertInvoiceResult.DataObject.InsertedEntityId, AmountPaid = 110.00M } } }; var invoicePaymentProxy = new PaymentProxy(); var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment); Assert.IsNotNull(insertInvoicePaymentResponse); Assert.IsFalse(insertInvoicePaymentResponse.IsSuccessfull); }
public void ShouldRetreivePaymentSummaryForInvoiceId() { var invoice = GetInvoiceTransaction01(); var invoiceProxy = new InvoiceProxy(); var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the first invoice for payment test - ShouldRetreivePaymentSummaryForInvoiceId."); var invoice01TransctionId = insertInvoiceResult.DataObject.InsertedEntityId; invoice = GetInvoiceTransaction02(); invoiceProxy = new InvoiceProxy(); insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the second invoice for payment test - ShouldRetreivePaymentSummaryForInvoiceId."); var invoice02TransactionId = insertInvoiceResult.DataObject.InsertedEntityId; var invoicePayment = new PaymentTransaction { TransactionDate = DateTime.Now, TransactionType = "SP", Currency = "AUD", Summary = string.Format("Test Payment insert for multiple invoices"), PaymentAccountId = _bankAccount01Id, PaymentItems = new List <PaymentItem> { new PaymentItem { InvoiceTransactionId = invoice01TransctionId, AmountPaid = 110.00M }, new PaymentItem { InvoiceTransactionId = invoice02TransactionId, AmountPaid = 150.00M } } }; var invoicePaymentProxy = new PaymentProxy(); var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment); Assert.IsNotNull(insertInvoicePaymentResponse); Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull); Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse); var paymentsResponse = new PaymentsProxy().GetPayments(null, null, invoice02TransactionId, null, null, null, null, null, null, null, null, null); Assert.IsNotNull(paymentsResponse, "Payments response is NULL."); Assert.IsTrue(paymentsResponse.IsSuccessfull, "Payments response was not successful."); Assert.IsNotNull(paymentsResponse.DataObject.PaymentTransactions, "Payments response does not contain a payments summary."); Assert.IsTrue(paymentsResponse.DataObject.PaymentTransactions.Count > 0, "No payment summaries found for transaction type."); Assert.AreEqual(150M, paymentsResponse.DataObject.PaymentTransactions[0].TotalAmount, "Incorrect payment amount"); }
public void InsertAndGetPaymentForSingleInvoice() { var invoice = GetInvoiceTransaction01(); var invoiceProxy = new InvoiceProxy(); var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the invoice for payment test."); var invoicePayment = new PaymentTransaction { TransactionDate = DateTime.Now, TransactionType = "SP", Currency = "AUD", Summary = string.Format("Test Payment insert for Inv# {0}", insertInvoiceResult.DataObject.GeneratedInvoiceNumber), PaymentAccountId = _bankAccount01Id, PaymentItems = new List <PaymentItem> { new PaymentItem() { InvoiceTransactionId = insertInvoiceResult.DataObject.InsertedEntityId, AmountPaid = 110.00M } } }; var invoicePaymentProxy = new PaymentProxy(); var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment); Assert.IsNotNull(insertInvoicePaymentResponse); Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull); Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse); var insertInvoicePaymentResult = insertInvoicePaymentResponse.DataObject; Assert.IsTrue(insertInvoicePaymentResult.InsertedEntityId > 0, string.Format("There was an error creating the invoice payment for Invoice Id {0}", insertInvoiceResult.DataObject.InsertedEntityId)); var getInvoicePaymentResponse = invoicePaymentProxy.GetPayment(insertInvoicePaymentResult.InsertedEntityId); var getInvoicePaymentResult = getInvoicePaymentResponse.DataObject; Assert.IsNotNull(getInvoicePaymentResult); Assert.IsTrue(getInvoicePaymentResult.TransactionId == insertInvoicePaymentResult.InsertedEntityId, "Incorrect payment transaction ID"); Assert.AreEqual(110M, getInvoicePaymentResult.TotalAmount, "Incorrect payment amount."); Assert.IsTrue(getInvoicePaymentResult.PaymentItems.Count == 1, "Incorrect number of payment items."); Assert.IsNull(getInvoicePaymentResult.ClearedDate, "Incorrect cleared date."); foreach (var paymentItem in getInvoicePaymentResult.PaymentItems) { Assert.AreEqual(paymentItem.InvoiceTransactionId, insertInvoiceResult.DataObject.InsertedEntityId, "Incorrect invoice payment item invoice transaction Id."); Assert.AreEqual(paymentItem.AmountPaid, 110M, "Incorrect invoice payment item paid amount."); } }
public void DeleteInvoicePayment() { var invoice = GetInvoiceTransaction01(); var invoiceProxy = new InvoiceProxy(); var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the invoice for payment test."); var invoicePayment = new PaymentTransaction { TransactionDate = DateTime.Now, TransactionType = "SP", Currency = "AUD", Summary = string.Format("Test Update Payment for Inv# {0}", insertInvoiceResult.DataObject.GeneratedInvoiceNumber), PaymentAccountId = _bankAccount01Id, PaymentItems = new List <PaymentItem> { new PaymentItem { InvoiceTransactionId = insertInvoiceResult.DataObject.InsertedEntityId, AmountPaid = 30.00M } } }; var invoicePaymentProxy = new PaymentProxy(); var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment); Assert.IsNotNull(insertInvoicePaymentResponse); Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull); Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse); var deleteInvoicePaymentResponse = invoicePaymentProxy.DeleteInvoicePayment(insertInvoicePaymentResponse.DataObject.InsertedEntityId); Assert.IsNotNull(deleteInvoicePaymentResponse); Assert.IsTrue(deleteInvoicePaymentResponse.IsSuccessfull, "Invoice payment was not deleted successfully."); }
public void UpdatePaymentForSingleInvoice() { var invoice = GetInvoiceTransaction01(); var invoiceProxy = new InvoiceProxy(); var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the invoice for payment test."); var invoicePayment = new PaymentTransaction { TransactionDate = DateTime.Now, TransactionType = "SP", Currency = "AUD", Summary = string.Format("Test Update Payment for Inv# {0}", insertInvoiceResult.DataObject.GeneratedInvoiceNumber), PaymentAccountId = _bankAccount01Id, PaymentItems = new List <PaymentItem> { new PaymentItem { InvoiceTransactionId = insertInvoiceResult.DataObject.InsertedEntityId, AmountPaid = 30.00M } } }; var invoicePaymentProxy = new PaymentProxy(); var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment); Assert.IsNotNull(insertInvoicePaymentResponse); Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull); Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse); var insertedInvoicePaymentEntityId = insertInvoicePaymentResponse.DataObject.InsertedEntityId; var insertedInvoicePaymentLastUpdatedId = insertInvoicePaymentResponse.DataObject.LastUpdatedId; Assert.IsTrue(insertedInvoicePaymentEntityId > 0, string.Format("There was an error creating the invoice payment for Invoice Id {0}", insertInvoiceResult.DataObject.InsertedEntityId)); invoicePayment = new PaymentTransaction { TransactionDate = DateTime.Now.Date, ClearedDate = DateTime.Now.Date.AddDays(2).Date, TransactionType = "SP", Currency = "AUD", Summary = string.Format("Test Update Payment for Inv# {0}", insertInvoiceResult.DataObject.GeneratedInvoiceNumber), PaymentAccountId = _bankAccount02Id, PaymentItems = new List <PaymentItem> { new PaymentItem { InvoiceTransactionId = insertInvoiceResult.DataObject.InsertedEntityId, AmountPaid = 60.00M } }, RequiresFollowUp = true, Notes = "Update payment amount to $60", LastUpdatedId = insertedInvoicePaymentLastUpdatedId }; var updateInvoicePaymentResponse = invoicePaymentProxy.UpdateInvoicePayment(insertedInvoicePaymentEntityId, invoicePayment); Assert.IsNotNull(updateInvoicePaymentResponse); Assert.IsTrue(updateInvoicePaymentResponse.IsSuccessfull); var getInvoicePaymentResponse = invoicePaymentProxy.GetPayment(insertedInvoicePaymentEntityId); var getInvoicePaymentResult = getInvoicePaymentResponse.DataObject; Assert.IsNotNull(getInvoicePaymentResult); Assert.IsTrue(getInvoicePaymentResult.TransactionId == insertedInvoicePaymentEntityId, "Incorrect payment transaction ID."); Assert.AreEqual(DateTime.Now.Date, getInvoicePaymentResult.TransactionDate, "Incorrect payment date."); Assert.AreEqual(DateTime.Now.Date.AddDays(2), getInvoicePaymentResult.ClearedDate, "Incorrect cleared date."); Assert.AreEqual("AUD", getInvoicePaymentResult.Currency, "Incorrect invoice payment currency."); Assert.AreEqual("SP", getInvoicePaymentResult.TransactionType, "Incorrect payment transaction type."); Assert.AreEqual(string.Format("Test Update Payment for Inv# {0}", insertInvoiceResult.DataObject.GeneratedInvoiceNumber), getInvoicePaymentResult.Summary); Assert.AreEqual(60M, getInvoicePaymentResult.TotalAmount, "Incorrect payment amount."); Assert.IsTrue(getInvoicePaymentResult.PaymentItems.Count == 1, "Incorrect number of payment items."); Assert.AreEqual(_bankAccount02Id, getInvoicePaymentResult.PaymentAccountId, "Incorrect payment account"); Assert.AreEqual("Update payment amount to $60", getInvoicePaymentResult.Notes, "Incorrect invoice payment notes."); Assert.IsTrue(getInvoicePaymentResult.PaymentItems.Count == 1, "Incorrect number of payment items."); Assert.IsTrue(getInvoicePaymentResult.RequiresFollowUp, "Incorrect requires follow up status."); var paymentItem = getInvoicePaymentResult.PaymentItems.Find( i => i.InvoiceTransactionId == insertInvoiceResult.DataObject.InsertedEntityId); Assert.IsNotNull(paymentItem, "No payment item for invoice transaction Id {0}", insertInvoiceResult.DataObject.InsertedEntityId); Assert.AreEqual(60M, paymentItem.AmountPaid, "Incorrect amount paid in payment item for invoie transaction Id {0}", paymentItem.InvoiceTransactionId); }
public void InsertAndGetPaymentForMultipleInvoiecs() { var invoice = GetInvoiceTransaction01(); var invoiceProxy = new InvoiceProxy(); var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the invoice for payment test."); var invoice01TransctionId = insertInvoiceResult.DataObject.InsertedEntityId; invoice = GetInvoiceTransaction02(); invoiceProxy = new InvoiceProxy(); insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the invoice for payment test."); var invoice02TransactionId = insertInvoiceResult.DataObject.InsertedEntityId; var invoicePayment = new PaymentTransaction { TransactionDate = DateTime.Now, TransactionType = "SP", Currency = "AUD", Summary = string.Format("Test Payment insert for multiple invoices"), PaymentAccountId = _bankAccount01Id, PaymentItems = new List <PaymentItem> { new PaymentItem { InvoiceTransactionId = invoice01TransctionId, AmountPaid = 110.00M }, new PaymentItem { InvoiceTransactionId = invoice02TransactionId, AmountPaid = 150.00M } } }; var invoicePaymentProxy = new PaymentProxy(); var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment); Assert.IsNotNull(insertInvoicePaymentResponse); Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull); Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse); var insertInvoicePaymentResult = insertInvoicePaymentResponse.DataObject; Assert.IsTrue(insertInvoicePaymentResult.InsertedEntityId > 0, string.Format("There was an error creating the invoice payment for Invoice Id {0}", insertInvoiceResult.DataObject.InsertedEntityId)); var getInvoicePaymentResponse = invoicePaymentProxy.GetPayment(insertInvoicePaymentResult.InsertedEntityId); var getInvoicePaymentResult = getInvoicePaymentResponse.DataObject; Assert.IsNotNull(getInvoicePaymentResult); Assert.IsTrue(getInvoicePaymentResult.TransactionId == insertInvoicePaymentResult.InsertedEntityId, "Incorrect payment transaction ID"); Assert.AreEqual(260M, getInvoicePaymentResult.TotalAmount, "Incorrect payment amount."); Assert.IsTrue(getInvoicePaymentResult.PaymentItems.Count == 2, "Incorrect number of payment items."); var invoicePaymentItem01 = getInvoicePaymentResult.PaymentItems.Find(i => i.InvoiceTransactionId == invoice01TransctionId); var invoicePaymentItem02 = getInvoicePaymentResult.PaymentItems.Find(i => i.InvoiceTransactionId == invoice02TransactionId); Assert.IsNotNull(invoicePaymentItem01, string.Format("No payment item found for invoice transaction Id {0}", invoice01TransctionId)); Assert.IsNotNull(invoicePaymentItem02, string.Format("No payment item found for invoice transaction Id {0}", invoice02TransactionId)); Assert.AreEqual(110M, invoicePaymentItem01.AmountPaid, "Incorrect amount paid in payment item for invoice transaction Id {0}", invoice01TransctionId); Assert.AreEqual(150M, invoicePaymentItem02.AmountPaid, "Incorrect amount paid in payment item for invoice transaction Id {0}", invoice02TransactionId); }
public void DeleteSaleInvoiceWithServiceLayout() { //Insert invoice. var invoice = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Service, transactionType: "S", emailContact: true, invoiceNumber: string.Format("TestInv{0}", Guid.NewGuid())); var proxy = new InvoiceProxy(); var response = proxy.InsertInvoice(invoice); Assert.IsTrue(response.IsSuccessfull); var results = response.DataObject; Assert.AreNotEqual(results.InsertedEntityId, 0); var tranId = results.InsertedEntityId; var invProxy = new InvoiceProxy(); var deleteResponse = invProxy.DeleteInvoice(tranId); Assert.IsTrue(deleteResponse.IsSuccessfull); //get invoice, verify it has been deleted. var getProxy = new InvoiceProxy(); var getResponse = getProxy.GetInvoice(tranId); Assert.IsNull(getResponse.DataObject); }
public void InsertSaleWithQuickPayment() { var invoice = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Service, transactionType: "S", emailContact: false, invoiceNumber: string.Format("TestInv{0}", Guid.NewGuid())); invoice.QuickPayment = new InvoiceQuickPaymentDetail { DatePaid = DateTime.Now.AddDays(-4), DateCleared = DateTime.Now.AddDays(-3), BankedToAccountId = _BankAccountId, Amount = new decimal(10.00), Reference = "Test quick payment reference", Summary = "Test quick payment summary" }; var proxy = new InvoiceProxy(); var response = proxy.InsertInvoice(invoice); Assert.IsTrue(response.IsSuccessfull); Assert.AreNotEqual(response.DataObject.InsertedEntityId, 0); //get invoice. var getResponse = proxy.GetInvoice(response.DataObject.InsertedEntityId); Assert.IsNotNull(getResponse.DataObject.PaymentCount); Assert.AreEqual(getResponse.DataObject.PaymentCount, (Int16)1); Assert.AreEqual(getResponse.DataObject.AmountPaid, new decimal(10.00)); Assert.AreEqual(getResponse.DataObject.AmountOwed, (getResponse.DataObject.TotalAmount - getResponse.DataObject.AmountPaid)); }
public void InsertSaleWithItemLayoutEmailToContactAndAutoNumberAndAutoPopulateFxRate() { var invoice = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Item, transactionType: "S", emailContact: true, autoPopulateFxRate: true); var proxy = new InvoiceProxy(); var response = proxy.InsertInvoice(invoice); Assert.IsTrue(response.IsSuccessfull, string.Format("Inserting an item layout invoice has failed.{0}", ItemLayoutForbiddenMessage)); var results = response.DataObject; Assert.IsNotNull(results.GeneratedInvoiceNumber); Assert.IsTrue(results.SentToContact); Assert.AreNotEqual(results.InsertedEntityId, 0); Assert.AreNotEqual(results.UtcLastModified, DateTime.MinValue); Assert.IsNotNull(results.LastUpdatedId); Assert.AreNotEqual(results.LastUpdatedId.Trim(), string.Empty); //get invoice. var getProxy = new InvoiceProxy(); var getResponse = getProxy.GetInvoice(results.InsertedEntityId); Assert.IsNotNull(getResponse.DataObject); VerifyInvoicesAreEqual(invoice, getResponse.DataObject); }
public void InsertSaleWithAutoPopulateFxRateShouldNotUsePassedInFxRate() { var invoice = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Item, transactionType: "S", autoPopulateFxRate: true, fxRate: 99); var proxy = new InvoiceProxy(); var response = proxy.InsertInvoice(invoice); Assert.IsTrue(response.IsSuccessfull, string.Format("Inserting an item layout invoice has failed.{0}", ItemLayoutForbiddenMessage)); var results = response.DataObject; Assert.AreNotEqual(results.InsertedEntityId, 0); Assert.AreNotEqual(results.UtcLastModified, DateTime.MinValue); Assert.IsNotNull(results.LastUpdatedId); Assert.AreNotEqual(results.LastUpdatedId.Trim(), string.Empty); //get invoice. var getProxy = new InvoiceProxy(); var getResponse = getProxy.GetInvoice(results.InsertedEntityId); Assert.IsNotNull(getResponse.DataObject); Assert.AreNotEqual(99, getResponse.DataObject.FxRate); }
public void InsertSaleAndCanUpdateUsingReturnedLastUpdateId() { var invoice = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Service, transactionType: "S", emailContact: false, invoiceNumber: string.Format("TestInv{0}", Guid.NewGuid())); var proxy = new InvoiceProxy(); var response = proxy.InsertInvoice(invoice); Assert.IsTrue(response.IsSuccessfull); var results = response.DataObject; Assert.IsNull(results.GeneratedInvoiceNumber); Assert.IsFalse(results.SentToContact); Assert.AreNotEqual(results.InsertedEntityId, 0); Assert.AreNotEqual(results.UtcLastModified, DateTime.MinValue); Assert.AreNotEqual(results.LastUpdatedId, null); Assert.AreNotEqual(results.LastUpdatedId.Trim(), string.Empty); //get invoice. var getResponse = proxy.GetInvoice(results.InsertedEntityId); Assert.IsNotNull(getResponse.DataObject); // Do an Update var getInvoice = getResponse.DataObject; getInvoice.Summary = "Update 1"; var updateResponse = proxy.UpdateInvoice(getInvoice.TransactionId.Value, getInvoice); Assert.IsTrue(updateResponse.IsSuccessfull); // Using the LastUpdatedId returned from the previous update, do another update getInvoice.Summary = "Update 2"; getInvoice.LastUpdatedId = updateResponse.DataObject.LastUpdatedId; var updateResponse2 = proxy.UpdateInvoice(getInvoice.TransactionId.Value, getInvoice); Assert.IsTrue(updateResponse2.IsSuccessfull); }
public void InsertDifferentCurrencyForMultiCurrencyFile() { //Insert invoice. var invoice = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Service, transactionType: "S", currency: "USD", fxRate: new decimal(1.50)); var proxy = new InvoiceProxy(); var response = proxy.InsertInvoice(invoice); Assert.IsTrue(response.IsSuccessfull, string.Format("Inserting a multi currency invoice has failed.{0}", MultiCurrencyForbiddenMessage)); var results = response.DataObject; Assert.AreNotEqual(results.InsertedEntityId, 0); Assert.AreNotEqual(results.UtcLastModified, DateTime.MinValue); Assert.AreNotEqual(results.LastUpdatedId, null); Assert.AreNotEqual(results.LastUpdatedId.Trim(), string.Empty); //get invoice. var getResponse = new InvoiceProxy().GetInvoice(results.InsertedEntityId); Assert.IsNotNull(getResponse.DataObject); VerifyInvoicesAreEqual(invoice, getResponse.DataObject); Assert.AreEqual(invoice.FxRate, getResponse.DataObject.FxRate); }
public void GetInvoicesFilterOnBillingContactId() { //Get Id of test contact associated with the invoice. var contactResponse = ContactTests.VerifyTestContactExistsOrCreate(contactType: Ola.RestClient.ContactType.Customer); var billingContactId = contactResponse.DataObject.Contacts[0].Id; //Create and insert test invoices for billing contact. var invoice = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Service, transactionType: "S", emailContact: false, billingContactId: billingContactId); var invoice2 = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Service, transactionType: "S", emailContact: false, billingContactId: billingContactId); var proxy = new InvoiceProxy(); proxy.InsertInvoice(invoice); proxy.InsertInvoice(invoice2); AssertInvoiceProxy(billingContactId: contactResponse.DataObject.Contacts[0].Id); }
public void InvalidCurrencyInsert() { //Insert invoice. var invoice = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Service, transactionType: "S", currency: "TEST"); var proxy = new InvoiceProxy(); var response = proxy.InsertInvoice(invoice); Assert.IsFalse(response.IsSuccessfull); Assert.IsNotNull(response.RawResponse); Assert.IsTrue(response.RawResponse.Contains("Please include a valid currency")); Assert.IsNotNull(response.ReasonCode); Assert.AreEqual(response.ReasonCode.Trim().ToLower(), "bad request"); }
public void TestPaging() { var invoice = GetInvoiceTransaction01(); var invoiceProxy = new InvoiceProxy(); var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice); Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0, "There was an error creating the invoice for payment test."); var invoicePayment1 = new PaymentTransaction { TransactionDate = DateTime.Now, TransactionType = "SP", Currency = "AUD", Summary = string.Format("Test Payment insert for Inv# {0}", insertInvoiceResult.DataObject.GeneratedInvoiceNumber), PaymentAccountId = _bankAccount01Id, PaymentItems = new List <PaymentItem> { new PaymentItem() { InvoiceTransactionId = insertInvoiceResult.DataObject.InsertedEntityId, AmountPaid = 50.00M } } }; var invoicePaymentProxy = new PaymentProxy(); var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment1); Assert.IsNotNull(insertInvoicePaymentResponse); Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull); Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse); var invoicePayment2 = new PaymentTransaction { TransactionDate = DateTime.Now, TransactionType = "SP", Currency = "AUD", Summary = string.Format("Test Payment insert for Inv# {0}", insertInvoiceResult.DataObject.GeneratedInvoiceNumber), PaymentAccountId = _bankAccount01Id, PaymentItems = new List <PaymentItem> { new PaymentItem() { InvoiceTransactionId = insertInvoiceResult.DataObject.InsertedEntityId, AmountPaid = 60.00M } } }; insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment2); Assert.IsNotNull(insertInvoicePaymentResponse); Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull); Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse); var paymentsProxy = new PaymentsProxy(); var paymentsPage1 = paymentsProxy.GetPayments(1, 1, insertInvoiceResult.DataObject.InsertedEntityId, null, "SP", null, null, null, null, null, null, null); Assert.IsNotNull(paymentsPage1); Assert.IsNotNull(paymentsPage1.DataObject); Assert.AreEqual(paymentsPage1.DataObject.PaymentTransactions.Count, 1); var paymentsPage2 = paymentsProxy.GetPayments(2, 1, insertInvoiceResult.DataObject.InsertedEntityId, null, "SP", null, null, null, null, null, null, null); Assert.IsNotNull(paymentsPage2); Assert.IsNotNull(paymentsPage2.DataObject); Assert.AreEqual(paymentsPage2.DataObject.PaymentTransactions.Count, 1); Assert.AreNotEqual(paymentsPage1.DataObject.PaymentTransactions[0].TransactionId, paymentsPage2.DataObject.PaymentTransactions[0].TransactionId); //Test number of rows returned for page. var paymentsPage3 = paymentsProxy.GetPayments(1, 2, insertInvoiceResult.DataObject.InsertedEntityId, null, "SP", null, null, null, null, null, null, null); Assert.IsNotNull(paymentsPage3); Assert.IsNotNull(paymentsPage3.DataObject); Assert.AreEqual(paymentsPage3.DataObject.PaymentTransactions.Count, 2); }
public void DeletePurchaseInvoiceWithItemLayout() { //Insert invoice. var invoice = GetTestInsertInvoice(invoiceLayout: InvoiceLayout.Item, transactionType: "S", emailContact: true); var proxy = new InvoiceProxy(); var response = proxy.InsertInvoice(invoice); Assert.IsTrue(response.IsSuccessfull); var results = response.DataObject; Assert.AreNotEqual(results.InsertedEntityId, 0); var tranId = results.InsertedEntityId; var invProxy = new InvoiceProxy(); var deleteResponse = invProxy.DeleteInvoice(tranId); Assert.IsTrue(deleteResponse.IsSuccessfull); //get invoice, verify it has been deleted. var getProxy = new InvoiceProxy(); var getResponse = getProxy.GetInvoice(tranId); Assert.IsNull(getResponse.DataObject); }