Small fixes in Report command and csv parsing.
parent
c8e38922c0
commit
78c57e65c8
|
@ -49,12 +49,12 @@ class ReportCommand extends Command {
|
|||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) :int {
|
||||
$reports = $this->trackingService->listReports();
|
||||
// Could just parse a csv file or actually get workItems from youtrack ...
|
||||
if ($input->hasParameterOption('--report') || $input->hasParameterOption('-r')) {
|
||||
if ($report = $input->getOption('report')) {
|
||||
$this->trackingService->setReportId($report);
|
||||
} else {
|
||||
$reports = $this->trackingService->listReports();
|
||||
$count = 1;
|
||||
foreach ($reports as $id => $name) {
|
||||
$output->writeln("[{$count}] {$name} ({$id})");
|
||||
|
@ -73,8 +73,10 @@ class ReportCommand extends Command {
|
|||
|
||||
// Currently we only support csv download.
|
||||
$report_id = $this->trackingService->getReportId();
|
||||
$report_name = $reports[$report_id];
|
||||
$file = $this->trackingService->downloadReport($report_id);
|
||||
// var_dump($file);
|
||||
$output->writeln("report: <info>{$report_name}</info>");
|
||||
$data = $this->csv->generateReportTable($file);
|
||||
$table = $this->buildTable($output, $data);
|
||||
$table->render();
|
||||
|
|
|
@ -122,6 +122,9 @@ class ReportCsv implements ReportCsvInterface
|
|||
$rows[] = ['Gesamt netto', number_format($totalHours, 2, ',', '.'), ' ', number_format($totalPrice, 2, ',', '.')];
|
||||
$add_separator = FALSE;
|
||||
}
|
||||
if (empty($data)) {
|
||||
$add_separator = TRUE;
|
||||
}
|
||||
foreach ($data as $invoice_element) {
|
||||
if ($invoice_element instanceof ExpensesInterface) {
|
||||
if (!isset($added_expenses)) {
|
||||
|
@ -176,8 +179,6 @@ class ReportCsv implements ReportCsvInterface
|
|||
foreach ($data as $line) {
|
||||
$project = explode('-', $line['id'])[0];
|
||||
$previous_project = explode('-', $previous)[0];
|
||||
$project_time += (float) $line['time'];
|
||||
$table[] = array_values($line);
|
||||
if ($project !== $previous_project) {
|
||||
// When project changes, add a sum of time for that project.
|
||||
$table[] = null;
|
||||
|
@ -187,7 +188,9 @@ class ReportCsv implements ReportCsvInterface
|
|||
$project_time = 0;
|
||||
$all_projects[] = $project;
|
||||
}
|
||||
$project_time += (float) $line['time'];
|
||||
$previous = $line['id'];
|
||||
$table[] = array_values($line);
|
||||
}
|
||||
// Add sum for the last project.
|
||||
$table[] = null;
|
||||
|
@ -217,7 +220,7 @@ class ReportCsv implements ReportCsvInterface
|
|||
// @TODO validate line
|
||||
$output[] = [
|
||||
'id' => $line[1],
|
||||
'name' => substr($line[2], 0, 80),
|
||||
'name' => substr($line[2], 0, 60),
|
||||
'time' => $line[4],
|
||||
'estimation' => $line[3],
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue