Add all-debtors mode beside custom ranges for balance claims criteria.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -78,6 +78,7 @@ export class AccountBalanceSettingsService {
|
||||
private requireRange(raw: AccountBalanceRangeDto, label: string): AccountBalanceRangeDto {
|
||||
const range = parseAccountBalanceRange(raw);
|
||||
if (!range) throw new BadRequestException(`${label} معتبر نیست.`);
|
||||
if (range.mode === 'all_debtors') return { mode: 'all_debtors' };
|
||||
return range;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
ACCOUNT_BALANCE_CLAIMS_TAG,
|
||||
ACCOUNT_BALANCE_EVALUATE_BATCH_SIZE,
|
||||
ACTIVITY_BOARD_SYSTEM_BALANCE_CLAIMS,
|
||||
accountBalanceInRange,
|
||||
accountBalanceMatchesCriterion,
|
||||
DEFAULT_ACCOUNT_BALANCE_FIRST_STAGE,
|
||||
parseAccountBalanceSettings,
|
||||
parseAccountBalanceWeightFields,
|
||||
@@ -624,15 +624,15 @@ export class BalanceClaimsService {
|
||||
},
|
||||
settings: AccountBalanceSettingsDto,
|
||||
): boolean {
|
||||
if (accountBalanceInRange(assets.rialBalance, settings.rial)) return true;
|
||||
if (accountBalanceMatchesCriterion(assets.rialBalance, settings.rial)) return true;
|
||||
|
||||
const fieldMap = parseAccountBalanceWeightFields(assets.mandehFields);
|
||||
for (const [key, range] of Object.entries(settings.weights)) {
|
||||
for (const [key, criterion] of Object.entries(settings.weights)) {
|
||||
const value =
|
||||
fieldMap[key] ??
|
||||
(key === 'MandeyeVazni' ? assets.goldBalance : null) ??
|
||||
null;
|
||||
if (accountBalanceInRange(value, range)) return true;
|
||||
if (accountBalanceMatchesCriterion(value, criterion)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Type } from 'class-transformer';
|
||||
import {
|
||||
IsIn,
|
||||
IsInt,
|
||||
IsNumber,
|
||||
IsObject,
|
||||
@@ -13,11 +14,16 @@ import {
|
||||
} from 'class-validator';
|
||||
|
||||
export class AccountBalanceRangeBody {
|
||||
@IsNumber()
|
||||
min!: number;
|
||||
@IsIn(['all_debtors', 'range'])
|
||||
mode!: 'all_debtors' | 'range';
|
||||
|
||||
@ValidateIf((o: AccountBalanceRangeBody) => o.mode === 'range')
|
||||
@IsNumber()
|
||||
max!: number;
|
||||
min?: number;
|
||||
|
||||
@ValidateIf((o: AccountBalanceRangeBody) => o.mode === 'range')
|
||||
@IsNumber()
|
||||
max?: number;
|
||||
}
|
||||
|
||||
export class UpdateAccountBalanceSettingsDto {
|
||||
|
||||
Reference in New Issue
Block a user