2.0.9 • Published 11 months ago
yc-format-money v2.0.9
1.先用np 之后看看改成bignumber 2.要写测试用例 3.调试使用debug/index.js
发布要保证测试用例通过
要先把通用api订出来
金额格式化通用api 1.formatNumberByCurrency (value, currencyId, type, enterpriseId) // 多参数调用 2.formatPrice(value, currencyId, enterpriseId) // 默认type=price 3.formatMoney(value, currencyId, enterpriseId) // 默认type=money 4.setCurrency(currencyId) // 用于避免每个方法都传币种id,一般一个单据都是一个,统一设置之后,只要调用formatPrice(8)或者formatMoney(8) 只传一个参数就可以了 5.setEnterpriseId(enterpiseId) // 避免每个方法都传租户id
要求: 1.查询币种服务的数据要缓存 2.要考虑币种查不到的情况,或者没有传currencyId的情况,默认给单价4位、金额2位,四舍五入
// 如何调试:使用vscode的debug来调试
API
formatNumberByCurrency(value, currencyId, type, enterpriseId)
type默认值为price, enterpriseId默认值为当前租户enterpriseId
formatPrice(value, currencyId, enterpriseId)
获取处理精度之后的价格
formatMoney(value, currencyId, enterpriseId)
获取处理精度之后的金额
setCurrency(currencyId)
设置当前currencyId
setEnterpriseId(enterpiseId)
设置当前enterpriseId