protected function prepareData() { $this->items = $this->prepareValues(); $this->collection->map(function (ReportRow $row) { $this->items[$row->getIdentifier()]['value'] += $row->getValue(); }); }
public function getSummary() { $totalValue = $this->getCollectionValue($this->collection); $totalCount = $this->collection->count(); $currentCollection = $this->filterCurrentItems($this->collection); $currentCount = $currentCollection->count(); $currentValue = $this->getCollectionValue($currentCollection); return ['totalValue' => $totalValue, 'currentValue' => $currentValue, 'totalCount' => $totalCount, 'currentCount' => $currentCount]; }
/** * {@inheritdoc} */ public function getReport(ReportConfiguration $configuration) { $criteria = $this->getCriteria($configuration); $collection = $this->repository->matching($criteria); $report = new ReportRowCollection(); $collection->map(function (ClientInterface $client) use($configuration, $report) { $ordersTotal = $this->calculateOrdersAmountForClient($client); $identifier = $client->getFirstName() . ' ' . $client->getLastName(); $report->add(new ReportRow($identifier, $ordersTotal)); }); return $report; }