Skip to content

Commit

Permalink
Add option to disable reconciliation when importing OFX files.
Browse files Browse the repository at this point in the history
  • Loading branch information
keriati committed Apr 7, 2024
1 parent b655009 commit 6109cb5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 */}
Expand Down
13 changes: 11 additions & 2 deletions packages/loot-core/src/client/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> => {
if (!reconcile) {
await send('api/transactions-add', {
accountId: id,
transactions,
});

return true;
}

const {
errors = [],
added,
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2564.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Features
authors: [keriati]
---

Add options to disable reconciliation when importing OFX files.

0 comments on commit 6109cb5

Please sign in to comment.