internal static Account FindOrAddAccount(ServiceContext context, AccountTypeEnum accountType, AccountClassificationEnum classification)
        {
            Account        typeOfAccount = null;
            List <Account> listOfAccount = FindAll <Account>(context, new Account(), 1, 500);

            if (listOfAccount.Count > 0)
            {
                foreach (Account acc in listOfAccount)
                {
                    if (acc.AccountType == accountType && acc.Classification == classification && acc.status != EntityStatusEnum.SyncError)
                    {
                        typeOfAccount = acc;
                        break;
                    }
                }
            }

            if (typeOfAccount == null)
            {
                DataService service = new DataService(context);
                Account     account;

                account = QBOHelper.CreateAccount(context, accountType, classification);
                account.Classification = classification;
                account.AccountType    = accountType;
                Account createdAccount = service.Add <Account>(account);
                typeOfAccount = createdAccount;
            }

            return(typeOfAccount);
        }
 public void AddCreditCardAccountTestUsingoAuth(ServiceContext qboContextoAuth)
 {
     //Creating the Account for Add
     Account account = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.CreditCard, AccountClassificationEnum.Liability);
     //Adding the Account
     Account added = Helper.Add <Account>(qboContextoAuth, account);
 }
        public void AccountAddAsyncTestsUsingoAuth(ServiceContext qboContextoAuth)
        {
            //Creating the Account for Add
            Account entity = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Expense);

            Account added = Helper.AddAsync <Account>(qboContextoAuth, entity);
        }
 public void AccountFindbyIdTestUsingoAuth(ServiceContext qboContextoAuth)
 {
     //Creating the Account for Adding
     Account account = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Asset);
     //Adding the Account
     Account added = Helper.Add <Account>(qboContextoAuth, account);
     Account found = Helper.FindById <Account>(qboContextoAuth, added);
 }
 public void AddExpenseAccountTestUsingoAuth(ServiceContext qboContextoAuth)
 {
     //Creating the Account for Add
     Account account = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Expense, AccountClassificationEnum.Expense);
     //Adding the Account
     Account added = Helper.Add <Account>(qboContextoAuth, account);
     //Verify the added Account
 }
Esempio n. 6
0
        [TestMethod][Ignore]  //TestComment: Returns Operation Not Supported:  DevKit tracker Item #150
        public void AccountDeleteAsyncTestsUsingoAuth()
        {
            //Creating the Account for Adding
            Account entity = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Expense);
            //Adding the Account
            Account added = Helper.Add <Account>(qboContextoAuth, entity);

            Helper.DeleteAsync <Account>(qboContextoAuth, added);
        }
Esempio n. 7
0
        [TestMethod][Ignore]  //TestComment: Test if entity type is not supported
        public void AddEquityBankAccountTestUsingoAuth()
        {
            //Creating the Account for Add
            Account account = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Equity, AccountClassificationEnum.Equity);
            //Adding the Account
            Account added = Helper.Add <Account>(qboContextoAuth, account);

            //Verify the added Account
            QBOHelper.VerifyAccount(account, added);
        }
        public void AccountFindByIdAsyncTestsUsingoAuth(ServiceContext qboContextoAuth)
        {
            //Creating the Account for Adding
            Account entity = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Expense);
            //Adding the Account
            Account added = Helper.Add <Account>(qboContextoAuth, entity);

            //FindById and verify
            Helper.FindByIdAsync <Account>(qboContextoAuth, added);
        }
 public void AccountSparseUpdateTestUsingoAuth(ServiceContext qboContextoAuth)
 {
     //Creating the Account for Adding
     Account account = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Asset);
     //Adding the Account
     Account added = Helper.Add <Account>(qboContextoAuth, account);
     //Change the data of added entity
     Account changed = QBOHelper.SparseUpdateAccount(qboContextoAuth, added.Id, added.SyncToken);
     //Update the returned entity data
     Account updated = Helper.Update <Account>(qboContextoAuth, changed);//Verify the updated Account
 }
        public void AccountUpdatedAsyncTestsUsingoAuth(ServiceContext qboContextoAuth)
        {
            //Creating the Account for Adding
            Account entity = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Expense);
            //Adding the Account
            Account added = Helper.Add <Account>(qboContextoAuth, entity);

            //Update the Account
            Account updated = QBOHelper.UpdateAccount(qboContextoAuth, added);
            //Call the service
            Account updatedReturned = Helper.UpdateAsync <Account>(qboContextoAuth, updated);
        }
