changes
This commit is contained in:
@@ -13,6 +13,7 @@ export const sanitizeUser = (user: User) => ({
|
||||
role: user.role,
|
||||
isActive: user.isActive,
|
||||
defaultCurrency: user.defaultCurrency,
|
||||
integrationsEnabled: Boolean(user.integrationsEnabled),
|
||||
reportPreferences: user.reportPreferences ?? {
|
||||
enabled: false,
|
||||
frequency: 'monthly',
|
||||
@@ -47,6 +48,7 @@ export const createUser = async (input: {
|
||||
passwordHash: await hashPassword(input.password),
|
||||
role: input.role ?? 'USER',
|
||||
defaultCurrency: input.defaultCurrency ?? env.DEFAULT_CURRENCY,
|
||||
integrationsEnabled: false,
|
||||
reportPreferences: {
|
||||
enabled: false,
|
||||
frequency: 'monthly',
|
||||
|
||||
@@ -113,7 +113,13 @@ const currentMonthKey = () => {
|
||||
return `${date.getFullYear()}-${`${date.getMonth() + 1}`.padStart(2, '0')}`;
|
||||
};
|
||||
|
||||
const monthRange = (monthKey: string) => ({ startDate: `${monthKey}-01`, endDate: `${monthKey}-31` });
|
||||
const monthRange = (monthKey: string) => {
|
||||
const [yearText, monthText] = monthKey.split('-');
|
||||
const year = Number(yearText);
|
||||
const month = Number(monthText);
|
||||
const lastDay = new Date(year, month, 0).getDate();
|
||||
return { startDate: `${monthKey}-01`, endDate: `${monthKey}-${String(lastDay).padStart(2, '0')}` };
|
||||
};
|
||||
|
||||
export const getCashflowSummary = async (userId: string) => {
|
||||
const expenseRepo = AppDataSource.getRepository(Expense);
|
||||
|
||||
Reference in New Issue
Block a user