public void Setup()
 {
     _merchantFeeDto = new TransactionCategoryDto {
         Type = "Expense", Name = "MF " + DateTime.UtcNow.Ticks
     };
     new TransactionCategoryProxy().Insert(_merchantFeeDto);
 }
        public void TestInsertAndGetDetailAccountWithHeaderAccountAssigned()
        {
            //set up header account first.
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Expense, "Header Account For Detail");

            dto.Level          = Constants.AccountLevel.Header;
            dto.DefaultTaxCode = null;

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after insert.");
            var headerAccountUid = dto.Uid;

            //set up a detail account with the above header account assigned to it.
            dto                  = GetNewTransactionCategory(AccountType.Expense, "Detail with Header");
            dto.Level            = Constants.AccountLevel.Detail;
            dto.HeaderAccountUid = headerAccountUid;
            proxy.Insert(dto);

            TransactionCategoryDto fromOla = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, fromOla);
        }
        private TransactionCategoryDto CreateTransactionCategory(string accountType, string accountName)
        {
            TransactionCategoryDto dto = new TransactionCategoryDto();

            dto.Type = accountType;
            dto.Name = accountName + " " + System.Guid.NewGuid().ToString();
            new TransactionCategoryProxy().Insert(dto);
            return(dto);
        }
        private TransactionCategoryDto GetNewTransactionCategory(string accountType, string accountName)
        {
            TransactionCategoryDto dto = new TransactionCategoryDto();

            dto.Type           = accountType;
            dto.Name           = this.TestUid + accountName;
            dto.LedgerCode     = System.Guid.NewGuid().ToString().Substring(0, 5);
            dto.DefaultTaxCode = "G1";
            return(dto);
        }
 private void SetupTransactionCategories()
 {
     this.AssetInventory      = CreateTransactionCategory(AccountType.Asset, "Inventory");
     this.AssetInventory2     = CreateTransactionCategory(AccountType.Asset, "Inventory 2");
     this.CoSHardware         = CreateTransactionCategory(AccountType.CostOfSales, "Hardware");
     this.IncomeHardwareSales = CreateTransactionCategory(AccountType.Income, "Hardware Sales");
     this.IncomeService       = CreateTransactionCategory(AccountType.Income, "Service");
     this.IncomeShipping      = CreateTransactionCategory(AccountType.Income, "Shipping");
     this.IncomeSubscription  = CreateTransactionCategory(AccountType.Income, "Subscription");
     this.IncomeMisc          = CreateTransactionCategory(AccountType.Income, "Misc");
     this.ExpenseOffice       = CreateTransactionCategory(AccountType.Expense, "Stationary, etc");
     this.ExpenseTelco        = CreateTransactionCategory(AccountType.Expense, "Telco");
     this.ExpenseMisc         = CreateTransactionCategory(AccountType.Expense, "Misc");
 }
 public static void AssertEqual(TransactionCategoryDto expected, TransactionCategoryDto actual, bool checkLevel = true)
 {
     Assert.AreEqual(expected.Uid, actual.Uid, "Different Uid.");
     if (checkLevel)
     {
         Assert.AreEqual(expected.Level.ToLowerInvariant(), actual.Level.ToLowerInvariant(), "Different Account Level.");
     }
     Assert.AreEqual(expected.Type, actual.Type, "Different Type.");
     Assert.AreEqual(expected.Name, actual.Name, "Different Name.");
     Assert.AreEqual(expected.LedgerCode, actual.LedgerCode, "Different LedgerCode.");
     Assert.AreEqual(expected.DefaultTaxCode, actual.DefaultTaxCode, "Different DefaultTaxCode.");
     Assert.AreEqual(expected.IsActive, actual.IsActive, "Different IsActive.");
     Assert.AreEqual(expected.HeaderAccountUid, actual.HeaderAccountUid, "Different Header Account Uid.");
 }
 public static void AssertEqual(TransactionCategoryDto expected, TransactionCategoryDto actual, bool checkLevel = true)
 {
     Assert.AreEqual(expected.Uid, actual.Uid, "Different Uid.");
     if (checkLevel)
     {
         Assert.AreEqual(expected.Level.ToLowerInvariant(), actual.Level.ToLowerInvariant(), "Different Account Level.");
     }
     Assert.AreEqual(expected.Type, actual.Type, "Different Type.");
     Assert.AreEqual(expected.Name, actual.Name, "Different Name.");
     Assert.AreEqual(expected.LedgerCode, actual.LedgerCode, "Different LedgerCode.");
     Assert.AreEqual(expected.DefaultTaxCode, actual.DefaultTaxCode, "Different DefaultTaxCode.");
     Assert.AreEqual(expected.IsActive, actual.IsActive, "Different IsActive.");
     Assert.AreEqual(expected.HeaderAccountUid, actual.HeaderAccountUid, "Different Header Account Uid.");
 }
        public void TestInsertAndGet()
        {
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Income, "For Testing Insert And Get");

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after insert.");

            TransactionCategoryDto fromOla = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, fromOla, false);
            Assert.AreEqual(fromOla.Level, Constants.AccountLevel.Detail);
        }
        public void TestInsertAndGetHeaderAccount()
        {
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Income, "For Testing Insert And Get Header");

            dto.Level          = Constants.AccountLevel.Header;
            dto.DefaultTaxCode = null;

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after insert.");

            TransactionCategoryDto fromOla = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, fromOla);
        }
        public void TestInsertAndGetLoanForBackwardCompatibility()
        {
            TransactionCategoryDto dto = this.GetNewTransactionCategory("Loan", "For Testing Insert And Get Loan Account");

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            dto.Type = AccountType.Liability;

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after insert.");

            TransactionCategoryDto fromOla = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, fromOla, false);
            Assert.AreEqual(fromOla.Level, Constants.AccountLevel.Detail);
        }
        public void TestDelete()
        {
            CrudProxy proxy = new TransactionCategoryProxy();

            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Liability, "TestDelete");

            proxy.Insert(dto);

            proxy.DeleteByUid(dto.Uid);

            try
            {
                proxy.GetByUid(dto.Uid);
                throw new Exception("Exception expected.");
            }
            catch (RestException ex)
            {
                Assert.AreEqual("RecordNotFoundException", ex.Type, "Incorrect error type.");
            }
        }
        public void TestInsertReturnsError()
        {
            CrudProxy proxy            = new TransactionCategoryProxy();
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Asset, "For TestInsertReturnsError");

            proxy.Insert(dto);

            //
            //	Set the uid to 0 - and re-insert
            //
            dto.Uid = 0;
            try
            {
                proxy.Insert(dto);
                throw new Exception("Exception expected.");
            }
            catch (RestException ex)
            {
                Assert.AreEqual("DuplicateNameException", ex.Type, "Incorrect error type.");
            }
        }
        public void TestUpdateResultingInRecordHasChangedException()
        {
            TransactionCategoryDto dto = this.GetNewTransactionCategory(AccountType.Income, "For TestUpdateResultingInRecordHasChangedException");

            CrudProxy proxy = new TransactionCategoryProxy();

            proxy.Insert(dto);

            int    uid            = dto.Uid;
            string lastUpdatedUid = dto.LastUpdatedUid;

            dto.Name = this.TestUid + "For TestUpdateSyncCheckError - Updated";
            proxy.Update(dto);

            //
            //	Ensure last updated uid is different
            //
            Assert.IsTrue(lastUpdatedUid != dto.LastUpdatedUid, "The LastUpdatedUid should have been updated (1).");

            TransactionCategoryDto dto2 = (TransactionCategoryDto)proxy.GetByUid(dto.Uid);

            Assert.IsTrue(lastUpdatedUid != dto.LastUpdatedUid, "The LastUpdatedUid should have been updated (2).");

            dto.LastUpdatedUid = lastUpdatedUid;
            dto.Type           = AccountType.OtherIncome;

            try
            {
                proxy.Update(dto);
                throw new Exception("The expected exception is not thrown.");
            }
            catch (RestException ex)
            {
                //	This was expected.
                Assert.AreEqual("RecordHasChangedException", ex.Type);
            }
        }
 private TransactionCategoryDto CreateTransactionCategory(string accountType, string accountName)
 {
     TransactionCategoryDto dto = new TransactionCategoryDto();
     dto.Type = accountType;
     dto.Name = accountName + " " + System.Guid.NewGuid().ToString();
     new TransactionCategoryProxy().Insert(dto);
     return dto;
 }
 private void SetupTransactionCategories()
 {
     this.AssetInventory = CreateTransactionCategory(AccountType.Asset, "Inventory");
     this.AssetInventory2 = CreateTransactionCategory(AccountType.Asset, "Inventory 2");
     this.CoSHardware = CreateTransactionCategory(AccountType.CostOfSales, "Hardware");
     this.IncomeHardwareSales = CreateTransactionCategory(AccountType.Income, "Hardware Sales");
     this.IncomeService = CreateTransactionCategory(AccountType.Income, "Service");
     this.IncomeShipping = CreateTransactionCategory(AccountType.Income, "Shipping");
     this.IncomeSubscription = CreateTransactionCategory(AccountType.Income, "Subscription");
     this.IncomeMisc = CreateTransactionCategory(AccountType.Income, "Misc");
     this.ExpenseOffice = CreateTransactionCategory(AccountType.Expense, "Stationary, etc");
     this.ExpenseTelco = CreateTransactionCategory(AccountType.Expense, "Telco");
     this.ExpenseMisc = CreateTransactionCategory(AccountType.Expense, "Misc");
 }
 public void Setup()
 {
     _merchantFeeDto = new TransactionCategoryDto {Type = "Expense", Name = "MF " + DateTime.UtcNow.Ticks};
     new TransactionCategoryProxy().Insert(_merchantFeeDto);
 }