Esempio n. 11
0
        public void AccountUpdateTestUsingoAuth()
        {
            //Creating the Account for Adding
            Account account = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Asset);
            //Adding the Account
            Account added = Helper.Add <Account>(qboContextoAuth, account);
            //Change the data of added entity
            Account changed = QBOHelper.UpdateAccount(qboContextoAuth, added);
            //Update the returned entity data
            Account updated = Helper.Update <Account>(qboContextoAuth, changed);//Verify the updated Account

            QBOHelper.VerifyAccount(changed, updated);
        }
        public void AccountBatchUsingoAuth(ServiceContext qboContextoAuth)
        {
            Dictionary <OperationEnum, object> batchEntries = new Dictionary <OperationEnum, object>();

            Account existing = Helper.FindOrAdd(qboContextoAuth, new Account());

            batchEntries.Add(OperationEnum.create, QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Asset));

            batchEntries.Add(OperationEnum.update, QBOHelper.UpdateAccount(qboContextoAuth, existing));

            batchEntries.Add(OperationEnum.query, "select * from Account");



            ReadOnlyCollection <IntuitBatchResponse> batchResponses = Helper.Batch <Account>(qboContextoAuth, batchEntries);
        }
Esempio n. 13
0
        public void AccountVoidTestUsingoAuth()
        {
            //Creating the Account for Adding
            Account account = QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Asset);
            //Adding the Account
            Account added = Helper.Add <Account>(qboContextoAuth, account);

            //Void the returned entity
            try
            {
                Account voided = Helper.Void <Account>(qboContextoAuth, added);
                Assert.AreEqual(EntityStatusEnum.Voided, voided.status);
            }
            catch (IdsException ex)
            {
                Assert.Fail();
            }
        }
Esempio n. 14
0
        public void AccountBatchUsingoAuth()
        {
            Dictionary <OperationEnum, object> batchEntries = new Dictionary <OperationEnum, object>();

            Account existing = Helper.FindOrAdd(qboContextoAuth, new Account());

            batchEntries.Add(OperationEnum.create, QBOHelper.CreateAccount(qboContextoAuth, AccountTypeEnum.Bank, AccountClassificationEnum.Asset));

            batchEntries.Add(OperationEnum.update, QBOHelper.UpdateAccount(qboContextoAuth, existing));

            batchEntries.Add(OperationEnum.query, "select * from Account");

            //IgnoreReason: Not Supported in v67
            //batchEntries.Add(OperationEnum.delete, existing);

            ReadOnlyCollection <IntuitBatchResponse> batchResponses = Helper.BatchTest <Account>(qboContextoAuth, batchEntries);

            int position = 0;

            foreach (IntuitBatchResponse resp in batchResponses)
            {
                if (resp.ResponseType == ResponseType.Exception)
                {
                    Assert.Fail(resp.Exception.ToString());
                }

                if (resp.ResponseType == ResponseType.Entity)
                {
                    Assert.IsFalse(string.IsNullOrEmpty((resp.Entity as Account).Id));
                }
                else if (resp.ResponseType == ResponseType.Query)
                {
                    Assert.IsTrue(resp.Entities != null && resp.Entities.Count > 0);
                }
                else if (resp.ResponseType == ResponseType.CdcQuery)
                {
                    Assert.IsTrue(resp.CDCResponse != null && resp.CDCResponse.entities != null && resp.CDCResponse.entities.Count > 0);
                }

                position++;
            }
        }