Skip to content

Commit

Permalink
Merge branch 'master' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
HansiWursti authored Jan 12, 2024
2 parents 11cfbdf + 6ce794f commit e9a2c45
Show file tree
Hide file tree
Showing 975 changed files with 12 additions and 305,147 deletions.
4 changes: 0 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,3 @@ packages/import-ynab5/**/node_modules/*
packages/loot-core/**/node_modules/*
packages/loot-core/**/lib-dist/*
packages/loot-core/**/proto/*

packages/node-libofx/libofx.*.js
packages/node-libofx/libofx/
packages/node-libofx/OpenSP-*/
Original file line number Diff line number Diff line change
Expand Up @@ -743,20 +743,13 @@ export function ImportTransactions({ modalProps, options }) {

const [clearOnImport, setClearOnImport] = useState(true);

const enableExperimentalOfxParser = useFeatureFlag('experimentalOfxParser');

async function parse(filename, options) {
setLoadingState('parsing');

const filetype = getFileType(filename);
setFilename(filename);
setFileType(filetype);

options = {
...options,
enableExperimentalOfxParser,
};

const { errors, transactions } = await parseTransactions(filename, options);
setLoadingState(null);
setError(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ export function ExperimentalFeatures() {
<FeatureToggle flag="goalTemplatesEnabled">
Goal templates
</FeatureToggle>

<FeatureToggle flag="experimentalOfxParser">
Experimental OFX parser
</FeatureToggle>
</View>
) : (
<LinkButton
Expand Down
1 change: 0 additions & 1 deletion packages/desktop-client/src/hooks/useFeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const DEFAULT_FEATURE_FLAG_STATE: Record<FeatureFlag, boolean> = {
reportBudget: false,
goalTemplatesEnabled: false,
customReports: false,
experimentalOfxParser: true,
};

export function useFeatureFlag(name: FeatureFlag): boolean {
Expand Down
3 changes: 1 addition & 2 deletions packages/desktop-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"!**/*.js.map",
"!node_modules/@jlongster/sql.js",
"!node_modules/absurd-sql",
"!node_modules/better-sqlite3/{benchmark,src,bin,docs,deps,build/Release/obj,build/Release/sqlite3.a,build/Release/test_extension.node}",
"!node_modules/node-libofx/{OpenSP-1.5.2,libofx,libofx.web.js,libofx.web.wasm,emscripten.cpp,Makefile}"
"!node_modules/better-sqlite3/{benchmark,src,bin,docs,deps,build/Release/obj,build/Release/sqlite3.a,build/Release/test_extension.node}"
],
"publish": {
"provider": "github",
Expand Down
1 change: 0 additions & 1 deletion packages/loot-core/bin/build-browser
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ if [ $NODE_ENV == 'development' ]; then
fi

cp ../../../node_modules/@jlongster/sql.js/dist/sql-wasm.wasm "$PUBLIC_DIR"/sql-wasm.wasm
cp ../../node-libofx/libofx.web.wasm "$PUBLIC_DIR"/libofx.web.wasm

yarn webpack --config ../webpack/webpack.browser.config.js \
--target "webworker" \
Expand Down
1 change: 0 additions & 1 deletion packages/loot-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"md5": "^2.3.0",
"mitt": "^3.0.0",
"node-fetch": "^2.6.9",
"node-libofx": "*",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"reselect": "^4.1.8",
Expand Down
3 changes: 0 additions & 3 deletions packages/loot-core/src/server/accounts/parse-file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ async function importFileWithRealTime(
global.restoreDateNow();
const { errors, transactions: originalTransactions } = await parseFile(
filepath,
{
enableExperimentalOfxParser: true,
},
);
global.restoreFakeDateNow();

Expand Down
52 changes: 3 additions & 49 deletions packages/loot-core/src/server/accounts/parse-file.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import csv2json from 'csv-parse/lib/sync';

import * as fs from '../../platform/server/fs';
import { dayFromDate } from '../../shared/months';
import { looselyParseAmount } from '../../shared/util';

import { ofx2json } from './ofx2json';
Expand All @@ -17,12 +16,11 @@ type ParseFileOptions = {
hasHeaderRow?: boolean;
delimiter?: string;
fallbackMissingPayeeToMemo?: boolean;
enableExperimentalOfxParser?: boolean;
};

export async function parseFile(
filepath: string,
options?: ParseFileOptions,
options: ParseFileOptions = {},
): Promise<ParseFileResult> {
const errors = Array<ParseError>();
const m = filepath.match(/\.[^.]*$/);
Expand Down Expand Up @@ -52,7 +50,7 @@ export async function parseFile(

async function parseCSV(
filepath: string,
options?: ParseFileOptions,
options: ParseFileOptions,
): Promise<ParseFileResult> {
const errors = Array<ParseError>();
const contents = await fs.readFile(filepath);
Expand Down Expand Up @@ -109,12 +107,8 @@ async function parseQIF(filepath: string): Promise<ParseFileResult> {

async function parseOFX(
filepath: string,
options?: ParseFileOptions,
options: ParseFileOptions,
): Promise<ParseFileResult> {
if (!options?.enableExperimentalOfxParser) {
return parseOFXNodeLibOFX(filepath, options);
}

const errors = Array<ParseError>();
const contents = await fs.readFile(filepath);

Expand Down Expand Up @@ -147,43 +141,3 @@ async function parseOFX(
}),
};
}

async function parseOFXNodeLibOFX(
filepath: string,
options: ParseFileOptions,
): Promise<ParseFileResult> {
const { getOFXTransactions, initModule } = await import(
/* webpackChunkName: 'xfo' */ 'node-libofx'
);
await initModule();

const errors = Array<ParseError>();
const contents = await fs.readFile(filepath, 'binary');

let data;
try {
data = getOFXTransactions(contents);
} catch (err) {
errors.push({
message: 'Failed importing file',
internal: err.stack,
});
return { errors };
}

// Banks don't always implement the OFX standard properly
// If no payee is available try and fallback to memo
const useMemoFallback = options.fallbackMissingPayeeToMemo;

return {
errors,
transactions: data.map(trans => ({
amount: trans.amount,
imported_id: trans.fi_id,
date: trans.date ? dayFromDate(new Date(trans.date * 1000)) : null,
payee_name: trans.name || (useMemoFallback ? trans.memo : null),
imported_payee: trans.name || (useMemoFallback ? trans.memo : null),
notes: !!trans.name || !useMemoFallback ? trans.memo || null : null, //memo used for payee
})),
};
}
3 changes: 1 addition & 2 deletions packages/loot-core/src/types/prefs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ export type FeatureFlag =
| 'sankeyReport'
| 'reportBudget'
| 'goalTemplatesEnabled'
| 'customReports'
| 'experimentalOfxParser';
| 'customReports';

export type LocalPrefs = Partial<
{
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/webpack/webpack.desktop.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
'pegjs',
],
},
externals: ['better-sqlite3', 'electron-log', 'node-fetch', 'node-libofx'],
externals: ['better-sqlite3', 'electron-log', 'node-fetch'],
plugins: [
new webpack.IgnorePlugin({
resourceRegExp: /original-fs/,
Expand Down
1 change: 0 additions & 1 deletion packages/node-libofx/.gitignore

This file was deleted.

38 changes: 0 additions & 38 deletions packages/node-libofx/Makefile

This file was deleted.

33 changes: 0 additions & 33 deletions packages/node-libofx/OpenSP-1.5.2/.cvsignore

This file was deleted.

Loading

0 comments on commit e9a2c45

Please sign in to comment.