private static void SetupBankAccounts() { var accountProxy = new AccountProxy(); var result1 = accountProxy.InsertAccount(new AccountDetail() { AccountType = Constants.AccountType.Asset, BSB = "111-111", Number = "12345-6789", Name = "TestBank " + System.Guid.NewGuid().ToString(), BankAccountName = "TestBank " + System.Guid.NewGuid().ToString(), IsBankAccount = true, Currency = "AUD", }); _bankAccount01Id = result1.DataObject.InsertedEntityId; var result2 = accountProxy.InsertAccount(new AccountDetail() { AccountType = Constants.AccountType.Asset, BSB = "222-222", Number = "2345-6789", Name = "TestBank " + System.Guid.NewGuid().ToString(), BankAccountName = "TestBank " + System.Guid.NewGuid().ToString(), IsBankAccount = true, Currency = "AUD", }); _bankAccount02Id = result1.DataObject.InsertedEntityId; }
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); }
public void InsertAccountWithHeader() { //Create and Insert var headerAccount = _accountHelper.GetTestHeaderAccount(); var accountProxy = new AccountProxy(); var headerInsertResponse = accountProxy.InsertAccount(headerAccount); Assert.NotNull(headerInsertResponse); Assert.True(headerInsertResponse.IsSuccessfull, "Reponse has not been successful"); Assert.True(headerInsertResponse.DataObject.InsertedEntityId > 0, "Zero accounts returned"); var headerAccountId = headerInsertResponse.DataObject.InsertedEntityId; var account = _accountHelper.GetTestAccount(); account.HeaderAccountId = headerAccountId; var response = accountProxy.InsertAccount(account); Assert.NotNull(response); Assert.True(response.IsSuccessfull, "Reponse has not been successful"); Assert.True(response.DataObject.InsertedEntityId > 0, "Zero accounts returned"); //Get account again and verify inserted fields. var acct = accountProxy.GetAccount(response.DataObject.InsertedEntityId); Assert.Equal(account.Name, acct.DataObject.Name); Assert.Equal(account.AccountType, acct.DataObject.AccountType); Assert.Equal(account.DefaultTaxCode, acct.DataObject.DefaultTaxCode); Assert.Equal(account.LedgerCode, acct.DataObject.LedgerCode); Assert.Equal(account.Currency, acct.DataObject.Currency); Assert.Equal(account.IsBankAccount, acct.DataObject.IsBankAccount); Assert.Equal(false, acct.DataObject.IncludeInForecaster); Assert.Equal(headerAccountId, acct.DataObject.HeaderAccountId); }
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); } }
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); }
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"); }
public void InsertBankAccount() { //Create and Insert var account = _accountHelper.GetTestBankAccount(); var accountProxy = new AccountProxy(); var response = accountProxy.InsertAccount(account); Assert.NotNull(response); Assert.True(response.IsSuccessfull, "Reponse has not been successful"); Assert.True(response.DataObject.InsertedEntityId > 0, "Zero accounts returned"); //Get account again and verify inserted fields. var acct = accountProxy.GetAccount(response.DataObject.InsertedEntityId); Assert.Equal(account.Name, acct.DataObject.Name); Assert.Equal(account.AccountType, acct.DataObject.AccountType); Assert.Equal(account.DefaultTaxCode, acct.DataObject.DefaultTaxCode); Assert.Equal(account.LedgerCode, acct.DataObject.LedgerCode); Assert.Equal(account.Currency, acct.DataObject.Currency); Assert.Equal(account.IsBankAccount, acct.DataObject.IsBankAccount); Assert.Equal(account.IncludeInForecaster, acct.DataObject.IncludeInForecaster); Assert.Equal(account.BSB, acct.DataObject.BSB); Assert.Equal(account.Number, acct.DataObject.Number); Assert.Equal(account.BankAccountName, acct.DataObject.BankAccountName); Assert.Equal(account.BankFileCreationEnabled, acct.DataObject.BankFileCreationEnabled); Assert.Equal(account.BankCode, acct.DataObject.BankCode); Assert.Equal(account.UserNumber, acct.DataObject.UserNumber); Assert.Equal(account.MerchantFeeAccountId, acct.DataObject.MerchantFeeAccountId); Assert.Equal(account.IncludePendingTransactions, acct.DataObject.IncludePendingTransactions); }
private static int CreateTransactionCategory(string accountType, string accountName) { var accountProxy = new AccountProxy(); var result = accountProxy.InsertAccount(new AccountDetail() { AccountType = accountType, Name = accountName + " " + System.Guid.NewGuid().ToString(), IsBankAccount = false, Currency = "AUD", }); var combinedName = string.Concat(accountType.Replace(" ", string.Empty), "|", accountName.Replace(" ", string.Empty)); switch (combinedName) { case "Asset|Inventory": _assetInventory = result.DataObject.InsertedEntityId; break; case "Income|HardwareSales": _incomeHardwareSales = result.DataObject.InsertedEntityId; break; case "CostOfSales|Hardware": _coSHardware = result.DataObject.InsertedEntityId; break; case "Expense|Misc": _expenseMisc = result.DataObject.InsertedEntityId; break; case "Income|Shipping": _incomeShipping = result.DataObject.InsertedEntityId; break; } return(result.DataObject.InsertedEntityId); }
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"); }
public void InsertHeaderAccount() { //Create and Insert var account = _accountHelper.GetTestHeaderAccount(); var accountProxy = new AccountProxy(); var response = accountProxy.InsertAccount(account); Assert.NotNull(response); Assert.True(response.IsSuccessfull, "Reponse has not been successful"); Assert.True(response.DataObject.InsertedEntityId > 0, "Zero accounts returned"); //Get account again and verify inserted fields. var acct = accountProxy.GetAccount(response.DataObject.InsertedEntityId); Assert.Equal(account.Name, acct.DataObject.Name); Assert.Equal("header", acct.DataObject.AccountLevel.ToLower()); Assert.Equal(account.AccountType, acct.DataObject.AccountType); Assert.Null(acct.DataObject.DefaultTaxCode); Assert.Equal(account.LedgerCode, acct.DataObject.LedgerCode); Assert.False(Convert.ToBoolean(acct.DataObject.IsBankAccount), "Header accounts cannot be bank accounts"); Assert.False(Convert.ToBoolean(acct.DataObject.IncludeInForecaster), "Header accounts cannot be included in forecaster"); }
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; } }
private void CreateTestAccounts() { var accountProxy = new AccountProxy(); if (_incomeAccountId == 0) { var result1 = accountProxy.InsertAccount(new AccountDetail() { AccountType = Constants.AccountType.Income, Name = "Income Account " + " " + System.Guid.NewGuid(), IsBankAccount = false, Currency = "AUD", }); _incomeAccountId = result1.DataObject.InsertedEntityId; } if (_expenseAccountId == 0) { var result3 = accountProxy.InsertAccount(new AccountDetail() { AccountType = Constants.AccountType.Expense, Name = "Expense Account " + " " + System.Guid.NewGuid(), IsBankAccount = false, Currency = "AUD", }); _expenseAccountId = result3.DataObject.InsertedEntityId; } if (_assetAccountId == 0) { var result5 = accountProxy.InsertAccount(new AccountDetail() { AccountType = Constants.AccountType.Asset, Name = "Asset Account " + " " + System.Guid.NewGuid(), IsBankAccount = false, Currency = "AUD", }); _assetAccountId = result5.DataObject.InsertedEntityId; } if (_bankAccountId == 0) { var acctname = "Bank Account " + " " + System.Guid.NewGuid(); var result6 = accountProxy.InsertAccount(new AccountDetail() { AccountType = Constants.AccountType.Asset, BSB = "111111", Number = "22222222", Name = acctname, BankAccountName = acctname, IsBankAccount = true, Currency = "AUD", }); _bankAccountId = result6.DataObject.InsertedEntityId; } }