forked from Yara724/api
Fix searching on GET APIs
This commit is contained in:
@@ -141,7 +141,15 @@ import {
|
||||
/** Maximum sum of line `totalPayment` across the claim (Toman; priced parts + factor lines after validation). */
|
||||
import { getClaimV2TotalPaymentCapToman } from "src/constants/repair-amount-limits";
|
||||
import { ListQueryV2Dto } from "src/common/dto/list-query-v2.dto";
|
||||
import { applyListQueryV2 } from "src/helpers/list-query-v2";
|
||||
import {
|
||||
UnifiedFileStatusReportDto,
|
||||
UnifiedFileStatusReportQueryDto,
|
||||
} from "src/common/dto/unified-file-status-report.dto";
|
||||
import {
|
||||
applyListQueryV2,
|
||||
isInListDateRange,
|
||||
parseListDateRange,
|
||||
} from "src/helpers/list-query-v2";
|
||||
import {
|
||||
countUnifiedFileStatuses,
|
||||
getUnifiedFileStatusCatalog,
|
||||
@@ -3416,13 +3424,37 @@ export class ExpertClaimService {
|
||||
return buckets;
|
||||
}
|
||||
|
||||
async getUnifiedFileStatusReportV2(actor: any) {
|
||||
async getUnifiedFileStatusReportV2(
|
||||
actor: any,
|
||||
query: UnifiedFileStatusReportQueryDto = {},
|
||||
): Promise<UnifiedFileStatusReportDto> {
|
||||
const { claims, blameById } =
|
||||
await this.collectClaimPortfolioWithBlame(actor);
|
||||
const { fromDate, toDate } = parseListDateRange(query.from, query.to);
|
||||
const filteredClaims = claims.filter((c) => {
|
||||
if (
|
||||
!isInListDateRange(
|
||||
c.createdAt as Date | string | undefined,
|
||||
fromDate,
|
||||
toDate,
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (!query.fileType) return true;
|
||||
const blame = c.blameRequestId
|
||||
? blameById.get(String(c.blameRequestId))
|
||||
: undefined;
|
||||
const type =
|
||||
blame?.type ??
|
||||
(c as { snapshot?: { accident?: { type?: string } } })?.snapshot
|
||||
?.accident?.type;
|
||||
return type === query.fileType;
|
||||
});
|
||||
return {
|
||||
statuses: getUnifiedFileStatusCatalog(),
|
||||
counts: countUnifiedFileStatuses(
|
||||
claims.map((c) => {
|
||||
filteredClaims.map((c) => {
|
||||
const blame = c.blameRequestId
|
||||
? blameById.get(String(c.blameRequestId))
|
||||
: undefined;
|
||||
@@ -3532,6 +3564,7 @@ export class ExpertClaimService {
|
||||
createdAt: (r) => r.createdAt,
|
||||
requestNo: (r) => r.publicId,
|
||||
status: (r) => r.unifiedFileStatus ?? r.status,
|
||||
fileType: (r) => r.blameRequestType,
|
||||
searchExtras: (r) =>
|
||||
[
|
||||
r.claimRequestId,
|
||||
|
||||
Reference in New Issue
Block a user