fixes and such

This commit is contained in:
2025-07-31 19:22:59 -04:00
parent 82dbefa565
commit 416ef3bc37
15 changed files with 720 additions and 91 deletions

View File

@ -1,7 +1,7 @@
import { createAuthClient } from "better-auth/svelte"
export const authClient = createAuthClient({
/** The base URL of the server (optional if you're using the same domain) */
baseURL: "http://localhost:5173",
baseURL: "https://budget.caseytimm.com",
})
export const { signIn, signUp, useSession } = authClient;

View File

@ -86,8 +86,8 @@ export async function pullData(amount = 100) {
await new Promise((resolve) => setTimeout(resolve, 1000));
if (code != null) break;
}
needCode = false;
if (code == null) {
needCode = false;
state.push('Code not provided within 5 minutes');
throw new Error('Code not provided within 5 minutes');
}
@ -188,27 +188,22 @@ export async function pullData(amount = 100) {
let currentPend =
await db`SELECT id, amount, description, date from transaction where account_id = ${account.id} AND pending=true`;
for (const pend of currentPend) {
const found = transactions.find((t) => `${t.postedDate}:${t.amount}` === pend.id);
state.push(
`Pending transaction: ${pend.id} ${pend.description} ${pend.amount} on ${pend.date} found: ${found ? 'yes' : 'no'}`
);
if (!found) {
const updated = transactions.find(
(t) => t.amount == pend.amount && new Date(t.postedDate) == pend.date
);
if (updated) {
state.push(
`I think I found an updated transaction: ${updated.statementDescription} ${updated.amount} for ${pend.description} ${pend.amount}`
);
const found = transactions.find((t) => `${t.postedDate}:${t.amount}` === pend.id && t.transactionType == "Memo");
await db`UPDATE budget_transaction SET transaction_id = ${updated.transactionId} WHERE transaction_id = ${pend.id}`;
} else {
state.push(`Orphaning no longer pending budget transaction with no new parent`);
await db`UPDATE budget_transaction SET transaction_id = null WHERE transaction_id = ${pend.id}`;
}
if (found && found.transactionType != "Memo")
{state.push(
`I think I found an updated transaction: ${found.statementDescription} ${found.amount} for ${pend.description} ${pend.amount}`
);
await db`UPDATE budget_transaction SET transaction_id = ${found.transactionId} WHERE transaction_id = ${pend.id}`;
await db`DELETE FROM transaction WHERE id = ${pend.id}`;
} else if (!found)
{
state.push(`Orphaning no longer pending budget transaction with no new parent`);
await db`UPDATE budget_transaction SET transaction_id = null WHERE transaction_id = ${pend.id}`;
state.push(`Removing pending transaction: ${pend.id}`);
await db`DELETE FROM transaction WHERE id = ${pend.id}`;
}
}
}
for (const transaction of transactions) {