Merge pull request #1058 from josepfo/fix/manually-entered-data-not-propagated-to-machine
fix: add manual data to customer info
This commit is contained in:
commit
c072803ac3
2 changed files with 13 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,12 +20,14 @@ 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 => Promise.all([getEditedData(customer.id), getCustomerById(customer.id)]))
|
||||
.then(([customerEditedData, customerOriginalData]) => selectLatestData(customerOriginalData, customerEditedData))
|
||||
.then(customer => {
|
||||
// BACKWARDS_COMPATIBILITY 7.5
|
||||
// machines before 7.5 expect customer with sanctions result
|
||||
|
|
@ -36,7 +38,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