fix: count matched broker cash withdrawals

This commit is contained in:
admin committed 2026-08-28 23:41:32 +03:00
1 parent 8202d292cd
commit 19a924647e
5 files changed
+11 -3

No files matched your search

+6
View File
@@ -1,5 +1,11 @@
# Changelog
## [Backend 0.15.3] - 2026-08-28
### Fixed
- Recognize confirmed broker withdrawals even when the broker description does not contain the word «вывод».
## [Backend 0.15.2] - 2026-08-28
### Fixed
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@family-budget/backend",
"version": "0.15.2",
"version": "0.15.3",
"private": true,
"scripts": {
"dev": "tsx watch src/app.ts",
+2 -1
View File
@@ -40,7 +40,8 @@ export function classifyPortfolioCash(amount: number, description: string, match
const text = description.toLowerCase().replace(/ё/g, 'е');
if (amount > 0 && /дивиденд|купон|процент/.test(text)) return 'income';
if (amount > 0 && (matchedExternalTransfer || /пополнение/.test(text)) && !text.includes('под нерассчитанные сделки')) return 'contribution';
if (amount < 0 && /вывод|перевод денежных средств|перечисление денежных средств|возврат денежных средств/.test(text) && (!text.includes('под нерассчитанные сделки') || matchedExternalTransfer)) return 'withdrawal';
if (amount < 0 && matchedExternalTransfer) return 'withdrawal';
if (amount < 0 && /вывод|перевод денежных средств|перечисление денежных средств|возврат денежных средств/.test(text) && !text.includes('под нерассчитанные сделки')) return 'withdrawal';
return 'other';
}
@@ -33,5 +33,6 @@ assert.equal(classifyPortfolioCash(52000, 'Зачисление денежных
assert.equal(classifyPortfolioCash(52000, 'Зачисление денежных средств для приобретения ценных бумаг', true), 'contribution');
assert.equal(classifyPortfolioCash(52000, 'Пополнение брокерского счёта'), 'contribution');
assert.equal(classifyPortfolioCash(-129000, 'Вывод ДС под нерассчитанные сделки', true), 'withdrawal');
assert.equal(classifyPortfolioCash(-129000, 'Сальдо расчетов по сделкам с ценными бумагами', true), 'withdrawal');
assert.equal(sumKnownPortfolioValuations([100, null, 25]), 125);
console.log('portfolio cash classification: OK');
+1 -1
View File
@@ -15,7 +15,7 @@
},
"backend": {
"name": "@family-budget/backend",
"version": "0.15.2",
"version": "0.15.3",
"dependencies": {
"@family-budget/shared": "*",
"cookie-parser": "^1.4.7",