Merge pull request #1103 from chaotixkilla/fix-missing-custom-req-data-machine-response
Fix missing customer data on machine requests
This commit is contained in:
commit
b353f68236
8 changed files with 100 additions and 32 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)
|
||||
limit $3`
|
||||
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`
|
||||
return db.oneOrNone(sql, [passableErrorCodes, id])
|
||||
.then(assignCustomerData)
|
||||
.then(getCustomInfoRequestsData)
|
||||
.then(camelizeDeep)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,13 +113,19 @@ const setCustomerData = (customerId, infoRequestId, data) => {
|
|||
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 = 'automatic',
|
||||
override_by = NULL,
|
||||
override_at = NULL`
|
||||
DO UPDATE SET customer_data = $3`
|
||||
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 = {
|
||||
getCustomInfoRequests,
|
||||
addCustomInfoRequest,
|
||||
|
|
@ -131,5 +137,6 @@ module.exports = {
|
|||
getCustomInfoRequest,
|
||||
batchGetCustomInfoRequest,
|
||||
setAuthorizedCustomRequest,
|
||||
setCustomerData
|
||||
setCustomerData,
|
||||
setCustomerDataViaMachine
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ function updateCustomerCustomInfoRequest (customerId, patch, req, res) {
|
|||
.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(customer => respond(req, res, { customer }))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue