Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fieldName"></param>
 /// <returns></returns>
 /// <exception cref="NoFieldNameException"> no such field name</exception>
 public List <MasterDataBase> GetValueSet(String fieldName)
 {
     if (fieldName.Equals(GL_ACCOUNT))
     {
         return(_mdMgmt.CostAccounts.ToList <MasterDataBase>());
     }
     else if (fieldName.Equals(REC_ACC))
     {
         return(_mdMgmt.LiquidityAccounts.ToList <MasterDataBase>());
     }
     else if (fieldName.Equals(VENDOR))
     {
         MasterDataFactoryBase factory = _mdMgmt
                                         .GetMasterDataFactory(MasterDataType.VENDOR);
         return(factory.AllEntities);
     }
     else if (fieldName.Equals(BUSINESS_AREA))
     {
         MasterDataFactoryBase factory = _mdMgmt
                                         .GetMasterDataFactory(MasterDataType.BUSINESS_AREA);
         return(factory.AllEntities);
     }
     throw new NoFieldNameException(fieldName);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// get value set
 /// </summary>
 /// <param name="fieldName"></param>
 /// <returns></returns>
 /// <exception cref="NoFieldNameException"></exception>
 public List <MasterDataBase> GetValueSet(String fieldName)
 {
     if (fieldName.Equals(GL_ACCOUNT))
     {
         return(_mdMgmt.RevenueAccounts.ToList <MasterDataBase>());
     }
     else if (fieldName.Equals(REC_ACC))
     {
         return(_mdMgmt.LiquidityAccounts.ToList <MasterDataBase>());
     }
     else if (fieldName.Equals(CUSTOMER))
     {
         MasterDataFactoryBase factory = _mdMgmt
                                         .GetMasterDataFactory(MasterDataType.CUSTOMER);
         return(factory.AllEntities);
     }
     throw new NoFieldNameException(fieldName);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// check core driver
        /// </summary>
        /// <param name="coreDriver"></param>
        private void checkCore(CoreDriver coreDriver)
        {
            Assert.AreEqual(true, coreDriver.IsInitialize);

            MasterDataManagement masterData = coreDriver.MdMgmt;

            foreach (MasterDataType type in Enum.GetValues(typeof(MasterDataType)))
            {
                MasterDataFactoryBase factory = masterData
                                                .GetMasterDataFactory(type);
                Assert.AreEqual(0, factory.AllEntities.Count);
            }

            TransactionDataManagement tranData = coreDriver
                                                 .TransMgmt;

            Assert.IsTrue(null != tranData);
            MonthIdentity[] monthIds = coreDriver.MonthIds;
            Assert.AreEqual(1, monthIds.Length);
        }
Ejemplo n.º 4
0
        public static void CheckMasterData(CoreDriver _coreDriver)
        {
            Assert.AreEqual(true, _coreDriver.IsInitialize);

            MasterDataManagement masterDataManagement = _coreDriver.MdMgmt;

            List <MasterDataBase> datas;

            // check vendor data
            VendorMasterDataFactory vendorFactory = (VendorMasterDataFactory)masterDataManagement
                                                    .GetMasterDataFactory(MasterDataType.VENDOR);

            Assert.AreEqual(2, vendorFactory.MasterDataCount);
            datas = vendorFactory.AllEntities;
            Assert.AreEqual(TestData.VENDOR_BUS, datas[0].Identity.ToString());
            Assert.AreEqual(TestData.VENDOR_BUS_DESCP, datas[0].Descp);
            Assert.AreEqual(TestData.VENDOR_SUBWAY, datas[1].Identity.ToString());
            Assert.AreEqual(TestData.VENDOR_SUBWAY_DESCP, datas[1].Descp);

            // check customer data
            CustomerMasterDataFactory customerFactory = (CustomerMasterDataFactory)masterDataManagement
                                                        .GetMasterDataFactory(MasterDataType.CUSTOMER);

            Assert.AreEqual(2, customerFactory.MasterDataCount);
            datas = customerFactory.AllEntities;
            Assert.AreEqual(TestData.CUSTOMER1, datas[0].Identity.ToString());
            Assert.AreEqual(TestData.CUSTOMER1_DESCP, datas[0].Descp);
            Assert.AreEqual(TestData.CUSTOMER2, datas[1].Identity.ToString());
            Assert.AreEqual(TestData.CUSTOMER2_DESCP, datas[1].Descp);

            // check business area
            BusinessAreaMasterDataFactory businessAreaFactory = (BusinessAreaMasterDataFactory)masterDataManagement
                                                                .GetMasterDataFactory(MasterDataType.BUSINESS_AREA);

            Assert.AreEqual(3, businessAreaFactory.MasterDataCount);
            datas = businessAreaFactory.AllEntities;
            Assert.AreEqual(TestData.BUSINESS_AREA_WORK, datas[0].Identity
                            .ToString());
            Assert.AreEqual(TestData.BUSINESS_AREA_WORK_DESCP, datas[0].Descp);
            Assert.AreEqual(CriticalLevel.HIGH,
                            ((BusinessAreaMasterData)datas[0]).CriLevel);
            Assert.AreEqual(TestData.BUSINESS_AREA_SNACKS, datas[1].Identity
                            .ToString());
            Assert.AreEqual(TestData.BUSINESS_AREA_SNACKS_DESCP, datas[1].Descp);
            Assert.AreEqual(CriticalLevel.LOW,
                            ((BusinessAreaMasterData)datas[1]).CriLevel);
            Assert.AreEqual(TestData.BUSINESS_AREA_ENTERTAIN, datas[2].Identity
                            .ToString());
            Assert.AreEqual(TestData.BUSINESS_AREA_ENTERTAIN_DESCP,
                            datas[2].Descp);
            Assert.AreEqual(CriticalLevel.MEDIUM,
                            ((BusinessAreaMasterData)datas[2]).CriLevel);

            // check bank key
            BankKeyMasterDataFactory bankKeyFactory = (BankKeyMasterDataFactory)masterDataManagement
                                                      .GetMasterDataFactory(MasterDataType.BANK_KEY);

            Assert.AreEqual(1, bankKeyFactory.MasterDataCount);
            datas = bankKeyFactory.AllEntities;
            Assert.AreEqual(TestData.BANK_KEY, datas[0].Identity.ToString());
            Assert.AreEqual(TestData.BANK_KEY_DESCP, datas[0].Descp);

            // check bank account
            BankAccountMasterDataFactory bankAccountFactory = (BankAccountMasterDataFactory)masterDataManagement
                                                              .GetMasterDataFactory(MasterDataType.BANK_ACCOUNT);

            Assert.AreEqual(2, bankAccountFactory.MasterDataCount);
            datas = bankAccountFactory.AllEntities;
            Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6235, datas[0].Identity
                            .ToString());
            Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6235_DESCP, datas[0].Descp);
            Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6235_ACC,
                            ((BankAccountMasterData)datas[0]).AccountNumber
                            .ToString());
            Assert.AreEqual(BankAccountType.SAVING_ACCOUNT,
                            ((BankAccountMasterData)datas[0]).BankAccType);
            Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6620, datas[1].Identity
                            .ToString());
            Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6620_DESCP, datas[1].Descp);
            Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6620_ACC,
                            ((BankAccountMasterData)datas[1]).AccountNumber
                            .ToString());
            Assert.AreEqual(BankAccountType.CREDIT_CARD,
                            ((BankAccountMasterData)datas[1]).BankAccType);

            // check G/L account
            GLAccountMasterDataFactory accountFactory = (GLAccountMasterDataFactory)masterDataManagement
                                                        .GetMasterDataFactory(MasterDataType.GL_ACCOUNT);

            Assert.AreEqual(5, accountFactory.MasterDataCount);
            datas = accountFactory.AllEntities;
            Assert.AreEqual(TestData.GL_ACCOUNT_CASH, datas[0].Identity
                            .ToString());
            Assert.AreEqual(TestData.GL_ACCOUNT_CASH_DESCP, datas[0].Descp);
            Assert.AreEqual(TestData.AMOUNT_VENDOR, ((GLAccountMasterData)datas[0]).InitAmount);

            Assert.AreEqual(TestData.GL_ACCOUNT_BANK, datas[1].Identity
                            .ToString());
            Assert.AreEqual(TestData.GL_ACCOUNT_BANK_DESCP, datas[1].Descp);
            Assert.AreEqual(TestData.BANK_ACCOUNT_CMB_6235,
                            ((GLAccountMasterData)datas[1]).BankAccount.ToString());
            Assert.AreEqual(new CurrencyAmount(), ((GLAccountMasterData)datas[1]).InitAmount);

            Assert.AreEqual(TestData.GL_ACCOUNT_EQUITY, datas[2].Identity
                            .ToString());
            Assert.AreEqual(TestData.GL_ACCOUNT_EQUITY_DESCP, datas[2].Descp);
            Assert.AreEqual(new CurrencyAmount(), ((GLAccountMasterData)datas[2]).InitAmount);

            Assert.AreEqual(TestData.GL_ACCOUNT_REV, datas[3].Identity
                            .ToString());
            Assert.AreEqual(TestData.GL_ACCOUNT_REV_DESCP, datas[3].Descp);
            Assert.AreEqual(new CurrencyAmount(), ((GLAccountMasterData)datas[3]).InitAmount);

            Assert.AreEqual(TestData.GL_ACCOUNT_COST, datas[4].Identity
                            .ToString());
            Assert.AreEqual(TestData.GL_ACCOUNT_COST_DESCP, datas[4].Descp);
            Assert.AreEqual(new CurrencyAmount(), ((GLAccountMasterData)datas[4]).InitAmount);
        }
