Making things nicer

This commit is contained in:
2025-08-01 10:18:29 -04:00
parent 416ef3bc37
commit 7ca5f67c1b
11 changed files with 300 additions and 258 deletions

View File

@ -21,6 +21,7 @@ export function isNeedCode() {
export function isRunning() {
return running;
}
const browser = await chromium.launchPersistentContext('context', {
channel: 'chrome',
headless: false,
@ -186,9 +187,9 @@ export async function pullData(amount = 100) {
state.push(`Checking for pending transactions for account ID: ${account.id}`);
let currentPend =
await db`SELECT id, amount, description, date from transaction where account_id = ${account.id} AND pending=true`;
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 && t.transactionType == "Memo");
const found = transactions.find((t) => `${t.description}:${t.amount}` === pend.id && t.transactionType == "Memo");
if (found && found.transactionType != "Memo")
{state.push(
@ -200,7 +201,7 @@ export async function pullData(amount = 100) {
{
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}`;
await db`UPDATE budget_transaction SET transaction_id = null, notes = notes || ${pend.description} WHERE transaction_id = ${pend.id}`;
state.push(`Removing pending transaction: ${pend.id}`);
await db`DELETE FROM transaction WHERE id = ${pend.id}`;
}
@ -218,7 +219,7 @@ export async function pullData(amount = 100) {
const accountId = transaction.accountId;
const id = pending
? `${transaction.postedDate}:${transaction.amount}`
? `${transaction.description}:${transaction.amount}`
: transaction.hostTranNumber;
await db`INSERT INTO transaction (
@ -251,7 +252,7 @@ export async function pullData(amount = 100) {
pending = EXCLUDED.pending`;
}
}
/*
state.push('Orphaning transactions');
const orphaned = await db`SELECT bt.id as id
@ -262,7 +263,7 @@ export async function pullData(amount = 100) {
state.push(`Orphaning transaction: ${orphan.id}`);
await db`UPDATE budget_transaction set transaction_id = null where id = ${orphan.id}`;
}
*/
state.push('Done');
} catch (error) {
console.error('Error in pullData:', error);