Example #17
0
        private void CreateTestAccounts()
        {
            if (_IncomeAccountId == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Income,
                    Name = "Income Account " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _IncomeAccountId = dto.Uid;
            }

            if (_IncomeAccountId2 == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Income,
                    Name = "Income Account " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _IncomeAccountId2 = dto.Uid;
            }

            if (_ExpenseAccountId == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Expense,
                    Name = "Expense Account " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _ExpenseAccountId = dto.Uid;
            }

            if (_ExpenseAccountId2 == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Expense,
                    Name = "Expense Account2 " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _ExpenseAccountId2 = dto.Uid;
            }

            if (_AssetAccountId == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Asset,
                    Name = "Asset Account " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _AssetAccountId = dto.Uid;
            }

            if (_BankAccountId == 0)
            {
                var acctname = "Bank Account " + " " + System.Guid.NewGuid();

                var dto = new BankAccountDto
                {
                    BSB           = "111111",
                    AccountNumber = "22222222",
                    Type          = AccountType.Asset,
                    Name          = acctname,
                    DisplayName   = acctname
                };

                new Ola.RestClient.Proxies.BankAccountProxy().Insert(dto);
                _BankAccountId = dto.Uid;
            }
        }
        private void CreateTestAccounts()
        {
            if (_IncomeAccountId == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Income,
                    Name = "Income Account " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _IncomeAccountId = dto.Uid;
            }

            if (_IncomeAccountId2 == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Income,
                    Name = "Income Account " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _IncomeAccountId2 = dto.Uid;
            }

            if (_ExpenseAccountId == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Expense,
                    Name = "Expense Account " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _ExpenseAccountId = dto.Uid;
            }

            if (_ExpenseAccountId2 == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Expense,
                    Name = "Expense Account2 " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _ExpenseAccountId2 = dto.Uid;
            }

            if (_AssetAccountId == 0)
            {
                var dto = new TransactionCategoryDto
                {
                    Type = AccountType.Asset,
                    Name = "Asset Account " + " " + System.Guid.NewGuid()
                };

                new Ola.RestClient.Proxies.TransactionCategoryProxy().Insert(dto);
                _AssetAccountId = dto.Uid;
            }

            if (_BankAccountId == 0)
            {
                var acctname = "Bank Account " + " " + System.Guid.NewGuid();

                var dto = new BankAccountDto
                {
                    BSB = "111111",
                    AccountNumber = "22222222",
                    Type = AccountType.Income,
                    Name = acctname,
                    DisplayName = acctname
                };

                new Ola.RestClient.Proxies.BankAccountProxy().Insert(dto);
                _BankAccountId = dto.Uid;
            }
        }
 private TransactionCategoryDto GetNewTransactionCategory(string accountType, string accountName)
 {
     TransactionCategoryDto dto = new TransactionCategoryDto();
     dto.Type = accountType;
     dto.Name = this.TestUid + accountName;
     dto.LedgerCode = System.Guid.NewGuid().ToString().Substring(0, 5);
     dto.DefaultTaxCode = "G1";
     return dto;
 }