fix: make paper & SMS receipts independent
This commit is contained in:
parent
206b8cfa09
commit
2ec09de962
2 changed files with 21 additions and 6 deletions
|
|
@ -23,16 +23,18 @@ const speedtestFiles = [
|
||||||
]
|
]
|
||||||
|
|
||||||
const addSmthInfo = (dstField, srcFields) => smth =>
|
const addSmthInfo = (dstField, srcFields) => smth =>
|
||||||
smth && smth.active ? _.set(dstField, _.pick(srcFields, smth)) : _.identity
|
(smth && smth.active) ? _.set(dstField, _.pick(srcFields, smth)) : _.identity
|
||||||
|
|
||||||
const addOperatorInfo = addSmthInfo(
|
const addOperatorInfo = addSmthInfo(
|
||||||
'operatorInfo',
|
'operatorInfo',
|
||||||
['name', 'phone', 'email', 'website', 'companyNumber']
|
['name', 'phone', 'email', 'website', 'companyNumber']
|
||||||
)
|
)
|
||||||
|
|
||||||
const addReceiptInfo = addSmthInfo(
|
const addReceiptInfo = receiptInfo => ret => {
|
||||||
'receiptInfo',
|
if (!receiptInfo) return ret
|
||||||
[
|
|
||||||
|
const fields = [
|
||||||
|
'paper',
|
||||||
'sms',
|
'sms',
|
||||||
'operatorWebsite',
|
'operatorWebsite',
|
||||||
'operatorEmail',
|
'operatorEmail',
|
||||||
|
|
@ -43,10 +45,22 @@ const addReceiptInfo = addSmthInfo(
|
||||||
'exchangeRate',
|
'exchangeRate',
|
||||||
'addressQRCode',
|
'addressQRCode',
|
||||||
]
|
]
|
||||||
)
|
const defaults = _.fromPairs(_.map(field => [field, false], fields))
|
||||||
|
|
||||||
|
receiptInfo = _.flow(
|
||||||
|
o => _.set('paper', o.active, o),
|
||||||
|
_.assign(defaults),
|
||||||
|
_.pick(fields),
|
||||||
|
)(receiptInfo)
|
||||||
|
|
||||||
|
return (receiptInfo.paper || receiptInfo.sms) ?
|
||||||
|
_.set('receiptInfo', receiptInfo, ret) :
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO: Simplify this. */
|
/* TODO: Simplify this. */
|
||||||
const buildTriggers = (allTriggers) => {
|
const buildTriggers = allTriggers => {
|
||||||
const normalTriggers = []
|
const normalTriggers = []
|
||||||
const customTriggers = _.filter(o => {
|
const customTriggers = _.filter(o => {
|
||||||
if (_.isEmpty(o.customInfoRequestId) || _.isNil(o.customInfoRequestId)) normalTriggers.push(o)
|
if (_.isEmpty(o.customInfoRequestId) || _.isNil(o.customInfoRequestId)) normalTriggers.push(o)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ type MachineInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReceiptInfo {
|
type ReceiptInfo {
|
||||||
|
paper: Boolean!
|
||||||
sms: Boolean!
|
sms: Boolean!
|
||||||
operatorWebsite: Boolean!
|
operatorWebsite: Boolean!
|
||||||
operatorEmail: Boolean!
|
operatorEmail: Boolean!
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue