Skip to content

Commit

Permalink
feat: 68 - daily granularity (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsaltares committed Jul 16, 2023
1 parent b70fe01 commit ff10825
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server/reports/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { z } from 'zod';
import { TransactionType } from '@server/transaction/types';

export const Date = z.union([z.string(), z.date()]);
export const TimeGranularities = ['Monthly', 'Quarterly', 'Yearly'] as const;
export const TimeGranularities = [
'Daily',
'Monthly',
'Quarterly',
'Yearly',
] as const;
export const TimeGranularity = z.enum(TimeGranularities);
export const CategoryAggregate = z.object({
id: z.string(),
Expand Down
4 changes: 4 additions & 0 deletions src/server/reports/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export const convertTransactionAmount = (

export const getFormatForGranularity = (granularity: TimeGranularity) => {
switch (granularity) {
case 'Daily':
return 'yyyy-MM-dd';
case 'Monthly':
return 'yyyy-MM';
case 'Quarterly':
Expand All @@ -71,6 +73,8 @@ export const getDisplayFormatForGranularity = (
granularity: TimeGranularity
) => {
switch (granularity) {
case 'Daily':
return 'dd MMM yyyy';
case 'Monthly':
return 'MMM yyyy';
case 'Quarterly':
Expand Down

0 comments on commit ff10825

Please sign in to comment.