aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/routes/methods.remote.ts
diff options
context:
space:
mode:
authorivar <i@oiee.no>2025-12-27 11:25:47 +0100
committerivar <i@oiee.no>2025-12-27 11:25:47 +0100
commit5a5717699b8b2d60b7d92c2087ed2cc22667e1cc (patch)
treeb3d2a5029af79a91a71e8464b5d5981187fe23cb /app/src/routes/methods.remote.ts
parentabf37599c877a8cc83e5a24c775c3999a9879abf (diff)
downloadsparebank1-actualbudget-5a5717699b8b2d60b7d92c2087ed2cc22667e1cc.tar.xz
sparebank1-actualbudget-5a5717699b8b2d60b7d92c2087ed2cc22667e1cc.zip
Almost there
Diffstat (limited to 'app/src/routes/methods.remote.ts')
-rw-r--r--app/src/routes/methods.remote.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/src/routes/methods.remote.ts b/app/src/routes/methods.remote.ts
index c669164..3fca715 100644
--- a/app/src/routes/methods.remote.ts
+++ b/app/src/routes/methods.remote.ts
@@ -1,20 +1,30 @@
import { db } from "$lib/server/db";
import { syncSession } from "$lib/server/db/schema";
-import * as v from "valibot"
import { command, query } from "$app/server";
import sb1 from "$lib/server/sb1";
+import { import_transactions } from "$lib/server/actual";
+import { ImportForm } from "$lib/shared";
const init_auth_session = command(async () => {
return await sb1.auth.init_auth_session()
})
-
const clear_auth_session = query(async () => {
await db.delete(syncSession)
})
+const do_import = command(ImportForm, async (form) => {
+ let x
+ for (const mapping of form.mappings) {
+ const transactions = await sb1.data.get_transactions(mapping.sb1Id)
+ if (!transactions?.length || x) continue
+ x = true
+ console.log(await import_transactions(mapping.actualId, transactions, form.dryRun))
+ }
+})
export {
init_auth_session,
+ do_import,
clear_auth_session
-} \ No newline at end of file
+}