Example #1
0
        private static void InsertEndTermValue(IDalSession session, IPortfolioHistorical portfolio, IList<IJournalEntryLine> dividends, IPeriodicReporting reportingPeriod)
        {
            IAccountTypeInternal account = portfolio.ParentAccount;
            IEndTermValue etv = new EndTermValue(account, reportingPeriod);

            Money InternalDividend = new Money(0m, account.BaseCurrency);
            Money InternalDividendTax = new Money(0m, account.BaseCurrency);
            Money ExternalDividend = new Money(0m, account.BaseCurrency);
            Money ExternalDividendTax = new Money(0m, account.BaseCurrency);

            if (dividends != null)
            {
                List<IJournalEntryLine> divs = dividends.ToList();
                if (divs.Exists(d => d.GiroAccount.Key == account.Key))
                {
                    if (divs.Exists(d => d.GLAccount.IsGrossDividendInternal))
                        InternalDividend = divs.Where(d => (d.GLAccount.IsGrossDividendInternal && (d.GiroAccount.Key == account.Key))).Select(m => m.Balance.BaseAmount).Sum();
                    if (divs.Exists(d => d.GLAccount.IsDividendTaxInternal))
                        InternalDividendTax = divs.Where(d => (d.GLAccount.IsDividendTaxInternal && (d.GiroAccount.Key == account.Key))).Select(m => m.Balance.BaseAmount).Sum();
                    if (divs.Exists(d => d.GLAccount.IsGrossDividendExternal))
                        ExternalDividend = divs.Where(d => (d.GLAccount.IsGrossDividendExternal && (d.GiroAccount.Key == account.Key))).Select(m => m.Balance.BaseAmount).Sum();
                    if (divs.Exists(d => d.GLAccount.IsDividendTaxExternal))
                        ExternalDividendTax = divs.Where(d => (d.GLAccount.IsDividendTaxExternal && (d.GiroAccount.Key == account.Key))).Select(m => m.Balance.BaseAmount).Sum();
                }
            }

            etv.CashValue = portfolio.CashPortfolio.TotalPortfolioValue;
            etv.FundValue = portfolio.FundPortfolio.TotalPortfolioValue;
            etv.ClosingValue = etv.FundValue + etv.CashValue;
            etv.CultureFundValue = portfolio.FundPortfolio.CultureFundValue.Abs();
            etv.GreenFundValue = portfolio.FundPortfolio.GreenFundValue.Abs();
            etv.InternalDividend = InternalDividend.Abs();
            etv.InternalDividendTax = InternalDividendTax.Abs();
            etv.ExternalDividend = ExternalDividend.Abs();
            etv.ExternalDividendTax = ExternalDividendTax.Abs();
            session.InsertOrUpdate(etv);
        }
Example #2
0
        public static IList GetEndValues(IDalSession session, IAccountTypeInternal account, EndTermType term, int year, bool ForcedSet)
        {
            IEndTermValue getter;
            IList returnValue = new EndTermValue[2];
            DateTime[] dates = GetEndDates(term, year);
            ReportingPeriodDetail reportingPeriodDetail = new ReportingPeriodDetail(term, year);
            IPeriodicReporting reportingPeriod = PeriodicReportingMapper.GetReportingPeriod(session, reportingPeriodDetail);

            getter = GetEndValue(session, dates[0], account);
            if (getter != null)
                returnValue[0] = getter;
            else
                returnValue[0] = new EndTermValue(account, reportingPeriod, new Money(0m, account.BaseCurrency), new Money(0m, account.BaseCurrency), new Money(0m, account.BaseCurrency));

            getter = GetEndValue(session, dates[1], account);
            if (getter != null)
                returnValue[1] = getter;
            else
                returnValue[1] = new EndTermValue(account, reportingPeriod, new Money(0m, account.BaseCurrency), new Money(0m, account.BaseCurrency), new Money(0m, account.BaseCurrency));

            return returnValue;
        }