Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-analytics-sheets-respect-filters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"mpesa2csv": patch
---

Fix analytics sheets ignoring active export filters (e.g. exclude charges, sort order).
33 changes: 14 additions & 19 deletions src/services/xlsxService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,54 +112,49 @@ export class XlsxService {
});
}

// Add Charges/Fees sheet if requested
// Add Charges/Fees sheet if requested.
// Always uses the unfiltered statement so the sheet has data even when
// "filter out charges" is active on the main sheet.
if (options?.includeChargesSheet) {
addChargesSheet(workbook, statement);
}

// Add Financial Summary sheet if requested
// All remaining analytics sheets use filteredStatement so active filters
// (e.g. exclude charges, sort order) are consistently reflected.
if (options?.includeSummarySheet) {
addFinancialSummarySheet(workbook, statement);
addFinancialSummarySheet(workbook, filteredStatement);
}

// Add Monthly/Weekly Breakdown sheet if requested
if (options?.includeBreakdownSheet) {
addMonthlyWeeklyBreakdownSheet(workbook, statement);
addMonthlyWeeklyBreakdownSheet(workbook, filteredStatement);
}

// Add Daily Balance Tracker sheet if requested
if (options?.includeDailyBalanceSheet) {
addDailyBalanceTrackerSheet(workbook, statement);
addDailyBalanceTrackerSheet(workbook, filteredStatement);
}

// Add Transaction Amount Distribution sheet if requested
if (options?.includeAmountDistributionSheet) {
addTransactionAmountDistributionSheet(workbook, statement);
addTransactionAmountDistributionSheet(workbook, filteredStatement);
}

// Add Top Contacts sheet if requested
if (options?.includeTopContactsSheet) {
addTopContactsSheet(workbook, statement);
addTopContactsSheet(workbook, filteredStatement);
}

// Add Money In sheet if requested
if (options?.includeMoneyInSheet) {
addMoneyInSheet(workbook, statement);
addMoneyInSheet(workbook, filteredStatement);
}

// Add Money Out sheet if requested
if (options?.includeMoneyOutSheet) {
addMoneyOutSheet(workbook, statement);
addMoneyOutSheet(workbook, filteredStatement);
}

// Add Recurring Transactions sheet if requested
if (options?.includeRecurringTransactionsSheet) {
addRecurringTransactionsSheet(workbook, statement);
addRecurringTransactionsSheet(workbook, filteredStatement);
}

// Add Time-of-Day Activity sheet if requested
if (options?.includeTimeOfDaySheet) {
addTimeOfDayActivitySheet(workbook, statement);
addTimeOfDayActivitySheet(workbook, filteredStatement);
}

const buffer = await workbook.xlsx.writeBuffer();
Expand Down
Loading