Skip to content

Commit

Permalink
Merge pull request #36 from fga-eps-mds/change-demand-date
Browse files Browse the repository at this point in the history
Demandas retroativas
  • Loading branch information
EzequielDeOliveira authored May 21, 2021
2 parents 117238d + 6398afd commit 4beeb0c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Controllers/DemandController.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const demandsSectorsStatistic = async (req, res) => {
const demandCreate = async (req, res) => {
try {
const {
name, description, process, categoryID, sectorID, clientID, userID,
name, description, process, categoryID, sectorID, clientID, userID, demandDate,
} = req.body;

const validFields = validation.validateDemand(
Expand All @@ -232,6 +232,8 @@ const demandCreate = async (req, res) => {
return res.status(400).json({ message: user.error });
}
const date = moment.utc(moment.tz('America/Sao_Paulo').format('YYYY-MM-DDTHH:mm:ss')).toDate();
const retroactiveDate = moment(demandDate).toDate();

const newDemand = await Demand.create({
name,
description,
Expand All @@ -249,7 +251,7 @@ const demandCreate = async (req, res) => {
date,
label: 'created',
},
createdAt: date,
createdAt: demandDate ? retroactiveDate : date,
updatedAt: date,
});

Expand Down

0 comments on commit 4beeb0c

Please sign in to comment.