Пример #1
0
		public void GetBankAccount()
		{
			var accountsProxy = new AccountProxy();
			var response = accountsProxy.GetAccount(_bankAcctId);

			Assert.IsNotNull(response, "Reponse is null");
			Assert.IsTrue(response.IsSuccessfull, "Reponse has not been successful");
			Assert.IsTrue(Convert.ToBoolean(response.DataObject.IsBankAccount), "Account returned is not a bank account");
		}
Пример #2
0
		private void CreateTestData()
		{
			var accountProxy = new AccountProxy();

			if (_nonBankAcctId == 0)
			{
				var account = GetTestAccount();
				var insertResult = accountProxy.InsertAccount(account);

				_nonBankAcctId = insertResult.DataObject.InsertedEntityId;
			}

			if (_bankAcctId == 0)
			{
				var account = GetTestBankAccount();
				var insertResult = accountProxy.InsertAccount(account);

				_bankAcctId = insertResult.DataObject.InsertedEntityId;
			}

			if (_inactiveAccountId == 0)
			{
				var account = GetTestAccount();
				account.IsActive = false;
				var insertResult = accountProxy.InsertAccount(account);

				_inactiveAccountId = insertResult.DataObject.InsertedEntityId;
			}

			if (_accountToBeUpdated == 0)
			{
				var account = GetTestAccount();
				var insertResult = accountProxy.InsertAccount(account);

				_accountToBeUpdated = insertResult.DataObject.InsertedEntityId;
			}

			if (_bankAccountToBeUpdated == 0)
			{
				var account = GetTestBankAccount();
				var insertResult = accountProxy.InsertAccount(account);

				_bankAccountToBeUpdated = insertResult.DataObject.InsertedEntityId;
			}

            if (_headerAccountId == 0)
            {
                var account = GetTestHeaderAccount();
                
                var insertResult = accountProxy.InsertAccount(account);

                _headerAccountId = insertResult.DataObject.InsertedEntityId;
            }

		    if (_accountToAssignToHeaderAccount == 0)
		    {
		        var account = GetTestAccount();
		        account.HeaderAccountId = _headerAccountId;
		        var insertResult = accountProxy.InsertAccount(account);
		        _accountToAssignToHeaderAccount = insertResult.DataObject.InsertedEntityId;
		    }
		}
Пример #3
0
        public void UpdateHeaderAccount()
        {
            //Create and Insert
            var account = GetTestHeaderAccount();

            var accountProxy = new AccountProxy();
            var response = accountProxy.InsertAccount(account);

            Assert.IsNotNull(response, "Reponse is null");
            Assert.IsTrue(response.IsSuccessfull, "Reponse has not been successful");
            Assert.Greater(response.DataObject.InsertedEntityId, 0, "Zero accounts returned");

            var accountId = response.DataObject.InsertedEntityId;

            //Get account again and verify inserted fields.
            var insertedAcctFromDb = accountProxy.GetAccount(accountId);

            var newName = string.Format("TestAccount_{0}", Guid.NewGuid());
            account.Name = newName;
            account.LastUpdatedId = insertedAcctFromDb.DataObject.LastUpdatedId;

            var updateResponse = accountProxy.UpdateAccount(response.DataObject.InsertedEntityId, account);
            Assert.IsNotNull(updateResponse, "Reponse is null");
            Assert.IsTrue(updateResponse.IsSuccessfull, "Reponse has not been successful");

            //Get account again and verify inserted fields.
            var updatedAcctFromDb = accountProxy.GetAccount(accountId);
            Assert.IsNotNull(updatedAcctFromDb, "Reponse is null");
            Assert.IsTrue(updatedAcctFromDb.IsSuccessfull, "Reponse has not been successful");

            Assert.AreEqual(updatedAcctFromDb.DataObject.Name, newName);
        }
Пример #4
0
		public void UpdateBankAccountBankFileCreationNotEnabled()
		{
			var accountProxy = new AccountProxy();

			//Get account, change fields then update.
			var acct = accountProxy.GetAccount(_bankAcctId);

			var newBankName = string.Format("UpdatedBankName_{0}", Guid.NewGuid());

			acct.DataObject.BankAccountName = newBankName;
			acct.DataObject.BankFileCreationEnabled = false;
			acct.DataObject.BankCode = null;
			acct.DataObject.UserNumber = null;

			var response = accountProxy.UpdateAccount(Convert.ToInt32(acct.DataObject.Id), acct.DataObject);

			Assert.IsNotNull(response, "Reponse is null");
			Assert.IsTrue(response.IsSuccessfull, "Reponse has not been successful");

			//Get account again and verify change.
			acct = accountProxy.GetAccount(_bankAcctId);

			Assert.IsNotNull(acct, "Account in null");
			Assert.AreEqual(acct.DataObject.BankAccountName, newBankName, "Bank account names not equal");
			Assert.AreEqual(acct.DataObject.BankFileCreationEnabled, false, "BankFileCreationEnabled not equal");

			//Bank code and user number should not have changed because BankFileCreationEnabled was false.
			Assert.IsNull(acct.DataObject.BankCode, "Bank code not null");
			Assert.IsNull(acct.DataObject.UserNumber, "User number not null");
		}
