|
|
@@ -0,0 +1,27 @@
|
|
|
+import { IBaseGlj, IInfoPriceItem, TaxType } from '@sc/types';
|
|
|
+
|
|
|
+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 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;
|
|
|
+};
|