fix: add manual data to customer info
This commit is contained in:
parent
87ead03d1f
commit
8fe9c2551a
2 changed files with 15 additions and 5 deletions
|
|
@ -88,6 +88,10 @@ function update (id, data, userToken, txId) {
|
|||
' where id=$1 returning *'
|
||||
|
||||
return db.one(sql, [id])
|
||||
.then(customerData => {
|
||||
return getEditedData(id)
|
||||
.then(customerEditedData => selectLatestData(customerData, customerEditedData))
|
||||
})
|
||||
.then(addComplianceOverrides(id, updateData, userToken))
|
||||
.then(populateOverrideUsernames)
|
||||
.then(computeStatus)
|
||||
|
|
@ -1053,5 +1057,7 @@ module.exports = {
|
|||
updateEditedPhoto,
|
||||
updateTxCustomerPhoto,
|
||||
enableTestCustomer,
|
||||
disableTestCustomer
|
||||
disableTestCustomer,
|
||||
selectLatestData,
|
||||
getEditedData
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const _ = require('lodash/fp')
|
|||
const compliance = require('../compliance')
|
||||
const complianceTriggers = require('../compliance-triggers')
|
||||
const configManager = require('../new-config-manager')
|
||||
const customers = require('../customers')
|
||||
const { get, add, getEditedData, selectLatestData, getCustomerById, update } = require('../customers')
|
||||
const httpError = require('../route-helpers').httpError
|
||||
const plugins = require('../plugins')
|
||||
const Tx = require('../tx')
|
||||
|
|
@ -20,11 +20,15 @@ function addOrUpdateCustomer (req) {
|
|||
const compatTriggers = complianceTriggers.getBackwardsCompatibleTriggers(triggers)
|
||||
const maxDaysThreshold = complianceTriggers.maxDaysThreshold(triggers)
|
||||
|
||||
return customers.get(customerData.phone)
|
||||
return get(customerData.phone)
|
||||
.then(customer => {
|
||||
if (customer) return customer
|
||||
|
||||
return customers.add(req.body)
|
||||
return add(req.body)
|
||||
})
|
||||
.then(customer => {
|
||||
return Promise.all([getEditedData(customer.id), getCustomerById(customer.id)])
|
||||
.then(([customerEditedData, customerOriginalData]) => selectLatestData(customerOriginalData, customerEditedData))
|
||||
})
|
||||
.then(customer => {
|
||||
// BACKWARDS_COMPATIBILITY 7.5
|
||||
|
|
@ -36,7 +40,7 @@ function addOrUpdateCustomer (req) {
|
|||
return compliance.validationPatch(req.deviceId, !!compatTriggers.sanctions, customer)
|
||||
.then(patch => {
|
||||
if (_.isEmpty(patch)) return customer
|
||||
return customers.update(customer.id, patch)
|
||||
return update(customer.id, patch)
|
||||
})
|
||||
})
|
||||
.then(customer => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue