fix: exclude internal broker cash transfers

This commit is contained in:
2026-08-28 08:56:02 +03:00
parent 7d2ccf9301
commit 52221dfdc1
5 changed files with 11 additions and 3 deletions

View File

@@ -1,5 +1,11 @@
# Changelog
## [Backend 0.15.1] - 2026-08-28
### Fixed
- Excluded internal transfers for pending securities purchases from broker contributions.
## [Frontend 0.16.0 / Backend 0.15.0 / Shared 0.10.0] - 2026-08-28
### Added

View File

@@ -1,6 +1,6 @@
{
"name": "@family-budget/backend",
"version": "0.15.0",
"version": "0.15.1",
"private": true,
"scripts": {
"dev": "tsx watch src/app.ts",

View File

@@ -39,7 +39,7 @@ export type PortfolioCashKind = 'income' | 'contribution' | 'withdrawal' | 'othe
export function classifyPortfolioCash(amount: number, description: string): PortfolioCashKind {
const text = description.toLowerCase().replace(/ё/g, 'е');
if (amount > 0 && /дивиденд|купон|процент/.test(text)) return 'income';
if (amount > 0 && /зачисление|пополнение денежных средств/.test(text)) return 'contribution';
if (amount > 0 && /зачисление|пополнение/.test(text) && !/для приобретения ценных бумаг|под нерассчитанные сделки/.test(text)) return 'contribution';
if (amount < 0 && /вывод|перевод денежных средств|перечисление денежных средств|возврат денежных средств/.test(text) && !text.includes('под нерассчитанные сделки')) return 'withdrawal';
return 'other';
}

View File

@@ -29,5 +29,7 @@ console.log('portfolio performance: OK');
assert.equal(classifyPortfolioCash(-12500, 'Перечисление денежных средств со счёта'), 'withdrawal');
assert.equal(classifyPortfolioCash(-12500, 'Перевод денежных средств под нерассчитанные сделки'), 'other');
assert.equal(classifyPortfolioCash(52000, 'Зачисление денежных средств для приобретения ценных бумаг'), 'other');
assert.equal(classifyPortfolioCash(52000, 'Пополнение брокерского счёта'), 'contribution');
assert.equal(sumKnownPortfolioValuations([100, null, 25]), 125);
console.log('portfolio cash classification: OK');

2
package-lock.json generated
View File

@@ -15,7 +15,7 @@
},
"backend": {
"name": "@family-budget/backend",
"version": "0.15.0",
"version": "0.15.1",
"dependencies": {
"@family-budget/shared": "*",
"cookie-parser": "^1.4.7",