fix: add missing custom requirement data on customer data communication with machine
fix: create function to reset the override flag in custom requirement data
This commit is contained in:
parent
45173e7c0e
commit
81d74eb40b
3 changed files with 18 additions and 3 deletions
|
|
@ -520,7 +520,11 @@ function getCustomersList (phone = null, name = null, address = null, id = null)
|
||||||
AND ($7 IS NULL OR id_card_data::json->>'documentNumber' = $7)
|
AND ($7 IS NULL OR id_card_data::json->>'documentNumber' = $7)
|
||||||
limit $3`
|
limit $3`
|
||||||
return db.any(sql, [ passableErrorCodes, anonymous.uuid, NUM_RESULTS, phone, name, address, id ])
|
return db.any(sql, [ passableErrorCodes, anonymous.uuid, NUM_RESULTS, phone, name, address, id ])
|
||||||
.then(customers => Promise.all(_.map(camelizeDeep, customers)))
|
.then(customers => Promise.all(_.map(customer =>
|
||||||
|
getCustomInfoRequestsData(customer)
|
||||||
|
.then(camelizeDeep), customers)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -569,6 +573,7 @@ function getCustomerById (id) {
|
||||||
) AS cl WHERE rn = 1`
|
) AS cl WHERE rn = 1`
|
||||||
return db.oneOrNone(sql, [passableErrorCodes, id])
|
return db.oneOrNone(sql, [passableErrorCodes, id])
|
||||||
.then(assignCustomerData)
|
.then(assignCustomerData)
|
||||||
|
.then(getCustomInfoRequestsData)
|
||||||
.then(camelizeDeep)
|
.then(camelizeDeep)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,15 @@ const setCustomerData = (customerId, infoRequestId, data) => {
|
||||||
return db.none(sql, [customerId, infoRequestId, data])
|
return db.none(sql, [customerId, infoRequestId, data])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setCustomerDataViaMachine = (customerId, infoRequestId, data) => {
|
||||||
|
const sql = `
|
||||||
|
INSERT INTO customers_custom_info_requests (customer_id, info_request_id, customer_data)
|
||||||
|
VALUES ($1, $2, $3)
|
||||||
|
ON CONFLICT (customer_id, info_request_id)
|
||||||
|
DO UPDATE SET customer_data = $3, override = $4, override_by = $5, override_at = now()`
|
||||||
|
return db.none(sql, [customerId, infoRequestId, data, 'automatic', null])
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getCustomInfoRequests,
|
getCustomInfoRequests,
|
||||||
addCustomInfoRequest,
|
addCustomInfoRequest,
|
||||||
|
|
@ -131,5 +140,6 @@ module.exports = {
|
||||||
getCustomInfoRequest,
|
getCustomInfoRequest,
|
||||||
batchGetCustomInfoRequest,
|
batchGetCustomInfoRequest,
|
||||||
setAuthorizedCustomRequest,
|
setAuthorizedCustomRequest,
|
||||||
setCustomerData
|
setCustomerData,
|
||||||
|
setCustomerDataViaMachine
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ function updateCustomerCustomInfoRequest (customerId, patch, req, res) {
|
||||||
.then(customer => respond(req, res, { customer }))
|
.then(customer => respond(req, res, { customer }))
|
||||||
}
|
}
|
||||||
|
|
||||||
return customInfoRequestQueries.setCustomerData(customerId, patch.infoRequestId, patch)
|
return customInfoRequestQueries.setCustomerDataViaMachine(customerId, patch.infoRequestId, patch)
|
||||||
.then(() => customers.getById(customerId))
|
.then(() => customers.getById(customerId))
|
||||||
.then(customer => respond(req, res, { customer }))
|
.then(customer => respond(req, res, { customer }))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue