Skip to content

Commit

Permalink
Merge pull request larowlan#101 from larowlan/47-comment
Browse files Browse the repository at this point in the history
[larowlan#47] Changes to bill
  • Loading branch information
larowlan authored Apr 12, 2018
2 parents 165faa4 + 0a6f7ea commit 4b58071
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
29 changes: 23 additions & 6 deletions src/Commands/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$rows[] = ['', '<comment>* Deleted or access denied tickets:</comment> ' . implode(',', $unknowns), '', ''];
}
$rows[] = new TableSeparator();
$rows[] = ['', 'Total', Formatter::formatDuration($total), '100%'];
$rows[] = ['', 'Total', Formatter::formatDuration($total), ''];
}
else {
$rows[] = [
Expand All @@ -248,7 +248,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$rows[] = ['<comment>* Deleted or access denied tickets:</comment> ' . implode(',', $unknowns), '', ''];
}
$rows[] = new TableSeparator();
$rows[] = ['Total', Formatter::formatDuration($total), '100%'];
$rows[] = ['Total', Formatter::formatDuration($total), ''];
}

if ($period === static::MONTH) {
Expand All @@ -266,10 +266,14 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$non_billable_hrs = $non_billable / 60 / 60;
$completed_hrs = $billable_hrs + $non_billable_hrs;

$expected = 0;
if ($no_weekdays_in_month > 0) {
$expected = $days_passed / $no_weekdays_in_month;
}
$rows[] = $this->formatProgressRow('No. Days', $days_passed, $no_weekdays_in_month);
$rows[] = $this->formatProgressRow('Billable Hrs', $billable_hrs, $total_billable_hrs);
$rows[] = $this->formatProgressRow('Billable Hrs', $billable_hrs, $total_billable_hrs, $expected);
$rows[] = $this->formatProgressRow('Non-billable Hrs', $non_billable_hrs, $total_non_billable_hrs);
$rows[] = $this->formatProgressRow('Total Hrs', $completed_hrs, $total_hrs);
$rows[] = $this->formatProgressRow('Total Hrs', $completed_hrs, $total_hrs, $expected);
}

$table->setRows($rows);
Expand Down Expand Up @@ -312,19 +316,32 @@ protected function getTotalMonthHours($m, $y) {
* Numerator for progress.
* @param float $denominator
* Denominator for progress.
* @param float $expected
* Expected progress.
*
* @return array
* Formatted row.
*/
protected function formatProgressRow($caption, $numerator, $denominator) {
protected function formatProgressRow($caption, $numerator, $denominator, $expected = NULL) {
if ($denominator < 0) {
return [$caption, "$numerator/$denominator", '0%'];
}
$difference = sprintf('-%s', $denominator - $numerator);
if ($numerator > $denominator) {
$difference = sprintf('-%s', $numerator - $denominator);
}
return [$caption, "$numerator/$denominator ($difference)", round(100 * $numerator / $denominator, 2) . '%'];
if ($expected && ($numerator / $denominator) < $expected) {
return [
$caption,
"$numerator/$denominator ($difference)",
'<error>' . round(100 * $numerator / $denominator, 2) . '%' . '</error>',
];
}
return [
$caption,
"$numerator/$denominator ($difference)",
round(100 * $numerator / $denominator, 2) . '%'
];
}

protected function getWeekdaysInMonth($m, $y) {
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/Send.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
if ((float) $entry->duration == 0) {
// Nothing to send, but mark sent so it doesn't show up tomorrow.
$this->repository->store([$entry->tid => 0]);
$lines[] = sprintf('Marked entry for <info>%d</info> as sent, < 15 minutes', $entry->tid);
$progress->advance();
continue;
}
Expand All @@ -92,10 +93,11 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}
}
$progress->finish();
$output->writeln('');
foreach ($lines as $line) {
$output->writeln($line);
}
$output->writeln('Done');
$output->writeln("Done \xF0\x9F\x8D\xBA \xF0\x9F\x8D\xBA \xF0\x9F\x8D\xBA");
$this->repository->store($entry_ids);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Reviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function headers($exact = FALSE) {
public function getSummary($date = 19780101, $check = FALSE, $exact = FALSE) {
$data = $this->repository->review($date, $check);
if (count($data) == 0 && !$check) {
throw new \Exception('All entries stored in remote system');
throw new \Exception("All entries stored in remote system \xF0\x9F\x8D\xBA \xF0\x9F\x8D\xBA \xF0\x9F\x8D\xBA");
}

$total = 0;
Expand Down

0 comments on commit 4b58071

Please sign in to comment.