fix: match broker transfers regardless of description
This commit is contained in:
1 parent
22e9656e92
commit
a6250f1592
5 files changed
+10
-4
No files matched your search
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## [Backend 0.15.5] - 2026-08-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- Trust a matched family-account transfer even when the broker uses an unexpected operation description.
|
||||
|
||||
## [Backend 0.15.4] - 2026-08-28
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@family-budget/backend",
|
||||
"version": "0.15.4",
|
||||
"version": "0.15.5",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/app.ts",
|
||||
|
||||
@@ -58,7 +58,7 @@ export function matchExternalCashTransfers(rows: PerformanceCashRow[]): Set<numb
|
||||
for (const target of external) {
|
||||
const targetAmount = Math.round(Number(target.amount_signed));
|
||||
if (!targetAmount || matchedExternal.has(target.id)) continue;
|
||||
const candidates = broker.filter((row) => !matchedBroker.has(row.id) && Math.sign(Number(row.amount_signed)) === -Math.sign(targetAmount) && Math.abs(Math.round(Number(row.amount_signed))) <= Math.abs(targetAmount) && Math.abs(Date.parse(row.operation_at) - Date.parse(target.operation_at)) <= 3 * 24 * 60 * 60 * 1000 && /вывод|сальдо расчетов|перевод|перечисление/.test(row.description.toLowerCase()));
|
||||
const candidates = broker.filter((row) => !matchedBroker.has(row.id) && Math.sign(Number(row.amount_signed)) === -Math.sign(targetAmount) && Math.abs(Math.round(Number(row.amount_signed))) <= Math.abs(targetAmount) && Math.abs(Date.parse(row.operation_at) - Date.parse(target.operation_at)) <= 3 * 24 * 60 * 60 * 1000);
|
||||
const exact = candidates.find((row) => Math.round(Number(row.amount_signed)) === -targetAmount);
|
||||
let group: PerformanceCashRow[] = exact ? [exact] : [];
|
||||
if (group.length === 0) {
|
||||
|
||||
@@ -36,7 +36,7 @@ assert.equal(classifyPortfolioCash(-129000, 'Вывод ДС под нерасс
|
||||
assert.equal(classifyPortfolioCash(-129000, 'Сальдо расчетов по сделкам с ценными бумагами', true), 'withdrawal');
|
||||
assert.equal(sumKnownPortfolioValuations([100, null, 25]), 125);
|
||||
const matched = matchExternalCashTransfers([
|
||||
{ id: 1, account_id: 1, alias: null, bank: 'VTB', account_number: 'broker', account_type: 'brokerage', operation_at: '2026-05-12T00:00:00+03:00', amount_signed: '-5102321', description: 'Вывод ДС под нерассчитанные сделки' },
|
||||
{ id: 1, account_id: 1, alias: null, bank: 'VTB', account_number: 'broker', account_type: 'brokerage', operation_at: '2026-05-12T00:00:00+03:00', amount_signed: '-5102321', description: 'Нестандартное описание операции' },
|
||||
{ id: 2, account_id: 1, alias: null, bank: 'VTB', account_number: 'broker', account_type: 'brokerage', operation_at: '2026-05-13T00:00:00+03:00', amount_signed: '-4885479', description: 'Вывод ДС под нерассчитанные сделки' },
|
||||
{ id: 3, account_id: 2, alias: null, bank: 'VTB', account_number: 'current', account_type: 'current', operation_at: '2026-05-12T00:00:00+03:00', amount_signed: '9987800', description: 'Вывод денежных средств с брокерского счета' },
|
||||
]);
|
||||
|
||||
Generated
+1
-1
@@ -15,7 +15,7 @@
|
||||
},
|
||||
"backend": {
|
||||
"name": "@family-budget/backend",
|
||||
"version": "0.15.4",
|
||||
"version": "0.15.5",
|
||||
"dependencies": {
|
||||
"@family-budget/shared": "*",
|
||||
"cookie-parser": "^1.4.7",
|
||||
|
||||
Reference in new issue
Block a user