Example #1
0
 public Havale_Viewer(Contract x, PaymentDraft y, Boolean haveTrans)
 {
     CurrentContract = x;
     CurrentDraft    = y;
     HaveTrans       = haveTrans;
     InitializeComponent();
 }
        public static PaymentDraft DefaultPaymentDraftWithKey(PaymentDraft draft, string key)
        {
            var paymentDraft = DefaultPaymentDraft(draft);

            paymentDraft.Key = key;
            return(paymentDraft);
        }
        public static PaymentDraft DefaultPaymentDraftWithCustomer(PaymentDraft draft, Customer customer)
        {
            var paymentDraft = DefaultPaymentDraft(draft);

            paymentDraft.Customer = customer.ToReference() as Reference <Customer>;
            return(paymentDraft);
        }
        public Payment CreatePayment(PaymentDraft paymentDraft)
        {
            IClient commerceToolsClient = this.GetService <IClient>();
            Payment payment             = commerceToolsClient.ExecuteAsync(new CreateCommand <Payment>(paymentDraft)).Result;

            return(payment);
        }
        public static PaymentDraft DefaultPaymentDraft(PaymentDraft paymentDraft)
        {
            var random = TestingUtility.RandomInt();

            paymentDraft.Key           = $"Key_{random}";
            paymentDraft.AmountPlanned = Money.FromDecimal("EUR", 1000);
            return(paymentDraft);
        }
        public NewPaymentTransfer(PaymentDraft d)
        {
            CurrentDraft = d;
            InitializeComponent();
            object          sender = new object();
            RoutedEventArgs e      = new RoutedEventArgs();

            CalcBtn_Click(sender, e);
        }
        public static PaymentDraft DefaultPaymentDraftWithTransaction(PaymentDraft draft, TransactionDraft transactionDraft)
        {
            var paymentDraft = DefaultPaymentDraft(draft);

            paymentDraft.Transactions = new List <TransactionDraft> {
                transactionDraft
            };
            return(paymentDraft);
        }
Example #8
0
        public void CreatePayment()
        {
            IClient      commerceToolsClient = this.paymentsFixture.GetService <IClient>();
            PaymentDraft paymentDraft        = this.paymentsFixture.GetPaymentDraft();
            Payment      payment             = commerceToolsClient
                                               .ExecuteAsync(new CreateCommand <Payment>(paymentDraft)).Result;

            this.paymentsFixture.PaymentsToDelete.Add(payment);
            Assert.Equal(paymentDraft.Key, payment.Key);
        }
Example #9
0
        /// <summary>
        /// Get Payment Draft
        /// </summary>
        /// <returns></returns>

        public PaymentDraft GetPaymentDraft()
        {
            int          centAmount   = this.RandomInt(100, 10000);
            PaymentDraft paymentDraft = new PaymentDraft
            {
                Key           = this.RandomString(10),
                AmountPlanned = Money.Parse($"{centAmount} EUR")
            };

            return(paymentDraft);
        }
        /// <summary>
        /// Get Payment Draft
        /// </summary>
        /// <returns></returns>

        public PaymentDraft GetPaymentDraft()
        {
            int          centAmount   = TestingUtility.RandomInt(100, 10000);
            PaymentDraft paymentDraft = new PaymentDraft
            {
                Key           = TestingUtility.RandomString(10),
                AmountPlanned = Money.FromDecimal("EUR", centAmount),
                Transactions  = new List <TransactionDraft>()
            };

            return(paymentDraft);
        }
        public PaymentDraft GetPaymentDraftWithCustomFields()
        {
            var          customFieldsDraft = CreateCustomFieldsDraft();
            int          centAmount        = TestingUtility.RandomInt(100, 10000);
            PaymentDraft paymentDraft      = new PaymentDraft
            {
                Key           = TestingUtility.RandomString(10),
                AmountPlanned = Money.FromDecimal("EUR", centAmount),
                Custom        = customFieldsDraft,
                Transactions  = new List <TransactionDraft>()
            };

            return(paymentDraft);
        }
        public static PaymentDraft DefaultPaymentDraftWithCustomType(PaymentDraft draft, Type type, Fields fields)
        {
            var customFieldsDraft = new CustomFieldsDraft
            {
                Type   = type.ToKeyResourceIdentifier(),
                Fields = fields
            };

            var paymentDraft = DefaultPaymentDraft(draft);

            paymentDraft.Custom = customFieldsDraft;

            return(paymentDraft);
        }