Ejemplo n.º 5
0
        public static void CreateMasterData(CoreDriver coreDriver)
        {
            ///
            /// check the factory is initialized, and the factory with no master data
            ///
            MasterDataManagement masterDataManagement = coreDriver.MdMgmt;

            // vendor
            VendorMasterDataFactory vendorFactory = (VendorMasterDataFactory)masterDataManagement
                                                    .GetMasterDataFactory(MasterDataType.VENDOR);

            Assert.AreEqual(0, vendorFactory.MasterDataCount);
            // customer
            CustomerMasterDataFactory customerFactory = (CustomerMasterDataFactory)masterDataManagement
                                                        .GetMasterDataFactory(MasterDataType.CUSTOMER);

            Assert.AreEqual(0, customerFactory.MasterDataCount);
            // business area
            BusinessAreaMasterDataFactory businessFactory = (BusinessAreaMasterDataFactory)masterDataManagement
                                                            .GetMasterDataFactory(MasterDataType.BUSINESS_AREA);

            Assert.AreEqual(0, businessFactory.MasterDataCount);
            // bank key
            BankKeyMasterDataFactory bankKeyFactory = (BankKeyMasterDataFactory)masterDataManagement
                                                      .GetMasterDataFactory(MasterDataType.BANK_KEY);

            Assert.AreEqual(0, bankKeyFactory.MasterDataCount);
            // bank account
            BankAccountMasterDataFactory bankAccountFactory = (BankAccountMasterDataFactory)masterDataManagement
                                                              .GetMasterDataFactory(MasterDataType.BANK_ACCOUNT);

            Assert.AreEqual(0, bankAccountFactory.MasterDataCount);
            // GL account
            GLAccountMasterDataFactory accountFactory = (GLAccountMasterDataFactory)masterDataManagement
                                                        .GetMasterDataFactory(MasterDataType.GL_ACCOUNT);

            Assert.AreEqual(0, accountFactory.MasterDataCount);

            /** add master data entities */
            // vendor
            VendorMasterData vendor = (VendorMasterData)vendorFactory
                                      .CreateNewMasterDataBase(new MasterDataIdentity(
                                                                   TestData.VENDOR_BUS), TestData.VENDOR_BUS_DESCP);

            Assert.IsTrue(vendor != null);
            vendor = (VendorMasterData)vendorFactory.CreateNewMasterDataBase(
                new MasterDataIdentity(TestData.VENDOR_SUBWAY),
                TestData.VENDOR_SUBWAY_DESCP);
            Assert.IsTrue(vendor != null);

            // duplicate id
            try
            {
                vendorFactory.CreateNewMasterDataBase(new MasterDataIdentity(
                                                          TestData.VENDOR_SUBWAY), TestData.VENDOR_SUBWAY_DESCP);
                Assert.Fail("Duplicate Id");
            }
            catch (MasterDataIdentityExists)
            {
            }

            // customer
            CustomerMasterData customer = (CustomerMasterData)customerFactory
                                          .CreateNewMasterDataBase(new MasterDataIdentity(
                                                                       TestData.CUSTOMER1), TestData.CUSTOMER1_DESCP);

            Assert.IsTrue(customer != null);
            customer = (CustomerMasterData)customerFactory
                       .CreateNewMasterDataBase(new MasterDataIdentity(
                                                    TestData.CUSTOMER2), TestData.CUSTOMER2_DESCP);
            Assert.IsTrue(customer != null);

            // duplicate id
            try
            {
                customerFactory.CreateNewMasterDataBase(new MasterDataIdentity(
                                                            TestData.CUSTOMER2), TestData.CUSTOMER2_DESCP);

                Assert.Fail("Duplicate Id");
            }
            catch (MasterDataIdentityExists)
            {
            }

            // bank key
            BankKeyMasterData bankKey = (BankKeyMasterData)bankKeyFactory
                                        .CreateNewMasterDataBase(new MasterDataIdentity(
                                                                     TestData.BANK_KEY), TestData.BANK_KEY_DESCP);

            Assert.IsTrue(bankKey != null);

            // duplicate id
            try
            {
                bankKeyFactory.CreateNewMasterDataBase(new MasterDataIdentity(
                                                           TestData.BANK_KEY), TestData.BANK_KEY_DESCP);
                Assert.Fail("Duplicate Id");
            }
            catch (MasterDataIdentityExists)
            {
            }

            // bank account
            MasterDataIdentity bankKeyId  = new MasterDataIdentity(TestData.BANK_KEY);
            BankAccountNumber  accountNum = new BankAccountNumber(
                TestData.BANK_ACCOUNT_CMB_6235_ACC);
            BankAccountMasterData bankAcc = (BankAccountMasterData)bankAccountFactory
                                            .CreateNewMasterDataBase(new MasterDataIdentity(
                                                                         TestData.BANK_ACCOUNT_CMB_6235),
                                                                     TestData.BANK_ACCOUNT_CMB_6235_DESCP, accountNum,
                                                                     bankKeyId, BankAccountType.SAVING_ACCOUNT);

            Assert.IsTrue(bankAcc != null);
            accountNum = new BankAccountNumber(TestData.BANK_ACCOUNT_CMB_6620_ACC);
            bankAcc    = (BankAccountMasterData)bankAccountFactory
                         .CreateNewMasterDataBase(new MasterDataIdentity(
                                                      TestData.BANK_ACCOUNT_CMB_6620),
                                                  TestData.BANK_ACCOUNT_CMB_6620_DESCP, accountNum,
                                                  bankKeyId, BankAccountType.CREDIT_CARD);
            Assert.IsTrue(bankAcc != null);

            // duplicate id
            try
            {
                bankAccountFactory.CreateNewMasterDataBase(new MasterDataIdentity(
                                                               TestData.BANK_ACCOUNT_CMB_6620),
                                                           TestData.BANK_ACCOUNT_CMB_6620_DESCP, accountNum, bankKey,
                                                           BankAccountType.SAVING_ACCOUNT);
                Assert.Fail("Duplicate Id");
            }
            catch (MasterDataIdentityExists)
            {
            }

            // business area
            BusinessAreaMasterData businessArea = (BusinessAreaMasterData)businessFactory
                                                  .CreateNewMasterDataBase(new MasterDataIdentity(
                                                                               TestData.BUSINESS_AREA_ENTERTAIN),
                                                                           TestData.BUSINESS_AREA_ENTERTAIN_DESCP,
                                                                           CriticalLevel.MEDIUM);

            Assert.IsTrue(businessArea != null);
            businessArea = (BusinessAreaMasterData)businessFactory
                           .CreateNewMasterDataBase(new MasterDataIdentity(
                                                        TestData.BUSINESS_AREA_WORK),
                                                    TestData.BUSINESS_AREA_WORK_DESCP, CriticalLevel.HIGH);
            Assert.IsTrue(businessArea != null);
            businessArea = (BusinessAreaMasterData)businessFactory
                           .CreateNewMasterDataBase(new MasterDataIdentity(
                                                        TestData.BUSINESS_AREA_SNACKS),
                                                    TestData.BUSINESS_AREA_SNACKS_DESCP, CriticalLevel.LOW);
            Assert.IsTrue(businessArea != null);

            // duplicate id
            try
            {
                businessArea = (BusinessAreaMasterData)businessFactory
                               .CreateNewMasterDataBase(new MasterDataIdentity(
                                                            TestData.BUSINESS_AREA_SNACKS),
                                                        TestData.BUSINESS_AREA_SNACKS_DESCP,
                                                        CriticalLevel.LOW);
                Assert.Fail("Duplicate Id");
            }
            catch (MasterDataIdentityExists)
            {
            }

            // G/L account
            MasterDataIdentity bankAccId = new MasterDataIdentity(
                TestData.BANK_ACCOUNT_CMB_6235);
            GLAccountMasterData glAccount = (GLAccountMasterData)accountFactory
                                            .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount(
                                                                         TestData.GL_ACCOUNT_BANK),
                                                                     TestData.GL_ACCOUNT_BANK_DESCP, bankAccId);

            Assert.IsTrue(glAccount != null);

            glAccount = (GLAccountMasterData)accountFactory
                        .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount(
                                                     TestData.GL_ACCOUNT_CASH),
                                                 TestData.GL_ACCOUNT_CASH_DESCP);
            Assert.IsTrue(glAccount != null);
            glAccount.SetInitAmount(TestData.AMOUNT_VENDOR);

            glAccount = (GLAccountMasterData)accountFactory
                        .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount(
                                                     TestData.GL_ACCOUNT_COST),
                                                 TestData.GL_ACCOUNT_COST_DESCP);
            Assert.IsTrue(glAccount != null);
            glAccount = (GLAccountMasterData)accountFactory
                        .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount(
                                                     TestData.GL_ACCOUNT_EQUITY),
                                                 TestData.GL_ACCOUNT_EQUITY_DESCP);
            Assert.IsTrue(glAccount != null);
            glAccount = (GLAccountMasterData)accountFactory
                        .CreateNewMasterDataBase(new MasterDataIdentity_GLAccount(
                                                     TestData.GL_ACCOUNT_REV), TestData.GL_ACCOUNT_REV_DESCP);
            Assert.IsTrue(glAccount != null);

            // duplicate id
            try
            {
                accountFactory.CreateNewMasterDataBase(
                    new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_REV),
                    TestData.GL_ACCOUNT_REV_DESCP);
                Assert.Fail("Duplicate Id");
            }
            catch (MasterDataIdentityExists)
            {
            }
        }