Audit histry api changes
This commit is contained in:
parent
419622f1cb
commit
0ae3303d86
@ -465,7 +465,14 @@ exports.getSubmissionHistory = async (req, res) => {
|
|||||||
|
|
||||||
// 1) Get all filtered submissions (or all)
|
// 1) Get all filtered submissions (or all)
|
||||||
const submissions = await Submission.findAll({
|
const submissions = await Submission.findAll({
|
||||||
where: whereSubmission
|
where: whereSubmission,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: Establishment,
|
||||||
|
as: "establishment",
|
||||||
|
attributes: ["factory_name", "establishment_code"],
|
||||||
|
}
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (submissions.length === 0) {
|
if (submissions.length === 0) {
|
||||||
@ -481,7 +488,10 @@ exports.getSubmissionHistory = async (req, res) => {
|
|||||||
...whereProduct
|
...whereProduct
|
||||||
},
|
},
|
||||||
include: [
|
include: [
|
||||||
{ model: Product, as: "product", attributes: ["product_name","hs_code"] }
|
{ model: Product, as: "product", attributes: ["product_name","hs_code"] },
|
||||||
|
{ model: UnitMaster, as: "unit", attributes: ["uom"], },
|
||||||
|
{ model: VariationReasonMaster, as: "variation_reason", attributes: ["reason"],},
|
||||||
|
{ model: ZeroTargetReasonMaster, as: "zero_target_reason", attributes: ["reason"], },
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -505,10 +515,15 @@ exports.getSubmissionHistory = async (req, res) => {
|
|||||||
return {
|
return {
|
||||||
submission_date: sub.created_at,
|
submission_date: sub.created_at,
|
||||||
establishment_id: sub.establishment_id,
|
establishment_id: sub.establishment_id,
|
||||||
|
factory_name: sub.establishment.factory_name,
|
||||||
|
establishment_code: sub.establishment.establishment_code,
|
||||||
year: sub.year,
|
year: sub.year,
|
||||||
quarter: sub.quarter,
|
quarter: sub.quarter,
|
||||||
hs_code: prod.product.hs_code,
|
hs_code: prod.product.hs_code,
|
||||||
product_name: prod.product.product_name,
|
product_name: prod.product.product_name,
|
||||||
|
unit: prod.unit.umo,
|
||||||
|
variation_reason: prod.variation_reason.reason,
|
||||||
|
zero_target_reason: prod.zero_target_reason.reason,
|
||||||
status: sub.status,
|
status: sub.status,
|
||||||
actor: "Establishment",
|
actor: "Establishment",
|
||||||
details: productHistory.map(h => ({
|
details: productHistory.map(h => ({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user