예제 #1
0
        /// <summary>
        /// Get group balance from start month to end month
        /// </summary>
        /// <param name="accountGroup"></param>
        /// <param name="startMonthId"></param>
        /// <param name="endMonthId"></param>
        /// <returns></returns>
        /// <exception cref="SystemException"></exception>
        public CurrencyAmount GetGroupBalance(GLAccountGroupENUM accountGroup,
                                              MonthIdentity startMonthId, MonthIdentity endMonthId)
        {
            CurrencyAmount       ret    = new CurrencyAmount();
            MasterDataManagement mdMgmt = this._mdMgmt;

            foreach (var item in _items)
            {
                GLAccountMasterData glAccount;
                try
                {
                    glAccount = (GLAccountMasterData)mdMgmt
                                .GetMasterData(item.Key, MasterDataType.GL_ACCOUNT);
                }
                catch (Exception e)
                {
                    _coreDriver.logDebugInfo(this.GetType(), 183, e.Message, MessageType.ERRO);
                    throw new SystemException(e);
                }
                if (glAccount.Group.Identity == accountGroup)
                {
                    ret.AddTo(item.Value.GetSumAmount(startMonthId, endMonthId));
                }
            }

            return(ret);
        }
        /// <summary>
        /// Set gl account
        /// </summary>
        /// <param name="glAccount"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="MasterDataIdentityNotDefined"></exception>
        public bool SetGLAccount(MasterDataIdentity_GLAccount glAccount)
        {
            if (_isSaved)
            {
                return(false);
            }

            // check G/L account
            if (glAccount == null)
            {
                throw new ArgumentNullException("G/L account");
            }
            MasterDataBase accountId = _management.GetMasterData(glAccount,
                                                                 MasterDataType.GL_ACCOUNT);

            if (accountId == null)
            {
                throw new MasterDataIdentityNotDefined(glAccount,
                                                       MasterDataType.GL_ACCOUNT);
            }

            _type      = AccountType.GL_ACCOUNT;
            _glAccount = glAccount;
            _vendor    = null;
            _customer  = null;

            return(true);
        }
예제 #3
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);
        }