fix(performance): ignore non-RUB cash flows (WealthLedger/main#55)
This commit is contained in:
@@ -44,6 +44,6 @@ describe('performance cash flows', () => {
|
|||||||
]);
|
]);
|
||||||
expect(result.flows).toHaveLength(1);
|
expect(result.flows).toHaveLength(1);
|
||||||
expect(formatDecimal(sumFlows(result.flows))).toBe('100');
|
expect(formatDecimal(sumFlows(result.flows))).toBe('100');
|
||||||
expect([...result.missingAmountAccounts]).toEqual(['A']);
|
expect([...result.missingAmountAccounts]).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -68,10 +68,8 @@ function appendCashFlow(
|
|||||||
missingAmountAccounts.add(operation.accountId);
|
missingAmountAccounts.add(operation.accountId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (value.currency !== 'RUB') {
|
// RUB-only: non-RUB cash movements have no rate to RUB and are left out of XIRR.
|
||||||
missingAmountAccounts.add(operation.accountId);
|
if (value.currency !== 'RUB') return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
const amount = magnitude(value.value);
|
const amount = magnitude(value.value);
|
||||||
flows.push({
|
flows.push({
|
||||||
accountId: operation.accountId,
|
accountId: operation.accountId,
|
||||||
|
|||||||
@@ -94,13 +94,6 @@ describe('investment performance read', () => {
|
|||||||
expect(result.data?.return).toMatchObject({ basis: 'period', value: '0.1' });
|
expect(result.data?.return).toMatchObject({ basis: 'period', value: '0.1' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('reports incomplete history for a non-RUB deposit', async () => {
|
|
||||||
const broken = account('A');
|
|
||||||
broken.operations.push({ ...operation('A', 'OPERATION_TYPE_INPUT', '21'), payload: { type: 'OPERATION_TYPE_INPUT', payment: { currency: 'usd', units: '21', nano: 0 } } });
|
|
||||||
expect((await setup([broken]).service.read('user', 'A')).meta.unavailable)
|
|
||||||
.toEqual([{ accountId: 'A', name: 'A', reason: 'OPERATIONS_HISTORY_INCOMPLETE' }]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('reports incomplete history for a deposit without an amount', async () => {
|
it('reports incomplete history for a deposit without an amount', async () => {
|
||||||
const broken = account('A');
|
const broken = account('A');
|
||||||
broken.operations.push({ ...operation('A', 'OPERATION_TYPE_INPUT', '0'), payload: { type: 'OPERATION_TYPE_INPUT' } } as never);
|
broken.operations.push({ ...operation('A', 'OPERATION_TYPE_INPUT', '0'), payload: { type: 'OPERATION_TYPE_INPUT' } } as never);
|
||||||
|
|||||||
Reference in New Issue
Block a user