From 915c562545093ec236fba80977f8d386fae5a7e3 Mon Sep 17 00:00:00 2001 From: Attila Kerekes <439392+keriati@users.noreply.github.com> Date: Thu, 11 Apr 2024 05:12:59 +0200 Subject: [PATCH] Add option to disable reconciliation when importing OFX files. (#2564) --- .../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 8ec04d8af..b4b1b5947 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) && ( - <CheckboxOption - id="form_fallback_missing_payee" - checked={fallbackMissingPayeeToMemo} - onChange={() => { - setFallbackMissingPayeeToMemo(state => !state); - parse( - filename, - getParseOptions('ofx', { - fallbackMissingPayeeToMemo: !fallbackMissingPayeeToMemo, - }), - ); - }} - > - Use Memo as a fallback for empty Payees - </CheckboxOption> + <> + <CheckboxOption + id="form_fallback_missing_payee" + checked={fallbackMissingPayeeToMemo} + onChange={() => { + setFallbackMissingPayeeToMemo(state => !state); + parse( + filename, + getParseOptions('ofx', { + fallbackMissingPayeeToMemo: !fallbackMissingPayeeToMemo, + }), + ); + }} + > + Use Memo as a fallback for empty Payees + </CheckboxOption> + <CheckboxOption + id="form_dont_reconcile" + checked={reconcile} + onChange={() => { + setReconcile(state => !state); + }} + > + Reconcile transactions + </CheckboxOption> + </> )} {/*Import Options */} diff --git a/packages/loot-core/src/client/actions/account.ts b/packages/loot-core/src/client/actions/account.ts index 0f31d3b4a..52b41608d 100644 --- a/packages/loot-core/src/client/actions/account.ts +++ b/packages/loot-core/src/client/actions/account.ts @@ -183,8 +183,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<boolean> => { + 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 000000000..af2421d17 --- /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. -- GitLab