update est
This commit is contained in:
parent
b762496709
commit
093589d858
@ -588,19 +588,19 @@ exports.updateEstablishment = async (req, res) => {
|
||||
|
||||
const { id } = req.params;
|
||||
|
||||
const { establishment_products, establishment_user, ...estData } = req.body;
|
||||
logger.error(`Error updating establishment: ${ req.body}`);
|
||||
// const {
|
||||
// establishment_products,
|
||||
// establishment_user,
|
||||
// establishment_code,
|
||||
// factory_name,
|
||||
// establishment_emirate_id,
|
||||
// establishment_city_town_id,
|
||||
// industry_code_production,
|
||||
// corporate_email,
|
||||
// ...estData
|
||||
// } = req.body;
|
||||
// const { establishment_products, establishment_user, ...estData } = req.body;
|
||||
// logger.error(`Error updating establishment: ${ req.body}`);
|
||||
const {
|
||||
establishment_products,
|
||||
establishment_user,
|
||||
establishment_code,
|
||||
factory_name,
|
||||
establishment_emirate_id,
|
||||
establishment_city_town_id,
|
||||
industry_code_production,
|
||||
corporate_email,
|
||||
...estData
|
||||
} = req.body;
|
||||
const user = await EstablishmentUser.findOne({where:{establishment_id:id}});
|
||||
|
||||
const resolveActionDoneBy = (item) => {
|
||||
@ -687,6 +687,27 @@ exports.updateEstablishment = async (req, res) => {
|
||||
return res.status(400).json({ status:"failed", message:"establishment_code already exists" });
|
||||
}
|
||||
}
|
||||
|
||||
if (establishment_code !== undefined)
|
||||
estData.establishment_code = establishment_code;
|
||||
|
||||
if (factory_name !== undefined)
|
||||
estData.factory_name = factory_name;
|
||||
|
||||
if (establishment_emirate_id !== undefined)
|
||||
estData.establishment_emirate_id = establishment_emirate_id;
|
||||
|
||||
if (establishment_city_town_id !== undefined)
|
||||
estData.establishment_city_town_id = establishment_city_town_id;
|
||||
|
||||
if (corporate_email !== undefined)
|
||||
estData.corporate_email = corporate_email;
|
||||
|
||||
// sync industry code & ISIC
|
||||
if (industry_code_production !== undefined) {
|
||||
estData.industry_code_production = industry_code_production;
|
||||
estData.isic_code = industry_code_production;
|
||||
}
|
||||
|
||||
estData.updated_by = estData.updated_by || req.user.id;
|
||||
estData.updated_at = estData.updated_at || new Date();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user