Block preliminary property assessor PDFs
This commit is contained in:
@@ -25,6 +25,14 @@ export interface ReportPayload {
|
||||
sourceLinks?: unknown;
|
||||
}
|
||||
|
||||
export function isDecisionGradeReportPayload(payload: ReportPayload): boolean {
|
||||
const decision = String(payload.verdict?.decision || "").trim().toLowerCase();
|
||||
const fairValueRange = String(payload.verdict?.fairValueRange || "").trim().toLowerCase();
|
||||
if (!decision || decision === "pending") return false;
|
||||
if (!fairValueRange || fairValueRange === "not established") return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function asStringArray(value: unknown): string[] {
|
||||
if (value == null) return [];
|
||||
if (typeof value === "string") {
|
||||
@@ -69,6 +77,11 @@ export function validateReportPayload(payload: ReportPayload): string[] {
|
||||
if (!address) {
|
||||
throw new ReportValidationError("The report payload must include subjectProperty.address.");
|
||||
}
|
||||
if (!isDecisionGradeReportPayload(payload)) {
|
||||
throw new ReportValidationError(
|
||||
"The report payload is still preliminary. Stop and complete the decision-grade analysis before generating or sending the property assessment PDF."
|
||||
);
|
||||
}
|
||||
return recipients;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user