Exemplo n.º 1
0
        ///<inheritdoc />
        public void SaveGroupCell(Sheet sheet, SaveGroupCellParams parameters)
        {
            var records = GetRecordsToUpdate(sheet, parameters.GroupIds);

            if (parameters.ExcludedRecords != null)
            {
                records = records.Where(r => !parameters.ExcludedRecords.Contains(r.RecordId));
            }
            int     recordsCount   = records.Count();
            decimal groupCellValue = parameters.Value;
            decimal cellValue      = CalcRecordCellValue(sheet, groupCellValue, recordsCount);

            foreach (var record in records)
            {
                if (record == records.Last())
                {
                    cellValue = CalcValueWithDivisionRemainder(cellValue, recordsCount, groupCellValue);
                }
                CellRepository.SaveCell(sheet, new Cell {
                    EntityId = record.RecordId,
                    PeriodId = parameters.PeriodId,
                    ColumnId = parameters.ColumnId,
                    Value    = cellValue
                });
            }
        }
        private void UpdateForecastCells()
        {
            List <Cell> cells = CellRepository.GetCells(ForecastSheet, Periods.Select(p => p.Id)).ToList();

            if (cells.IsNullOrEmpty())
            {
                return;
            }
            List <(Guid entityId, Guid periodId, decimal fact, decimal potential)> data =
                Calculate(cells, Periods);

            data.ForEach(d => {
                CellRepository.SaveCell(ForecastSheet, d.entityId, _factIndicatorId, d.periodId,
                                        new ValueInfo {
                    Value = d.fact
                });
                CellRepository.SaveCell(ForecastSheet, d.entityId, _potentialIndicatorId, d.periodId,
                                        new ValueInfo {
                    Value = d.potential
                });
            });
        }