| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import { GljType, IBaseGlj, IInfoPriceItem, TaxType } from '@sc/types';
- import { roundForObj } from '@sc/util';
- export const getInfoMarketPrice = (info: IInfoPriceItem, taxType: TaxType) => {
- // 1: 一般计税 2: 简易计税
- const fieldArray = ['noTaxPrice']; // 一般计税 - 不含税价 || 简易计税 - 含税价
- if (taxType === TaxType.GENERAL) {
- fieldArray.push('taxPrice');
- } else {
- fieldArray.unshift('taxPrice');
- }
- // 一个放后面,一个放前面
- let infoPrice = (info as any)[fieldArray[0]];
- if (infoPrice === null || infoPrice === undefined) infoPrice = (info as any)[fieldArray[1]]; // 信息价只有一个价格(含税价/不含税价),则不分计税方式,套用仅有的价格。
- 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 = '';
- const arr = [];
- for (const p of pops) {
- const tmpK = obj[p] === undefined || obj[p] === null || obj[p] === '' ? 'null' : obj[p];
- arr.push(tmpK);
- }
- index = arr.join('|-|');
- return index;
- };
- // 是否是人工
- export const isLabour = (type: GljType) => {
- return type === GljType.LABOUR;
- };
- // 是否是材料
- export const isMaterial = (type: GljType) => {
- const rootType = +String(type).charAt(0);
- return rootType === 2;
- };
- // 是否是机械
- export const isMachine = (type: GljType) => {
- const rootType = +String(type).charAt(0);
- return rootType === 3;
- };
|