mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-30 10:14:53 -05:00
Fix ofx/qfx import options (#1649)
* Fix ofx/qfx import options * Release notes
This commit is contained in:
committed by
GitHub
parent
108daedff5
commit
9fde36dca1
@@ -655,15 +655,13 @@ export default function ImportTransactions({ modalProps, options }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fileType = getFileType(options.filename);
|
const fileType = getFileType(options.filename);
|
||||||
|
const parseOptions = getParseOptions(
|
||||||
parse(
|
fileType,
|
||||||
options.filename,
|
{ csvDelimiter, hasHeaderRow },
|
||||||
fileType === 'csv'
|
{ fallbackMissingPayeeToMemo },
|
||||||
? { delimiter: csvDelimiter, hasHeaderRow }
|
|
||||||
: fileType === 'ofx'
|
|
||||||
? { fallbackMissingPayeeToMemo }
|
|
||||||
: null,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
parse(options.filename, parseOptions);
|
||||||
}, [parseTransactions, options.filename]);
|
}, [parseTransactions, options.filename]);
|
||||||
|
|
||||||
function onSplitMode() {
|
function onSplitMode() {
|
||||||
@@ -707,15 +705,13 @@ export default function ImportTransactions({ modalProps, options }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fileType = getFileType(res[0]);
|
const fileType = getFileType(res[0]);
|
||||||
|
const parseOptions = getParseOptions(
|
||||||
parse(
|
fileType,
|
||||||
res[0],
|
{ csvDelimiter, hasHeaderRow },
|
||||||
fileType === 'csv'
|
{ fallbackMissingPayeeToMemo },
|
||||||
? { delimiter: csvDelimiter }
|
|
||||||
: fileType === 'ofx'
|
|
||||||
? { fallbackMissingPayeeToMemo }
|
|
||||||
: null,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
parse(res[0], parseOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUpdateFields(field, name) {
|
function onUpdateFields(field, name) {
|
||||||
@@ -731,10 +727,9 @@ export default function ImportTransactions({ modalProps, options }) {
|
|||||||
for (let trans of transactions) {
|
for (let trans of transactions) {
|
||||||
trans = fieldMappings ? applyFieldMappings(trans, fieldMappings) : trans;
|
trans = fieldMappings ? applyFieldMappings(trans, fieldMappings) : trans;
|
||||||
|
|
||||||
let date =
|
let date = isOfxFile(filetype)
|
||||||
filetype === 'qfx' || filetype === 'ofx'
|
? trans.date
|
||||||
? trans.date
|
: parseDate(trans.date, parseDateFormat);
|
||||||
: parseDate(trans.date, parseDateFormat);
|
|
||||||
if (date == null) {
|
if (date == null) {
|
||||||
errorMessage = `Unable to parse date ${
|
errorMessage = `Unable to parse date ${
|
||||||
trans.date || '(empty)'
|
trans.date || '(empty)'
|
||||||
@@ -768,12 +763,12 @@ export default function ImportTransactions({ modalProps, options }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filetype !== 'ofx' && filetype !== 'qfx') {
|
if (!isOfxFile(filetype)) {
|
||||||
let key = `parse-date-${accountId}-${filetype}`;
|
let key = `parse-date-${accountId}-${filetype}`;
|
||||||
savePrefs({ [key]: parseDateFormat });
|
savePrefs({ [key]: parseDateFormat });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filetype === 'ofx') {
|
if (isOfxFile(filetype)) {
|
||||||
savePrefs({
|
savePrefs({
|
||||||
[`ofx-fallback-missing-payee-${accountId}`]: fallbackMissingPayeeToMemo,
|
[`ofx-fallback-missing-payee-${accountId}`]: fallbackMissingPayeeToMemo,
|
||||||
});
|
});
|
||||||
@@ -906,15 +901,18 @@ export default function ImportTransactions({ modalProps, options }) {
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{filetype === 'ofx' && (
|
{isOfxFile(filetype) && (
|
||||||
<CheckboxOption
|
<CheckboxOption
|
||||||
id="form_fallback_missing_payee"
|
id="form_fallback_missing_payee"
|
||||||
checked={fallbackMissingPayeeToMemo}
|
checked={fallbackMissingPayeeToMemo}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
setFallbackMissingPayeeToMemo(state => !state);
|
setFallbackMissingPayeeToMemo(state => !state);
|
||||||
parse(filename, {
|
parse(
|
||||||
fallbackMissingPayeeToMemo: !fallbackMissingPayeeToMemo,
|
filename,
|
||||||
});
|
getParseOptions('ofx', {
|
||||||
|
fallbackMissingPayeeToMemo: !fallbackMissingPayeeToMemo,
|
||||||
|
}),
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Use Memo as a fallback for empty Payees
|
Use Memo as a fallback for empty Payees
|
||||||
@@ -964,7 +962,13 @@ export default function ImportTransactions({ modalProps, options }) {
|
|||||||
value={csvDelimiter}
|
value={csvDelimiter}
|
||||||
onChange={value => {
|
onChange={value => {
|
||||||
setCsvDelimiter(value);
|
setCsvDelimiter(value);
|
||||||
parse(filename, { delimiter: value, hasHeaderRow });
|
parse(
|
||||||
|
filename,
|
||||||
|
getParseOptions('csv', {
|
||||||
|
delimiter: value,
|
||||||
|
hasHeaderRow,
|
||||||
|
}),
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
style={{ width: 50 }}
|
style={{ width: 50 }}
|
||||||
/>
|
/>
|
||||||
@@ -974,10 +978,13 @@ export default function ImportTransactions({ modalProps, options }) {
|
|||||||
checked={hasHeaderRow}
|
checked={hasHeaderRow}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
setHasHeaderRow(!hasHeaderRow);
|
setHasHeaderRow(!hasHeaderRow);
|
||||||
parse(filename, {
|
parse(
|
||||||
delimiter: csvDelimiter,
|
filename,
|
||||||
hasHeaderRow: !hasHeaderRow,
|
getParseOptions('csv', {
|
||||||
});
|
delimiter: csvDelimiter,
|
||||||
|
hasHeaderRow: !hasHeaderRow,
|
||||||
|
}),
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
File has header row
|
File has header row
|
||||||
@@ -1051,3 +1058,18 @@ export default function ImportTransactions({ modalProps, options }) {
|
|||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getParseOptions(fileType, csvOptions, ofxOptions) {
|
||||||
|
if (fileType === 'csv') {
|
||||||
|
const { csvDelimiter, hasHeaderRow } = csvOptions;
|
||||||
|
return { csvDelimiter, hasHeaderRow };
|
||||||
|
} else if (isOfxFile(fileType)) {
|
||||||
|
const { fallbackMissingPayeeToMemo } = ofxOptions;
|
||||||
|
return { fallbackMissingPayeeToMemo };
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
function isOfxFile(fileType) {
|
||||||
|
return fileType === 'ofx' || fileType === 'qfx';
|
||||||
|
}
|
||||||
|
|||||||
6
upcoming-release-notes/1649.md
Normal file
6
upcoming-release-notes/1649.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
category: Bugfix
|
||||||
|
authors: [joel-jeremy]
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix qfx import issues reported in v23.9.0.
|
||||||
Reference in New Issue
Block a user