From 6109cb5d36c792defb60d418ecf06a1fcf89c409 Mon Sep 17 00:00:00 2001 From: Attila Kerekes Date: Sun, 7 Apr 2024 11:03:09 +0200 Subject: [PATCH] Add option to disable reconciliation when importing OFX files. --- .../components/modals/ImportTransactions.jsx | 48 ++++++++++++------- .../loot-core/src/client/actions/account.ts | 13 ++++- upcoming-release-notes/2564.md | 6 +++ 3 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 upcoming-release-notes/2564.md diff --git a/packages/desktop-client/src/components/modals/ImportTransactions.jsx b/packages/desktop-client/src/components/modals/ImportTransactions.jsx index 8ec04d8afd0..b4b1b59474d 100644 --- a/packages/desktop-client/src/components/modals/ImportTransactions.jsx +++ b/packages/desktop-client/src/components/modals/ImportTransactions.jsx @@ -755,6 +755,7 @@ export function ImportTransactions({ modalProps, options }) { const [outValue, setOutValue] = useState(''); const [flipAmount, setFlipAmount] = useState(false); const [multiplierEnabled, setMultiplierEnabled] = useState(false); + const [reconcile, setReconcile] = useState(true); const { accountId, categories, onImported } = options; // This cannot be set after parsing the file, because changing it @@ -980,7 +981,11 @@ export function ImportTransactions({ modalProps, options }) { savePrefs({ [`flip-amount-${accountId}-${filetype}`]: flipAmount }); } - const didChange = await importTransactions(accountId, finalTransactions); + const didChange = await importTransactions( + accountId, + finalTransactions, + reconcile, + ); if (didChange) { await getPayees(); } @@ -1105,21 +1110,32 @@ export function ImportTransactions({ modalProps, options }) { )} {isOfxFile(filetype) && ( - { - setFallbackMissingPayeeToMemo(state => !state); - parse( - filename, - getParseOptions('ofx', { - fallbackMissingPayeeToMemo: !fallbackMissingPayeeToMemo, - }), - ); - }} - > - Use Memo as a fallback for empty Payees - + <> + { + setFallbackMissingPayeeToMemo(state => !state); + parse( + filename, + getParseOptions('ofx', { + fallbackMissingPayeeToMemo: !fallbackMissingPayeeToMemo, + }), + ); + }} + > + Use Memo as a fallback for empty Payees + + { + setReconcile(state => !state); + }} + > + Reconcile transactions + + )} {/*Import Options */} diff --git a/packages/loot-core/src/client/actions/account.ts b/packages/loot-core/src/client/actions/account.ts index f6448ce9e56..43556f4b38a 100644 --- a/packages/loot-core/src/client/actions/account.ts +++ b/packages/loot-core/src/client/actions/account.ts @@ -203,8 +203,17 @@ export function parseTransactions(filepath, options) { }; } -export function importTransactions(id, transactions) { - return async (dispatch: Dispatch) => { +export function importTransactions(id: string, transactions, reconcile = true) { + return async (dispatch: Dispatch): Promise => { + if (!reconcile) { + await send('api/transactions-add', { + accountId: id, + transactions, + }); + + return true; + } + const { errors = [], added, diff --git a/upcoming-release-notes/2564.md b/upcoming-release-notes/2564.md new file mode 100644 index 00000000000..af2421d177a --- /dev/null +++ b/upcoming-release-notes/2564.md @@ -0,0 +1,6 @@ +--- +category: Features +authors: [keriati] +--- + +Add options to disable reconciliation when importing OFX files.