Skip to content

Commit

Permalink
add small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vlesia committed May 22, 2024
1 parent e3b4c86 commit d0c9b3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
15 changes: 4 additions & 11 deletions src/controllers/expenses.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,16 @@ const getOne = async (req, res) => {
};

const create = async (req, res) => {
const { userId, spentAt, title, amount, category, note } = req.body;
const user = await getById(userId);
const body = req.body;
const user = await getById(body.userId);

if (!user || !spentAt || !title || !amount) {
if (!user) {
res.sendStatus(HTTP_STATUS_CODES.BAD_REQUEST);

return;
}

const expense = await expensesService.create({
userId,
spentAt,
title,
amount,
category,
note,
});
const expense = await expensesService.create(body);

res.statusCode = HTTP_STATUS_CODES.CREATED;
res.send(expense);
Expand Down
6 changes: 0 additions & 6 deletions src/utils/getFilteredExpenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ const getFilteredExpenses = ({ userId, categories, from, to }) => {
queryFilters.category = categories;
}

// if (from && to) {
// queryFilters.spentAt = {
// [Op.between]: [from, to],
// };
// }

if (from || to) {
queryFilters.spentAt = {};

Expand Down

0 comments on commit d0c9b3c

Please sign in to comment.