Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard Page: Add YTD Option #690

Merged
merged 1 commit into from
Jul 17, 2023
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: 1 addition & 1 deletion src/pages/Dashboard/BaseDashboardChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineComponent({
data() {
return {
period: 'This Year' as PeriodKey,
periodOptions: ['This Year', 'This Quarter', 'This Month'] as PeriodKey[],
periodOptions: ['This Year', 'YTD', 'This Quarter', 'This Month'] as PeriodKey[],
};
},
watch: {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Cashflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default defineComponent({
data: () => ({
data: [] as { inflow: number; outflow: number; yearmonth: string }[],
periodList: [],
periodOptions: ['This Year', 'This Quarter'],
periodOptions: ['This Year', 'YTD', 'This Quarter'],
hasData: false,
}),
computed: {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PeriodSelector
class="px-3"
:value="period"
:options="['This Year', 'This Quarter', 'This Month']"
:options="['This Year', 'YTD', 'This Quarter', 'This Month']"
@change="(value) => (period = value)"
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Dashboard/PeriodSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default defineComponent({
value: { type: String as PropType<PeriodKey>, default: 'This Year' },
options: {
type: Array as PropType<PeriodKey[]>,
default: () => ['This Year', 'This Quarter', 'This Month'],
default: () => ['This Year', 'YTD', 'This Quarter', 'This Month'],
},
},
emits: ['change'],
Expand All @@ -65,6 +65,7 @@ export default defineComponent({
this.periodSelectorMap = {
'': t`Set Period`,
'This Year': t`This Year`,
'YTD': t`YTD`,
'This Quarter': t`This Quarter`,
'This Month': t`This Month`,
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/ProfitAndLoss.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default defineComponent({
data: () => ({
data: [] as { yearmonth: string; balance: number }[],
hasData: false,
periodOptions: ['This Year', 'This Quarter'],
periodOptions: ['This Year', 'YTD', 'This Quarter'],
}),
computed: {
chartData() {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export function getDatesAndPeriodList(period: PeriodKey): {

if (period === 'This Year') {
fromDate = toDate.minus({ months: 12 });
} else if (period === 'YTD') {
fromDate = DateTime.now().startOf('Year');
} else if (period === 'This Quarter') {
fromDate = toDate.minus({ months: 3 });
} else if (period === 'This Month') {
Expand All @@ -35,6 +37,10 @@ export function getDatesAndPeriodList(period: PeriodKey): {
while (true) {
const nextDate = periodList.at(0)!.minus({ months: 1 });
if (nextDate.toMillis() < fromDate.toMillis()) {
if (period === 'YTD'){
periodList.unshift(nextDate);
break;
}
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export type DropdownItem = {

export type UIGroupedFields = Map<string, Map<string, Field[]>>;
export type ExportFormat = 'csv' | 'json';
export type PeriodKey = 'This Year' | 'This Quarter' | 'This Month';
export type PeriodKey = 'This Year'| 'YTD' | 'This Quarter' | 'This Month';

export type PrintValues = {
print: Record<string, unknown>;
Expand Down