Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Nov 4, 2024
1 parent bd9db8b commit 7297816
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
26 changes: 14 additions & 12 deletions packages/loot-core/src/server/accounts/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ async function downloadGoCardlessTransactions(
}
}

async function downloadSimpleFinTransactions(acctId, since) {
async function downloadSimpleFinTransactions(
acctId: AccountEntity['id'] | AccountEntity['id'][],
since: string | string[],
) {
const userToken = await asyncStorage.getItem('user-token');
if (!userToken) return;

Expand Down Expand Up @@ -808,6 +811,7 @@ export async function syncAccount(
userKey,
acctId,
bankId,
syncStartDate,
newAccount,
);
} else {
Expand Down Expand Up @@ -835,12 +839,13 @@ export async function SimpleFinBatchSync(
);

const promises = [];
for (let i = 0; i < startDates.length; i++) {
const startDate = startDates[i];
for (let i = 0; i < accounts.length; i++) {
const account = accounts[i];
const download = res[account.accountId];

const acctRow = await db.select('accounts', account.id);
const oldestTransaction = await getAccountOldestTransaction(account.id);
const newAccount = oldestTransaction == null;

if (download.error_code) {
promises.push(
Expand All @@ -854,15 +859,12 @@ export async function SimpleFinBatchSync(
}

promises.push(
processBankSyncDownload(
download,
account.id,
acctRow,
startDate === null,
).then(res => ({
accountId: account.id,
res,
})),
processBankSyncDownload(download, account.id, acctRow, newAccount).then(
res => ({
accountId: account.id,
res,
}),
),
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ handlers['accounts-bank-sync'] = async function ({ id }) {
return { errors, newTransactions, matchedTransactions, updatedAccounts };
};

handlers['simplefin-batch-sync'] = async function ({ ids }) {
handlers['simplefin-batch-sync'] = async function ({ ids = [] }) {
const accounts = await db.runQuery(
`SELECT a.*, b.bank_id as bankId FROM accounts a
LEFT JOIN banks b ON a.bank = b.id
Expand Down
5 changes: 4 additions & 1 deletion packages/loot-core/src/types/models/gocardless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export type GoCardlessAmount = {
export type GoCardlessTransaction = {
additionalInformation?: string;
bookingStatus?: string;
balanceAfterTransaction?: Pick<Balance, 'balanceType' | 'balanceAmount'>;
balanceAfterTransaction?: Pick<
GoCardlessBalance,
'balanceType' | 'balanceAmount'
>;
bankTransactionCode?: string;
bookingDate?: string;
bookingDateTime?: string;
Expand Down

0 comments on commit 7297816

Please sign in to comment.