7/24 收银台 日期筛选,合计
This commit is contained in:
@@ -87,7 +87,7 @@ export function convertToChineseCapital(num: number | string): string {
|
||||
* 标准化为Big实例,空/undefined/null转0
|
||||
* @param num 数字 | 数字字符串
|
||||
*/
|
||||
function toBig(num: string | number | undefined | null): Big {
|
||||
export function toBig(num: string | number | undefined | null): Big {
|
||||
if (num === null || num === undefined || num === '') return new Big(0);
|
||||
return new Big(num);
|
||||
}
|
||||
@@ -112,6 +112,12 @@ export function maxMoney(a: string | number, b: string | number): number {
|
||||
const bigB = toBig(b);
|
||||
return Number(bigA.gt(bigB) ? bigA : bigB);
|
||||
}
|
||||
// 取较小值
|
||||
export function minMoney(a: string | number, b: string | number): number {
|
||||
const bigA = toBig(a);
|
||||
const bigB = toBig(b);
|
||||
return Number(bigA.lt(bigB) ? bigA : bigB);
|
||||
}
|
||||
/**
|
||||
* 减法 a - b
|
||||
*/
|
||||
@@ -119,6 +125,12 @@ export function sub(a: string | number, b: string | number): number {
|
||||
return Number(toBig(a).minus(toBig(b)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加法 a + b
|
||||
*/
|
||||
export function add(a: string | number, b: string | number): number {
|
||||
return Number(toBig(a).plus(toBig(b)));
|
||||
}
|
||||
/**
|
||||
* 乘法 a * b
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user