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
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,14 @@ <h2>Finances</h2>

<!-- Date Range Filter -->
<div class="filters" style="margin-bottom: 1rem;">
<button class="btn btn-secondary" id="prevMonthBtn" style="margin-right: 0.5rem;">&#8249; Prev</button>
<label style="margin-right: 0.5rem;">From:</label>
<input type="date" id="financeStartDate" class="filter-input" style="width: auto;">
<label style="margin-left: 1rem; margin-right: 0.5rem;">To:</label>
<input type="date" id="financeEndDate" class="filter-input" style="width: auto;">
<button class="btn btn-secondary" id="filterFinancesBtn" style="margin-left: 0.5rem;">Apply</button>
<button class="btn btn-secondary" id="resetFinanceFilterBtn" style="margin-left: 0.5rem;">This Month</button>
<button class="btn btn-secondary" id="nextMonthBtn" style="margin-left: 0.5rem;">Next &#8250;</button>
</div>

<!-- Tabs for Expenses, Revenue, Other Charges -->
Expand Down
2 changes: 1 addition & 1 deletion js/app.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions js/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class TaskManager {
// Finance filters
document.getElementById('filterFinancesBtn')!.addEventListener('click', () => this.renderFinances());
document.getElementById('resetFinanceFilterBtn')!.addEventListener('click', () => this.resetFinanceFilter());
document.getElementById('prevMonthBtn')!.addEventListener('click', () => this.navigateToPrevMonth());
document.getElementById('nextMonthBtn')!.addEventListener('click', () => this.navigateToNextMonth());

// Shop section
document.getElementById('addRewardBtn')!.addEventListener('click', () => this.openRewardModal());
Expand Down Expand Up @@ -1455,6 +1457,26 @@ class TaskManager {
this.renderFinances();
}

navigateToPrevMonth(): void {
const startInput = document.getElementById('financeStartDate') as HTMLInputElement;
const base = startInput.value ? new Date(startInput.value + 'T00:00:00') : new Date();
const firstDay = new Date(base.getFullYear(), base.getMonth() - 1, 1);
const lastDay = new Date(firstDay.getFullYear(), firstDay.getMonth() + 1, 0);
startInput.valueAsDate = firstDay;
(document.getElementById('financeEndDate') as HTMLInputElement).valueAsDate = lastDay;
this.renderFinances();
}

navigateToNextMonth(): void {
const startInput = document.getElementById('financeStartDate') as HTMLInputElement;
const base = startInput.value ? new Date(startInput.value + 'T00:00:00') : new Date();
const firstDay = new Date(base.getFullYear(), base.getMonth() + 1, 1);
const lastDay = new Date(firstDay.getFullYear(), firstDay.getMonth() + 1, 0);
startInput.valueAsDate = firstDay;
(document.getElementById('financeEndDate') as HTMLInputElement).valueAsDate = lastDay;
this.renderFinances();
}

getFinanceDateRange(): { startDate: string; endDate: string } {
const startDate = (document.getElementById('financeStartDate') as HTMLInputElement).value;
const endDate = (document.getElementById('financeEndDate') as HTMLInputElement).value;
Expand Down
Loading