feat: add VTB broker XLSX converter

This commit is contained in:
2026-08-19 15:53:58 +03:00
parent e78445888f
commit 076ab7b055
7 changed files with 224 additions and 4 deletions

View File

@@ -12,8 +12,13 @@ const CASHBACK_KEYWORD = 'зачисление';
function computeFingerprint(
accountNumber: string,
tx: { operationAt: string; amountSigned: number; commission: number; description: string },
tx: { operationAt: string; amountSigned: number; commission: number; description: string; sourceId?: string },
): string {
if (tx.sourceId) {
const raw = [accountNumber, tx.sourceId.trim()].join('|');
const hash = crypto.createHash('sha256').update(raw, 'utf-8').digest('hex');
return `sha256:${hash}`;
}
const raw = [
accountNumber,
tx.operationAt,
@@ -91,6 +96,9 @@ function validateStructure(body: unknown): ValidationError | null {
if (typeof t.description !== 'string' || !t.description) {
return { status: 400, error: 'BAD_REQUEST', message: `transactions[${i}].description must be a non-empty string` };
}
if (t.sourceId !== undefined && (typeof t.sourceId !== 'string' || !t.sourceId.trim())) {
return { status: 400, error: 'BAD_REQUEST', message: `transactions[${i}].sourceId must be a non-empty string when provided` };
}
if (typeof t.amountSigned !== 'number' || !Number.isInteger(t.amountSigned)) {
return { status: 400, error: 'BAD_REQUEST', message: `transactions[${i}].amountSigned must be an integer` };
}