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));
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="monthId"></param>
        /// <returns></returns>
        public ObservableCollection <AbstractAdapterItem> GetItems(MonthIdentity monthId)
        {
            CoreDriver coreDriver = _dataCore.BackendCoreDriver;

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

            if (_curMonthId == null ||
                _curMonthId.Equals(monthId) == false)
            {
                // clear
                _items.Clear();

                // change month
                _curMonthId = monthId;
                GLAccountBalanceCollection balCol = coreDriver.TransMgmt.AccountBalanceCol;
                MasterDataManagement       mdMgmt = coreDriver.MdMgmt;

                // for each cost group
                List <CostReportItem> costList = new List <CostReportItem>();
                foreach (GLAccountGroupENUM group in GLAccountGroup.COST_GROUP)
                {
                    List <MasterDataIdentity_GLAccount> ids = mdMgmt
                                                              .GetGLAccountsBasedGroup(group);
                    // for g/l account in each group
                    foreach (MasterDataIdentity_GLAccount id in ids)
                    {
                        // get master data
                        GLAccountMasterData masterData = (GLAccountMasterData)mdMgmt
                                                         .GetMasterData(id, MasterDataType.GL_ACCOUNT);
                        // get balance item
                        GLAccountBalanceItem item = balCol.GetBalanceItem(id);
                        costList.Add(new CostReportItem(id, masterData.Descp
                                                        , item.GetAmount(_curMonthId), this));
                    }
                }
                // sort
                costList.Sort();
                foreach (CostReportItem costItem in costList)
                {
                    _items.Add(costItem);
                }
            }

            return(_items);
        }