Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BJKMLHdxMwSUeYcdkwqX4W
18 lines
1.1 KiB
TypeScript
18 lines
1.1 KiB
TypeScript
import type { GridRow } from './statementGrid';
|
|
|
|
/** Строки без распознанного кода, в которых есть значения (P6-10): они блокируют «Подтвердить данные». Порядок — по `row_index`, строки без индекса в конце. */
|
|
export function unresolvedLines(rows: GridRow[]): GridRow[] {
|
|
const found = rows.filter(
|
|
(row) =>
|
|
(row.lineStatus === 'unreadable' || row.lineStatus === 'missing') &&
|
|
Object.values(row.cells).some((cell) => cell !== undefined && (cell.amount !== null || cell.string_value !== null)),
|
|
);
|
|
// порядок как в бланке: по row_index (без индекса — в конец), при равенстве — как пришло
|
|
return found
|
|
.map((row, i) => ({ row, i }))
|
|
.sort((a, b) => (a.row.rowIndex ?? Number.POSITIVE_INFINITY) - (b.row.rowIndex ?? Number.POSITIVE_INFINITY) || a.i - b.i)
|
|
.map(({ row }) => row);
|
|
}
|
|
|
|
export const unresolvedHint = (n: number): string => `Разберите строки без кода: ${n}`;
|