- = reportChart([
- 'type' => 'bar',
- 'labels' => array_column($columns, 0),
- 'series' => [
- ['label' => 'Income', 'data' => $chart['income'], 'tone' => 'success'],
- ['label' => 'Expenses', 'data' => $chart['expenses'], 'tone' => 'danger'],
- ['label' => 'Net profit', 'data' => $chart['profit'], 'tone' => 'accent', 'type' => 'line'],
- ],
- 'format' => 'money',
- ], 'lg', "Income, expenses and net profit per $period") ?>
+
+ = reportQuarterCards($quarters, true) ?>
+
+ = reportSectionOpen('Income, expenses and profit by month', escapeHtml((string) $year)) ?>
+
+ = reportChart([
+ 'type' => 'bar',
+ 'labels' => array_column($columns, 0),
+ 'series' => [
+ ['label' => 'Income', 'data' => $chart['income'], 'tone' => 'success'],
+ ['label' => 'Expenses', 'data' => $chart['expenses'], 'tone' => 'danger'],
+ ['label' => 'Net profit', 'data' => $chart['profit'], 'tone' => 'accent', 'type' => 'line'],
+ ],
+ 'format' => 'money',
+ ], 'lg', 'Income, expenses and net profit per month') ?>
+
-
+
= reportSectionOpen('Statement', escapeHtml($current_year ? 'Last year is ' . ($year - 1) . ' to ' . date('M j', strtotime($prev_to)) : 'Last year is ' . ($year - 1)), 'itflow-report-long') ?>
diff --git a/agent/reports/tax_summary.php b/agent/reports/tax_summary.php
index 5aac4ba59..ee0d09e6a 100644
--- a/agent/reports/tax_summary.php
+++ b/agent/reports/tax_summary.php
@@ -65,6 +65,37 @@ $paid_total = $sum($paid_months);
$prev_tax_total = array_sum(array_column($prev['parts'], 'total'));
$has_purchases = (bool) $purchases['parts'];
+// Quarterly has a card for each quarter in place of the chart - each against the same quarter last year
+$quarters = $view === 'quarter' ? reportQuarters($year, $current_year) : [];
+if ($quarters) {
+ $add_parts = function (array $parts) {
+ $months = taxReportMonths();
+ foreach ($parts as $part) {
+ foreach ($part['months'] as $m => $amount) {
+ $months[$m] += $amount;
+ }
+ }
+ return $months;
+ };
+ $prev_tax_months = $add_parts($prev['parts']);
+ $prev_paid_months = $has_purchases
+ ? $add_parts(taxReportPurchases(($year - 1) . '-01-01', $current_year ? dashboardShiftMonths(date('Y-m-d'), -12) : ($year - 1) . '-12-31')['parts'])
+ : taxReportMonths();
+ foreach ($quarters as &$quarter) {
+ $collected = reportQuarterSum($tax_months, $quarter);
+ $collected_prev = reportQuarterSum($prev_tax_months, $quarter);
+ $quarter['rows'] = [
+ ['label' => 'Taxable', 'now' => reportQuarterSum($sales['taxable'], $quarter), 'prev' => reportQuarterSum($prev['taxable'], $quarter), 'good' => 'up'],
+ ['label' => 'Collected', 'now' => $collected, 'prev' => $collected_prev, 'good' => 'up', 'strong' => !$has_purchases],
+ ];
+ if ($has_purchases) {
+ $quarter['rows'][] = ['label' => 'Net tax', 'now' => $collected - reportQuarterSum($paid_months, $quarter),
+ 'prev' => $collected_prev - reportQuarterSum($prev_paid_months, $quarter), 'good' => 'up', 'strong' => true];
+ }
+ }
+ unset($quarter);
+}
+
// A table row for each figure: [group, name, sub, months, emphasis]
$grid = [];
foreach ($sales['parts'] as $label => $part) {
@@ -147,11 +178,12 @@ if ($has_purchases) {
= reportEmpty($basis === 'invoiced' ? "No invoices were sent in $year." : "No payments came in during $year.", 'fa-percent', 'secondary') ?>
-
- = reportSectionOpen('Tax collected by ' . ($view === 'quarter' ? 'quarter' : 'month'), escapeHtml((string) $year)) ?>
+
+ = reportQuarterCards($quarters) ?>
+
+ = reportSectionOpen('Tax collected by month', escapeHtml((string) $year)) ?>
$series,
'stacked' => true,
'format' => 'money',
- ], 'sm', 'Tax collected per ' . ($view === 'quarter' ? 'quarter' : 'month') . ', by part');
+ ], 'sm', 'Tax collected per month, by part');
?>
diff --git a/css/itflow_custom.css b/css/itflow_custom.css
index ab9500046..eef192c31 100644
--- a/css/itflow_custom.css
+++ b/css/itflow_custom.css
@@ -6813,6 +6813,67 @@ a.itflow-report-stat:focus-visible {
color: var(--bs-secondary-color);
}
+/* A report's quarters on its Quarterly view (reportQuarterCards()) - a card each, in the same
+ strip as the figures along the top: the quarter's lines with the change on last year's.
+ Four across where they fit, two by two where they don't, one a row on a phone - never three
+ and one. By the strip's own width, as the side menu changes how much there is */
+.itflow-report-quarters-wrap {
+ container-type: inline-size;
+}
+.itflow-report-quarters {
+ grid-template-columns: minmax(0, 1fr);
+}
+@container (min-width: 30rem) {
+ .itflow-report-quarters {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+}
+@container (min-width: 60rem) {
+ .itflow-report-quarters {
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ }
+}
+.itflow-report-quarter {
+ justify-content: flex-start;
+ gap: .45rem;
+}
+.itflow-report-quarter-head {
+ display: flex;
+ align-items: baseline;
+ gap: .45rem;
+ font-size: .8rem;
+ color: var(--bs-secondary-color);
+}
+.itflow-report-quarter-head strong {
+ font-size: 1rem;
+ color: var(--bs-body-color);
+}
+.itflow-report-quarter-rows {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto auto;
+ align-items: baseline;
+ gap: .2rem .5rem;
+ font-size: .875rem;
+ font-variant-numeric: tabular-nums;
+}
+.itflow-report-quarter-rows > span {
+ white-space: nowrap;
+}
+.itflow-report-quarter-rows > span:nth-child(3n+1) {
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.itflow-report-quarter-rows > span:nth-child(3n) {
+ font-size: .8rem;
+}
+.itflow-report-quarter-foot {
+ font-size: .75rem;
+ color: var(--bs-tertiary-color);
+}
+.itflow-report-quarter.is-later {
+ opacity: .55;
+}
+
.itflow-report-chart {
position: relative;
height: 260px;
diff --git a/functions/reports.php b/functions/reports.php
index 7af2df7f4..ef6991fe2 100644
--- a/functions/reports.php
+++ b/functions/reports.php
@@ -1549,6 +1549,72 @@ function reportChartColumns(array $months, array $columns, $months_shown) {
return $out;
}
+/**
+ * A year's quarters, for a report's Quarterly view: label, months, first and last month,
+ * whether it is 'done', 'now' (under way, this year) or 'later' (still to come), and what each
+ * is compared with - the same quarter last year, or for the one under way, last year's to
+ * today's date. reportQuarterCards() draws them once the report has put its 'rows' in.
+ */
+function reportQuarters($year, $current_year) {
+ $month = $current_year ? intval(date('n')) : 12;
+ $quarters = [];
+ foreach (reportYearColumns('quarter') as $i => [$label, $first, $last]) {
+ $state = $first > $month ? 'later' : ($current_year && $month <= $last ? 'now' : 'done');
+ $quarters[$i] = [
+ 'label' => $label, 'first' => $first, 'last' => $last, 'state' => $state,
+ 'months' => date('M', mktime(0, 0, 0, $first, 1)) . ' – ' . date('M', mktime(0, 0, 0, $last, 1)),
+ 'compare' => "$label " . ($year - 1) . ($state === 'now' ? ' to ' . date('M j') : ''),
+ 'rows' => [],
+ ];
+ }
+ return $quarters;
+}
+
+/** A quarter's share of a year's amounts by month. */
+function reportQuarterSum(array $months, array $quarter) {
+ $sum = 0.0;
+ for ($m = $quarter['first']; $m <= $quarter['last']; $m++) {
+ $sum += $months[$m] ?? 0;
+ }
+ return $sum;
+}
+
+/**
+ * A report's quarters as a row of cards - its Quarterly view, in place of a chart that had
+ * only four bars to show. Each card has the quarter's figures and how each compares with the
+ * same quarter last year; the one under way says so, and the ones still to come are dimmed.
+ * Each of a quarter's 'rows' is ['label' => .., 'now' => amount, 'prev' => amount,
+ * 'good' => up | down, 'strong' => true for its bottom line]. $whole leaves off the cents.
+ */
+function reportQuarterCards(array $quarters, $whole = false) {
+ $money = function ($amount) use ($whole) {
+ return escapeHtml($whole ? reportMoneyWhole($amount) : reportMoney($amount));
+ };
+ $html = '