Пример #5
0
		public void UpdateBankAccount()
		{
			var accountProxy = new AccountProxy();

			//Get account, change name then update.
			var acct = accountProxy.GetAccount(_bankAccountToBeUpdated);

			var newName = string.Format("UpdatedAccount_{0}", Guid.NewGuid());
			var newBankAccountName = string.Format("Update Bank Account_{0}", Guid.NewGuid());

			var updatedAccount = new AccountDetail
			{
				Name = newName,
				AccountType = "Equity",
				IsActive = false,
				IsBankAccount = true,
				LastUpdatedId = acct.DataObject.LastUpdatedId,
				DefaultTaxCode = null,
				Currency = "AUD",
				LedgerCode = "BB",
				IncludeInForecaster = false,
				BSB = "020202",
				Number = "22222222",
				BankAccountName = newBankAccountName,
				BankFileCreationEnabled = true,
				BankCode = "B",
				UserNumber = "333",
				MerchantFeeAccountId = _bankAcctId,
				IncludePendingTransactions = false
			};

			var response = accountProxy.UpdateAccount(Convert.ToInt32(acct.DataObject.Id), updatedAccount);

			Assert.IsNotNull(response, "Reponse is null");
			Assert.IsTrue(response.IsSuccessfull, "Reponse has not been successful");

			//Get account again and verify change.
			acct = accountProxy.GetAccount(_bankAccountToBeUpdated);

			Assert.IsNotNull(acct, "Account in null");
			Assert.AreEqual(acct.DataObject.Name, newName, "Names not equal");
			Assert.AreEqual(acct.DataObject.AccountType, "Equity", "Account types not equal");
			Assert.AreEqual(acct.DataObject.IsActive, false, "IsAcive not equal");
			Assert.IsNull(acct.DataObject.DefaultTaxCode, "Default should be null");
			Assert.AreEqual(acct.DataObject.Currency, "AUD", "Currencies not equal");
			Assert.AreEqual(acct.DataObject.LedgerCode, "BB", "Ledger codes not equal");
			Assert.AreEqual(acct.DataObject.IncludeInForecaster, false, "Include in Forecaster not equal");
			Assert.AreEqual(acct.DataObject.BSB, "020202", "BSBs not equal");
			Assert.AreEqual(acct.DataObject.Number, "22222222", "Account Numbers not equal");
			Assert.AreEqual(acct.DataObject.BankAccountName, newBankAccountName, "Bank account names not equal");
			Assert.AreEqual(acct.DataObject.BankFileCreationEnabled, true, "BankFileCreationEnabled not equal");
			Assert.AreEqual(acct.DataObject.BankCode, "B", "Bank codes not equal");
			Assert.AreEqual(acct.DataObject.UserNumber, "333", "User numbers not equal");
			Assert.AreEqual(acct.DataObject.MerchantFeeAccountId, _bankAcctId, "Merchant accounts not equal");
			Assert.AreEqual(acct.DataObject.IncludePendingTransactions, false, "IncludePendingTransactions not equal");
		}
Пример #6
0
		public void UpdateBankAccountBankFileCreationEnabled()
		{
			var accountProxy = new AccountProxy();

			//Get account, change name then update.
			var acct = accountProxy.GetAccount(_bankAcctId);

			var newBankName = string.Format("UpdatedBankName_{0}", Guid.NewGuid());

			acct.DataObject.BankAccountName = newBankName;
			acct.DataObject.BankFileCreationEnabled = true;
			acct.DataObject.BankCode = "AAA";
			acct.DataObject.UserNumber = "222";

			var response = accountProxy.UpdateAccount(Convert.ToInt32(acct.DataObject.Id), acct.DataObject);

			Assert.IsNotNull(response, "Reponse is null");
			Assert.IsTrue(response.IsSuccessfull, "Reponse has not been successful");

			//Get account again and verify change.
			acct = accountProxy.GetAccount(_bankAcctId);

			Assert.IsNotNull(acct, "Account in null");
			Assert.AreEqual(acct.DataObject.BankAccountName, newBankName, "Bank account names not equal");
			Assert.AreEqual(acct.DataObject.BankFileCreationEnabled, true, "BankFileCreationEnabled not equal");
			Assert.AreEqual(acct.DataObject.BankCode, "AAA", "Bank codes not equal");
			Assert.AreEqual(acct.DataObject.UserNumber, "222", "User numbers not equal");

			//Reset Bank Code and Customer Number for other tests.
			acct.DataObject.BankFileCreationEnabled = true;
			acct.DataObject.BankCode = "TBA";
			acct.DataObject.UserNumber = "111";

			accountProxy.UpdateAccount(Convert.ToInt32(acct.DataObject.Id), acct.DataObject);
		}
