fixes and such
This commit is contained in:
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user