test(analytics): cover net category semantics

This commit is contained in:
2026-08-19 07:49:54 +03:00
parent a79629a60d
commit 019714a8cf
4 changed files with 61 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
import { pool } from '../db/pool';
import { effectiveAmountCase } from './analyticsSemantics';
import type {
AnalyticsSummaryResponse,
TopCategory,
@@ -14,14 +15,7 @@ interface BaseParams {
onlyConfirmed?: boolean;
}
const effectiveAmount = `
CASE
WHEN t.amount_signed = 0 AND t.commission > 0
AND t.description ILIKE '%зачисление%'
THEN t.commission
WHEN t.amount_signed < 0 THEN t.amount_signed - t.commission
ELSE t.amount_signed + t.commission
END`;
const effectiveAmount = effectiveAmountCase('t');
function analyticsTransactions(where: string): string {
return `