Пример #7
0
		public void UpdateAccount()
		{
			var accountProxy = new AccountProxy();

			//Get account, change name then update.
			var acct = accountProxy.GetAccount(_accountToBeUpdated);

			var newName = string.Format("UpdatedAccount_{0}", Guid.NewGuid());

			var updatedAccount = new AccountDetail
			{
				Name = newName,
				AccountType = "Equity",
				IsActive = false,
				IsBankAccount = false,
				LastUpdatedId = acct.DataObject.LastUpdatedId,
				DefaultTaxCode = "G1,G4",
				Currency = "AUD",
				LedgerCode = "BB"
			};

			var response = accountProxy.UpdateAccount(Convert.ToInt32(acct.DataObject.Id), updatedAccount);

			Assert.IsNotNull(response, "Reponse is null");
			Assert.IsTrue(response.IsSuccessfull, "Reponse has not been successful");

			//Get account again and verify change.
			acct = accountProxy.GetAccount(_accountToBeUpdated);

			Assert.IsNotNull(acct, "Account is null");
			Assert.AreEqual(acct.DataObject.Name, newName, "Names not equal");
			Assert.AreEqual(acct.DataObject.AccountType, "Equity", "Account types not equal");
			Assert.AreEqual(acct.DataObject.IsActive, false, "IsActive not equal");
			Assert.AreEqual(acct.DataObject.DefaultTaxCode, "G1,G4", "Default tax codes not equal");
			Assert.AreEqual(acct.DataObject.Currency, "AUD", "Currencies not equal");
			Assert.AreEqual(acct.DataObject.LedgerCode, "BB", "Ledger codes not equal");
			Assert.AreEqual(acct.DataObject.IncludeInForecaster, false, "Include in Forecaster should be false for non bank accounts");
		}
Пример #8
0
        public void InsertHeaderAccount()
        {
            //Create and Insert
            var account = GetTestHeaderAccount();

            var accountProxy = new AccountProxy();
            var response = accountProxy.InsertAccount(account);

            Assert.IsNotNull(response, "Reponse is null");
            Assert.IsTrue(response.IsSuccessfull, "Reponse has not been successful");
            Assert.Greater(response.DataObject.InsertedEntityId, 0, "Zero accounts returned");

            //Get account again and verify inserted fields.
            var acct = accountProxy.GetAccount(response.DataObject.InsertedEntityId);

            Assert.AreEqual(acct.DataObject.Name, account.Name, "Names not equal");
            Assert.AreEqual(acct.DataObject.AccountLevel.ToLower(), "header");
            Assert.AreEqual(acct.DataObject.AccountType, account.AccountType, "Account types not equal");
            Assert.IsNull(acct.DataObject.DefaultTaxCode, "Tax code should be null");
            Assert.AreEqual(acct.DataObject.LedgerCode, account.LedgerCode, "Ledger codes not equal");
            Assert.IsFalse(Convert.ToBoolean(acct.DataObject.IsBankAccount), "Header accounts cannot be bank accounts");
            Assert.IsFalse(Convert.ToBoolean(acct.DataObject.IncludeInForecaster), "Header accounts cannot be included in forecaster");
        }
