Ejemplo n.º 1
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);
        }
        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));
        }
Ejemplo n.º 3
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
        }