You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
744 B
JavaScript
26 lines
744 B
JavaScript
const pg = require('../pg')
|
|
const joinjs = require('join-js').default;
|
|
const debug = require('debug')('sos:db:config')
|
|
const mappings = require('../mappings')
|
|
const dbUtil = require('../util')
|
|
|
|
const config = module.exports = {}
|
|
|
|
config.getLatestConfig = async () => {
|
|
const {rows} = await pg.query('select * from sos.v_config')
|
|
|
|
return joinjs.mapOne(rows, mappings, 'configMap', 'config_')
|
|
}
|
|
|
|
config.getTaxRate = async () => {
|
|
const current = await config.getLatestConfig()
|
|
return parseFloat(current.default_tax_percent)
|
|
}
|
|
|
|
config.setShippingAddress = async (address_uuid, user_uuid) =>
|
|
dbUtil.executeFunction({
|
|
name: 'set_shipping_source',
|
|
params: [address_uuid, user_uuid],
|
|
returnType: 'config',
|
|
single: true,
|
|
}) |