Quellcode durchsuchen

feat(wise-cost-util): 添加采保费率计算

zhangweicheng vor 4 Jahren
Ursprung
Commit
43f80bd9fd
2 geänderte Dateien mit 9 neuen und 1 gelöschten Zeilen
  1. 1 1
      wise-cost-util/package.json
  2. 8 0
      wise-cost-util/src/glj.ts

+ 1 - 1
wise-cost-util/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@sc/wise-cost-util",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "description": "wise-cost项目前后端业务通用工具包",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",

+ 8 - 0
wise-cost-util/src/glj.ts

@@ -1,4 +1,5 @@
 import { GljType, IBaseGlj, IInfoPriceItem, TaxType } from '@sc/types';
+import { roundForObj } from '@sc/util';
 
 export const getInfoMarketPrice = (info: IInfoPriceItem, taxType: TaxType) => {
   // 1: 一般计税 2: 简易计税
@@ -14,6 +15,13 @@ export const getInfoMarketPrice = (info: IInfoPriceItem, taxType: TaxType) => {
   return parseFloat(infoPrice);
 };
 
+// 计算采保费率后的市场价
+export const calcMarketPriceByInfoPrice = (infoPrice: number, purchaseFeeRate: number, decimal: number) => {
+  if (!purchaseFeeRate) return infoPrice;
+  return roundForObj(infoPrice * (1 + purchaseFeeRate / 100), decimal);
+};
+
+// roundForObj()
 // 返回五大项组成的索引
 export const getIndex = (obj: IBaseGlj, pops = ['code', 'name', 'specs', 'unit', 'type']): string => {
   let index = '';