Example #13
0
        /// <summary>
        /// Gets a test payment draft.
        /// </summary>
        /// <param name="project">Project</param>
        /// <param name="customerId">Customer ID</param>
        /// <returns>PaymentDraft</returns>
        public static PaymentDraft GetTestPaymentDraft(Project.Project project, string customerId)
        {
            Reference customerReference = new Reference();

            customerReference.Id            = customerId;
            customerReference.ReferenceType = Common.ReferenceType.Customer;

            Money amountPlanned = Helper.GetTestMoney(project);

            PaymentDraft paymentDraft = new PaymentDraft();

            paymentDraft.Customer      = customerReference;
            paymentDraft.AmountPlanned = amountPlanned;

            return(paymentDraft);
        }
Example #14
0
        public async Task ShouldCreateAndDeletePaymentAsync()
        {
            PaymentDraft       paymentDraft = Helper.GetTestPaymentDraft(_project, _testCustomers[1].Id);
            Response <Payment> response     = await _client.Payments().CreatePaymentAsync(paymentDraft);

            Assert.IsTrue(response.Success);

            Payment payment = response.Result;

            Assert.NotNull(payment.Id);

            string deletedPaymentId = payment.Id;

            Response <JObject> deleteResponse = await _client.Payments().DeletePaymentAsync(payment);

            Assert.IsTrue(deleteResponse.Success);

            response = await _client.Payments().GetPaymentByIdAsync(deletedPaymentId);

            Assert.IsFalse(response.Success);
        }
