import React, { useState } from 'react'; import { send } from 'loot-core/src/platform/client/fetch'; import { View, P, ButtonWithLoading } from 'loot-design/src/components/common'; import { colors } from 'loot-design/src/style'; import { Page } from '../Page'; function renderResults(results) { let { numBlankPayees, numCleared, numDeleted } = results; if (numBlankPayees === 0 && numCleared === 0 && numDeleted === 0) { return (

No split transactions found needing repair.

); } let fixed = ''; if (numBlankPayees > 0) { fixed += `${numBlankPayees} split transactions with a blank payee`; } if (numCleared > 0) { if (fixed !== '') { fixed += ', and '; } fixed += `${numCleared} split transactions with the wrong cleared flag`; } if (numDeleted > 0) { if (fixed !== '') { fixed += ', and '; } fixed += `${numDeleted} split transactions that weren't properly deleted`; } return (

Fixed {fixed}.

); } export default function FixSplitsTool() { let [loading, setLoading] = useState(false); let [results, setResults] = useState(null); async function onFix() { setLoading(true); let res = await send('tools/fix-split-transactions'); setResults(res); setLoading(false); } return (

This tool does two things:

If you see blank payees on splits or account balances (or any balances) are incorrect, this may fix it.

Repair split transactions {results && renderResults(results)}
); }