Ejemplo n.º 1
0
        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.");
        }
Ejemplo n.º 2
0
        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.");
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }