Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
soker90 committed Aug 31, 2022
1 parent 150bd44 commit f244f95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getTransactionsSumByMonth = async ({
$match: {
user,
date: {
$gte: new Date(year, month || 0).getTime(),
$gte: new Date(year, month || 0, 1).getTime(),
$lt: new Date(Number(month ? year : year + 1), Number(month ? month + 1 : 0)).getTime()
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/client/src/pages/Budgets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const Budgets = () => {
const { expenses, incomes } = useBudgets({ year, month })

const expensesTotal = useMemo(() => {
const total = expenses?.[0]?.budgets?.reduce((sum, expense) => sum + expense.real, 0) ?? 0
const estimated = expenses?.[0]?.budgets?.reduce((sum, expense) => sum + expense.amount, 0) ?? 0
const total = expenses?.reduce((sum, { budgets }) => sum + budgets?.[0]?.real, 0) ?? 0
const estimated = expenses?.reduce((sum, { budgets }) => sum + budgets?.[0]?.amount, 0) ?? 0
return {
total,
estimated,
Expand All @@ -22,8 +22,8 @@ const Budgets = () => {
}, [expenses])

const incomesTotal = useMemo(() => {
const total = incomes?.[0]?.budgets?.reduce((sum, expense) => sum + expense.real, 0) ?? 0
const estimated = incomes?.[0]?.budgets?.reduce((sum, expense) => sum + expense.amount, 0) ?? 0
const total = incomes?.reduce((sum, { budgets }) => sum + budgets?.[0]?.real, 0) ?? 0
const estimated = incomes?.reduce((sum, { budgets }) => sum + budgets?.[0]?.amount, 0) ?? 0
return {
total,
estimated,
Expand Down

0 comments on commit f244f95

Please sign in to comment.