Пример #1
0
        /// <summary>
        /// check transaction data
        /// </summary>
        /// <param name="coreDriver"></param>
        public static void CheckTransactionData(CoreDriver coreDriver)
        {
            TransactionDataManagement transManagement = coreDriver.TransMgmt;

            MonthIdentity[] monthIds = coreDriver.MonthIds;
            // Assert.AreEqual(2, monthIds.length);

            MonthLedger ledger07 = transManagement.GetLedger(monthIds[0]);
            MonthLedger ledger08 = transManagement.GetLedger(monthIds[1]);

            CheckLedger2012_07(ledger07.Entities);
            CheckLedger2012_08(ledger08.Entities);
        }
        public async Task TestCreateTransWithTemplate()
        {
            Assert.IsTrue(_coreDriver.IsInitialize);
            MasterDataCreater.CreateMasterData(_coreDriver);

            await TemplateCreater.CreateTemplate(_coreDriver, _coreDriver.TmMgmt);

            // create transaction data
            DateTime date = DateTime.Parse("2012.07.02");

            VendorEntry vendor = (VendorEntry)_coreDriver.TmMgmt.GetEntryTemplate(1)
                                 .GenerateEntry();

            vendor.SetValue(EntryTemplate.POSTING_DATE, date);
            await vendor.SaveAsync(true);

            CustomerEntry customer = (CustomerEntry)_coreDriver.TmMgmt.GetEntryTemplate(3)
                                     .GenerateEntry();

            customer.SetValue(EntryTemplate.POSTING_DATE, date);
            customer.SetValue(EntryTemplate.AMOUNT, TestData.AMOUNT_CUSTOMER);
            await customer.SaveAsync(true);

            GLAccountEntry glEntry = (GLAccountEntry)_coreDriver.TmMgmt.GetEntryTemplate(2)
                                     .GenerateEntry();

            glEntry.SetValue(EntryTemplate.POSTING_DATE, date);
            glEntry.SetValue(EntryTemplate.AMOUNT, TestData.AMOUNT_GL);
            await glEntry.SaveAsync(true);

            TransactionDataManagement transManagement = _coreDriver.TransMgmt;

            // month 08
            date = DateTime.Parse("2012.08.02");
            HeadEntity headEntity = await DocumentCreater.CreateVendorDoc(_coreDriver,
                                                                          date);

            DocumentIdentity docId = headEntity.DocIdentity;

            transManagement.ReverseDocument(docId);

            // check
            TransactionDataChecker.CheckTransactionData(_coreDriver);

            // reload
            await _coreDriver.RestartAsync();

            TransactionDataChecker.CheckTransactionData(_coreDriver);
        }
Пример #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);
        }
        public static void CheckAccountBalance(CoreDriver coreDriver)
        {
            TransactionDataManagement  transMgmt = coreDriver.TransMgmt;
            GLAccountBalanceCollection balCol    = transMgmt.AccountBalanceCol;

            MonthIdentity month07 = new MonthIdentity(2012, 7);
            MonthIdentity month08 = new MonthIdentity(2012, 8);

            MasterDataIdentity_GLAccount glAccount2 = new MasterDataIdentity_GLAccount(
                TestData.GL_ACCOUNT_CASH);
            GLAccountBalanceItem balItem = balCol.GetBalanceItem(glAccount2);
            CurrencyAmount       amount2 = new CurrencyAmount(123.45 - 23.45);

            Assert.AreEqual(amount2, balItem.Sum);
            Assert.AreEqual(amount2, balItem.GetAmount(month07));
            Assert.AreEqual(new CurrencyAmount(), balItem.GetAmount(month08));

            Assert.AreEqual(amount2, balCol.GetGroupBalance(GLAccountGroupENUM.CASH));
            Assert.AreEqual(amount2,
                            balCol.GetGroupBalance(GLAccountGroupENUM.CASH, month07, month07));
            Assert.AreEqual(new CurrencyAmount(),
                            balCol.GetGroupBalance(GLAccountGroupENUM.CASH, month08, month08));

            // cost
            Assert.AreEqual(new CurrencyAmount(123.45),
                            balCol.GetGroupBalance(GLAccountGroupENUM.COST_PURE));
            Assert.AreEqual(new CurrencyAmount(123.45), balCol.GetGroupBalance(
                                GLAccountGroupENUM.COST_PURE, month07, month07));
            Assert.AreEqual(new CurrencyAmount(), balCol.GetGroupBalance(
                                GLAccountGroupENUM.COST_PURE, month08, month08));

            // revenue
            Assert.AreEqual(new CurrencyAmount(-543.21),
                            balCol.GetGroupBalance(GLAccountGroupENUM.SALARY));
            Assert.AreEqual(new CurrencyAmount(-543.21),
                            balCol.GetGroupBalance(GLAccountGroupENUM.SALARY, month07, month07));
            Assert.AreEqual(new CurrencyAmount(),
                            balCol.GetGroupBalance(GLAccountGroupENUM.SALARY, month08, month08));
        }