Example #15
0
 internal static bool ValidPaymentDraft(string paymentNumber, PaymentDraft p)
 {
     try
     {
         using (var en = new RTMEntities())
         {
             var t = (from items in en.PaymentDrafts where items.PaymentDraftNumber == paymentNumber select items).FirstOrDefault();
             if (t == null || t.PaymentDraftId == p.PaymentDraftId)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (System.Exception ex)
     {
         ErrorHandler.ShowErrorMessage(Errors.ConnectionError);
         return(false);
     }
 }
Example #16
0
        public void Init()
        {
            _client = Helper.GetClient();

            Task <Response <Project.Project> > projectTask = _client.Project().GetProjectAsync();

            projectTask.Wait();
            Assert.IsTrue(projectTask.Result.Success);
            _project = projectTask.Result.Result;

            _testCustomers = new List <Customer>();
            _testPayments  = new List <Payment>();

            for (int i = 0; i < 5; i++)
            {
                CustomerDraft customerDraft = Helper.GetTestCustomerDraft();
                Task <Response <CustomerCreatedMessage> > customerCreatedTask = _client.Customers().CreateCustomerAsync(customerDraft);
                customerCreatedTask.Wait();
                Assert.IsTrue(customerCreatedTask.Result.Success);

                CustomerCreatedMessage customerCreatedMessage = customerCreatedTask.Result.Result;
                Assert.NotNull(customerCreatedMessage.Customer);
                Assert.NotNull(customerCreatedMessage.Customer.Id);

                _testCustomers.Add(customerCreatedMessage.Customer);

                PaymentDraft paymentDraft = Helper.GetTestPaymentDraft(_project, customerCreatedMessage.Customer.Id);
                Task <Response <Payment> > paymentTask = _client.Payments().CreatePaymentAsync(paymentDraft);
                paymentTask.Wait();
                Assert.IsTrue(paymentTask.Result.Success);

                Payment payment = paymentTask.Result.Result;
                Assert.NotNull(payment.Id);

                _testPayments.Add(payment);
            }
        }
        public void Init()
        {
            _client = new Client(Helper.GetConfiguration());

            Task <Response <Project.Project> > projectTask = _client.Project().GetProjectAsync();

            projectTask.Wait();
            Assert.IsTrue(projectTask.Result.Success);
            _project = projectTask.Result.Result;

            Assert.IsTrue(_project.Languages.Count > 0, "No Languages");
            Assert.IsTrue(_project.Currencies.Count > 0, "No Currencies");

            _testCustomers = new List <Customer>();
            _testCarts     = new List <Cart>();
            _testCartsExternalAmountTaxMode = new List <Cart>();
            CustomerDraft customerDraft;
            Task <Response <CustomerCreatedMessage> > customerTask;
            CustomerCreatedMessage customerCreatedMessage;
            CartDraft cartDraft;
            Cart      cart;
            Task <Response <Cart> > cartTask;

            for (int i = 0; i < 5; i++)
            {
                customerDraft = Helper.GetTestCustomerDraft();
                customerTask  = _client.Customers().CreateCustomerAsync(customerDraft);
                customerTask.Wait();
                Assert.IsTrue(customerTask.Result.Success);

                customerCreatedMessage = customerTask.Result.Result;
                Assert.NotNull(customerCreatedMessage.Customer);
                Assert.NotNull(customerCreatedMessage.Customer.Id);

                _testCustomers.Add(customerCreatedMessage.Customer);

                cartDraft = Helper.GetTestCartDraft(_project, customerCreatedMessage.Customer.Id);
                cartTask  = _client.Carts().CreateCartAsync(cartDraft);
                cartTask.Wait();
                Assert.NotNull(cartTask.Result);
                Assert.IsTrue(cartTask.Result.Success, "CreateCartAsync failed");
                cart = cartTask.Result.Result;
                Assert.NotNull(cart.Id);
                Console.Error.WriteLine(string.Format("CartManagerTest - Information Only - Init TestCartDraft TaxMode: {0}", cartDraft.TaxMode == null ? "(default)" : cart.TaxMode.ToString()));

                _testCarts.Add(cart);


                cartDraft         = Helper.GetTestCartDraft(_project, customerCreatedMessage.Customer.Id);
                cartDraft.TaxMode = TaxMode.ExternalAmount;
                cartTask          = _client.Carts().CreateCartAsync(cartDraft);
                cartTask.Wait();
                Assert.NotNull(cartTask.Result);
                Assert.IsTrue(cartTask.Result.Success, "CreateCartAsync failed");
                cart = cartTask.Result.Result;
                Assert.IsTrue(cart.TaxMode == TaxMode.ExternalAmount, string.Format("Cart created using ExternalAmount TaxMode failed - TaxMode: {0}", cart.TaxMode));
                Assert.NotNull(cart.Id);
                Console.Error.WriteLine(string.Format("CartManagerTest - Information Only - Init TestCartDraft TaxMode: {0}", cartDraft.TaxMode == null ? "(default)" : cart.TaxMode.ToString()));

                _testCartsExternalAmountTaxMode.Add(cart);
            }

            //customer/cart with external tax mode enabled

            customerDraft = Helper.GetTestCustomerDraft();
            customerTask  = _client.Customers().CreateCustomerAsync(customerDraft);
            customerTask.Wait();
            Assert.IsTrue(customerTask.Result.Success);
            customerCreatedMessage = customerTask.Result.Result;
            Assert.NotNull(customerCreatedMessage.Customer);
            Assert.NotNull(customerCreatedMessage.Customer.Id);

            _testCustomers.Add(customerCreatedMessage.Customer);

            cartDraft = Helper.GetTestCartDraftUsingExternalTaxMode(_project, customerCreatedMessage.Customer.Id);
            cartTask  = _client.Carts().CreateCartAsync(cartDraft);
            cartTask.Wait();
            Assert.NotNull(cartTask.Result);
            Assert.IsTrue(cartTask.Result.Success, "CreateCartAsync failed");
            cart = cartTask.Result.Result;
            Assert.NotNull(cart.Id);
            Console.Error.WriteLine(string.Format("CartManagerTest - Information Only - Init TestCartDraft TaxMode: {0}", cart.TaxMode));

            _testCarts.Add(cart);

            ProductTypeDraft productTypeDraft = Helper.GetTestProductTypeDraft();
            Task <Response <ProductType> > testProductTypeTask =
                _client.ProductTypes().CreateProductTypeAsync(productTypeDraft);

            testProductTypeTask.Wait();
            Assert.IsTrue(testProductTypeTask.Result.Success, "CreateProductType failed");
            _testProductType = testProductTypeTask.Result.Result;
            Assert.NotNull(_testProductType.Id);

            TaxCategoryDraft taxCategoryDraft = Helper.GetTestTaxCategoryDraft(_project);
            Task <Response <TaxCategory> > taxCategoryTask =
                _client.TaxCategories().CreateTaxCategoryAsync(taxCategoryDraft);

            taxCategoryTask.Wait();
            Assert.IsTrue(taxCategoryTask.Result.Success, "CreateTaxCategory failed");
            _testTaxCategory = taxCategoryTask.Result.Result;
            Assert.NotNull(_testTaxCategory.Id);

            Task <Response <ZoneQueryResult> > zoneQueryResultTask = _client.Zones().QueryZonesAsync();

            zoneQueryResultTask.Wait();
            Assert.IsTrue(zoneQueryResultTask.Result.Success);

            if (zoneQueryResultTask.Result.Result.Results.Count > 0)
            {
                _testZone        = zoneQueryResultTask.Result.Result.Results[0];
                _createdTestZone = false;
            }
            else
            {
                ZoneDraft zoneDraft = Helper.GetTestZoneDraft();
                Task <Response <Zone> > zoneTask = _client.Zones().CreateZoneAsync(zoneDraft);
                zoneTask.Wait();
                Assert.IsTrue(zoneTask.Result.Success, "CreateZone failed");
                _testZone        = zoneTask.Result.Result;
                _createdTestZone = true;
            }

            Assert.NotNull(_testZone.Id);

            foreach (string country in _project.Countries)
            {
                Location location =
                    _testZone.Locations
                    .Where(l => l.Country.Equals(country, StringComparison.OrdinalIgnoreCase))
                    .FirstOrDefault();

                if (location == null)
                {
                    location         = new Location();
                    location.Country = country;

                    AddLocationAction       addLocationAction = new AddLocationAction(location);
                    Task <Response <Zone> > updateZoneTask    = _client.Zones().UpdateZoneAsync(_testZone, addLocationAction);
                    updateZoneTask.Wait();
                    Assert.IsTrue(updateZoneTask.Result.Success, "UpdateZone failed");
                    _testZone = updateZoneTask.Result.Result;
                }
            }

            Assert.NotNull(_testZone.Locations.Count > 0);

            ShippingMethodDraft shippingMethodDraft =
                Helper.GetTestShippingMethodDraft(_project, _testTaxCategory, _testZone);
            Task <Response <ShippingMethod> > shippingMethodTask =
                _client.ShippingMethods().CreateShippingMethodAsync(shippingMethodDraft);

            shippingMethodTask.Wait();
            Assert.IsTrue(shippingMethodTask.Result.Success, "CreateShippingMethod failed");
            _testShippingMethod = shippingMethodTask.Result.Result;

            Assert.NotNull(_testShippingMethod.Id);

            ProductDraft productDraft = Helper.GetTestProductDraft(_project, _testProductType.Id, _testTaxCategory.Id);
            Task <Response <Product> > testProductTask = _client.Products().CreateProductAsync(productDraft);

            testProductTask.Wait();
            Assert.IsTrue(testProductTask.Result.Success, "CreateProduct failed");
            _testProduct = testProductTask.Result.Result;

            Assert.NotNull(_testProduct.Id);

            PaymentDraft paymentDraft = Helper.GetTestPaymentDraft(_project, _testCustomers[0].Id);
            Task <Response <Payment> > paymentTask = _client.Payments().CreatePaymentAsync(paymentDraft);

            paymentTask.Wait();
            Assert.IsTrue(paymentTask.Result.Success, "CreatePayment failed");
            _testPayment = paymentTask.Result.Result;

            Assert.NotNull(_testPayment.Id);

            TypeDraft typeDraft = Helper.GetTypeDraft(_project);
            Task <Response <Type> > typeTask = _client.Types().CreateTypeAsync(typeDraft);

            typeTask.Wait();
            Assert.IsTrue(typeTask.Result.Success, "CreateType failed");
            _testType = typeTask.Result.Result;
        }
 public NewPaymentTransfer(Contract x)
 {
     CurrentContract = x;
     CurrentDraft    = new PaymentDraft();
     InitializeComponent();
 }