feat: show daily total revenue row
This commit is contained in:
+19
@@ -460,6 +460,25 @@
|
|||||||
headerRow.append(differenceT4Header);
|
headerRow.append(differenceT4Header);
|
||||||
head.append(headerRow);
|
head.append(headerRow);
|
||||||
|
|
||||||
|
const dailyTotals = totalsForDates(rows, dates);
|
||||||
|
const totalRow = document.createElement('tr');
|
||||||
|
const totalLabel = document.createElement('td');
|
||||||
|
totalLabel.textContent = '每日总收入';
|
||||||
|
totalRow.append(totalLabel);
|
||||||
|
dailyTotals.forEach((total) => {
|
||||||
|
const cell = document.createElement('td');
|
||||||
|
cell.textContent = money(total.value);
|
||||||
|
totalRow.append(cell);
|
||||||
|
});
|
||||||
|
const latestTotal = dailyTotals.length ? dailyTotals[dailyTotals.length - 1].value : null;
|
||||||
|
const previousTotal = dailyTotals.length > 1 ? dailyTotals[dailyTotals.length - 2].value : null;
|
||||||
|
const fourthPreviousTotal = dailyTotals.length >= 4 ? dailyTotals[dailyTotals.length - 4].value : null;
|
||||||
|
totalRow.append(
|
||||||
|
createDifferenceCell(previousTotal === null ? null : latestTotal - previousTotal),
|
||||||
|
createDifferenceCell(fourthPreviousTotal === null ? null : latestTotal - fourthPreviousTotal),
|
||||||
|
);
|
||||||
|
body.append(totalRow);
|
||||||
|
|
||||||
const pageCount = Math.max(1, Math.ceil(pivot.length / state.pageSize));
|
const pageCount = Math.max(1, Math.ceil(pivot.length / state.pageSize));
|
||||||
if (state.page > pageCount) state.page = pageCount;
|
if (state.page > pageCount) state.page = pageCount;
|
||||||
const start = (state.page - 1) * state.pageSize;
|
const start = (state.page - 1) * state.pageSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user