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) {

View File

@ -9,50 +9,6 @@
let budgets = $derived(data.budgets);
let budgetTransactions = $derived(data.budgetTransactions);
let last30days = $derived(data.last30DaysTransactionsSums.reverse());
let chartData = $derived(
last30days.reduce(
(acc, curr) => [...acc, acc[acc.length - 1] + Number(curr.sum)],
[Number(total)]
)
);
let chartDates = $derived([
'now',
...last30days.map((day) => `${day.date.getMonth() + 1}/${day.date.getDate()}`)
]);
const option = $derived({
xAxis: {
type: 'category',
data: chartDates
},
yAxis: {
type: 'value'
},
series: [
{
data: chartData,
type: 'line',
label: {
show: false,
position: 'top',
formatter: (params) => {
return `$${params.value.toFixed(2)}`;
},
fontSize: 20,
padding: 10,
backgroundColor: 'rgba(255, 255, 255, 0.8)',
borderRadius: 5
},
emphasis: {
label: {
show: true // Labels appear on hover
}
}
}
]
});
</script>
<span class="font-sans text-xl"
@ -61,8 +17,6 @@
></span
>
<div class="container" use:echarts={option} />
<div class="text-xl divider">Unallocated Transactions</div>
<TransactionList {budgets} {budgetTransactions} transactions={unallocatedTrans} />

View File

@ -53,26 +53,28 @@
{#if needCode}
<div class="alert alert-warning">
<span>Need Code</span>
<input
type="text"
bind:value={code}
placeholder="Enter code"
class="input input-bordered w-full max-w-xs"
/>
<button
class="btn btn-primary"
onclick={() => {
fetch('/api/united/code', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ code })
}).then(() => {
code = '';
});
}}
>
Send Code
</button>
<form>
<span>Need Code</span>
<input
type="text"
bind:value={code}
placeholder="Enter code"
class="input input-bordered w-full max-w-xs"
/>
<button
class="btn btn-primary"
onclick={() => {
fetch('/api/united/code', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ code })
}).then(() => {
code = '';
});
}}
>
Send Code
</button>
</form>
</div>
{/if}