Skip to content

Commit

Permalink
Formatting fix - apply yarn lint --fix to ynab5 files
Browse files Browse the repository at this point in the history
  • Loading branch information
Marethyu1 committed Nov 4, 2023
1 parent f26ec0f commit 0ecb949
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/loot-core/src/server/importers/ynab5-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export namespace YNAB5 {
id: string;
name: string;
deleted: boolean;
transfer_acct?: string
transfer_acct?: string;
}

interface CategoryGroup {
Expand Down
18 changes: 12 additions & 6 deletions packages/loot-core/src/server/importers/ynab5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as monthUtils from '../../shared/months';
import { sortByKey, groupBy } from '../../shared/util';

import { YNAB5 } from './ynab5-types';
import Payee = YNAB5.Payee;

function amountFromYnab(amount: number) {
// ynabs multiplies amount by 1000 and actual by 100
Expand Down Expand Up @@ -144,9 +143,12 @@ async function importTransactions(
let transactionsGrouped = groupBy(data.transactions, 'account_id');
let subtransactionsGrouped = groupBy(data.subtransactions, 'transaction_id');

const payeesByTransferAcct = payees.filter((payee: Payee) => payee?.transfer_acct)
.map((payee: Payee) => [payee.transfer_acct, payee])
const payeeTransferAcctHashMap = new Map<string, Payee>(payeesByTransferAcct);
const payeesByTransferAcct = payees
.filter((payee: YNAB5.Payee) => payee?.transfer_acct)
.map((payee: YNAB5.Payee) => [payee.transfer_acct, payee]);
const payeeTransferAcctHashMap = new Map<string, YNAB5.Payee>(
payeesByTransferAcct,
);

// Go ahead and generate ids for all of the transactions so we can
// reliably resolve transfers
Expand Down Expand Up @@ -185,8 +187,12 @@ async function importTransactions(
? subtransactions.map(subtrans => {
let payee = null;
if (subtrans.transfer_account_id) {
const mappedTransferAccountId = entityIdMap.get(subtrans.transfer_account_id);
payee = payeeTransferAcctHashMap.get(mappedTransferAccountId)?.id;
const mappedTransferAccountId = entityIdMap.get(
subtrans.transfer_account_id,
);
payee = payeeTransferAcctHashMap.get(
mappedTransferAccountId,
)?.id;
}

return {
Expand Down

0 comments on commit 0ecb949

Please sign in to comment.