Merge pull request #1180 from chaotixkilla/fix-zeroconf-to-oneconf-customer-id
Fix customer ID not being updated on 0-conf turned 1-conf cash-out transactions
This commit is contained in:
commit
28a8e5a470
1 changed files with 11 additions and 2 deletions
|
|
@ -2,13 +2,14 @@ const _ = require('lodash/fp')
|
||||||
const pgp = require('pg-promise')()
|
const pgp = require('pg-promise')()
|
||||||
|
|
||||||
const helper = require('./cash-out-helper')
|
const helper = require('./cash-out-helper')
|
||||||
|
const { anonymousCustomer } = require('../constants')
|
||||||
|
|
||||||
const toDb = helper.toDb
|
const toDb = helper.toDb
|
||||||
const toObj = helper.toObj
|
const toObj = helper.toObj
|
||||||
|
|
||||||
const UPDATEABLE_FIELDS = ['txHash', 'txVersion', 'status', 'dispense', 'dispenseConfirmed',
|
const UPDATEABLE_FIELDS = ['txHash', 'txVersion', 'status', 'dispense', 'dispenseConfirmed',
|
||||||
'notified', 'redeem', 'phone', 'error', 'swept', 'publishedAt', 'confirmedAt', 'errorCode',
|
'notified', 'redeem', 'phone', 'error', 'swept', 'publishedAt', 'confirmedAt', 'errorCode',
|
||||||
'receivedCryptoAtoms', 'walletScore' ]
|
'receivedCryptoAtoms', 'walletScore', 'customerId' ]
|
||||||
|
|
||||||
module.exports = {upsert, update, insert}
|
module.exports = {upsert, update, insert}
|
||||||
|
|
||||||
|
|
@ -52,7 +53,15 @@ function diff (oldTx, newTx) {
|
||||||
// We never null out an existing field
|
// We never null out an existing field
|
||||||
if (oldTx && _.isNil(newTx[fieldKey])) return
|
if (oldTx && _.isNil(newTx[fieldKey])) return
|
||||||
|
|
||||||
updatedTx[fieldKey] = newTx[fieldKey]
|
switch (fieldKey) {
|
||||||
|
case 'customerId':
|
||||||
|
if (oldTx.customerId === anonymousCustomer.uuid) {
|
||||||
|
return updatedTx['customerId'] = newTx['customerId']
|
||||||
|
}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
return updatedTx[fieldKey] = newTx[fieldKey]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return updatedTx
|
return updatedTx
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue