예제 #1
0
        public Dictionary <string, string> Calc(Dictionary <string, string> template)
        {
            SystemProfileService systemProfile = SystemProfileService.GetInstance(mContext);
            var curYear   = systemProfile.GetInt(SystemProfileCategory.Account, SystemProfileKey.CurrentYear);
            var curPeriod = systemProfile.GetInt(SystemProfileCategory.Account, SystemProfileKey.CurrentPeriod);

            AccountBalanceService abService = AccountBalanceService.GetInstance(mContext);

            m_lstYear   = abService.QueryOccurs(curYear, 1, curYear, 12);
            m_lstOccurs = abService.QueryOccurs(curYear, curPeriod, curYear, curPeriod);
            m_lstAso    = DataManager.GetInstance(mContext).Query <AccountSubject>(null).OrderBy(a => a.no).ToList();

            Dictionary <string, string> result = new Dictionary <string, string>();
            List <string> sumKeys = new List <string>();

            foreach (KeyValuePair <string, string> kv in template)
            {
                if (Regex.IsMatch(kv.Value, "(L)") && !Regex.IsMatch(kv.Value, "(SL)"))
                {
                    sumKeys.Add(kv.Key);
                    continue;
                }
                result.Add(kv.Key, Calc(kv.Value));
            }

            sumKeys.Sort();
            foreach (string key in sumKeys)
            {
                result.Add(key, SampleCalculator.sumLine(template[key], key, result));
            }

            return(result);
        }
예제 #2
0
        public Dictionary <string, string> Calc(IDictionary <string, object> filter, IDictionary <string, string> template)
        {
            var beginYear   = int.Parse(filter["beginYear"].ToString());
            var beginPeriod = int.Parse(filter["beginPeriod"].ToString());
            var endYear     = int.Parse(filter["endYear"].ToString());
            var endPeriod   = int.Parse(filter["endPeriod"].ToString());

            AccountBalanceService abService = AccountBalanceService.GetInstance(mContext);
            var prev = CommonUtils.CalcPrevPeriod(new PeridStrunct {
                Year = beginYear, Period = beginPeriod
            });

            m_lstBegin  = abService.QuerySettled(prev.Year, prev.Period);
            m_lstOccurs = abService.QueryOccurs(beginYear, beginPeriod, endYear, endPeriod);
            m_lstAso    = DataManager.GetInstance(mContext).Query <AccountSubject>(null).OrderBy(a => a.no).ToList();

            Dictionary <string, string> result = new Dictionary <string, string>();
            List <string> sumKeys = new List <string>();

            foreach (KeyValuePair <string, string> kv in template)
            {
                if (Regex.IsMatch(kv.Value, "(L)"))
                {
                    sumKeys.Add(kv.Key);
                    continue;
                }
                var rnt = Calc(kv.Value);
                result.Add(kv.Key, rnt);
                logger.Debug("{0} {1} {2}", kv.Key, rnt, kv.Value);
            }

            sumKeys.Sort();
            foreach (string key in sumKeys)
            {
                result.Add(key, SampleCalculator.sumLine(template[key], key, result));
            }

            return(result);
        }
예제 #3
0
        public List <CashflowSheetItem> ListSheet(Dictionary <string, string> filter)
        {
            List <ExcelTemplateItem> lstTemplate = TemplateSevice.GetInstance(mContext).FindTemplate("现金流量表");
            var result = new List <CashflowSheetItem>();

            var beginYear   = int.Parse(filter["beginYear"]);
            var beginPeriod = int.Parse(filter["beginPeriod"]);
            var endYear     = int.Parse(filter["endYear"]);
            var endPeriod   = int.Parse(filter["endPeriod"]);
            var prev        = CommonUtils.CalcPrevPeriod(new PeridStrunct {
                Year = beginYear, Period = beginPeriod
            });
            var curYear = SystemProfileService.GetInstance(mContext).GetInt(SystemProfileCategory.Account, SystemProfileKey.CurrentYear);

            m_lstAso    = DataManager.GetInstance(mContext).Query <AccountSubject>(null).OrderBy(a => a.no).ToList();
            m_lstBegin  = AccountBalanceService.GetInstance(mContext).QuerySettled(prev.Year, prev.Period);
            m_lstOccurs = AccountBalanceService.GetInstance(mContext).QueryOccurs(beginYear, beginPeriod, endYear, endPeriod);
            m_lstYear   = AccountBalanceService.GetInstance(mContext).QueryOccurs(curYear, 1, curYear, 12);

            Dictionary <int, CalTempObj> dictTemplate = new Dictionary <int, CalTempObj>();

            foreach (var template in lstTemplate)
            {
                var item = new CashflowSheetItem();
                item.Name   = template.a;
                item.LineNo = template.b;
                var lineNo = 0;
                if (int.TryParse(item.LineNo, out lineNo))
                {
                    item.Amount = CalcFormula(lineNo, template.c);
                    dictTemplate.Add(lineNo, new CalTempObj(template, item.Amount));
                }
                result.Add(item);
            }

            foreach (var item in result)
            {
                //计算扩展列
                var lineNo = 0;
                if (int.TryParse(item.LineNo, out lineNo))
                {
                    decimal extendAmount = 0;
                    if (CalcExtend(lineNo, dictTemplate, out extendAmount))
                    {
                        item.Amount = extendAmount;
                    }
                }
            }

            foreach (var item in result)
            {
                //计算合计列L
                var lineNo = 0;
                if (int.TryParse(item.LineNo, out lineNo))
                {
                    decimal sumAmount = 0;
                    if (CalcSum(lineNo, dictTemplate, out sumAmount))
                    {
                        item.Flag   = 1;
                        item.Amount = sumAmount;
                        dictTemplate[lineNo].originAmount = item.Amount;
                    }
                }
            }
            return(result);
        }