Пример #5
0
        public async Task TestCreateTransDataWithEntry()
        {
            Assert.IsTrue(_coreDriver.IsInitialize);
            MasterDataCreater.CreateMasterData(_coreDriver);

            // month 08, reverse document
            DateTime date = DateTime.Parse("2012.07.02");
            // ledger
            VendorEntry vendorEntry = new VendorEntry(_coreDriver, _coreDriver.MdMgmt);

            vendorEntry.SetValue(EntryTemplate.POSTING_DATE, date);
            vendorEntry.SetValue(EntryTemplate.TEXT, TestData.TEXT_VENDOR_DOC);
            vendorEntry.SetValue(VendorEntry.VENDOR, new MasterDataIdentity(
                                     TestData.VENDOR_BUS));
            vendorEntry.SetValue(VendorEntry.REC_ACC,
                                 new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_CASH));
            vendorEntry.SetValue(VendorEntry.GL_ACCOUNT,
                                 new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_COST));
            vendorEntry.SetValue(VendorEntry.BUSINESS_AREA, new MasterDataIdentity(
                                     TestData.BUSINESS_AREA_WORK));
            vendorEntry.SetValue(EntryTemplate.AMOUNT, TestData.AMOUNT_VENDOR);
            await vendorEntry.SaveAsync(true);

            // customer
            CustomerEntry customerEntry = new CustomerEntry(_coreDriver, _coreDriver.MdMgmt);

            customerEntry.SetValue(EntryTemplate.POSTING_DATE, date);
            customerEntry.SetValue(EntryTemplate.TEXT, TestData.TEXT_CUSTOMER_DOC);
            customerEntry.SetValue(CustomerEntry.CUSTOMER, new MasterDataIdentity(
                                       TestData.CUSTOMER1));
            customerEntry.SetValue(CustomerEntry.REC_ACC,
                                   new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_BANK));
            customerEntry.SetValue(CustomerEntry.GL_ACCOUNT,
                                   new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_REV));
            customerEntry.SetValue(EntryTemplate.AMOUNT, TestData.AMOUNT_CUSTOMER);
            await customerEntry.SaveAsync(true);

            // GL
            GLAccountEntry glAccEntry = new GLAccountEntry(_coreDriver, _coreDriver.MdMgmt);

            glAccEntry.SetValue(EntryTemplate.POSTING_DATE, date);
            glAccEntry.SetValue(EntryTemplate.TEXT, TestData.TEXT_GL_DOC);
            glAccEntry.SetValue(GLAccountEntry.SRC_ACCOUNT,
                                new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_BANK));
            glAccEntry.SetValue(GLAccountEntry.DST_ACCOUNT,
                                new MasterDataIdentity_GLAccount(TestData.GL_ACCOUNT_CASH));
            glAccEntry.SetValue(EntryTemplate.AMOUNT, TestData.AMOUNT_GL);
            await glAccEntry.SaveAsync(true);

            TransactionDataManagement transManagement = _coreDriver.TransMgmt;

            date = DateTime.Parse("2012.08.02");
            HeadEntity headEntity = await DocumentCreater.CreateVendorDoc(_coreDriver,
                                                                          date);

            DocumentIdentity docId = headEntity.DocIdentity;

            transManagement.ReverseDocument(docId);

            // check
            TransactionDataChecker.CheckTransactionData(_coreDriver);

            // reload
            await _coreDriver.RestartAsync();

            TransactionDataChecker.CheckTransactionData(_coreDriver);
        }
Пример #6
0
        /// <summary>
        /// set balance data
        /// </summary>
        private void setBalanceData()
        {
            // int index = MonthSelection.SelectedIndex;
            MonthItem monthItem = MonthSelection.SelectedItem as MonthItem;

            if (monthItem == null)
            {
                return;
            }
            CoreDriver coreDriver = DataCore.GetInstance().BackendCoreDriver;

            if (coreDriver.IsInitialize == false)
            {
                return;
            }

            TransactionDataManagement  transMgmt = coreDriver.TransMgmt;
            GLAccountBalanceCollection balCol    = transMgmt.AccountBalanceCol;

            #region revenue
            CurrencyAmount revenue = new CurrencyAmount();
            foreach (GLAccountGroupENUM group in GLAccountGroup.REVENUE_GROUP)
            {
                CurrencyAmount cur = balCol
                                     .GetGroupBalance(group, monthItem.MonthId, monthItem.MonthId);
                cur.Negate();
                revenue.AddTo(cur);
            }
            // set value
            incomingAmount.Text = revenue.ToString();
            #endregion

            #region cost
            CurrencyAmount cost = new CurrencyAmount();
            foreach (GLAccountGroupENUM group in GLAccountGroup.COST_GROUP)
            {
                CurrencyAmount cur = balCol
                                     .GetGroupBalance(group, monthItem.MonthId, monthItem.MonthId);
                cost.AddTo(cur);
            }
            // set value
            this.outgoingAmount.Text = cost.ToString();
            #endregion

            #region balance
            CurrencyAmount balance = new CurrencyAmount();
            foreach (GLAccountGroupENUM group in GLAccountGroup.BALANCE_GROUP)
            {
                CurrencyAmount cur = balCol
                                     .GetGroupBalance(group);
                balance.AddTo(cur);
            }
            // set value
            this.balanceAmount.Text = balance.ToString();
            #endregion

            #region liquidity
            CurrencyAmount liquidity = new CurrencyAmount();
            foreach (GLAccountGroupENUM group in GLAccountGroup.Liquidity_GROUP)
            {
                CurrencyAmount cur = balCol
                                     .GetGroupBalance(group);
                liquidity.AddTo(cur);
            }
            // set value
            this.liquidityAmount.Text = liquidity.ToString();
            #endregion
        }