Skip to content

Commit

Permalink
log mismatched split amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Dec 12, 2024
1 parent ef95850 commit 6c5349c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/desktop-client/src/components/settings/FixSplits.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';

import { runQuery } from 'loot-core/src/client/query-helpers';
import { send } from 'loot-core/src/platform/client/fetch';
import { q } from 'loot-core/src/shared/query';
import { type Handlers } from 'loot-core/src/types/handlers';

import { theme } from '../../style';
Expand Down Expand Up @@ -61,6 +63,29 @@ export function FixSplits() {
async function onFix() {
setLoading(true);
const res = await send('tools/fix-split-transactions');

const allTransactions = (
await runQuery(
q('transactions')
.options({ splits: 'grouped' })
.filter({
is_parent: true,
})
.select('*'),
)
).data;

const mismatchedSplits = allTransactions.filter(t => {

Check failure on line 78 in packages/desktop-client/src/components/settings/FixSplits.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Parameter 't' implicitly has an 'any' type.
const subValue = t.subtransactions.reduce(
(acc, st) => acc + st.amount,

Check failure on line 80 in packages/desktop-client/src/components/settings/FixSplits.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Parameter 'acc' implicitly has an 'any' type.

Check failure on line 80 in packages/desktop-client/src/components/settings/FixSplits.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Parameter 'st' implicitly has an 'any' type.
0,
);

return subValue !== t.amount;
});

console.log(mismatchedSplits);

setResults(res);
setLoading(false);
}
Expand Down

0 comments on commit 6c5349c

Please sign in to comment.