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, })