protected override void newDoc(HeadEntity head) { List <ItemEntity> items = head.Items; foreach (ItemEntity itemEntity in items) { MasterDataIdentity id = itemEntity.GLAccount; if (id != null) { DocumentIndexItem item; if (!_list.TryGetValue(id, out item)) { item = new DocumentIndexItemWithBalance(_coreDriver, id, MasterDataType.BUSINESS_AREA); _list.Add(id, item); } // add document item.addDoc(head); // add amount CurrencyAmount amount = itemEntity.Amount; if (itemEntity.CdIndicator == CreditDebitIndicator.CREDIT) { amount.Negate(); } item.addAmount(head.MonthID, amount); } } }
/// <summary> /// reverse document /// </summary> /// <param name="head"></param> protected override void reverseDoc(HeadEntity head) { List <ItemEntity> items = head.Items; foreach (ItemEntity itemEntity in items) { MasterDataIdentity id = itemEntity.GLAccount; if (!_list.ContainsKey(id)) { continue; } DocumentIndexItem item; if (_list.TryGetValue(id, out item) == false) { continue; } // remove document item.removeDoc(head); // remove amount CurrencyAmount amount = itemEntity.Amount; if (itemEntity.CdIndicator == CreditDebitIndicator.DEBIT) { amount.Negate(); } item.addAmount(head.MonthID, amount); } }
/// <summary> /// get the amount from item /// </summary> /// <param name="item"></param> /// <returns></returns> private CurrencyAmount getAmountFromItem(ItemEntity item) { if (_type == MasterDataType.BUSINESS_AREA) { MasterDataIdentity business = item.BusinessArea; if (this._id.Equals(business)) { if (item.CdIndicator == CreditDebitIndicator.DEBIT) { return(item.Amount); } else { CurrencyAmount amount = item.Amount; amount.Negate(); return(amount); } } } else if (_type == MasterDataType.CUSTOMER) { MasterDataIdentity customer = item.Customer; if (this._id.Equals(customer)) { if (item.CdIndicator == CreditDebitIndicator.DEBIT) { return(item.Amount); } else { CurrencyAmount amount = item.Amount; amount.Negate(); return(amount); } } } else if (_type == MasterDataType.VENDOR) { MasterDataIdentity vendor = item.Vendor; if (this._id.Equals(vendor)) { if (item.CdIndicator == CreditDebitIndicator.DEBIT) { return(item.Amount); } else { CurrencyAmount amount = item.Amount; amount.Negate(); return(amount); } } } return(new CurrencyAmount()); }
/// <summary> /// remove document /// </summary> /// <param name="head"></param> internal override void removeDoc(HeadEntity head) { base.removeDoc(head); // add the balance items List <ItemEntity> items = head.Items; foreach (ItemEntity item in items) { CurrencyAmount amount = getAmountFromItem(item); amount.Negate(); _sum.AddTo(amount); } }
/// <summary> /// reverse document /// </summary> /// <param name="doc"></param> private void reverseDoc(HeadEntity doc) { foreach (ItemEntity item in doc.DocItems) { CurrencyAmount amount = item.Amount; if (item.CdIndicator == CreditDebitIndicator.DEBIT) { amount.Negate(); } GLAccountBalanceItem balItem; if (!_items.TryGetValue(item.GLAccount, out balItem)) { continue; } balItem.AddAmount(doc.MonthID, amount); } }
/// <summary> /// set report when new doc /// </summary> /// <param name="head"></param> private void newDoc(HeadEntity head) { foreach (ItemEntity item in head.DocItems) { CurrencyAmount amount = item.Amount; if (item.CdIndicator == CreditDebitIndicator.CREDIT) { amount.Negate(); } GLAccountBalanceItem balItem; if (!_items.TryGetValue(item.GLAccount, out balItem)) { continue; } balItem.AddAmount(head.MonthID, amount); } }
/// <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 }