Пример #1
0
        public ConfirmPage(WizardData wizardData)
        {
            InitializeComponent();

            AccountResource account = wizardData.Account;

            try
            {
                IJKEService         channel           = ServiceManager.GetChannel();
                string              today             = DateTime.Now.ToShortDateString();
                TransactionResource previewTansaction = channel.GetTransactionPreview(account.AccountNumber,
                                                                                      wizardData.Organization.Name, today, wizardData.Percentage);
                wizardData.PreviewTransaction = previewTansaction;

                AccountResource previewAccount = new AccountResource();
                previewAccount.Balance          = previewTansaction.PostBalance;
                previewAccount.Dividends        = account.Dividends;
                previewAccount.DividendsETD     = account.DividendsETD;
                previewAccount.Contributions    = account.Contributions + previewTansaction.Amount;
                previewAccount.ContributionsETD = account.ContributionsETD + previewTansaction.Amount;
                wizardData.PreviewAccount       = previewAccount;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // Bind wizard state to UI
            this.DataContext = wizardData;
        }
Пример #2
0
        public void GetTransactionPreviewTest()
        {
            using (JKEFactory factory = ServiceManager.CreateFactory())
            {
                IJKEService target = factory.CreateChannel();
                string      userId = "jbrown";

                AccountResource[] accounts = target.GetUserAccounts(userId);
                Assert.IsNotNull(accounts);
                Assert.IsTrue(accounts.Length > 0);
                AccountResource account = accounts[0];

                OrganizationResource[] organizations = target.GetOrganizations();
                Assert.IsNotNull(organizations);
                Assert.IsTrue(organizations.Length > 0);
                OrganizationResource organization = organizations[0];

                TransactionResource[] transactions = target.GetTransactionsForAccount(userId, account.Type);
                Assert.IsNotNull(transactions);
                int before = transactions.Length;

                double percentage = 2;
                double amount     = account.Dividends * percentage / 100;

                string today = DateTime.Now.ToShortDateString();

                TransactionResource preview = target.GetTransactionPreview(account.AccountNumber, organization.Name, today, percentage);
                Assert.IsNotNull(preview);

                Assert.AreEqual(amount, preview.Amount);
                Assert.AreEqual(account.AccountNumber, preview.AccountNumber);

                DateTime newDate = Convert.ToDateTime(preview.Date, CultureInfo.InvariantCulture);
                Assert.AreEqual(today, newDate.ToShortDateString());

                Assert.AreEqual(organization.Name, preview.Source);
                Assert.AreEqual(account.Balance - amount, preview.PostBalance);
            }
        }