Пример #9
0
        public void InsertAccountWithHeader()
        {
            //Create and Insert
            var headerAccount = GetTestHeaderAccount();
            var accountProxy = new AccountProxy();
            var headerInsertResponse = accountProxy.InsertAccount(headerAccount);
            Assert.IsNotNull(headerInsertResponse, "Reponse is null");
            Assert.IsTrue(headerInsertResponse.IsSuccessfull, "Reponse has not been successful");
            Assert.Greater(headerInsertResponse.DataObject.InsertedEntityId, 0, "Zero accounts returned");

            var headerAccountId = headerInsertResponse.DataObject.InsertedEntityId;

            var account = GetTestAccount();
            account.HeaderAccountId = headerAccountId;

            var response = accountProxy.InsertAccount(account);

            Assert.IsNotNull(response, "Reponse is null");
            Assert.IsTrue(response.IsSuccessfull, "Reponse has not been successful");
            Assert.Greater(response.DataObject.InsertedEntityId, 0, "Zero accounts returned");

            //Get account again and verify inserted fields.
            var acct = accountProxy.GetAccount(response.DataObject.InsertedEntityId);

            Assert.AreEqual(acct.DataObject.Name, account.Name, "Names not equal");
            Assert.AreEqual(acct.DataObject.AccountType, account.AccountType, "Account types not equal");
            Assert.AreEqual(acct.DataObject.DefaultTaxCode, account.DefaultTaxCode, "Tax codes not equal");
            Assert.AreEqual(acct.DataObject.LedgerCode, account.LedgerCode, "Leadge codes not equal");
            Assert.AreEqual(acct.DataObject.Currency, account.Currency, "Currencies not equal");
            Assert.AreEqual(acct.DataObject.IsBankAccount, account.IsBankAccount, "IsBankAccount not equal");
            Assert.AreEqual(acct.DataObject.IncludeInForecaster, false, "IncludeInForecaster should be false for non bank accounts");
            Assert.AreEqual(acct.DataObject.HeaderAccountId, headerAccountId);
        }
Пример #10
0
		public void InsertBankAccount()
		{
			//Create and Insert
			var account = GetTestBankAccount();

			var accountProxy = new AccountProxy();
			var response = accountProxy.InsertAccount(account);

			Assert.IsNotNull(response, "Reponse is null");
			Assert.IsTrue(response.IsSuccessfull, "Reponse has not been successful");
			Assert.Greater(response.DataObject.InsertedEntityId, 0, "Zero accounts returned");

			//Get account again and verify inserted fields.
			var acct = accountProxy.GetAccount(response.DataObject.InsertedEntityId);

			Assert.AreEqual(acct.DataObject.Name, account.Name, "Names not equal");
			Assert.AreEqual(acct.DataObject.AccountType, account.AccountType, "Account types not equal");
			Assert.AreEqual(acct.DataObject.DefaultTaxCode, account.DefaultTaxCode, "Tax codes not equal");
			Assert.AreEqual(acct.DataObject.LedgerCode, account.LedgerCode, "Ledger codes not equal");
			Assert.AreEqual(acct.DataObject.Currency, account.Currency, "Currencis not equal");
			Assert.AreEqual(acct.DataObject.IsBankAccount, account.IsBankAccount, "IsBankAccount not equal");
			Assert.AreEqual(acct.DataObject.IncludeInForecaster, account.IncludeInForecaster, "Include in Forecaster not equal");
			Assert.AreEqual(acct.DataObject.BSB, account.BSB, "BSBs not equal");
			Assert.AreEqual(acct.DataObject.Number, account.Number, "Account numbers not equal");
			Assert.AreEqual(acct.DataObject.BankAccountName, account.BankAccountName, "Bank account names not equal");
			Assert.AreEqual(acct.DataObject.BankFileCreationEnabled, account.BankFileCreationEnabled, "BankFileCreationEnabled not equal");
			Assert.AreEqual(acct.DataObject.BankCode, account.BankCode, "Bank codes not equal");
			Assert.AreEqual(acct.DataObject.UserNumber, account.UserNumber, "User numbers not equal");
			Assert.AreEqual(acct.DataObject.MerchantFeeAccountId, account.MerchantFeeAccountId, "Merchant accounts not equal");
			Assert.AreEqual(acct.DataObject.IncludePendingTransactions, account.IncludePendingTransactions, "IncludePendingTransactions not equal");
		}
Пример #11
0
        private static int GetAccount(string accountType)
        {
            var accountsProxy = new AccountsProxy();
            var accountsResponse = accountsProxy.GetAccounts(isActive: true, accountType: accountType);

            if (accountsResponse.DataObject.Accounts.Count == 0)
            {
                var account = new AccountDetail
                {
                    Name = string.Format("TestAccount_{0}", Guid.NewGuid()),
                    AccountType = "Asset",
                    IsActive = true,
                    DefaultTaxCode = "G1",
                    LedgerCode = "AA",
                    Currency = "AUD",
                    IsBankAccount = false
                };

                var accountProxy = new AccountProxy();
                var accountResponse = accountProxy.InsertAccount(account);
                if (accountResponse.IsSuccessfull)
                    _inventoryAccountId = accountResponse.DataObject.InsertedEntityId;
                return _inventoryAccountId;
            }
            else
            {
                return accountsResponse.DataObject.Accounts.First().Id.Value;
            }
        }