Update establishment API action_done_by filed change added
This commit is contained in:
parent
c3d432c217
commit
432f93fc4f
@ -600,6 +600,12 @@ exports.updateEstablishment = async (req, res) => {
|
||||
return res.status(400).json({ status:"failed", message:"establishment_code already exists" });
|
||||
}
|
||||
}
|
||||
const resolveActionDoneBy = (item) => {
|
||||
if (item?.action_done_by) return item.action_done_by;
|
||||
|
||||
if (req.user.role === "Admin") return "admin_users";
|
||||
return "establishment_users";
|
||||
};
|
||||
estData.updated_by = estData.updated_by || req.user.id;
|
||||
estData.updated_at = estData.updated_at || new Date();
|
||||
// update establishment
|
||||
@ -688,7 +694,8 @@ exports.updateEstablishment = async (req, res) => {
|
||||
{
|
||||
is_active: 0,
|
||||
updated_by: removedData?.updated_by ,
|
||||
action_done_by: removedData?.action_done_by || null,
|
||||
// action_done_by: removedData?.action_done_by || null,
|
||||
action_done_by: req.user.role === "Admin" ? "admin_users" : "establishment_users",
|
||||
updated_at: new Date()
|
||||
},
|
||||
{
|
||||
@ -709,7 +716,8 @@ exports.updateEstablishment = async (req, res) => {
|
||||
product_id: item.product_id,
|
||||
is_active: 1,
|
||||
created_by: item.created_by || null,
|
||||
action_done_by: item.action_done_by,
|
||||
// action_done_by: item.action_done_by,
|
||||
action_done_by: resolveActionDoneBy(item),
|
||||
created_at: new Date()
|
||||
});
|
||||
}
|
||||
@ -722,7 +730,8 @@ exports.updateEstablishment = async (req, res) => {
|
||||
{
|
||||
is_active: 1,
|
||||
updated_by: item.updated_by || null,
|
||||
action_done_by: item.action_done_by,
|
||||
// action_done_by: item.action_done_by,
|
||||
action_done_by: resolveActionDoneBy(item),
|
||||
updated_at: new Date()
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user