@rfc0/patty 0.0.0-stage → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +214 -2
- package/dist/adapters/access-tokens.js +7 -0
- package/dist/adapters/accounts.js +37 -0
- package/dist/adapters/auth.js +11 -0
- package/dist/adapters/bills.js +32 -0
- package/dist/adapters/budgets.js +29 -0
- package/dist/adapters/categories.js +32 -0
- package/dist/adapters/client-grants.js +7 -0
- package/dist/adapters/credit-cards.js +33 -0
- package/dist/adapters/currencies.js +2 -0
- package/dist/adapters/currency-rates.js +18 -0
- package/dist/adapters/dashboards.js +43 -0
- package/dist/adapters/demo.js +13 -0
- package/dist/adapters/instance-settings.js +7 -0
- package/dist/adapters/invites.js +7 -0
- package/dist/adapters/recurring.js +55 -0
- package/dist/adapters/sessions.js +7 -0
- package/dist/adapters/settings.js +4 -0
- package/dist/adapters/setup-codes.js +7 -0
- package/dist/adapters/tags.js +9 -0
- package/dist/adapters/transactions.js +95 -0
- package/dist/adapters/users.js +7 -0
- package/dist/common/build-version.js +5 -0
- package/dist/common/errors.js +118 -0
- package/dist/common/net.js +71 -0
- package/dist/common/result.js +7 -0
- package/dist/composition/auth.js +106 -0
- package/dist/composition/boot.js +27 -0
- package/dist/composition/cli.js +86 -0
- package/dist/composition/demo/seed.js +92 -0
- package/dist/composition/demo/shell.js +107 -0
- package/dist/composition/export.js +89 -0
- package/dist/composition/http.js +110 -0
- package/dist/composition/import.js +55 -0
- package/dist/composition/lazy-modules.js +2 -0
- package/dist/composition/runtime.js +115 -0
- package/dist/composition/sign-in/interpreter.js +154 -0
- package/dist/composition/sign-in/server.js +36 -0
- package/dist/composition/sign-in/wiring.js +23 -0
- package/dist/composition/stdio.js +69 -0
- package/dist/config.js +136 -0
- package/dist/controllers/account/account.js +88 -0
- package/dist/controllers/account/transaction.js +119 -0
- package/dist/controllers/account/transfer.js +34 -0
- package/dist/controllers/aggregate.js +40 -0
- package/dist/controllers/auth/access-tokens.js +61 -0
- package/dist/controllers/auth/grants.js +136 -0
- package/dist/controllers/auth/key-export.js +20 -0
- package/dist/controllers/auth/owner.js +80 -0
- package/dist/controllers/auth/password.js +35 -0
- package/dist/controllers/auth/session.js +50 -0
- package/dist/controllers/auth/step-up.js +8 -0
- package/dist/controllers/auth/users.js +183 -0
- package/dist/controllers/budgets.js +87 -0
- package/dist/controllers/categories.js +67 -0
- package/dist/controllers/correlations.js +112 -0
- package/dist/controllers/credit-card/bill.js +105 -0
- package/dist/controllers/credit-card/credit-card.js +129 -0
- package/dist/controllers/credit-card/transaction.js +181 -0
- package/dist/controllers/currencies.js +1 -0
- package/dist/controllers/currency-rates.js +40 -0
- package/dist/controllers/dashboards.js +68 -0
- package/dist/controllers/demo/seed.js +31 -0
- package/dist/controllers/demo/tour.js +12 -0
- package/dist/controllers/deps.js +6 -0
- package/dist/controllers/instance.js +6 -0
- package/dist/controllers/merchants.js +12 -0
- package/dist/controllers/recurring.js +70 -0
- package/dist/controllers/resolve.js +37 -0
- package/dist/controllers/settings.js +47 -0
- package/dist/controllers/status.js +19 -0
- package/dist/controllers/summary.js +21 -0
- package/dist/controllers/tags.js +19 -0
- package/dist/controllers/transaction/bulk.js +6 -0
- package/dist/controllers/transaction/core.js +49 -0
- package/dist/controllers/transaction/read.js +28 -0
- package/dist/diplomat/auth/credentials.js +58 -0
- package/dist/diplomat/auth/sign-in-store.js +18 -0
- package/dist/diplomat/cli/commands/auth.js +100 -0
- package/dist/diplomat/cli/commands/db.js +72 -0
- package/dist/diplomat/cli/commands/demo.js +68 -0
- package/dist/diplomat/cli/commands/key.js +119 -0
- package/dist/diplomat/cli/commands/login.js +151 -0
- package/dist/diplomat/cli/commands/setup.js +132 -0
- package/dist/diplomat/cli/commands/users.js +123 -0
- package/dist/diplomat/cli/commands.js +61 -0
- package/dist/diplomat/cli/export-file.js +37 -0
- package/dist/diplomat/cli/import-file.js +44 -0
- package/dist/diplomat/cli/io.js +61 -0
- package/dist/diplomat/cli/key-export-approval.js +37 -0
- package/dist/diplomat/cli/messages.js +96 -0
- package/dist/diplomat/cli/prompt.js +74 -0
- package/dist/diplomat/cli/terminal.js +81 -0
- package/dist/diplomat/client-config/clients.js +150 -0
- package/dist/diplomat/client-config/merge.js +41 -0
- package/dist/diplomat/db/bootstrap.js +98 -0
- package/dist/diplomat/db/database-files.js +147 -0
- package/dist/diplomat/db/driver.js +167 -0
- package/dist/diplomat/db/effects.js +101 -0
- package/dist/diplomat/db/engine.js +9 -0
- package/dist/diplomat/db/export.js +22 -0
- package/dist/diplomat/db/file-lock.js +82 -0
- package/dist/diplomat/db/key-lock.js +14 -0
- package/dist/diplomat/db/locale-cache.js +23 -0
- package/dist/diplomat/db/migration-barrier.js +57 -0
- package/dist/diplomat/db/migration-journal.js +18 -0
- package/dist/diplomat/db/migration-lock.js +15 -0
- package/dist/diplomat/db/migrations.js +11 -0
- package/dist/diplomat/db/present.js +17 -0
- package/dist/diplomat/db/queries/aggregate-whitelist.js +35 -0
- package/dist/diplomat/db/queries/filters.js +59 -0
- package/dist/diplomat/db/queries/fts.js +18 -0
- package/dist/diplomat/db/queries/scope.js +8 -0
- package/dist/diplomat/db/queries/transaction-select.js +26 -0
- package/dist/diplomat/db/queries/tx-predicates.js +13 -0
- package/dist/diplomat/db/repos/access-tokens.js +27 -0
- package/dist/diplomat/db/repos/accounts.js +91 -0
- package/dist/diplomat/db/repos/bills.js +93 -0
- package/dist/diplomat/db/repos/budgets.js +72 -0
- package/dist/diplomat/db/repos/categories.js +53 -0
- package/dist/diplomat/db/repos/client-grants.js +67 -0
- package/dist/diplomat/db/repos/correlations.js +66 -0
- package/dist/diplomat/db/repos/credit-cards.js +67 -0
- package/dist/diplomat/db/repos/currencies.js +8 -0
- package/dist/diplomat/db/repos/currency-rates.js +40 -0
- package/dist/diplomat/db/repos/dashboards.js +123 -0
- package/dist/diplomat/db/repos/health.js +12 -0
- package/dist/diplomat/db/repos/instance-settings.js +14 -0
- package/dist/diplomat/db/repos/instance.js +58 -0
- package/dist/diplomat/db/repos/invites.js +43 -0
- package/dist/diplomat/db/repos/merchants.js +121 -0
- package/dist/diplomat/db/repos/recurring.js +29 -0
- package/dist/diplomat/db/repos/sessions.js +19 -0
- package/dist/diplomat/db/repos/settings.js +41 -0
- package/dist/diplomat/db/repos/setup-codes.js +28 -0
- package/dist/diplomat/db/repos/sub-categories.js +67 -0
- package/dist/diplomat/db/repos/tags.js +51 -0
- package/dist/diplomat/db/repos/transaction-tags.js +57 -0
- package/dist/diplomat/db/repos/transactions.js +163 -0
- package/dist/diplomat/db/repos/users.js +47 -0
- package/dist/diplomat/db/safety-copy.js +87 -0
- package/dist/diplomat/db/schema.js +348 -0
- package/dist/diplomat/db/seed/categories.js +112 -0
- package/dist/diplomat/db/seed/currencies.js +9 -0
- package/dist/diplomat/db/seed/demo/br.js +98 -0
- package/dist/diplomat/db/seed/demo/co.js +89 -0
- package/dist/diplomat/db/seed/demo/index.js +12 -0
- package/dist/diplomat/db/seed/demo/mx.js +90 -0
- package/dist/diplomat/db/seed/demo/shared.js +39 -0
- package/dist/diplomat/db/seed/demo/us.js +90 -0
- package/dist/diplomat/db/seed/merchant-rules.js +188 -0
- package/dist/diplomat/db/sqlite-errors.js +40 -0
- package/dist/diplomat/db/tenancy-integrity.js +45 -0
- package/dist/diplomat/db/version-guard.js +16 -0
- package/dist/diplomat/http/auth-pages.js +41 -0
- package/dist/diplomat/http/auth-paths.js +46 -0
- package/dist/diplomat/http/bearer.js +15 -0
- package/dist/diplomat/http/connect-pages.js +51 -0
- package/dist/diplomat/http/context.js +17 -0
- package/dist/diplomat/http/cookies.js +27 -0
- package/dist/diplomat/http/form-pages.js +38 -0
- package/dist/diplomat/http/hooks/auth.js +106 -0
- package/dist/diplomat/http/hooks/demo-marker.js +59 -0
- package/dist/diplomat/http/openapi.js +73 -0
- package/dist/diplomat/http/principal.js +1 -0
- package/dist/diplomat/http/rate-limiter.js +78 -0
- package/dist/diplomat/http/remedy.js +26 -0
- package/dist/diplomat/http/respond.js +50 -0
- package/dist/diplomat/http/routes/account.js +226 -0
- package/dist/diplomat/http/routes/aggregate.js +28 -0
- package/dist/diplomat/http/routes/auth.js +105 -0
- package/dist/diplomat/http/routes/budget.js +34 -0
- package/dist/diplomat/http/routes/category.js +109 -0
- package/dist/diplomat/http/routes/connect.js +124 -0
- package/dist/diplomat/http/routes/credit-card.js +263 -0
- package/dist/diplomat/http/routes/currency-rates.js +60 -0
- package/dist/diplomat/http/routes/currency.js +16 -0
- package/dist/diplomat/http/routes/dashboard.js +93 -0
- package/dist/diplomat/http/routes/invite.js +63 -0
- package/dist/diplomat/http/routes/recurring.js +65 -0
- package/dist/diplomat/http/routes/settings.js +38 -0
- package/dist/diplomat/http/routes/summary.js +23 -0
- package/dist/diplomat/http/routes/system.js +29 -0
- package/dist/diplomat/http/routes/tag.js +51 -0
- package/dist/diplomat/http/routes/tokens.js +72 -0
- package/dist/diplomat/http/routes/transaction.js +55 -0
- package/dist/diplomat/http/routes/transfer.js +35 -0
- package/dist/diplomat/http/routes/ui.js +110 -0
- package/dist/diplomat/http/routes/users.js +156 -0
- package/dist/diplomat/http/routes/well-known.js +26 -0
- package/dist/diplomat/http/routes.js +85 -0
- package/dist/diplomat/http/session.js +34 -0
- package/dist/diplomat/http/token-pages.js +75 -0
- package/dist/diplomat/http/ui-files.js +21 -0
- package/dist/diplomat/http/user-pages.js +93 -0
- package/dist/diplomat/mcp/annotations.js +8 -0
- package/dist/diplomat/mcp/auth-info.js +20 -0
- package/dist/diplomat/mcp/context.js +14 -0
- package/dist/diplomat/mcp/definition.js +3 -0
- package/dist/diplomat/mcp/gate.js +15 -0
- package/dist/diplomat/mcp/instructions.js +19 -0
- package/dist/diplomat/mcp/prompts.js +125 -0
- package/dist/diplomat/mcp/register.js +12 -0
- package/dist/diplomat/mcp/remedy.js +17 -0
- package/dist/diplomat/mcp/resources.js +93 -0
- package/dist/diplomat/mcp/respond.js +20 -0
- package/dist/diplomat/mcp/route.js +62 -0
- package/dist/diplomat/mcp/scopes.js +53 -0
- package/dist/diplomat/mcp/server.js +26 -0
- package/dist/diplomat/mcp/shared.js +5 -0
- package/dist/diplomat/mcp/stdio-session.js +94 -0
- package/dist/diplomat/mcp/stdio.js +23 -0
- package/dist/diplomat/mcp/tool-name.js +59 -0
- package/dist/diplomat/mcp/tools/account.js +218 -0
- package/dist/diplomat/mcp/tools/aggregate.js +32 -0
- package/dist/diplomat/mcp/tools/budget.js +99 -0
- package/dist/diplomat/mcp/tools/category.js +103 -0
- package/dist/diplomat/mcp/tools/correlations.js +70 -0
- package/dist/diplomat/mcp/tools/credit-card.js +239 -0
- package/dist/diplomat/mcp/tools/currency-rates.js +62 -0
- package/dist/diplomat/mcp/tools/dashboard.js +75 -0
- package/dist/diplomat/mcp/tools/index.js +31 -0
- package/dist/diplomat/mcp/tools/recurring.js +62 -0
- package/dist/diplomat/mcp/tools/summary.js +30 -0
- package/dist/diplomat/mcp/tools/system.js +83 -0
- package/dist/diplomat/mcp/tools/tag.js +48 -0
- package/dist/diplomat/mcp/tools/transaction.js +53 -0
- package/dist/diplomat/mcp/tools/transfer.js +28 -0
- package/dist/diplomat/mcp/tour.js +87 -0
- package/dist/logic/account.js +79 -0
- package/dist/logic/aggregate.js +37 -0
- package/dist/logic/auth/bearer.js +35 -0
- package/dist/logic/auth/grant.js +126 -0
- package/dist/logic/auth/key-export.js +10 -0
- package/dist/logic/auth/keychain.js +3 -0
- package/dist/logic/auth/message.js +22 -0
- package/dist/logic/auth/origin.js +57 -0
- package/dist/logic/auth/owner.js +22 -0
- package/dist/logic/auth/password.js +3 -0
- package/dist/logic/auth/redact.js +25 -0
- package/dist/logic/auth/revoke.js +28 -0
- package/dist/logic/auth/scope.js +17 -0
- package/dist/logic/auth/session.js +30 -0
- package/dist/logic/auth/sign-in-flow.js +305 -0
- package/dist/logic/auth/time.js +2 -0
- package/dist/logic/auth/token.js +74 -0
- package/dist/logic/auth/user-plans.js +84 -0
- package/dist/logic/auth/users.js +78 -0
- package/dist/logic/balance.js +2 -0
- package/dist/logic/bill.js +74 -0
- package/dist/logic/budget.js +78 -0
- package/dist/logic/category.js +37 -0
- package/dist/logic/classify.js +21 -0
- package/dist/logic/correlations.js +147 -0
- package/dist/logic/credit-card.js +2 -0
- package/dist/logic/currency-rate.js +69 -0
- package/dist/logic/dashboard.js +40 -0
- package/dist/logic/demo/database.js +30 -0
- package/dist/logic/demo/plan.js +308 -0
- package/dist/logic/demo/tour.js +33 -0
- package/dist/logic/export-destination.js +12 -0
- package/dist/logic/key-import.js +15 -0
- package/dist/logic/locale.js +5 -0
- package/dist/logic/localize.js +12 -0
- package/dist/logic/merchant.js +31 -0
- package/dist/logic/migration.js +1 -0
- package/dist/logic/money.js +12 -0
- package/dist/logic/period.js +45 -0
- package/dist/logic/persistence.js +48 -0
- package/dist/logic/recurring.js +51 -0
- package/dist/logic/resolve.js +44 -0
- package/dist/logic/summary.js +29 -0
- package/dist/logic/tag.js +13 -0
- package/dist/logic/transaction.js +197 -0
- package/dist/main.js +42 -0
- package/dist/models/account.js +197 -0
- package/dist/models/aggregate.js +61 -0
- package/dist/models/auth/bearer.js +11 -0
- package/dist/models/auth/entity.js +17 -0
- package/dist/models/auth/errors.js +42 -0
- package/dist/models/auth/grant.js +58 -0
- package/dist/models/auth/key-export.js +11 -0
- package/dist/models/auth/message.js +50 -0
- package/dist/models/auth/mode.js +7 -0
- package/dist/models/auth/origin.js +16 -0
- package/dist/models/auth/owner.js +36 -0
- package/dist/models/auth/password.js +24 -0
- package/dist/models/auth/principal.js +26 -0
- package/dist/models/auth/redact.js +4 -0
- package/dist/models/auth/scope.js +9 -0
- package/dist/models/auth/session.js +19 -0
- package/dist/models/auth/sign-in-flow.js +102 -0
- package/dist/models/auth/sign-in.js +41 -0
- package/dist/models/auth/time.js +5 -0
- package/dist/models/auth/token.js +50 -0
- package/dist/models/auth/users.js +52 -0
- package/dist/models/bill.js +55 -0
- package/dist/models/budget.js +106 -0
- package/dist/models/category.js +52 -0
- package/dist/models/client-config.js +18 -0
- package/dist/models/correlations.js +215 -0
- package/dist/models/credit-card.js +156 -0
- package/dist/models/currency-rate.js +83 -0
- package/dist/models/dashboard.js +54 -0
- package/dist/models/database.js +16 -0
- package/dist/models/date.js +8 -0
- package/dist/models/demo/core.js +58 -0
- package/dist/models/demo/tour.js +41 -0
- package/dist/models/encryption-key.js +2 -0
- package/dist/models/error.js +13 -0
- package/dist/models/export.js +9 -0
- package/dist/models/id.js +2 -0
- package/dist/models/instance.js +7 -0
- package/dist/models/key-import.js +6 -0
- package/dist/models/locale.js +25 -0
- package/dist/models/merchant.js +12 -0
- package/dist/models/money.js +14 -0
- package/dist/models/package.js +12 -0
- package/dist/models/page.js +56 -0
- package/dist/models/persistence.js +1 -0
- package/dist/models/prompts.js +5 -0
- package/dist/models/recurring.js +54 -0
- package/dist/models/remedy.js +17 -0
- package/dist/models/resolution.js +1 -0
- package/dist/models/startup.js +7 -0
- package/dist/models/summary.js +24 -0
- package/dist/models/tag.js +14 -0
- package/dist/models/tenancy.js +10 -0
- package/dist/models/transaction-tag.js +6 -0
- package/dist/models/transaction.js +275 -0
- package/dist/wire/db/access-tokens.js +1 -0
- package/dist/wire/db/accounts.js +7 -0
- package/dist/wire/db/aggregate.js +16 -0
- package/dist/wire/db/bills.js +14 -0
- package/dist/wire/db/budgets.js +33 -0
- package/dist/wire/db/categories.js +14 -0
- package/dist/wire/db/client-grants.js +1 -0
- package/dist/wire/db/correlations.js +49 -0
- package/dist/wire/db/credit-cards.js +1 -0
- package/dist/wire/db/currencies.js +1 -0
- package/dist/wire/db/currency-rates.js +1 -0
- package/dist/wire/db/dashboards.js +1 -0
- package/dist/wire/db/instance-settings.js +1 -0
- package/dist/wire/db/invites.js +1 -0
- package/dist/wire/db/merchants.js +18 -0
- package/dist/wire/db/recurring.js +19 -0
- package/dist/wire/db/sessions.js +1 -0
- package/dist/wire/db/settings.js +1 -0
- package/dist/wire/db/setup-codes.js +1 -0
- package/dist/wire/db/tags.js +1 -0
- package/dist/wire/db/tenancy.js +1 -0
- package/dist/wire/db/transactions.js +89 -0
- package/dist/wire/db/users.js +1 -0
- package/dist/wire/in/accounts.js +26 -0
- package/dist/wire/in/aggregate.js +10 -0
- package/dist/wire/in/auth.js +107 -0
- package/dist/wire/in/bills.js +11 -0
- package/dist/wire/in/budgets.js +11 -0
- package/dist/wire/in/categories.js +9 -0
- package/dist/wire/in/cli.js +106 -0
- package/dist/wire/in/coerce.js +6 -0
- package/dist/wire/in/common.js +17 -0
- package/dist/wire/in/credit-cards.js +16 -0
- package/dist/wire/in/currency-rates.js +8 -0
- package/dist/wire/in/period.js +7 -0
- package/dist/wire/in/recurring.js +6 -0
- package/dist/wire/in/settings.js +5 -0
- package/dist/wire/in/summary.js +5 -0
- package/dist/wire/in/tags.js +2 -0
- package/dist/wire/in/transactions.js +31 -0
- package/dist/wire/out/bills.js +9 -0
- package/dist/wire/out/budgets.js +10 -0
- package/dist/wire/out/client-config.js +2 -0
- package/dist/wire/out/common.js +4 -0
- package/dist/wire/out/credit-cards.js +15 -0
- package/dist/wire/out/currency-rates.js +11 -0
- package/dist/wire/out/errors.js +58 -0
- package/dist/wire/out/recurring.js +6 -0
- package/dist/wire/out/status.js +10 -0
- package/dist/wire/out/summary.js +9 -0
- package/dist/wire/out/transactions.js +52 -0
- package/drizzle/0000_futuristic_umar.sql +124 -0
- package/drizzle/0001_fts5_search.sql +23 -0
- package/drizzle/0002_rename_graph_to_history.sql +7 -0
- package/drizzle/0003_lyrical_hairball.sql +2 -0
- package/drizzle/0004_misty_ikaris.sql +7 -0
- package/drizzle/0005_credit-liability-accounts.sql +14 -0
- package/drizzle/0006_smart_aqueduct.sql +1 -0
- package/drizzle/0007_add_dashboards.sql +5 -0
- package/drizzle/0008_yummy_madripoor.sql +1 -0
- package/drizzle/0009_version_groundwork.sql +9 -0
- package/drizzle/0010_category_merchant_association_cascade.sql +16 -0
- package/drizzle/0011_dashboard_id_normalization.sql +16 -0
- package/drizzle/0012_hot_the_spike.sql +12 -0
- package/drizzle/0013_recurring_rules_merchant.sql +1 -0
- package/drizzle/0014_dashboard_source_discriminator.sql +17 -0
- package/drizzle/0015_currencies_decimals.sql +1 -0
- package/drizzle/0016_unusual_zaran.sql +13 -0
- package/drizzle/0017_premium_blur.sql +1 -0
- package/drizzle/0018_auth_identity.sql +39 -0
- package/drizzle/0019_access_tokens.sql +16 -0
- package/drizzle/0020_stdio_sign_in.sql +27 -0
- package/drizzle/0021_tenancy_data.sql +289 -0
- package/drizzle/0022_user_management.sql +17 -0
- package/drizzle/0023_instance_settings_row.sql +2 -0
- package/drizzle/0024_credentials_changed_at.sql +2 -0
- package/drizzle/0025_instance_kind.sql +2 -0
- package/drizzle/0026_demo_seeded_at.sql +2 -0
- package/drizzle/0027_demo_country.sql +2 -0
- package/drizzle/0028_reset_sign_ins.sql +2 -0
- package/drizzle/meta/0000_snapshot.json +894 -0
- package/drizzle/meta/0003_snapshot.json +910 -0
- package/drizzle/meta/0004_snapshot.json +951 -0
- package/drizzle/meta/0005_snapshot.json +991 -0
- package/drizzle/meta/0006_snapshot.json +998 -0
- package/drizzle/meta/0007_snapshot.json +1029 -0
- package/drizzle/meta/0008_snapshot.json +1049 -0
- package/drizzle/meta/0009_snapshot.json +1121 -0
- package/drizzle/meta/0010_snapshot.json +1121 -0
- package/drizzle/meta/0011_snapshot.json +1136 -0
- package/drizzle/meta/0012_snapshot.json +1227 -0
- package/drizzle/meta/0013_snapshot.json +1247 -0
- package/drizzle/meta/0014_snapshot.json +1267 -0
- package/drizzle/meta/0015_snapshot.json +1275 -0
- package/drizzle/meta/0016_snapshot.json +1371 -0
- package/drizzle/meta/0017_snapshot.json +1392 -0
- package/drizzle/meta/0018_snapshot.json +1603 -0
- package/drizzle/meta/0019_snapshot.json +1713 -0
- package/drizzle/meta/0020_snapshot.json +1904 -0
- package/drizzle/meta/0021_snapshot.json +2186 -0
- package/drizzle/meta/0022_snapshot.json +2311 -0
- package/drizzle/meta/0023_snapshot.json +2311 -0
- package/drizzle/meta/0024_snapshot.json +2318 -0
- package/drizzle/meta/0025_snapshot.json +2326 -0
- package/drizzle/meta/0026_snapshot.json +2333 -0
- package/drizzle/meta/0027_snapshot.json +2340 -0
- package/drizzle/meta/0028_snapshot.json +2340 -0
- package/drizzle/meta/_journal.json +209 -0
- package/package.json +106 -4
- package/skills/dashboard-building/SKILL.md +201 -0
- package/skills/patty-tour/SKILL.md +34 -0
- package/ui/app.css +758 -0
- package/ui/app.js +543 -0
- package/ui/connect-result.html +16 -0
- package/ui/connect.html +53 -0
- package/ui/dashboards/accounts.html +3189 -0
- package/ui/dashboards/budget.html +1734 -0
- package/ui/dashboards/cards.html +4032 -0
- package/ui/dashboards/categories.html +4694 -0
- package/ui/dashboards/comparative.html +2475 -0
- package/ui/dashboards/dashboards.html +839 -0
- package/ui/dashboards/overview.html +2405 -0
- package/ui/dashboards/pending.html +2973 -0
- package/ui/dashboards/projections.html +2528 -0
- package/ui/dashboards/tags.html +1365 -0
- package/ui/invite.html +44 -0
- package/ui/login.html +26 -0
- package/ui/money.js +175 -0
- package/ui/setup.html +29 -0
- package/ui/shell.html +96 -0
- package/ui/token-created.html +24 -0
- package/ui/tokens.html +58 -0
- package/ui/user-invited.html +27 -0
- package/ui/users.html +60 -0
|
@@ -0,0 +1,2405 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
.controls-area {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: 1rem;
|
|
6
|
+
background: var(--panel-bg);
|
|
7
|
+
border: 1px solid var(--panel-border);
|
|
8
|
+
padding: 0.5rem 1rem;
|
|
9
|
+
border-radius: 14px;
|
|
10
|
+
backdrop-filter: blur(12px);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.controls-area label {
|
|
14
|
+
font-size: 0.85rem;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
color: var(--text-muted);
|
|
17
|
+
text-transform: uppercase;
|
|
18
|
+
letter-spacing: 0.05em;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.select-custom {
|
|
22
|
+
background: rgba(255, 255, 255, 0.05);
|
|
23
|
+
border: 1px solid var(--panel-border);
|
|
24
|
+
color: var(--text-main);
|
|
25
|
+
padding: 0.4rem 1rem;
|
|
26
|
+
border-radius: 10px;
|
|
27
|
+
font-weight: 600;
|
|
28
|
+
outline: none;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
transition: var(--transition-smooth);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.select-custom:focus {
|
|
34
|
+
border-color: var(--accent-primary);
|
|
35
|
+
box-shadow: 0 0 0 2px var(--accent-primary-glow);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* KPI cards grid */
|
|
39
|
+
.kpis-row {
|
|
40
|
+
display: grid;
|
|
41
|
+
grid-template-columns: repeat(4, 1fr);
|
|
42
|
+
gap: 1.25rem;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* base: ui/app.css (#164) */
|
|
46
|
+
.kpi-card {
|
|
47
|
+
padding: 1.25rem 1.5rem;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
gap: 0.5rem;
|
|
50
|
+
backdrop-filter: blur(12px);
|
|
51
|
+
/* Pre-existing gap, not introduced by the #164 refactor (confirmed against origin/main):
|
|
52
|
+
.kpi-card::before (ui/app.css) is position:absolute and needs a positioned ancestor.
|
|
53
|
+
This file never set one, so the (invisible here — no .income/.expense/.net modifier
|
|
54
|
+
ever applies a background to it) accent bar was positioning against the viewport. */
|
|
55
|
+
position: relative;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.kpi-title {
|
|
59
|
+
font-size: 0.85rem;
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
color: var(--text-muted);
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
gap: 0.5rem;
|
|
65
|
+
text-transform: uppercase;
|
|
66
|
+
letter-spacing: 0.05em;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.kpi-value {
|
|
70
|
+
font-size: 1.5rem;
|
|
71
|
+
font-weight: 700;
|
|
72
|
+
color: #fff;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.kpi-details {
|
|
76
|
+
font-size: 0.78rem;
|
|
77
|
+
color: var(--text-muted);
|
|
78
|
+
display: flex;
|
|
79
|
+
justify-content: space-between;
|
|
80
|
+
border-top: 1px solid rgba(255, 255, 255, 0.04);
|
|
81
|
+
padding-top: 0.5rem;
|
|
82
|
+
margin-top: 0.25rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Panels styling (base: ui/app.css, #164) */
|
|
86
|
+
.panel {
|
|
87
|
+
backdrop-filter: blur(12px);
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.panel-header {
|
|
94
|
+
padding: 0.9rem 1.5rem;
|
|
95
|
+
border-bottom: 1px solid var(--panel-border);
|
|
96
|
+
display: flex;
|
|
97
|
+
justify-content: space-between;
|
|
98
|
+
align-items: center;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.panel-header h2 {
|
|
102
|
+
font-size: 1.1rem;
|
|
103
|
+
font-weight: 700;
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: 0.75rem;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.panel-header h2 i {
|
|
110
|
+
color: var(--accent-primary);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Calendar & Details Split Row */
|
|
114
|
+
.calendar-split-row {
|
|
115
|
+
display: grid;
|
|
116
|
+
grid-template-columns: 1.15fr 1fr;
|
|
117
|
+
gap: 1.5rem;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.calendar-legend {
|
|
121
|
+
display: flex;
|
|
122
|
+
gap: 1rem;
|
|
123
|
+
font-size: 0.8rem;
|
|
124
|
+
color: var(--text-muted);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.legend-item {
|
|
128
|
+
display: flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
gap: 0.4rem;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.dot {
|
|
134
|
+
width: 8px;
|
|
135
|
+
height: 8px;
|
|
136
|
+
border-radius: 50%;
|
|
137
|
+
display: inline-block;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.dot-inc { background-color: var(--income-color); }
|
|
141
|
+
.dot-exp { background-color: var(--expense-color); }
|
|
142
|
+
.dot-trans { background-color: var(--text-muted); }
|
|
143
|
+
|
|
144
|
+
.calendar-panel-body {
|
|
145
|
+
padding: 0.75rem 1.5rem 0.85rem 1.5rem;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.calendar-grid-header {
|
|
149
|
+
display: grid;
|
|
150
|
+
grid-template-columns: repeat(7, 1fr);
|
|
151
|
+
text-align: center;
|
|
152
|
+
font-weight: 700;
|
|
153
|
+
color: var(--text-muted);
|
|
154
|
+
font-size: 0.8rem;
|
|
155
|
+
text-transform: uppercase;
|
|
156
|
+
letter-spacing: 0.05em;
|
|
157
|
+
padding-bottom: 0.75rem;
|
|
158
|
+
border-bottom: 1px solid var(--panel-border);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.calendar-grid-body {
|
|
162
|
+
display: grid;
|
|
163
|
+
grid-template-columns: repeat(7, 1fr);
|
|
164
|
+
gap: 6px;
|
|
165
|
+
margin-top: 6px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.calendar-day {
|
|
169
|
+
box-sizing: border-box;
|
|
170
|
+
background: rgba(255, 255, 255, 0.015);
|
|
171
|
+
border: 1px solid var(--panel-border);
|
|
172
|
+
border-radius: 12px;
|
|
173
|
+
height: 72px;
|
|
174
|
+
padding: 0.25rem 0.2rem 0.15rem 0.2rem;
|
|
175
|
+
display: flex;
|
|
176
|
+
flex-direction: column;
|
|
177
|
+
justify-content: flex-start;
|
|
178
|
+
transition: var(--transition-smooth);
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
overflow: hidden;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.calendar-day:hover {
|
|
184
|
+
background: rgba(255, 255, 255, 0.04);
|
|
185
|
+
border-color: rgba(139, 92, 246, 0.3);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.calendar-day.empty {
|
|
189
|
+
background: transparent;
|
|
190
|
+
border: none;
|
|
191
|
+
cursor: default;
|
|
192
|
+
pointer-events: none;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.calendar-day.today {
|
|
196
|
+
border-color: #d97706;
|
|
197
|
+
background: rgba(217, 119, 6, 0.08);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.calendar-day.selected-day {
|
|
201
|
+
border-color: var(--accent-primary);
|
|
202
|
+
background: rgba(139, 92, 246, 0.12);
|
|
203
|
+
box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.calendar-day.selected-day .day-num {
|
|
207
|
+
color: #c084fc;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.day-num {
|
|
211
|
+
font-size: 0.8rem;
|
|
212
|
+
font-weight: 700;
|
|
213
|
+
color: var(--text-muted);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.day-header {
|
|
217
|
+
display: flex;
|
|
218
|
+
justify-content: space-between;
|
|
219
|
+
align-items: center;
|
|
220
|
+
width: 100%;
|
|
221
|
+
height: 14px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.calendar-day.today .day-num {
|
|
225
|
+
color: #fbbf24;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.day-flows {
|
|
229
|
+
display: flex;
|
|
230
|
+
flex-direction: column;
|
|
231
|
+
gap: 2px;
|
|
232
|
+
margin-top: 2px;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.day-flow {
|
|
236
|
+
font-size: 0.62rem;
|
|
237
|
+
font-weight: 700;
|
|
238
|
+
border-radius: 4px;
|
|
239
|
+
padding: 1px 3px;
|
|
240
|
+
white-space: nowrap;
|
|
241
|
+
overflow: hidden;
|
|
242
|
+
text-overflow: ellipsis;
|
|
243
|
+
display: flex;
|
|
244
|
+
align-items: center;
|
|
245
|
+
justify-content: center;
|
|
246
|
+
gap: 2px;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.day-flow.inflow {
|
|
250
|
+
background: rgba(16, 185, 129, 0.1);
|
|
251
|
+
color: var(--income-color);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.day-flow.outflow {
|
|
255
|
+
background: rgba(244, 63, 94, 0.1);
|
|
256
|
+
color: var(--expense-color);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.day-flow.transflow {
|
|
260
|
+
background: rgba(156, 163, 175, 0.12);
|
|
261
|
+
color: var(--text-muted);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* Custom Scrollbar for calendar details panel */
|
|
265
|
+
#calendar-details-content::-webkit-scrollbar {
|
|
266
|
+
width: 6px;
|
|
267
|
+
}
|
|
268
|
+
#calendar-details-content::-webkit-scrollbar-track {
|
|
269
|
+
background: transparent;
|
|
270
|
+
}
|
|
271
|
+
#calendar-details-content::-webkit-scrollbar-thumb {
|
|
272
|
+
background: rgba(255, 255, 255, 0.15);
|
|
273
|
+
border-radius: 10px;
|
|
274
|
+
}
|
|
275
|
+
#calendar-details-content::-webkit-scrollbar-thumb:hover {
|
|
276
|
+
background: rgba(139, 92, 246, 0.35);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* Widgets grid styling */
|
|
280
|
+
.widgets-grid {
|
|
281
|
+
display: grid;
|
|
282
|
+
grid-template-columns: repeat(2, 1fr);
|
|
283
|
+
gap: 1.5rem;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.widget-card {
|
|
287
|
+
background: var(--panel-bg);
|
|
288
|
+
border: 1px solid var(--panel-border);
|
|
289
|
+
border-radius: 24px;
|
|
290
|
+
padding: 1.5rem;
|
|
291
|
+
display: flex;
|
|
292
|
+
flex-direction: column;
|
|
293
|
+
gap: 1rem;
|
|
294
|
+
backdrop-filter: blur(12px);
|
|
295
|
+
box-shadow: var(--card-shadow);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.widget-header {
|
|
299
|
+
display: flex;
|
|
300
|
+
justify-content: space-between;
|
|
301
|
+
align-items: center;
|
|
302
|
+
border-bottom: 1px solid var(--panel-border);
|
|
303
|
+
padding-bottom: 0.75rem;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.widget-header h3 {
|
|
307
|
+
font-size: 1rem;
|
|
308
|
+
font-weight: 700;
|
|
309
|
+
display: flex;
|
|
310
|
+
align-items: center;
|
|
311
|
+
gap: 0.5rem;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.widget-header h3 i {
|
|
315
|
+
color: var(--accent-primary);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.widget-link {
|
|
319
|
+
font-size: 0.8rem;
|
|
320
|
+
color: var(--accent-primary);
|
|
321
|
+
text-decoration: none;
|
|
322
|
+
font-weight: 600;
|
|
323
|
+
transition: var(--transition-smooth);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.widget-link:hover {
|
|
327
|
+
color: #a78bfa;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/* .net-worth-summary/.nw-* base: ui/app.css (shared with accounts.html). The "n.a." fallback
|
|
331
|
+
state is unique to overview.html (accounts.html hides the block instead), so it stays local. */
|
|
332
|
+
.net-worth-summary .nw-total.na {
|
|
333
|
+
font-style: italic;
|
|
334
|
+
opacity: 0.7;
|
|
335
|
+
color: var(--text-muted);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.widget-body {
|
|
339
|
+
display: flex;
|
|
340
|
+
flex-direction: column;
|
|
341
|
+
gap: 0.25rem;
|
|
342
|
+
min-height: 180px;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.widget-body.chart-body {
|
|
346
|
+
justify-content: center;
|
|
347
|
+
align-items: center;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/* List items inside widgets */
|
|
351
|
+
.list-item {
|
|
352
|
+
display: flex;
|
|
353
|
+
justify-content: space-between;
|
|
354
|
+
align-items: center;
|
|
355
|
+
padding: 0.75rem 0.5rem;
|
|
356
|
+
border-radius: 8px;
|
|
357
|
+
transition: var(--transition-smooth);
|
|
358
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.02);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.list-item:hover {
|
|
362
|
+
background: rgba(255, 255, 255, 0.02);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.list-item:last-child {
|
|
366
|
+
border-bottom: none;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.list-item-meta {
|
|
370
|
+
display: flex;
|
|
371
|
+
flex-direction: column;
|
|
372
|
+
gap: 2px;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.list-item-title {
|
|
376
|
+
font-size: 0.88rem;
|
|
377
|
+
font-weight: 600;
|
|
378
|
+
color: #fff;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.list-item-subtitle {
|
|
382
|
+
font-size: 0.75rem;
|
|
383
|
+
color: var(--text-muted);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.list-item-value {
|
|
387
|
+
font-size: 0.88rem;
|
|
388
|
+
font-weight: 700;
|
|
389
|
+
color: #fff;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/* Pending item styles */
|
|
393
|
+
.pending-item {
|
|
394
|
+
display: flex;
|
|
395
|
+
justify-content: space-between;
|
|
396
|
+
align-items: center;
|
|
397
|
+
padding: 0.65rem 0.5rem;
|
|
398
|
+
border-radius: 8px;
|
|
399
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.02);
|
|
400
|
+
transition: var(--transition-smooth);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.pending-item:hover {
|
|
404
|
+
background: rgba(255, 255, 255, 0.02);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.pending-item:last-child {
|
|
408
|
+
border-bottom: none;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.pending-meta {
|
|
412
|
+
display: flex;
|
|
413
|
+
flex-direction: column;
|
|
414
|
+
gap: 2px;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.pending-desc {
|
|
418
|
+
font-size: 0.85rem;
|
|
419
|
+
font-weight: 600;
|
|
420
|
+
color: #fff;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.pending-date-cat {
|
|
424
|
+
font-size: 0.72rem;
|
|
425
|
+
color: var(--text-muted);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.pending-action-area {
|
|
429
|
+
display: flex;
|
|
430
|
+
align-items: center;
|
|
431
|
+
gap: 0.75rem;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.pending-value {
|
|
435
|
+
font-size: 0.85rem;
|
|
436
|
+
font-weight: 700;
|
|
437
|
+
color: var(--expense-color);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.pending-value.income {
|
|
441
|
+
color: var(--income-color);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.btn-action-confirm {
|
|
445
|
+
background: rgba(16, 185, 129, 0.12);
|
|
446
|
+
border: 1px solid rgba(16, 185, 129, 0.25);
|
|
447
|
+
color: var(--income-color);
|
|
448
|
+
border-radius: 6px;
|
|
449
|
+
padding: 3px 8px;
|
|
450
|
+
font-size: 0.72rem;
|
|
451
|
+
font-weight: 700;
|
|
452
|
+
cursor: pointer;
|
|
453
|
+
transition: var(--transition-smooth);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.btn-action-confirm:hover {
|
|
457
|
+
background: var(--income-color);
|
|
458
|
+
color: #0c0e17;
|
|
459
|
+
border-color: var(--income-color);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/* Loading overlays */
|
|
463
|
+
.loading-wrapper {
|
|
464
|
+
position: relative;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/* .loading-overlay/.spinner base: ui/app.css (#164) */
|
|
468
|
+
.loading-overlay {
|
|
469
|
+
width: 100%; height: 100%;
|
|
470
|
+
background: rgba(12, 14, 23, 0.7);
|
|
471
|
+
display: none;
|
|
472
|
+
border-radius: 20px;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.loading-overlay.active {
|
|
476
|
+
display: flex;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.spinner {
|
|
480
|
+
width: 32px;
|
|
481
|
+
height: 32px;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.badge-status {
|
|
485
|
+
font-size: 0.7rem;
|
|
486
|
+
padding: 2px 6px;
|
|
487
|
+
border-radius: 4px;
|
|
488
|
+
font-weight: 700;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
.status-eff {
|
|
492
|
+
background: rgba(16, 185, 129, 0.15);
|
|
493
|
+
color: var(--income-color);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.status-pend {
|
|
497
|
+
background: rgba(245, 158, 11, 0.15);
|
|
498
|
+
color: var(--warning-color);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/* Toast notification styling (.toast base: ui/app.css, #164 — overview has no
|
|
502
|
+
.toast-container; this is the single persistent toast element itself) */
|
|
503
|
+
.toast {
|
|
504
|
+
position: fixed;
|
|
505
|
+
bottom: 2rem;
|
|
506
|
+
right: 2rem;
|
|
507
|
+
background: #111322;
|
|
508
|
+
z-index: 1100;
|
|
509
|
+
transform: translateY(100px);
|
|
510
|
+
opacity: 0;
|
|
511
|
+
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
.toast.show {
|
|
515
|
+
transform: translateY(0);
|
|
516
|
+
opacity: 1;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.toast-success i { color: var(--income-color); }
|
|
520
|
+
.toast-error i { color: var(--expense-color); }
|
|
521
|
+
|
|
522
|
+
/* Default mobile/tablet fluid styles for calendar row */
|
|
523
|
+
.calendar-split-row .panel {
|
|
524
|
+
height: auto;
|
|
525
|
+
}
|
|
526
|
+
.calendar-details-body {
|
|
527
|
+
flex: 1;
|
|
528
|
+
overflow-y: auto;
|
|
529
|
+
min-height: 0;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/* Desktop lock heights (prevents layout jumping) */
|
|
533
|
+
@media (min-width: 1025px) {
|
|
534
|
+
.calendar-split-row .panel {
|
|
535
|
+
height: 610px;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/* Responsive */
|
|
540
|
+
@media (max-width: 1024px) {
|
|
541
|
+
.kpis-row {
|
|
542
|
+
grid-template-columns: repeat(2, 1fr);
|
|
543
|
+
}
|
|
544
|
+
.calendar-split-row {
|
|
545
|
+
grid-template-columns: 1fr;
|
|
546
|
+
}
|
|
547
|
+
.widgets-grid {
|
|
548
|
+
grid-template-columns: 1fr;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/* Custom Select component styling */
|
|
553
|
+
.select-container-custom {
|
|
554
|
+
position: relative;
|
|
555
|
+
display: inline-block;
|
|
556
|
+
min-width: 120px;
|
|
557
|
+
user-select: none;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
.select-trigger-custom {
|
|
561
|
+
background: rgba(255, 255, 255, 0.05);
|
|
562
|
+
border: 1px solid var(--panel-border);
|
|
563
|
+
color: var(--text-main);
|
|
564
|
+
padding: 0.5rem 2.2rem 0.5rem 0.75rem;
|
|
565
|
+
border-radius: 8px;
|
|
566
|
+
cursor: pointer;
|
|
567
|
+
font-size: 0.85rem;
|
|
568
|
+
font-weight: 600;
|
|
569
|
+
display: flex;
|
|
570
|
+
align-items: center;
|
|
571
|
+
justify-content: space-between;
|
|
572
|
+
transition: var(--transition-smooth);
|
|
573
|
+
min-height: 36px;
|
|
574
|
+
box-sizing: border-box;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.select-trigger-custom:hover {
|
|
578
|
+
border-color: rgba(255, 255, 255, 0.15);
|
|
579
|
+
background: rgba(255, 255, 255, 0.08);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.select-container-custom.open .select-trigger-custom {
|
|
583
|
+
border-color: var(--accent-primary);
|
|
584
|
+
box-shadow: 0 0 0 2px var(--accent-primary-glow);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.select-trigger-custom::after {
|
|
588
|
+
content: '\f078';
|
|
589
|
+
font-family: 'Font Awesome 6 Free';
|
|
590
|
+
font-weight: 900;
|
|
591
|
+
font-size: 0.7rem;
|
|
592
|
+
color: var(--text-muted);
|
|
593
|
+
position: absolute;
|
|
594
|
+
right: 12px;
|
|
595
|
+
transition: transform 0.3s ease;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.select-container-custom.open .select-trigger-custom::after {
|
|
599
|
+
transform: rotate(180deg);
|
|
600
|
+
color: var(--accent-primary);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.select-options-custom {
|
|
604
|
+
display: none;
|
|
605
|
+
position: absolute;
|
|
606
|
+
top: calc(100% + 6px);
|
|
607
|
+
left: 0;
|
|
608
|
+
width: 100%;
|
|
609
|
+
background: rgba(22, 22, 34, 0.98); /* Opaque dark background to prevent bleed-through */
|
|
610
|
+
border: 1px solid var(--panel-border);
|
|
611
|
+
border-radius: 12px;
|
|
612
|
+
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
|
|
613
|
+
z-index: 1000;
|
|
614
|
+
max-height: 250px;
|
|
615
|
+
overflow-y: auto;
|
|
616
|
+
padding: 4px;
|
|
617
|
+
backdrop-filter: blur(20px);
|
|
618
|
+
box-sizing: border-box;
|
|
619
|
+
animation: selectFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
@keyframes selectFadeIn {
|
|
623
|
+
from { opacity: 0; transform: translateY(-8px); }
|
|
624
|
+
to { opacity: 1; transform: translateY(0); }
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
.select-container-custom.open .select-options-custom {
|
|
628
|
+
display: block;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.select-option-custom {
|
|
632
|
+
padding: 0.5rem 0.75rem;
|
|
633
|
+
color: var(--text-muted); /* Highly readable text color on dark backgrounds */
|
|
634
|
+
font-size: 0.82rem;
|
|
635
|
+
font-weight: 500;
|
|
636
|
+
border-radius: 6px;
|
|
637
|
+
cursor: pointer;
|
|
638
|
+
transition: var(--transition-smooth);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.select-option-custom:hover {
|
|
642
|
+
background: rgba(255, 255, 255, 0.08);
|
|
643
|
+
color: #fff;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
.select-option-custom.selected {
|
|
647
|
+
background: var(--accent-primary-glow);
|
|
648
|
+
color: var(--accent-primary);
|
|
649
|
+
font-weight: 700;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.select-options-custom::-webkit-scrollbar {
|
|
653
|
+
width: 6px;
|
|
654
|
+
}
|
|
655
|
+
.select-options-custom::-webkit-scrollbar-track {
|
|
656
|
+
background: transparent;
|
|
657
|
+
}
|
|
658
|
+
.select-options-custom::-webkit-scrollbar-thumb {
|
|
659
|
+
background: rgba(255, 255, 255, 0.1);
|
|
660
|
+
border-radius: 3px;
|
|
661
|
+
}
|
|
662
|
+
</style>
|
|
663
|
+
|
|
664
|
+
<!-- Header -->
|
|
665
|
+
<header>
|
|
666
|
+
<div class="header-title-area">
|
|
667
|
+
<h1><i class="fa-solid fa-house"></i> <span data-i18n="overview_title">Overview</span></h1>
|
|
668
|
+
<p data-i18n="overview_subtitle">Monthly financial summary, calendar, and quick shortcuts</p>
|
|
669
|
+
</div>
|
|
670
|
+
<div class="controls-area">
|
|
671
|
+
<label for="month-select" data-i18n="reference_label">Reference:</label>
|
|
672
|
+
<select id="month-select" class="select-custom">
|
|
673
|
+
<option value="1">Janeiro</option>
|
|
674
|
+
<option value="2">Fevereiro</option>
|
|
675
|
+
<option value="3">Março</option>
|
|
676
|
+
<option value="4">Abril</option>
|
|
677
|
+
<option value="5">Maio</option>
|
|
678
|
+
<option value="6">Junho</option>
|
|
679
|
+
<option value="7" selected>Julho</option>
|
|
680
|
+
<option value="8">Agosto</option>
|
|
681
|
+
<option value="9">Setembro</option>
|
|
682
|
+
<option value="10">Outubro</option>
|
|
683
|
+
<option value="11">Novembro</option>
|
|
684
|
+
<option value="12">Dezembro</option>
|
|
685
|
+
</select>
|
|
686
|
+
<select id="year-select" class="select-custom">
|
|
687
|
+
<option value="2025">2025</option>
|
|
688
|
+
<option value="2026" selected>2026</option>
|
|
689
|
+
<option value="2027">2027</option>
|
|
690
|
+
</select>
|
|
691
|
+
</div>
|
|
692
|
+
</header>
|
|
693
|
+
|
|
694
|
+
<!-- Loading Overlay for the whole dashboard -->
|
|
695
|
+
<div class="loading-wrapper">
|
|
696
|
+
<div id="dashboard-loading" class="loading-overlay active">
|
|
697
|
+
<div class="spinner"></div>
|
|
698
|
+
</div>
|
|
699
|
+
|
|
700
|
+
<!-- KPI Cards Row -->
|
|
701
|
+
<div class="kpis-row">
|
|
702
|
+
<!-- Incomes card -->
|
|
703
|
+
<div class="kpi-card">
|
|
704
|
+
<div class="kpi-title">
|
|
705
|
+
<i class="fa-solid fa-circle-arrow-up" style="color: var(--income-color);"></i>
|
|
706
|
+
Receitas Totais
|
|
707
|
+
</div>
|
|
708
|
+
<div class="kpi-value" id="kpi-income-val">—</div>
|
|
709
|
+
<div class="kpi-details">
|
|
710
|
+
<span>Efetivado: <strong id="kpi-income-eff" style="color: var(--income-color)">—</strong></span>
|
|
711
|
+
<span>Pendente: <strong id="kpi-income-pend">—</strong></span>
|
|
712
|
+
</div>
|
|
713
|
+
</div>
|
|
714
|
+
<!-- Expenses card -->
|
|
715
|
+
<div class="kpi-card">
|
|
716
|
+
<div class="kpi-title">
|
|
717
|
+
<i class="fa-solid fa-circle-arrow-down" style="color: var(--expense-color);"></i>
|
|
718
|
+
Despesas Totais
|
|
719
|
+
</div>
|
|
720
|
+
<div class="kpi-value" id="kpi-expense-val">—</div>
|
|
721
|
+
<div class="kpi-details">
|
|
722
|
+
<span>Efetivado: <strong id="kpi-expense-eff" style="color: var(--expense-color)">—</strong></span>
|
|
723
|
+
<span>Pendente: <strong id="kpi-expense-pend">—</strong></span>
|
|
724
|
+
</div>
|
|
725
|
+
</div>
|
|
726
|
+
<!-- Balance card -->
|
|
727
|
+
<div class="kpi-card">
|
|
728
|
+
<div class="kpi-title">
|
|
729
|
+
<i class="fa-solid fa-scale-balanced" style="color: var(--accent-primary);"></i>
|
|
730
|
+
Saldo Resultante
|
|
731
|
+
</div>
|
|
732
|
+
<div class="kpi-value" id="kpi-balance-val">—</div>
|
|
733
|
+
<div class="kpi-details">
|
|
734
|
+
<span>Líquido mensal (Receitas x Despesas)</span>
|
|
735
|
+
</div>
|
|
736
|
+
</div>
|
|
737
|
+
<!-- Card Bill card -->
|
|
738
|
+
<div class="kpi-card">
|
|
739
|
+
<div class="kpi-title">
|
|
740
|
+
<i class="fa-solid fa-credit-card" style="color: var(--warning-color);"></i>
|
|
741
|
+
Faturas do Mês
|
|
742
|
+
</div>
|
|
743
|
+
<div class="kpi-value" id="kpi-cards-val">—</div>
|
|
744
|
+
<div class="kpi-details">
|
|
745
|
+
<span>Total de faturas em aberto no período</span>
|
|
746
|
+
</div>
|
|
747
|
+
</div>
|
|
748
|
+
</div>
|
|
749
|
+
|
|
750
|
+
<!-- Calendar & Details Panel (Split Layout) -->
|
|
751
|
+
<div class="calendar-split-row" style="margin-top: 1.5rem;">
|
|
752
|
+
<!-- Calendar (Left Column) -->
|
|
753
|
+
<div class="panel" style="margin-top: 0;">
|
|
754
|
+
<div class="panel-header">
|
|
755
|
+
<h2><i class="fa-solid fa-calendar-days"></i> <span data-i18n="due_calendar">Daily Flow & Dues</span></h2>
|
|
756
|
+
<div class="calendar-legend">
|
|
757
|
+
<span class="legend-item"><span class="dot dot-inc"></span> Receitas</span>
|
|
758
|
+
<span class="legend-item"><span class="dot dot-exp"></span> Despesas</span>
|
|
759
|
+
<span class="legend-item"><span class="dot dot-trans"></span> Transferências</span>
|
|
760
|
+
</div>
|
|
761
|
+
</div>
|
|
762
|
+
<div class="calendar-panel-body">
|
|
763
|
+
<div class="calendar-grid-header">
|
|
764
|
+
<div>Dom</div><div>Seg</div><div>Ter</div><div>Qua</div><div>Qui</div><div>Sex</div><div>Sáb</div>
|
|
765
|
+
</div>
|
|
766
|
+
<div class="calendar-grid-body" id="calendar-days">
|
|
767
|
+
<!-- Populated dynamically via JS -->
|
|
768
|
+
</div>
|
|
769
|
+
</div>
|
|
770
|
+
</div>
|
|
771
|
+
|
|
772
|
+
<!-- Calendar Daily Details Panel (Right Column) -->
|
|
773
|
+
<div class="panel" id="calendar-details-panel">
|
|
774
|
+
<div class="panel-header">
|
|
775
|
+
<h2 id="calendar-details-title"><i class="fa-solid fa-calendar-day"></i> Lançamentos</h2>
|
|
776
|
+
</div>
|
|
777
|
+
<div class="calendar-details-body" id="calendar-details-content" style="padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 0.75rem;">
|
|
778
|
+
<!-- Dynamically populated or placeholder -->
|
|
779
|
+
</div>
|
|
780
|
+
</div>
|
|
781
|
+
</div>
|
|
782
|
+
|
|
783
|
+
<!-- Widgets Grid -->
|
|
784
|
+
<div class="widgets-grid" style="margin-top: 1.5rem;">
|
|
785
|
+
<!-- Widget 1: Contas Bancárias -->
|
|
786
|
+
<div class="widget-card">
|
|
787
|
+
<div class="widget-header">
|
|
788
|
+
<h3><i class="fa-solid fa-building-columns"></i> Contas Bancárias</h3>
|
|
789
|
+
<a href="/ui/accounts" class="widget-link">Ver todas <i class="fa-solid fa-arrow-right"></i></a>
|
|
790
|
+
</div>
|
|
791
|
+
<div class="net-worth-summary" id="net-worth-summary" style="display:none;"></div>
|
|
792
|
+
<div class="widget-body" id="widget-accounts-body">
|
|
793
|
+
<!-- Populated dynamically -->
|
|
794
|
+
</div>
|
|
795
|
+
</div>
|
|
796
|
+
|
|
797
|
+
<!-- Widget 2: Faturas de Cartão -->
|
|
798
|
+
<div class="widget-card">
|
|
799
|
+
<div class="widget-header">
|
|
800
|
+
<h3><i class="fa-solid fa-credit-card"></i> Faturas de Cartão</h3>
|
|
801
|
+
<a href="/ui/cards" class="widget-link">Ver detalhes <i class="fa-solid fa-arrow-right"></i></a>
|
|
802
|
+
</div>
|
|
803
|
+
<div class="widget-body" id="widget-cards-body">
|
|
804
|
+
<!-- Populated dynamically -->
|
|
805
|
+
</div>
|
|
806
|
+
</div>
|
|
807
|
+
|
|
808
|
+
<!-- Widget 3: Transações Pendentes -->
|
|
809
|
+
<div class="widget-card">
|
|
810
|
+
<div class="widget-header">
|
|
811
|
+
<h3><i class="fa-solid fa-clock"></i> Próximos Pendentes</h3>
|
|
812
|
+
<a href="/ui/pending" class="widget-link">Ver todos <i class="fa-solid fa-arrow-right"></i></a>
|
|
813
|
+
</div>
|
|
814
|
+
<div class="widget-body" id="widget-pending-body" style="position:relative;">
|
|
815
|
+
<!-- Loading spinner for widget confirm action -->
|
|
816
|
+
<div id="pending-widget-loading" class="loading-overlay">
|
|
817
|
+
<div class="spinner"></div>
|
|
818
|
+
</div>
|
|
819
|
+
<div id="pending-items-container" style="width:100%; display:flex; flex-direction:column; gap:0.25rem;">
|
|
820
|
+
<!-- Populated dynamically -->
|
|
821
|
+
</div>
|
|
822
|
+
</div>
|
|
823
|
+
</div>
|
|
824
|
+
|
|
825
|
+
<!-- Widget 4: Distribuição de Despesas -->
|
|
826
|
+
<div class="widget-card">
|
|
827
|
+
<div class="widget-header">
|
|
828
|
+
<h3><i class="fa-solid fa-chart-pie"></i> Distribuição de Despesas</h3>
|
|
829
|
+
<a href="/ui/comparative" class="widget-link">Ver categorias <i class="fa-solid fa-arrow-right"></i></a>
|
|
830
|
+
</div>
|
|
831
|
+
<div class="widget-body chart-body">
|
|
832
|
+
<div class="chart-container-inner" style="height: 180px; width: 100%; position: relative; display: flex; align-items: center; justify-content: center;">
|
|
833
|
+
<canvas id="expensePieChart"></canvas>
|
|
834
|
+
</div>
|
|
835
|
+
</div>
|
|
836
|
+
</div>
|
|
837
|
+
</div>
|
|
838
|
+
</div>
|
|
839
|
+
|
|
840
|
+
<div class="toast" id="toast"></div>
|
|
841
|
+
|
|
842
|
+
<script>
|
|
843
|
+
// Global variables for dashboard state
|
|
844
|
+
var selectedMonth = 7;
|
|
845
|
+
var selectedYear = 2026;
|
|
846
|
+
var allTransactions = [];
|
|
847
|
+
var accounts = [];
|
|
848
|
+
var creditCards = [];
|
|
849
|
+
var categories = [];
|
|
850
|
+
var consolidatedNetWorth = null; // { baseCurrency, total, excluded } from get_account_balances (ADR-026)
|
|
851
|
+
var expensePieChartInstance = null;
|
|
852
|
+
|
|
853
|
+
// Money formatting — per currency, never blended (issue #174 fix). Every accumulator below
|
|
854
|
+
// is keyed by currency; formatMultiCurrency renders each currency's own amount side by side
|
|
855
|
+
// instead of collapsing them into a single mislabeled total. addMultiCurrency/valueIn/
|
|
856
|
+
// primaryCurrencyOf/magnitudeOf/mergeCurrencyMaps/formatMultiCurrencyWith/DEFAULT_CURRENCY
|
|
857
|
+
// are shared globals from ui/money.js (loaded before this fragment's script — see
|
|
858
|
+
// docs/ui.md) rather than defined here. formatCurrency/formatCurrencyNoSymbol stay local —
|
|
859
|
+
// and formatMultiCurrency is just a 1-line delegate to formatMultiCurrencyWith passing
|
|
860
|
+
// formatCurrency — because they need this fragment's own resolved currentLocale, which the
|
|
861
|
+
// shell-loaded, load-once money.js has no access to.
|
|
862
|
+
function formatCurrency(value, currency) {
|
|
863
|
+
const loc = currentLocale === 'pt' ? 'pt-BR' : (currentLocale === 'es' ? 'es-ES' : 'en-US');
|
|
864
|
+
return window.formatMoney(value || 0, currency || DEFAULT_CURRENCY, { locale: loc });
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// Same rendering as formatCurrency but without the currency symbol, for space-constrained
|
|
868
|
+
// spots (calendar day cells) — still uses the currency's own decimals (e.g. BTC's 8) rather
|
|
869
|
+
// than a flat 2, so a crypto amount isn't silently truncated.
|
|
870
|
+
function formatCurrencyNoSymbol(value, currency) {
|
|
871
|
+
const code = currency || DEFAULT_CURRENCY;
|
|
872
|
+
const loc = currentLocale === 'pt' ? 'pt-BR' : (currentLocale === 'es' ? 'es-ES' : 'en-US');
|
|
873
|
+
const meta = (window.__appCurrencies && window.__appCurrencies[code]) || null;
|
|
874
|
+
const decimals = meta ? meta.decimals : 2;
|
|
875
|
+
return new Intl.NumberFormat(loc, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }).format(Number(value) || 0);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function formatMultiCurrency(map, delimiter) {
|
|
879
|
+
return window.formatMultiCurrencyWith(map, formatCurrency, delimiter);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
function escapeHtml(str) {
|
|
883
|
+
if (!str) return '';
|
|
884
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
// Escapes a value for safe embedding as a single-quoted JS string literal *inside* an
|
|
888
|
+
// HTML attribute (e.g. onclick="fn('${escapeJsAttr(value)}')"). escapeHtml() alone is not
|
|
889
|
+
// enough here: the browser HTML-decodes the attribute before the JS parser reads it, so an
|
|
890
|
+
// HTML-escaped quote round-trips back into a real quote and still breaks out of the string.
|
|
891
|
+
// Escaping backslash+quote for the JS layer first, then HTML-escaping the result for the
|
|
892
|
+
// attribute layer, survives that decode step correctly for both layers.
|
|
893
|
+
function escapeJsAttr(str) {
|
|
894
|
+
if (!str) return '';
|
|
895
|
+
return escapeHtml(String(str).replace(/\\/g, '\\\\').replace(/'/g, "\\'"));
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// Date helper
|
|
899
|
+
function getLastDay(year, month) {
|
|
900
|
+
return new Date(year, month, 0).getDate();
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
// Fetch transactions for selected month using safe pagination
|
|
904
|
+
async function fetchMonthTransactions(year, month) {
|
|
905
|
+
let allItems = [];
|
|
906
|
+
let cursor = null;
|
|
907
|
+
|
|
908
|
+
while (true) {
|
|
909
|
+
const queryParams = new URLSearchParams({
|
|
910
|
+
month: String(month),
|
|
911
|
+
year: String(year),
|
|
912
|
+
sort: 'date',
|
|
913
|
+
dir: 'desc'
|
|
914
|
+
});
|
|
915
|
+
if (cursor) {
|
|
916
|
+
queryParams.set('cursor', cursor);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
const url = `/api/transactions?${queryParams.toString()}`;
|
|
920
|
+
const res = await fetch(url);
|
|
921
|
+
if (!res.ok) throw new Error(`HTTP error ${res.status}`);
|
|
922
|
+
|
|
923
|
+
const data = await res.json();
|
|
924
|
+
|
|
925
|
+
let items = [];
|
|
926
|
+
let nextCursor = null;
|
|
927
|
+
if (data && typeof data === 'object') {
|
|
928
|
+
if (Array.isArray(data.items)) {
|
|
929
|
+
items = data.items;
|
|
930
|
+
nextCursor = data.nextCursor;
|
|
931
|
+
} else if (Array.isArray(data)) {
|
|
932
|
+
items = data;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
allItems.push(...items);
|
|
937
|
+
|
|
938
|
+
if (!nextCursor) {
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
cursor = nextCursor;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
return allItems;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// Toast controller
|
|
948
|
+
function showToast(message, type = 'success') {
|
|
949
|
+
const toast = document.getElementById('toast');
|
|
950
|
+
toast.className = `toast toast-${type}`;
|
|
951
|
+
toast.innerHTML = `
|
|
952
|
+
<i class="${type === 'success' ? 'fa-solid fa-circle-check' : 'fa-solid fa-circle-xmark'}"></i>
|
|
953
|
+
<span>${escapeHtml(message)}</span>
|
|
954
|
+
`;
|
|
955
|
+
toast.classList.add('show');
|
|
956
|
+
setTimeout(() => {
|
|
957
|
+
toast.classList.remove('show');
|
|
958
|
+
}, 3500);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// Initialize controllers
|
|
962
|
+
|
|
963
|
+
// Translation engine and dictionaries
|
|
964
|
+
var TRANSLATIONS = {
|
|
965
|
+
en: {
|
|
966
|
+
// Sidebar Menu
|
|
967
|
+
tooltip_overview: "Overview",
|
|
968
|
+
tooltip_pending: "Pending",
|
|
969
|
+
tooltip_comparative: "Comparative",
|
|
970
|
+
tooltip_projections: "Projections",
|
|
971
|
+
tooltip_accounts: "Bank Accounts",
|
|
972
|
+
tooltip_cards: "Credit Cards",
|
|
973
|
+
menu_categories: "Categories",
|
|
974
|
+
menu_dashboards: "Dashboards",
|
|
975
|
+
|
|
976
|
+
// Month names
|
|
977
|
+
january: "January", february: "February", march: "March", april: "April", may: "May", june: "June",
|
|
978
|
+
july: "July", august: "August", september: "September", october: "October", november: "November", december: "December",
|
|
979
|
+
|
|
980
|
+
// General UI terms
|
|
981
|
+
reference_label: "Reference:",
|
|
982
|
+
day_sun: "Sun", day_mon: "Mon", day_tue: "Tue", day_wed: "Wed", day_thu: "Thu", day_fri: "Fri", day_sat: "Sat",
|
|
983
|
+
paid: "Paid", unpaid: "Unpaid", active: "Active", inactive: "Inactive",
|
|
984
|
+
|
|
985
|
+
// Overview Dashboard
|
|
986
|
+
overview_title: "Overview",
|
|
987
|
+
overview_subtitle: "Monthly financial summary, calendar, and quick shortcuts",
|
|
988
|
+
accounts_balance: "Accounts Balance",
|
|
989
|
+
expenses_month: "Expenses this Month",
|
|
990
|
+
card_bills: "Credit Card Bills",
|
|
991
|
+
incomes_month: "Incomes this Month",
|
|
992
|
+
final_projection: "Final Projection:",
|
|
993
|
+
recent_transactions: "Recent Transactions",
|
|
994
|
+
due_calendar: "Daily Flow & Dues",
|
|
995
|
+
expenses_distribution: "Expenses Distribution",
|
|
996
|
+
quick_shortcuts: "Quick Shortcuts",
|
|
997
|
+
new_transaction: "New Transaction",
|
|
998
|
+
new_transfer: "New Transfer",
|
|
999
|
+
new_category: "New Category",
|
|
1000
|
+
new_card: "New Card",
|
|
1001
|
+
new_account: "New Account",
|
|
1002
|
+
no_expenses_month: "No expenses recorded this month.",
|
|
1003
|
+
no_recent_transactions: "No recent transactions found.",
|
|
1004
|
+
no_dues_period: "No transactions due in this period.",
|
|
1005
|
+
income: "Income",
|
|
1006
|
+
expense: "Expense",
|
|
1007
|
+
paid_reconciled: "Paid / Reconciled",
|
|
1008
|
+
net_worth_label: "Net worth (home currency)",
|
|
1009
|
+
net_worth_excluded: "{n} account(s) excluded (no rate)",
|
|
1010
|
+
net_worth_unavailable: "—",
|
|
1011
|
+
|
|
1012
|
+
// Projections / Heatmap Dashboard
|
|
1013
|
+
projections_title: "Recurring & Installment Projections",
|
|
1014
|
+
projections_subtitle: "Advanced visual mapping and projection of active recurrences and installments for the next months",
|
|
1015
|
+
projection_label: "Projection:",
|
|
1016
|
+
months_3: "3 Months",
|
|
1017
|
+
months_6: "6 Months",
|
|
1018
|
+
months_9: "9 Months",
|
|
1019
|
+
months_12: "12 Months",
|
|
1020
|
+
heatmap_income_title: "Recurrent / Installment Incomes",
|
|
1021
|
+
heatmap_expense_title: "Recurrent / Installment Expenses",
|
|
1022
|
+
total: "Total",
|
|
1023
|
+
no_recurrent_incomes: "No active recurrent or installment incomes in the selected semester.",
|
|
1024
|
+
no_recurrent_expenses: "No active recurrent or installment expenses in the selected semester.",
|
|
1025
|
+
modal_details_title: "Projection Breakdown",
|
|
1026
|
+
modal_details_subtitle: "Details of projected transactions for the category and month",
|
|
1027
|
+
col_date: "Date",
|
|
1028
|
+
col_desc: "Description",
|
|
1029
|
+
col_value: "Value",
|
|
1030
|
+
col_status: "Status",
|
|
1031
|
+
btn_close: "Close",
|
|
1032
|
+
|
|
1033
|
+
// Comparative Dashboard
|
|
1034
|
+
comparative_title: "Comparative Dashboard",
|
|
1035
|
+
comparative_subtitle: "Analysis and comparison of monthly incomes vs expenses, and category limits",
|
|
1036
|
+
month_summary_title: "Month Summary",
|
|
1037
|
+
cat_spending_title: "Spending by Category",
|
|
1038
|
+
card_limits_title: "Category Budgets & Limits",
|
|
1039
|
+
col_category: "Category",
|
|
1040
|
+
col_limit: "Budget Limit",
|
|
1041
|
+
col_spent: "Spent",
|
|
1042
|
+
col_status_limit: "Status",
|
|
1043
|
+
col_percentage: "Percentage",
|
|
1044
|
+
within_limit: "Within Limit",
|
|
1045
|
+
exceeded: "Exceeded",
|
|
1046
|
+
reception: "Incomes",
|
|
1047
|
+
deduction: "Expenses",
|
|
1048
|
+
net_balance: "Net Balance",
|
|
1049
|
+
performance: "Financial Health",
|
|
1050
|
+
no_spending_month: "No category spend recorded this month.",
|
|
1051
|
+
|
|
1052
|
+
// Accounts Dashboard
|
|
1053
|
+
accounts_title: "Bank Accounts",
|
|
1054
|
+
accounts_subtitle: "Manage accounts, checking balances, and reviewing statements",
|
|
1055
|
+
active_account_statement: "Account Statement",
|
|
1056
|
+
btn_new_transaction: "New Transaction",
|
|
1057
|
+
btn_new_transfer: "New Transfer",
|
|
1058
|
+
search_description_placeholder: "Type to search...",
|
|
1059
|
+
filter_type_label: "Type",
|
|
1060
|
+
filter_type_all: "All",
|
|
1061
|
+
filter_type_income: "Incomes",
|
|
1062
|
+
filter_type_expense: "Expenses",
|
|
1063
|
+
col_actions: "Actions",
|
|
1064
|
+
action_confirm: "Confirm",
|
|
1065
|
+
action_edit: "Edit",
|
|
1066
|
+
action_delete: "Delete",
|
|
1067
|
+
no_transactions_account: "No transactions recorded for this account in the selected month.",
|
|
1068
|
+
confirm_delete_title: "Are you sure you want to permanently delete this transaction?",
|
|
1069
|
+
modal_new_tx_title: "New Transaction",
|
|
1070
|
+
modal_new_transfer_title: "New Transfer",
|
|
1071
|
+
label_account: "Account",
|
|
1072
|
+
label_description: "Description",
|
|
1073
|
+
label_value: "Value",
|
|
1074
|
+
label_date: "Date",
|
|
1075
|
+
label_category: "Category / Subcategory",
|
|
1076
|
+
label_type: "Type",
|
|
1077
|
+
label_status: "Status",
|
|
1078
|
+
status_pending: "Pending",
|
|
1079
|
+
status_confirmed: "Paid / Confirmed",
|
|
1080
|
+
btn_cancel: "Cancel",
|
|
1081
|
+
btn_save: "Save",
|
|
1082
|
+
label_origin: "Origin Account",
|
|
1083
|
+
label_destination: "Destination Account",
|
|
1084
|
+
|
|
1085
|
+
// Pending Dashboard
|
|
1086
|
+
pending_title: "Pending Transactions",
|
|
1087
|
+
pending_subtitle: "Monitoring and quick confirmation of pending or future transactions",
|
|
1088
|
+
pending_kpi_total: "Total Pending",
|
|
1089
|
+
pending_kpi_incomes: "Pending Incomes",
|
|
1090
|
+
pending_kpi_expenses: "Pending Expenses",
|
|
1091
|
+
pending_chart_incomes: "Pending Incomes Trend",
|
|
1092
|
+
pending_chart_expenses: "Pending Expenses Trend",
|
|
1093
|
+
btn_confirm: "Confirm",
|
|
1094
|
+
btn_edit: "Edit",
|
|
1095
|
+
btn_delete: "Delete",
|
|
1096
|
+
no_pending_transactions: "No pending transactions found for this period.",
|
|
1097
|
+
toast_success_confirm: "Transaction confirmed successfully!",
|
|
1098
|
+
|
|
1099
|
+
// Categories Dashboard
|
|
1100
|
+
categories_title: "Category Management",
|
|
1101
|
+
categories_subtitle: "Visualize, search, and manage categories and subcategories in a clean tree list",
|
|
1102
|
+
btn_new_category: "New Category",
|
|
1103
|
+
search_category_placeholder: "Search categories...",
|
|
1104
|
+
col_type: "Type",
|
|
1105
|
+
col_actions_cat: "Actions",
|
|
1106
|
+
subcategories_label: "Subcategories",
|
|
1107
|
+
no_subcategories: "No subcategories registered.",
|
|
1108
|
+
modal_new_cat_title: "New Category",
|
|
1109
|
+
modal_new_subcat_title: "New Subcategory",
|
|
1110
|
+
label_name: "Name",
|
|
1111
|
+
label_color: "Color",
|
|
1112
|
+
label_parent_category: "Parent Category (Read-Only)",
|
|
1113
|
+
toast_success_cat: "Category created successfully!",
|
|
1114
|
+
toast_success_subcat: "Subcategory created successfully!",
|
|
1115
|
+
|
|
1116
|
+
// Cards Dashboard
|
|
1117
|
+
cards_title: "Credit Cards",
|
|
1118
|
+
cards_subtitle: "Manage credit cards, credit limits, and statement history",
|
|
1119
|
+
card_bill_details: "Card Bill Details",
|
|
1120
|
+
btn_pay_bill: "Pay Bill",
|
|
1121
|
+
btn_revert_payment: "Revert Payment",
|
|
1122
|
+
bill_status: "Bill Status:",
|
|
1123
|
+
status_open: "Open",
|
|
1124
|
+
status_closed: "Closed",
|
|
1125
|
+
status_paid: "Paid",
|
|
1126
|
+
no_card_transactions: "No transactions recorded for this card bill in the selected cycle.",
|
|
1127
|
+
|
|
1128
|
+
// Dashboards Manager Dashboard
|
|
1129
|
+
dashboards_title: "Dashboards Monitor",
|
|
1130
|
+
dashboards_subtitle: "List, view source, and upload patty dashboards",
|
|
1131
|
+
col_dashboard: "Dashboard",
|
|
1132
|
+
col_last_update: "Last Updated",
|
|
1133
|
+
btn_view_source: "View Source",
|
|
1134
|
+
btn_download: "Download",
|
|
1135
|
+
upload_new_dashboard: "Upload New Dashboard",
|
|
1136
|
+
placeholder_dashboard_name: "Dashboard Name (e.g. pending)",
|
|
1137
|
+
upload_instructions: "Select or drop HTML file here to upload",
|
|
1138
|
+
btn_upload: "Upload",
|
|
1139
|
+
modal_source_title: "HTML Source Code",
|
|
1140
|
+
|
|
1141
|
+
// Tags Management
|
|
1142
|
+
menu_tags: "Tags",
|
|
1143
|
+
tags_title: "Tag Management",
|
|
1144
|
+
tags_subtitle: "Manage tags to label and organize your transactions",
|
|
1145
|
+
panel_title_tags: "Active Tags",
|
|
1146
|
+
btn_new_tag: "New Tag",
|
|
1147
|
+
label_tag_name: "Tag Name",
|
|
1148
|
+
placeholder_tag_name: "E.g. work, travel, refund",
|
|
1149
|
+
empty_tags_message: "No tags registered.",
|
|
1150
|
+
btn_save: "Save",
|
|
1151
|
+
btn_cancel: "Cancel",
|
|
1152
|
+
toast_success_tag_created: 'Tag "{name}" created successfully!',
|
|
1153
|
+
toast_success_tag_deleted: 'Tag "{name}" deleted successfully!',
|
|
1154
|
+
confirm_delete_tag: 'Are you sure you want to delete tag "{name}"?\n(This action will remove the tag from all linked transactions)'
|
|
1155
|
+
},
|
|
1156
|
+
pt: {
|
|
1157
|
+
// Sidebar Menu
|
|
1158
|
+
tooltip_overview: "Visão Geral",
|
|
1159
|
+
tooltip_pending: "Pendentes",
|
|
1160
|
+
tooltip_comparative: "Comparativo",
|
|
1161
|
+
tooltip_projections: "Projeções",
|
|
1162
|
+
tooltip_accounts: "Contas Bancárias",
|
|
1163
|
+
tooltip_cards: "Cartões de Crédito",
|
|
1164
|
+
menu_categories: "Categorias",
|
|
1165
|
+
menu_dashboards: "Dashboards",
|
|
1166
|
+
|
|
1167
|
+
// Month names
|
|
1168
|
+
january: "Janeiro", february: "Fevereiro", march: "Março", april: "Abril", may: "Maio", june: "Junho",
|
|
1169
|
+
july: "Julho", august: "Agosto", september: "Setembro", october: "Outubro", november: "Novembro", december: "Dezembro",
|
|
1170
|
+
|
|
1171
|
+
// General UI terms
|
|
1172
|
+
reference_label: "Referência:",
|
|
1173
|
+
day_sun: "Dom", day_mon: "Seg", day_tue: "Ter", day_wed: "Qua", day_thu: "Qui", day_fri: "Sex", day_sat: "Sáb",
|
|
1174
|
+
paid: "Pago", unpaid: "Não Pago", active: "Ativo", inactive: "Inativo",
|
|
1175
|
+
|
|
1176
|
+
// Overview Dashboard
|
|
1177
|
+
overview_title: "Visão Geral",
|
|
1178
|
+
overview_subtitle: "Consolidado financeiro mensal, calendário e atalhos rápidos",
|
|
1179
|
+
accounts_balance: "Saldo em Contas",
|
|
1180
|
+
expenses_month: "Despesas do Mês",
|
|
1181
|
+
card_bills: "Faturas de Cartão",
|
|
1182
|
+
incomes_month: "Receitas do Mês",
|
|
1183
|
+
final_projection: "Projeção Final:",
|
|
1184
|
+
recent_transactions: "Lançamentos Recentes",
|
|
1185
|
+
due_calendar: "Fluxo Diário",
|
|
1186
|
+
expenses_distribution: "Distribuição de Despesas",
|
|
1187
|
+
quick_shortcuts: "Atalhos Rápidos",
|
|
1188
|
+
new_transaction: "Novo Lançamento",
|
|
1189
|
+
new_transfer: "Nova Transferência",
|
|
1190
|
+
new_category: "Nova Categoria",
|
|
1191
|
+
new_card: "Novo Cartão",
|
|
1192
|
+
new_account: "Nova Conta",
|
|
1193
|
+
no_expenses_month: "Sem despesas registradas neste mês.",
|
|
1194
|
+
no_recent_transactions: "Nenhuma transação recente encontrada.",
|
|
1195
|
+
no_dues_period: "Sem vencimentos neste período.",
|
|
1196
|
+
income: "Receita",
|
|
1197
|
+
expense: "Despesa",
|
|
1198
|
+
paid_reconciled: "Pago / Conciliado",
|
|
1199
|
+
net_worth_label: "Patrimônio Líquido (moeda base)",
|
|
1200
|
+
net_worth_excluded: "{n} conta(s) excluída(s) (sem cotação)",
|
|
1201
|
+
net_worth_unavailable: "—",
|
|
1202
|
+
|
|
1203
|
+
// Projections / Heatmap Dashboard
|
|
1204
|
+
projections_title: "Projeção de Recorrências e Parcelas",
|
|
1205
|
+
projections_subtitle: "Mapeamento visual avançado e projeção de recorrências e parcelas ativas para os próximos meses",
|
|
1206
|
+
projection_label: "Projeção:",
|
|
1207
|
+
months_3: "3 Meses",
|
|
1208
|
+
months_6: "6 Meses",
|
|
1209
|
+
months_9: "9 Meses",
|
|
1210
|
+
months_12: "12 Meses",
|
|
1211
|
+
heatmap_income_title: "Receitas Recorrentes / Parceladas",
|
|
1212
|
+
heatmap_expense_title: "Despesas Recorrentes / Parceladas",
|
|
1213
|
+
total: "Total",
|
|
1214
|
+
no_recurrent_incomes: "Nenhuma receita recorrente/parcelada ativa no semestre.",
|
|
1215
|
+
no_recurrent_expenses: "Nenhuma despesa recorrente/parcelada ativa no semestre.",
|
|
1216
|
+
modal_details_title: "Detalhamento de Projeções",
|
|
1217
|
+
modal_details_subtitle: "Detalhes das transações projetadas para a categoria e mês",
|
|
1218
|
+
col_date: "Data",
|
|
1219
|
+
col_desc: "Descrição",
|
|
1220
|
+
col_value: "Valor",
|
|
1221
|
+
col_status: "Status",
|
|
1222
|
+
btn_close: "Fechar",
|
|
1223
|
+
|
|
1224
|
+
// Comparative Dashboard
|
|
1225
|
+
comparative_title: "Dashboard Comparativo",
|
|
1226
|
+
comparative_subtitle: "Análise e comparação mensal de receitas vs despesas e limites por categoria",
|
|
1227
|
+
month_summary_title: "Resumo do Mês",
|
|
1228
|
+
cat_spending_title: "Gastos por Categoria",
|
|
1229
|
+
card_limits_title: "Orçamentos e Limites de Categorias",
|
|
1230
|
+
col_category: "Categoria",
|
|
1231
|
+
col_limit: "Limite de Orçamento",
|
|
1232
|
+
col_spent: "Gasto",
|
|
1233
|
+
col_status_limit: "Status",
|
|
1234
|
+
col_percentage: "Porcentagem",
|
|
1235
|
+
within_limit: "Dentro do Limite",
|
|
1236
|
+
exceeded: "Excedido",
|
|
1237
|
+
reception: "Receitas",
|
|
1238
|
+
deduction: "Despesas",
|
|
1239
|
+
net_balance: "Saldo Líquido",
|
|
1240
|
+
performance: "Saúde Financeira",
|
|
1241
|
+
no_spending_month: "Sem despesas registradas por categoria neste mês.",
|
|
1242
|
+
|
|
1243
|
+
// Accounts Dashboard
|
|
1244
|
+
accounts_title: "Minhas Contas",
|
|
1245
|
+
accounts_subtitle: "Gerencie contas, consulte saldos e revise extratos",
|
|
1246
|
+
active_account_statement: "Extrato de Conta",
|
|
1247
|
+
btn_new_transaction: "Novo Lançamento",
|
|
1248
|
+
btn_new_transfer: "Nova Transferência",
|
|
1249
|
+
search_description_placeholder: "Digite para filtrar...",
|
|
1250
|
+
filter_type_label: "Tipo",
|
|
1251
|
+
filter_type_all: "Todos",
|
|
1252
|
+
filter_type_income: "Receitas",
|
|
1253
|
+
filter_type_expense: "Despesas",
|
|
1254
|
+
col_actions: "Ações",
|
|
1255
|
+
action_confirm: "Confirmar",
|
|
1256
|
+
action_edit: "Editar",
|
|
1257
|
+
action_delete: "Excluir",
|
|
1258
|
+
no_transactions_account: "Nenhum lançamento nesta conta para o mês selecionado.",
|
|
1259
|
+
confirm_delete_title: "Deseja excluir definitivamente a transação?",
|
|
1260
|
+
modal_new_tx_title: "Novo Lançamento",
|
|
1261
|
+
modal_new_transfer_title: "Nova Transferência",
|
|
1262
|
+
label_account: "Conta",
|
|
1263
|
+
label_description: "Descrição",
|
|
1264
|
+
label_value: "Valor",
|
|
1265
|
+
label_date: "Data",
|
|
1266
|
+
label_category: "Categoria / Subcategoria",
|
|
1267
|
+
label_type: "Tipo",
|
|
1268
|
+
label_status: "Status",
|
|
1269
|
+
status_pending: "Pendente",
|
|
1270
|
+
status_confirmed: "Pago / Confirmado",
|
|
1271
|
+
btn_cancel: "Cancelar",
|
|
1272
|
+
btn_save: "Salvar",
|
|
1273
|
+
label_origin: "Conta Origem",
|
|
1274
|
+
label_destination: "Conta Destino",
|
|
1275
|
+
|
|
1276
|
+
// Pending Dashboard
|
|
1277
|
+
pending_title: "Transações Pendentes",
|
|
1278
|
+
pending_subtitle: "Monitoramento e confirmação rápida de lançamentos pendentes ou futuros",
|
|
1279
|
+
pending_kpi_total: "Total Pendente",
|
|
1280
|
+
pending_kpi_incomes: "Receitas Pendentes",
|
|
1281
|
+
pending_kpi_expenses: "Despesas Pendentes",
|
|
1282
|
+
pending_chart_incomes: "Tendência de Receitas Pendentes",
|
|
1283
|
+
pending_chart_expenses: "Tendência de Despesas Pendentes",
|
|
1284
|
+
btn_confirm: "Confirmar",
|
|
1285
|
+
btn_edit: "Editar",
|
|
1286
|
+
btn_delete: "Excluir",
|
|
1287
|
+
no_pending_transactions: "Nenhuma transação pendente encontrada para este período.",
|
|
1288
|
+
toast_success_confirm: "Transação confirmada com sucesso!",
|
|
1289
|
+
|
|
1290
|
+
// Categories Dashboard
|
|
1291
|
+
categories_title: "Gerenciamento de Categorias",
|
|
1292
|
+
categories_subtitle: "Visualize, pesquise e gerencie categorias e subcategorias em árvore",
|
|
1293
|
+
btn_new_category: "Nova Categoria",
|
|
1294
|
+
search_category_placeholder: "Pesquisar categorias...",
|
|
1295
|
+
col_type: "Tipo",
|
|
1296
|
+
col_actions_cat: "Ações",
|
|
1297
|
+
subcategories_label: "Subcategorias",
|
|
1298
|
+
no_subcategories: "Nenhuma subcategoria cadastrada.",
|
|
1299
|
+
modal_new_cat_title: "Nova Categoria",
|
|
1300
|
+
modal_new_subcat_title: "Nova Subcategoria",
|
|
1301
|
+
label_name: "Nome",
|
|
1302
|
+
label_color: "Cor",
|
|
1303
|
+
label_parent_category: "Categoria Pai (Somente Leitura)",
|
|
1304
|
+
toast_success_cat: "Categoria criada com sucesso!",
|
|
1305
|
+
toast_success_subcat: "Subcategoria criada com sucesso!",
|
|
1306
|
+
|
|
1307
|
+
// Cards Dashboard
|
|
1308
|
+
cards_title: "Cartões de Crédito",
|
|
1309
|
+
cards_subtitle: "Gerencie cartões de crédito, limites e histórico de faturas",
|
|
1310
|
+
card_bill_details: "Detalhamento de Fatura",
|
|
1311
|
+
btn_pay_bill: "Pagar Fatura",
|
|
1312
|
+
btn_revert_payment: "Estornar Pagamento",
|
|
1313
|
+
bill_status: "Status da Fatura:",
|
|
1314
|
+
status_open: "Aberta",
|
|
1315
|
+
status_closed: "Fechada",
|
|
1316
|
+
status_paid: "Paga",
|
|
1317
|
+
no_card_transactions: "Nenhuma transação registrada nesta fatura para o ciclo selecionado.",
|
|
1318
|
+
|
|
1319
|
+
// Dashboards Manager Dashboard
|
|
1320
|
+
dashboards_title: "Monitor de Dashboards",
|
|
1321
|
+
dashboards_subtitle: "Liste, visualize o código fonte e envie dashboards para o servidor do patty",
|
|
1322
|
+
col_dashboard: "Dashboard",
|
|
1323
|
+
col_last_update: "Última Atualização",
|
|
1324
|
+
btn_view_source: "Ver Código",
|
|
1325
|
+
btn_download: "Baixar HTML",
|
|
1326
|
+
upload_new_dashboard: "Enviar Novo Dashboard",
|
|
1327
|
+
placeholder_dashboard_name: "Nome do Dashboard (ex: pending)",
|
|
1328
|
+
upload_instructions: "Selecione ou solte o arquivo HTML aqui para upload",
|
|
1329
|
+
btn_upload: "Fazer Upload",
|
|
1330
|
+
modal_source_title: "Código Fonte HTML",
|
|
1331
|
+
|
|
1332
|
+
// Tags Management
|
|
1333
|
+
menu_tags: "Tags",
|
|
1334
|
+
tags_title: "Gerenciar Tags",
|
|
1335
|
+
tags_subtitle: "Gerencie as tags utilizadas para rotular e categorizar suas transações",
|
|
1336
|
+
panel_title_tags: "Tags Ativas",
|
|
1337
|
+
btn_new_tag: "Nova Tag",
|
|
1338
|
+
label_tag_name: "Nome da Tag",
|
|
1339
|
+
placeholder_tag_name: "Ex: trabalho, viagem, reembolso",
|
|
1340
|
+
empty_tags_message: "Nenhuma tag cadastrada.",
|
|
1341
|
+
btn_save: "Salvar",
|
|
1342
|
+
btn_cancel: "Cancelar",
|
|
1343
|
+
toast_success_tag_created: 'Tag "{name}" criada com sucesso!',
|
|
1344
|
+
toast_success_tag_deleted: 'Tag "{name}" excluída com sucesso!',
|
|
1345
|
+
confirm_delete_tag: 'Deseja realmente excluir a tag "{name}"?\n(Esta ação removerá a tag de todas as transações vinculadas)'
|
|
1346
|
+
},
|
|
1347
|
+
es: {
|
|
1348
|
+
// Sidebar Menu
|
|
1349
|
+
tooltip_overview: "Vista General",
|
|
1350
|
+
tooltip_pending: "Pendientes",
|
|
1351
|
+
tooltip_comparative: "Comparativo",
|
|
1352
|
+
tooltip_projections: "Proyecciones",
|
|
1353
|
+
tooltip_accounts: "Cuentas Bancárias",
|
|
1354
|
+
tooltip_cards: "Tarjetas de Crédito",
|
|
1355
|
+
menu_categories: "Categorías",
|
|
1356
|
+
menu_dashboards: "Dashboards",
|
|
1357
|
+
|
|
1358
|
+
// Month names
|
|
1359
|
+
january: "Enero", february: "Febrero", march: "Marzo", april: "Abril", may: "Mayo", june: "Junio",
|
|
1360
|
+
july: "Julio", august: "Agosto", september: "Septiembre", october: "Octubre", november: "Noviembre", december: "Diciembre",
|
|
1361
|
+
|
|
1362
|
+
// General UI terms
|
|
1363
|
+
reference_label: "Referencia:",
|
|
1364
|
+
day_sun: "Dom", day_mon: "Lun", day_tue: "Mar", day_wed: "Mié", day_thu: "Jue", day_fri: "Vie", day_sat: "Sáb",
|
|
1365
|
+
paid: "Pagado", unpaid: "No Pagado", active: "Activo", inactive: "Inactivo",
|
|
1366
|
+
|
|
1367
|
+
// Overview Dashboard
|
|
1368
|
+
overview_title: "Vista General",
|
|
1369
|
+
overview_subtitle: "Resumen financiero mensual, calendario y accesos rápidos",
|
|
1370
|
+
accounts_balance: "Saldo en Cuentas",
|
|
1371
|
+
expenses_month: "Gastos del Mes",
|
|
1372
|
+
card_bills: "Facturas de Tarjeta",
|
|
1373
|
+
incomes_month: "Ingresos del Mes",
|
|
1374
|
+
final_projection: "Proyección Final:",
|
|
1375
|
+
recent_transactions: "Transacciones Recientes",
|
|
1376
|
+
due_calendar: "Calendario de Pagos",
|
|
1377
|
+
expenses_distribution: "Distribución de Gastos",
|
|
1378
|
+
quick_shortcuts: "Accesos Rápidos",
|
|
1379
|
+
new_transaction: "Nueva Transacción",
|
|
1380
|
+
new_transfer: "Nueva Transferencia",
|
|
1381
|
+
new_category: "Nueva Categoría",
|
|
1382
|
+
new_card: "Nueva Tarjeta",
|
|
1383
|
+
new_account: "Nueva Cuenta",
|
|
1384
|
+
no_expenses_month: "No hay gastos registrados este mes.",
|
|
1385
|
+
no_recent_transactions: "No se encontraron transacciones recientes.",
|
|
1386
|
+
no_dues_period: "Sin vencimientos en este período.",
|
|
1387
|
+
income: "Ingreso",
|
|
1388
|
+
expense: "Gasto",
|
|
1389
|
+
paid_reconciled: "Pagado / Conciliado",
|
|
1390
|
+
net_worth_label: "Patrimonio Neto (moneda base)",
|
|
1391
|
+
net_worth_excluded: "{n} cuenta(s) excluida(s) (sin cotización)",
|
|
1392
|
+
net_worth_unavailable: "—",
|
|
1393
|
+
|
|
1394
|
+
// Projections / Heatmap Dashboard
|
|
1395
|
+
projections_title: "Proyección de Recurrencias y Cuotas",
|
|
1396
|
+
projections_subtitle: "Mapeo visual avanzado y proyección de recurrencias y cuotas activas para los próximos meses",
|
|
1397
|
+
projection_label: "Proyección:",
|
|
1398
|
+
months_3: "3 Meses",
|
|
1399
|
+
months_6: "6 Meses",
|
|
1400
|
+
months_9: "9 Meses",
|
|
1401
|
+
months_12: "12 Meses",
|
|
1402
|
+
heatmap_income_title: "Ingresos Recurrentes / Cuotas",
|
|
1403
|
+
heatmap_expense_title: "Gastos Recurrentes / Cuotas",
|
|
1404
|
+
total: "Total",
|
|
1405
|
+
no_recurrent_incomes: "Ningún ingreso recurrente o en cuotas activo en el semestre seleccionado.",
|
|
1406
|
+
no_recurrent_expenses: "Ningún gasto recurrente o en cuotas activo en el semestre seleccionado.",
|
|
1407
|
+
modal_details_title: "Detalle de Proyecciones",
|
|
1408
|
+
modal_details_subtitle: "Detalles de transacciones proyectadas para la categoría y mes",
|
|
1409
|
+
col_date: "Fecha",
|
|
1410
|
+
col_desc: "Descripción",
|
|
1411
|
+
col_value: "Valor",
|
|
1412
|
+
col_status: "Estado",
|
|
1413
|
+
btn_close: "Cerrar",
|
|
1414
|
+
|
|
1415
|
+
// Comparative Dashboard
|
|
1416
|
+
comparative_title: "Dashboard Comparativo",
|
|
1417
|
+
comparative_subtitle: "Análisis y comparación mensual de ingresos vs gastos y límites por categoría",
|
|
1418
|
+
month_summary_title: "Resumen del Mes",
|
|
1419
|
+
cat_spending_title: "Gastos por Categoría",
|
|
1420
|
+
card_limits_title: "Presupuestos y Límites de Categorías",
|
|
1421
|
+
col_category: "Categoría",
|
|
1422
|
+
col_limit: "Límite de Presupuesto",
|
|
1423
|
+
col_spent: "Gastado",
|
|
1424
|
+
col_status_limit: "Estado",
|
|
1425
|
+
col_percentage: "Porcentaje",
|
|
1426
|
+
within_limit: "Dentro del Límite",
|
|
1427
|
+
exceeded: "Excedido",
|
|
1428
|
+
reception: "Ingresos",
|
|
1429
|
+
deduction: "Gastos",
|
|
1430
|
+
net_balance: "Saldo Neto",
|
|
1431
|
+
performance: "Salud Financiera",
|
|
1432
|
+
no_spending_month: "No hay gastos registrados por categoría este mes.",
|
|
1433
|
+
|
|
1434
|
+
// Accounts Dashboard
|
|
1435
|
+
accounts_title: "Cuentas Bancarias",
|
|
1436
|
+
accounts_subtitle: "Administre cuentas, consulte saldos y revise extractos",
|
|
1437
|
+
active_account_statement: "Extracto de Cuenta",
|
|
1438
|
+
btn_new_transaction: "Nueva Transacción",
|
|
1439
|
+
btn_new_transfer: "Nueva Transferencia",
|
|
1440
|
+
search_description_placeholder: "Escriba para filtrar...",
|
|
1441
|
+
filter_type_label: "Tipo",
|
|
1442
|
+
filter_type_all: "Todos",
|
|
1443
|
+
filter_type_income: "Ingresos",
|
|
1444
|
+
filter_type_expense: "Gastos",
|
|
1445
|
+
col_actions: "Acciones",
|
|
1446
|
+
action_confirm: "Confirmar",
|
|
1447
|
+
action_edit: "Editar",
|
|
1448
|
+
action_delete: "Eliminar",
|
|
1449
|
+
no_transactions_account: "No hay transacciones registradas en esta cuenta en el mes seleccionado.",
|
|
1450
|
+
confirm_delete_title: "¿Está seguro de eliminar definitivamente esta transacción?",
|
|
1451
|
+
modal_new_tx_title: "Nueva Transacción",
|
|
1452
|
+
modal_new_transfer_title: "Nueva Transferencia",
|
|
1453
|
+
label_account: "Cuenta",
|
|
1454
|
+
label_description: "Descripción",
|
|
1455
|
+
label_value: "Valor",
|
|
1456
|
+
label_date: "Fecha",
|
|
1457
|
+
label_category: "Categoría / Subcategoría",
|
|
1458
|
+
label_type: "Tipo",
|
|
1459
|
+
label_status: "Estado",
|
|
1460
|
+
status_pending: "Pendiente",
|
|
1461
|
+
status_confirmed: "Pagado / Confirmado",
|
|
1462
|
+
btn_cancel: "Cancelar",
|
|
1463
|
+
btn_save: "Guardar",
|
|
1464
|
+
label_origin: "Cuenta Origen",
|
|
1465
|
+
label_destination: "Cuenta Destino",
|
|
1466
|
+
|
|
1467
|
+
// Pending Dashboard
|
|
1468
|
+
pending_title: "Transacciones Pendientes",
|
|
1469
|
+
pending_subtitle: "Monitoreo y confirmación rápida de transacciones pendientes o futuras",
|
|
1470
|
+
pending_kpi_total: "Total Pendiente",
|
|
1471
|
+
pending_kpi_incomes: "Ingresos Pendientes",
|
|
1472
|
+
pending_kpi_expenses: "Gastos Pendientes",
|
|
1473
|
+
pending_chart_incomes: "Tendencia de Ingresos Pendientes",
|
|
1474
|
+
pending_chart_expenses: "Tendencia de Gastos Pendientes",
|
|
1475
|
+
btn_confirm: "Confirmar",
|
|
1476
|
+
btn_edit: "Editar",
|
|
1477
|
+
btn_delete: "Eliminar",
|
|
1478
|
+
no_pending_transactions: "No se encontraron transacciones pendientes en este período.",
|
|
1479
|
+
toast_success_confirm: "¡Transacción confirmada con éxito!",
|
|
1480
|
+
|
|
1481
|
+
// Categories Dashboard
|
|
1482
|
+
categories_title: "Gestión de Categorías",
|
|
1483
|
+
categories_subtitle: "Visualice, busque y gestione categorías y subcategorías en árbol",
|
|
1484
|
+
btn_new_category: "Nueva Categoría",
|
|
1485
|
+
search_category_placeholder: "Buscar categorías...",
|
|
1486
|
+
col_type: "Tipo",
|
|
1487
|
+
col_actions_cat: "Acciones",
|
|
1488
|
+
subcategories_label: "Subcategorías",
|
|
1489
|
+
no_subcategories: "Ninguna subcategoría registrada.",
|
|
1490
|
+
modal_new_cat_title: "Nueva Categoría",
|
|
1491
|
+
modal_new_subcat_title: "Nueva Subcategoría",
|
|
1492
|
+
label_name: "Nombre",
|
|
1493
|
+
label_color: "Color",
|
|
1494
|
+
label_parent_category: "Categoría Padre (Solo Lectura)",
|
|
1495
|
+
toast_success_cat: "¡Categoría creada con éxito!",
|
|
1496
|
+
toast_success_subcat: "¡Subcategoría creada con éxito!",
|
|
1497
|
+
|
|
1498
|
+
// Cards Dashboard
|
|
1499
|
+
cards_title: "Tarjetas de Crédito",
|
|
1500
|
+
cards_subtitle: "Gestione tarjetas de crédito, límites y facturas",
|
|
1501
|
+
card_bill_details: "Detalle de Factura",
|
|
1502
|
+
btn_pay_bill: "Pagar Factura",
|
|
1503
|
+
btn_revert_payment: "Revertir Pago",
|
|
1504
|
+
bill_status: "Estado de la Factura:",
|
|
1505
|
+
status_open: "Abierta",
|
|
1506
|
+
status_closed: "Cerrada",
|
|
1507
|
+
status_paid: "Pagada",
|
|
1508
|
+
no_card_transactions: "Ninguna transacción registrada en esta factura para el ciclo seleccionado.",
|
|
1509
|
+
|
|
1510
|
+
// Dashboards Manager Dashboard
|
|
1511
|
+
dashboards_title: "Gestor de Dashboards",
|
|
1512
|
+
dashboards_subtitle: "Liste, vea el código fuente y suba dashboards al servidor de patty",
|
|
1513
|
+
col_dashboard: "Dashboard",
|
|
1514
|
+
col_last_update: "Última Actualización",
|
|
1515
|
+
btn_view_source: "Ver Código",
|
|
1516
|
+
btn_download: "Descargar HTML",
|
|
1517
|
+
upload_new_dashboard: "Subir Nuevo Dashboard",
|
|
1518
|
+
placeholder_dashboard_name: "Nombre del Dashboard (ej: pending)",
|
|
1519
|
+
upload_instructions: "Seleccione o arrastre el archivo HTML aquí para subir",
|
|
1520
|
+
btn_upload: "Subir Dashboard",
|
|
1521
|
+
modal_source_title: "Código Fuente HTML",
|
|
1522
|
+
|
|
1523
|
+
// Tags Management
|
|
1524
|
+
menu_tags: "Etiquetas",
|
|
1525
|
+
tags_title: "Administrar Etiquetas",
|
|
1526
|
+
tags_subtitle: "Administre las etiquetas utilizadas para etiquetar y organizar sus transacciones",
|
|
1527
|
+
panel_title_tags: "Etiquetas Activas",
|
|
1528
|
+
btn_new_tag: "Nueva Etiqueta",
|
|
1529
|
+
label_tag_name: "Nombre de la Etiqueta",
|
|
1530
|
+
placeholder_tag_name: "Ej: trabajo, viaje, reembolso",
|
|
1531
|
+
empty_tags_message: "No hay etiquetas registradas.",
|
|
1532
|
+
btn_save: "Guardar",
|
|
1533
|
+
btn_cancel: "Cancelar",
|
|
1534
|
+
toast_success_tag_created: '¡Etiqueta "{name}" creada con éxito!',
|
|
1535
|
+
toast_success_tag_deleted: '¡Etiqueta "{name}" eliminada con éxito!',
|
|
1536
|
+
confirm_delete_tag: '¿Realmente deseja eliminar la etiqueta "{name}"?\n(Esta acción eliminará la etiqueta de todas las transacciones vinculadas)'
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
|
|
1540
|
+
var currentLocale = 'en'; // English as default
|
|
1541
|
+
|
|
1542
|
+
// Helper to translate in JS
|
|
1543
|
+
function t(key) {
|
|
1544
|
+
const tDict = TRANSLATIONS[currentLocale] || TRANSLATIONS['en'];
|
|
1545
|
+
return tDict[key] || key;
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
async function checkLocale() {
|
|
1549
|
+
try {
|
|
1550
|
+
const res = await fetch('/api/status');
|
|
1551
|
+
if (res.ok) {
|
|
1552
|
+
const data = await res.json();
|
|
1553
|
+
if (data.locale && TRANSLATIONS[data.locale]) {
|
|
1554
|
+
currentLocale = data.locale;
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
} catch (err) {
|
|
1558
|
+
console.error("Failed to read locale preferences:", err);
|
|
1559
|
+
}
|
|
1560
|
+
translatePage();
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
function translatePage() {
|
|
1564
|
+
const tDict = TRANSLATIONS[currentLocale] || TRANSLATIONS['en'];
|
|
1565
|
+
|
|
1566
|
+
// 1. Static texts
|
|
1567
|
+
document.querySelectorAll('[data-i18n]').forEach(el => {
|
|
1568
|
+
const key = el.getAttribute('data-i18n');
|
|
1569
|
+
if (tDict[key]) {
|
|
1570
|
+
const icon = el.querySelector('i');
|
|
1571
|
+
if (icon) {
|
|
1572
|
+
const iconOuter = icon.outerHTML;
|
|
1573
|
+
el.innerHTML = iconOuter + ' ' + tDict[key];
|
|
1574
|
+
} else {
|
|
1575
|
+
el.textContent = tDict[key];
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
|
|
1580
|
+
// 2. Placeholders
|
|
1581
|
+
document.querySelectorAll('[data-i18n-placeholder]').forEach(el => {
|
|
1582
|
+
const key = el.getAttribute('data-i18n-placeholder');
|
|
1583
|
+
if (tDict[key]) {
|
|
1584
|
+
el.placeholder = tDict[key];
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
|
|
1588
|
+
// 3. Tooltips
|
|
1589
|
+
document.querySelectorAll('[data-i18n-tooltip]').forEach(el => {
|
|
1590
|
+
const key = el.getAttribute('data-i18n-tooltip');
|
|
1591
|
+
if (tDict[key]) {
|
|
1592
|
+
el.setAttribute('data-tooltip', tDict[key]);
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
// 4. Document title translation
|
|
1597
|
+
if (tDict['overview_title'] && document.title.includes("Overview") || document.title.includes("Visão")) {
|
|
1598
|
+
// dynamic title update fallback if needed
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
// 5. Translate select months
|
|
1602
|
+
const monthSelects = [
|
|
1603
|
+
document.getElementById('month-select'),
|
|
1604
|
+
document.getElementById('start-month-select')
|
|
1605
|
+
];
|
|
1606
|
+
monthSelects.forEach(monthSelect => {
|
|
1607
|
+
if (monthSelect) {
|
|
1608
|
+
const monthKeys = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
|
|
1609
|
+
Array.from(monthSelect.options).forEach((opt, idx) => {
|
|
1610
|
+
const key = monthKeys[idx];
|
|
1611
|
+
if (tDict[key]) {
|
|
1612
|
+
opt.textContent = tDict[key];
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
|
|
1618
|
+
// 6. Translate projection months select options (3, 6, 9, 12 months)
|
|
1619
|
+
const hmSelect = document.getElementById('heatmap-months-select');
|
|
1620
|
+
if (hmSelect) {
|
|
1621
|
+
Array.from(hmSelect.options).forEach(opt => {
|
|
1622
|
+
const val = opt.value;
|
|
1623
|
+
const key = `months_${val}`;
|
|
1624
|
+
if (tDict[key]) {
|
|
1625
|
+
opt.textContent = tDict[key];
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
// Automatically initialize/refresh custom selects on all pages
|
|
1631
|
+
if (typeof initCustomSelects === 'function') {
|
|
1632
|
+
initCustomSelects();
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
// Custom Select Component implementation
|
|
1637
|
+
function initCustomSelects() {
|
|
1638
|
+
document.querySelectorAll('select.select-custom').forEach(select => {
|
|
1639
|
+
if (select.nextElementSibling && select.nextElementSibling.classList.contains('select-container-custom')) {
|
|
1640
|
+
// Already initialized, just sync selected value
|
|
1641
|
+
const container = select.nextElementSibling;
|
|
1642
|
+
const triggerSpan = container.querySelector('.select-trigger-custom span');
|
|
1643
|
+
const selectedOpt = select.options[select.selectedIndex];
|
|
1644
|
+
if (selectedOpt && triggerSpan) {
|
|
1645
|
+
triggerSpan.textContent = selectedOpt.textContent;
|
|
1646
|
+
}
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
select.style.display = 'none';
|
|
1650
|
+
const container = document.createElement('div');
|
|
1651
|
+
container.className = 'select-container-custom';
|
|
1652
|
+
|
|
1653
|
+
// Match specific element custom min-widths
|
|
1654
|
+
if (select.id === 'heatmap-months-select') {
|
|
1655
|
+
container.style.minWidth = '110px';
|
|
1656
|
+
} else if (select.id === 'year-select') {
|
|
1657
|
+
container.style.minWidth = '90px';
|
|
1658
|
+
} else if (select.id === 'filter-type') {
|
|
1659
|
+
container.style.minWidth = '130px';
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
const trigger = document.createElement('div');
|
|
1663
|
+
trigger.className = 'select-trigger-custom';
|
|
1664
|
+
const triggerSpan = document.createElement('span');
|
|
1665
|
+
trigger.appendChild(triggerSpan);
|
|
1666
|
+
container.appendChild(trigger);
|
|
1667
|
+
const optionsContainer = document.createElement('div');
|
|
1668
|
+
optionsContainer.className = 'select-options-custom';
|
|
1669
|
+
container.appendChild(optionsContainer);
|
|
1670
|
+
|
|
1671
|
+
function syncSelected() {
|
|
1672
|
+
const selectedOpt = select.options[select.selectedIndex] || select.options[0];
|
|
1673
|
+
if (selectedOpt) {
|
|
1674
|
+
triggerSpan.textContent = selectedOpt.textContent;
|
|
1675
|
+
Array.from(optionsContainer.children).forEach(child => {
|
|
1676
|
+
if (child.getAttribute('data-value') === select.value) {
|
|
1677
|
+
child.classList.add('selected');
|
|
1678
|
+
} else {
|
|
1679
|
+
child.classList.remove('selected');
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
function populateOptions() {
|
|
1686
|
+
optionsContainer.innerHTML = '';
|
|
1687
|
+
Array.from(select.options).forEach(opt => {
|
|
1688
|
+
const optDiv = document.createElement('div');
|
|
1689
|
+
optDiv.className = 'select-option-custom';
|
|
1690
|
+
optDiv.textContent = opt.textContent;
|
|
1691
|
+
optDiv.setAttribute('data-value', opt.value);
|
|
1692
|
+
optDiv.addEventListener('click', (e) => {
|
|
1693
|
+
e.stopPropagation();
|
|
1694
|
+
select.value = opt.value;
|
|
1695
|
+
select.dispatchEvent(new Event('change'));
|
|
1696
|
+
syncSelected();
|
|
1697
|
+
container.classList.remove('open');
|
|
1698
|
+
});
|
|
1699
|
+
optionsContainer.appendChild(optDiv);
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
populateOptions();
|
|
1704
|
+
syncSelected();
|
|
1705
|
+
|
|
1706
|
+
trigger.addEventListener('click', (e) => {
|
|
1707
|
+
e.stopPropagation();
|
|
1708
|
+
const isOpen = container.classList.contains('open');
|
|
1709
|
+
document.querySelectorAll('.select-container-custom').forEach(el => {
|
|
1710
|
+
el.classList.remove('open');
|
|
1711
|
+
});
|
|
1712
|
+
if (!isOpen) {
|
|
1713
|
+
populateOptions();
|
|
1714
|
+
syncSelected();
|
|
1715
|
+
container.classList.add('open');
|
|
1716
|
+
setTimeout(() => {
|
|
1717
|
+
const selectedEl = optionsContainer.querySelector('.select-option-custom.selected');
|
|
1718
|
+
if (selectedEl) {
|
|
1719
|
+
const itemHeight = selectedEl.offsetHeight || 36;
|
|
1720
|
+
optionsContainer.scrollTop = Math.max(0, selectedEl.offsetTop - itemHeight);
|
|
1721
|
+
}
|
|
1722
|
+
}, 10);
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
|
|
1726
|
+
select.parentNode.insertBefore(container, select.nextSibling);
|
|
1727
|
+
select.addEventListener('change', syncSelected);
|
|
1728
|
+
|
|
1729
|
+
// Watch for dynamic options updates
|
|
1730
|
+
const observer = new MutationObserver(() => {
|
|
1731
|
+
syncSelected();
|
|
1732
|
+
});
|
|
1733
|
+
observer.observe(select, { childList: true, subtree: true });
|
|
1734
|
+
|
|
1735
|
+
setTimeout(syncSelected, 200);
|
|
1736
|
+
setTimeout(syncSelected, 1000);
|
|
1737
|
+
});
|
|
1738
|
+
|
|
1739
|
+
// Global click listener to close options dropdowns when clicking outside
|
|
1740
|
+
if (!window.customSelectGlobalBound) {
|
|
1741
|
+
window.customSelectGlobalBound = true;
|
|
1742
|
+
document.addEventListener('click', () => {
|
|
1743
|
+
document.querySelectorAll('.select-container-custom').forEach(el => {
|
|
1744
|
+
el.classList.remove('open');
|
|
1745
|
+
});
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
|
|
1751
|
+
var monthSelect = document.getElementById('month-select');
|
|
1752
|
+
var yearSelect = document.getElementById('year-select');
|
|
1753
|
+
|
|
1754
|
+
// Sync with query params or local date
|
|
1755
|
+
var params = new URLSearchParams(window.location.search);
|
|
1756
|
+
var queryMonth = parseInt(params.get('month'));
|
|
1757
|
+
var queryYear = parseInt(params.get('year'));
|
|
1758
|
+
|
|
1759
|
+
var now = new Date();
|
|
1760
|
+
selectedMonth = !isNaN(queryMonth) ? queryMonth : (now.getMonth() + 1);
|
|
1761
|
+
selectedYear = !isNaN(queryYear) ? queryYear : now.getFullYear();
|
|
1762
|
+
|
|
1763
|
+
if (monthSelect) monthSelect.value = selectedMonth;
|
|
1764
|
+
if (yearSelect) yearSelect.value = selectedYear;
|
|
1765
|
+
|
|
1766
|
+
// Handle date filter change
|
|
1767
|
+
var handleFilterChange = () => {
|
|
1768
|
+
selectedMonth = parseInt(monthSelect.value);
|
|
1769
|
+
selectedYear = parseInt(yearSelect.value);
|
|
1770
|
+
|
|
1771
|
+
// Update URL params quietly (without page reload)
|
|
1772
|
+
const newUrl = `${window.location.pathname}?month=${selectedMonth}&year=${selectedYear}`;
|
|
1773
|
+
window.history.pushState({ path: newUrl }, '', newUrl);
|
|
1774
|
+
|
|
1775
|
+
loadDashboardData();
|
|
1776
|
+
};
|
|
1777
|
+
|
|
1778
|
+
// Locale must resolve before the first render: loadDashboardData's render chain now
|
|
1779
|
+
// includes renderNetWorth(), which reads currentLocale via t() — unlike the static
|
|
1780
|
+
// data-i18n elements translatePage() fixes up later, that dynamically-built badge is
|
|
1781
|
+
// never revisited once /api/status resolves, so a fire-and-forget checkLocale() would
|
|
1782
|
+
// race it and could leave non-English users with an English label (mirrors budget.html's
|
|
1783
|
+
// await-then-load init sequencing). The live-update hook is registered only after
|
|
1784
|
+
// checkLocale() resolves too — the shell connects its SSE feed as soon as this fragment's
|
|
1785
|
+
// script finishes executing (synchronously, before any awaited promise here settles), so
|
|
1786
|
+
// registering the hook any earlier would let an early-arriving event call
|
|
1787
|
+
// loadDashboardData() while currentLocale is still unresolved, reintroducing the same race
|
|
1788
|
+
// through a second, concurrent path. The month/year filter listeners are gated the same
|
|
1789
|
+
// way and for the same reason: attached here rather than above, so a user who changes
|
|
1790
|
+
// either select before locale resolves can't trigger a loadDashboardData() call that
|
|
1791
|
+
// renders renderNetWorth() (or anything else locale-dependent) in English regardless of
|
|
1792
|
+
// their actual locale.
|
|
1793
|
+
//
|
|
1794
|
+
// ownFragmentMarker is captured before the await so that, if the user navigates to a
|
|
1795
|
+
// different dashboard while checkLocale()'s request is still in flight, this stale
|
|
1796
|
+
// continuation can detect it's no longer live (app.js's renderFragment() removes this
|
|
1797
|
+
// fragment's DOM on navigation) and bail out — otherwise it would overwrite the new
|
|
1798
|
+
// fragment's own window.onAppDataChanged with overview's, misrouting later SSE events,
|
|
1799
|
+
// and wire up filter listeners against a torn-down fragment.
|
|
1800
|
+
// The initial load is kicked off before the hook is registered (not after), matching every
|
|
1801
|
+
// other default dashboard's convention: a stray SSE message must never reach a handler
|
|
1802
|
+
// whose own first render hasn't been kicked off yet.
|
|
1803
|
+
(async function initOverview() {
|
|
1804
|
+
const ownFragmentMarker = document.getElementById('dashboard-loading');
|
|
1805
|
+
await checkLocale();
|
|
1806
|
+
if (!ownFragmentMarker || !ownFragmentMarker.isConnected) return;
|
|
1807
|
+
if (monthSelect) monthSelect.addEventListener('change', handleFilterChange);
|
|
1808
|
+
if (yearSelect) yearSelect.addEventListener('change', handleFilterChange);
|
|
1809
|
+
loadDashboardData();
|
|
1810
|
+
window.onAppDataChanged = handleAppDataChanged;
|
|
1811
|
+
})();
|
|
1812
|
+
|
|
1813
|
+
// Main data loading orchestrator
|
|
1814
|
+
async function loadDashboardData() {
|
|
1815
|
+
const loadingOverlay = document.getElementById('dashboard-loading');
|
|
1816
|
+
if (loadingOverlay) loadingOverlay.classList.add('active');
|
|
1817
|
+
|
|
1818
|
+
try {
|
|
1819
|
+
const projectedAsOfStr = `${selectedYear}-${String(selectedMonth).padStart(2, '0')}-${getLastDay(selectedYear, selectedMonth)}`;
|
|
1820
|
+
|
|
1821
|
+
// 1. Fetch metadata (accounts, balances, cards, categories) in parallel
|
|
1822
|
+
const [accountsData, balancesData, cardsData, categoriesData] = await Promise.all([
|
|
1823
|
+
fetch('/api/accounts').then(r => r.json()),
|
|
1824
|
+
fetch(`/api/accounts/balances?projectedAsOf=${projectedAsOfStr}`).then(r => r.json()).catch(err => {
|
|
1825
|
+
console.error("Failed to load balances", err);
|
|
1826
|
+
return { balances: [], consolidatedNetWorth: null };
|
|
1827
|
+
}),
|
|
1828
|
+
fetch('/api/credit-cards').then(r => r.json()),
|
|
1829
|
+
fetch('/api/categories').then(r => r.json())
|
|
1830
|
+
]);
|
|
1831
|
+
|
|
1832
|
+
// Map balances to accounts
|
|
1833
|
+
accounts = accountsData.map(acc => {
|
|
1834
|
+
const balInfo = (balancesData.balances || []).find(b => b.name === acc.name) || { balance: acc.initialBalance || 0 };
|
|
1835
|
+
return {
|
|
1836
|
+
...acc,
|
|
1837
|
+
balance: typeof balInfo.balance !== 'undefined' ? balInfo.balance : acc.initialBalance
|
|
1838
|
+
};
|
|
1839
|
+
});
|
|
1840
|
+
consolidatedNetWorth = balancesData.consolidatedNetWorth || null;
|
|
1841
|
+
|
|
1842
|
+
creditCards = cardsData;
|
|
1843
|
+
categories = categoriesData;
|
|
1844
|
+
|
|
1845
|
+
// 2. Fetch monthly transactions via cursor pagination (preventing 50-limit truncation)
|
|
1846
|
+
allTransactions = await fetchMonthTransactions(selectedYear, selectedMonth);
|
|
1847
|
+
|
|
1848
|
+
// 3. Fetch credit card bills of the next cycle (the one currently open/accumulating during selectedMonth)
|
|
1849
|
+
let nextMonth = selectedMonth + 1;
|
|
1850
|
+
let nextYear = selectedYear;
|
|
1851
|
+
if (nextMonth === 13) {
|
|
1852
|
+
nextMonth = 1;
|
|
1853
|
+
nextYear += 1;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
const billPromises = creditCards.map(async card => {
|
|
1857
|
+
try {
|
|
1858
|
+
const res = await fetch(`/api/bills?card=${encodeURIComponent(card.name)}&month=${nextMonth}&year=${nextYear}`);
|
|
1859
|
+
if (res.ok) {
|
|
1860
|
+
return { cardName: card.name, data: await res.json() };
|
|
1861
|
+
}
|
|
1862
|
+
} catch (e) {
|
|
1863
|
+
console.error(e);
|
|
1864
|
+
}
|
|
1865
|
+
// Fallback for not created/404 bills
|
|
1866
|
+
return {
|
|
1867
|
+
cardName: card.name,
|
|
1868
|
+
data: {
|
|
1869
|
+
bill: { month: nextMonth, year: nextYear, status: 'open' },
|
|
1870
|
+
transactions: [],
|
|
1871
|
+
total: 0
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
});
|
|
1875
|
+
const cardBills = await Promise.all(billPromises);
|
|
1876
|
+
|
|
1877
|
+
// 4. Render everything
|
|
1878
|
+
renderKPIs(cardBills);
|
|
1879
|
+
renderCalendar();
|
|
1880
|
+
renderAccountsWidget();
|
|
1881
|
+
renderNetWorth();
|
|
1882
|
+
renderCardsWidget(cardBills);
|
|
1883
|
+
renderPendingWidget();
|
|
1884
|
+
renderCategoryChart();
|
|
1885
|
+
|
|
1886
|
+
} catch (err) {
|
|
1887
|
+
console.error("Error loading dashboard data:", err);
|
|
1888
|
+
showToast("Erro ao carregar os dados financeiros.", "error");
|
|
1889
|
+
} finally {
|
|
1890
|
+
if (loadingOverlay) loadingOverlay.classList.remove('active');
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
// Render KPI summary cards — every accumulator is a currency -> amount map (never a
|
|
1895
|
+
// blended scalar), so a month mixing BRL/USD/BTC activity keeps each currency's own total.
|
|
1896
|
+
function renderKPIs(cardBills) {
|
|
1897
|
+
const totalIncome = {};
|
|
1898
|
+
const effIncome = {};
|
|
1899
|
+
const pendIncome = {};
|
|
1900
|
+
|
|
1901
|
+
const totalExpense = {};
|
|
1902
|
+
const effExpense = {};
|
|
1903
|
+
const pendExpense = {};
|
|
1904
|
+
|
|
1905
|
+
allTransactions.forEach(t => {
|
|
1906
|
+
// Ignore all transfers (including bill payments)
|
|
1907
|
+
if (t.type === 'transfer') return;
|
|
1908
|
+
|
|
1909
|
+
const amount = parseFloat(t.amount) || 0;
|
|
1910
|
+
const currency = t.currency || DEFAULT_CURRENCY;
|
|
1911
|
+
const isEffective = t.status === 'effective';
|
|
1912
|
+
|
|
1913
|
+
if (t.type === 'income') {
|
|
1914
|
+
addMultiCurrency(totalIncome, currency, amount);
|
|
1915
|
+
addMultiCurrency(isEffective ? effIncome : pendIncome, currency, amount);
|
|
1916
|
+
} else if (t.type === 'expense') {
|
|
1917
|
+
addMultiCurrency(totalExpense, currency, amount);
|
|
1918
|
+
addMultiCurrency(isEffective ? effExpense : pendExpense, currency, amount);
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
|
|
1922
|
+
// Sum credit card bills in open/pending status for this month, per the card's own
|
|
1923
|
+
// (fixed-at-creation) currency.
|
|
1924
|
+
const totalBills = {};
|
|
1925
|
+
cardBills.forEach(cb => {
|
|
1926
|
+
if (cb.data && typeof cb.data.total !== 'undefined') {
|
|
1927
|
+
const cardInfo = creditCards.find(c => c.name === cb.cardName);
|
|
1928
|
+
addMultiCurrency(totalBills, (cardInfo && cardInfo.currency) || DEFAULT_CURRENCY, parseFloat(cb.data.total) || 0);
|
|
1929
|
+
}
|
|
1930
|
+
});
|
|
1931
|
+
|
|
1932
|
+
// Update KPI elements
|
|
1933
|
+
document.getElementById('kpi-income-val').textContent = formatMultiCurrency(totalIncome);
|
|
1934
|
+
document.getElementById('kpi-income-eff').textContent = formatMultiCurrency(effIncome);
|
|
1935
|
+
document.getElementById('kpi-income-pend').textContent = formatMultiCurrency(pendIncome);
|
|
1936
|
+
|
|
1937
|
+
document.getElementById('kpi-expense-val').textContent = formatMultiCurrency(totalExpense);
|
|
1938
|
+
document.getElementById('kpi-expense-eff').textContent = formatMultiCurrency(effExpense);
|
|
1939
|
+
document.getElementById('kpi-expense-pend').textContent = formatMultiCurrency(pendExpense);
|
|
1940
|
+
|
|
1941
|
+
const netBalance = {};
|
|
1942
|
+
new Set([...Object.keys(totalIncome), ...Object.keys(totalExpense)]).forEach(c => {
|
|
1943
|
+
netBalance[c] = valueIn(totalIncome, c) - valueIn(totalExpense, c);
|
|
1944
|
+
});
|
|
1945
|
+
const balElement = document.getElementById('kpi-balance-val');
|
|
1946
|
+
balElement.textContent = formatMultiCurrency(netBalance);
|
|
1947
|
+
const netBalanceCurrency = primaryCurrencyOf(netBalance);
|
|
1948
|
+
if (valueIn(netBalance, netBalanceCurrency) >= 0) {
|
|
1949
|
+
balElement.style.color = 'var(--income-color)';
|
|
1950
|
+
} else {
|
|
1951
|
+
balElement.style.color = 'var(--expense-color)';
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
document.getElementById('kpi-cards-val').textContent = formatMultiCurrency(totalBills);
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
// Render Monthly Calendar
|
|
1958
|
+
function renderCalendar() {
|
|
1959
|
+
const container = document.getElementById('calendar-days');
|
|
1960
|
+
container.innerHTML = '';
|
|
1961
|
+
|
|
1962
|
+
const firstDayDate = new Date(selectedYear, selectedMonth - 1, 1);
|
|
1963
|
+
const firstDayIndex = firstDayDate.getDay(); // 0 = Sun, 1 = Mon ...
|
|
1964
|
+
const numDays = getLastDay(selectedYear, selectedMonth);
|
|
1965
|
+
|
|
1966
|
+
const now = new Date();
|
|
1967
|
+
const isCurrentMonth = now.getFullYear() === selectedYear && (now.getMonth() + 1) === selectedMonth;
|
|
1968
|
+
const todayDay = now.getDate();
|
|
1969
|
+
|
|
1970
|
+
// Populate empty cells before day 1
|
|
1971
|
+
for (let i = 0; i < firstDayIndex; i++) {
|
|
1972
|
+
const emptyCell = document.createElement('div');
|
|
1973
|
+
emptyCell.className = 'calendar-day empty';
|
|
1974
|
+
container.appendChild(emptyCell);
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
// Populate days 1 to numDays
|
|
1978
|
+
for (let d = 1; d <= numDays; d++) {
|
|
1979
|
+
const dayStr = `${selectedYear}-${String(selectedMonth).padStart(2, '0')}-${String(d).padStart(2, '0')}`;
|
|
1980
|
+
|
|
1981
|
+
// Calculate inflows, outflows and transfers for this day — per currency, then
|
|
1982
|
+
// reduced to that day's own primary currency for this compact cell (the day's full
|
|
1983
|
+
// per-transaction breakdown, in each transaction's own currency, is one click away
|
|
1984
|
+
// via updateDayDetails).
|
|
1985
|
+
const dayIncomeByCurrency = {};
|
|
1986
|
+
const dayExpenseByCurrency = {};
|
|
1987
|
+
const dayTransferByCurrency = {};
|
|
1988
|
+
|
|
1989
|
+
allTransactions.forEach(t => {
|
|
1990
|
+
if (t.date === dayStr) {
|
|
1991
|
+
const amount = parseFloat(t.amount) || 0;
|
|
1992
|
+
const currency = t.currency || DEFAULT_CURRENCY;
|
|
1993
|
+
if (t.type === 'income') addMultiCurrency(dayIncomeByCurrency, currency, amount);
|
|
1994
|
+
else if (t.type === 'expense') addMultiCurrency(dayExpenseByCurrency, currency, amount);
|
|
1995
|
+
else if (t.type === 'transfer') addMultiCurrency(dayTransferByCurrency, currency, amount);
|
|
1996
|
+
}
|
|
1997
|
+
});
|
|
1998
|
+
|
|
1999
|
+
// Each flow picks its OWN primary currency independently — sharing one currency
|
|
2000
|
+
// across all three would silently zero out (and hide) a real flow whenever it
|
|
2001
|
+
// happened to be in a different currency than whichever flow dominated the day.
|
|
2002
|
+
const incomeCurrency = primaryCurrencyOf(dayIncomeByCurrency);
|
|
2003
|
+
const expenseCurrency = primaryCurrencyOf(dayExpenseByCurrency);
|
|
2004
|
+
const transferCurrency = primaryCurrencyOf(dayTransferByCurrency);
|
|
2005
|
+
const dayIncome = valueIn(dayIncomeByCurrency, incomeCurrency);
|
|
2006
|
+
const dayExpense = valueIn(dayExpenseByCurrency, expenseCurrency);
|
|
2007
|
+
const dayTransfer = valueIn(dayTransferByCurrency, transferCurrency);
|
|
2008
|
+
|
|
2009
|
+
const dayCell = document.createElement('div');
|
|
2010
|
+
dayCell.className = 'calendar-day';
|
|
2011
|
+
if (isCurrentMonth && d === todayDay) {
|
|
2012
|
+
dayCell.classList.add('today');
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
// Header number - Transfer (transflow) is inline in the header
|
|
2016
|
+
let transflowHtml = '';
|
|
2017
|
+
if (dayTransfer > 0) {
|
|
2018
|
+
transflowHtml = `<div class="day-flow transflow" style="padding: 0px 3px; flex-grow: 1; margin-left: 6px;">⇄ ${formatCurrencyNoSymbol(dayTransfer, transferCurrency)}</div>`;
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
let flowsHtml = '';
|
|
2022
|
+
const hasAnyFlow = magnitudeOf(dayIncomeByCurrency) > 0 || magnitudeOf(dayExpenseByCurrency) > 0 || magnitudeOf(dayTransferByCurrency) > 0;
|
|
2023
|
+
if (hasAnyFlow) {
|
|
2024
|
+
if (dayIncome > 0) {
|
|
2025
|
+
flowsHtml += `<div class="day-flow inflow">+${formatCurrencyNoSymbol(dayIncome, incomeCurrency)}</div>`;
|
|
2026
|
+
} else {
|
|
2027
|
+
flowsHtml += `<div class="day-flow" style="visibility: hidden;"> </div>`;
|
|
2028
|
+
}
|
|
2029
|
+
if (dayExpense > 0) {
|
|
2030
|
+
flowsHtml += `<div class="day-flow outflow">-${formatCurrencyNoSymbol(dayExpense, expenseCurrency)}</div>`;
|
|
2031
|
+
} else {
|
|
2032
|
+
flowsHtml += `<div class="day-flow" style="visibility: hidden;"> </div>`;
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
dayCell.innerHTML = `
|
|
2037
|
+
<div class="day-header">
|
|
2038
|
+
<span class="day-num">${d}</span>
|
|
2039
|
+
${transflowHtml}
|
|
2040
|
+
</div>
|
|
2041
|
+
<div class="day-flows">
|
|
2042
|
+
${flowsHtml}
|
|
2043
|
+
</div>
|
|
2044
|
+
`;
|
|
2045
|
+
|
|
2046
|
+
// Add click event to drilldown transactions of this day
|
|
2047
|
+
dayCell.addEventListener('click', () => updateDayDetails(d, dayStr));
|
|
2048
|
+
container.appendChild(dayCell);
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
// Select default day details to display
|
|
2052
|
+
const defaultDay = isCurrentMonth ? todayDay : 1;
|
|
2053
|
+
const defaultDateStr = `${selectedYear}-${String(selectedMonth).padStart(2, '0')}-${String(defaultDay).padStart(2, '0')}`;
|
|
2054
|
+
updateDayDetails(defaultDay, defaultDateStr);
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
// Update Daily Details Sidebar panel
|
|
2058
|
+
function updateDayDetails(dayNum, dateStr) {
|
|
2059
|
+
const titleEl = document.getElementById('calendar-details-title');
|
|
2060
|
+
const contentEl = document.getElementById('calendar-details-content');
|
|
2061
|
+
|
|
2062
|
+
titleEl.innerHTML = `<i class="fa-solid fa-calendar-day"></i> Lançamentos (${dayNum}/${String(selectedMonth).padStart(2, '0')})`;
|
|
2063
|
+
contentEl.innerHTML = '';
|
|
2064
|
+
|
|
2065
|
+
// Highlight the selected cell in the calendar
|
|
2066
|
+
const allDays = document.querySelectorAll('.calendar-day');
|
|
2067
|
+
allDays.forEach(cell => {
|
|
2068
|
+
cell.classList.remove('selected-day');
|
|
2069
|
+
const numSpan = cell.querySelector('.day-num');
|
|
2070
|
+
if (numSpan && parseInt(numSpan.textContent) === dayNum && !cell.classList.contains('empty')) {
|
|
2071
|
+
cell.classList.add('selected-day');
|
|
2072
|
+
}
|
|
2073
|
+
});
|
|
2074
|
+
|
|
2075
|
+
const matches = allTransactions.filter(t => t.date === dateStr);
|
|
2076
|
+
|
|
2077
|
+
if (matches.length === 0) {
|
|
2078
|
+
contentEl.innerHTML = `
|
|
2079
|
+
<div style="margin: auto; text-align: center; color: var(--text-muted); padding: 3rem 0;">
|
|
2080
|
+
<i class="fa-regular fa-calendar-minus" style="font-size: 2.2rem; margin-bottom: 0.75rem; color: var(--text-dark);"></i>
|
|
2081
|
+
<div style="font-size: 0.82rem; font-style: italic;">Nenhum lançamento registrado neste dia.</div>
|
|
2082
|
+
</div>
|
|
2083
|
+
`;
|
|
2084
|
+
return;
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
matches.forEach(t => {
|
|
2088
|
+
const isIncome = t.type === 'income';
|
|
2089
|
+
const isTransfer = t.type === 'transfer';
|
|
2090
|
+
|
|
2091
|
+
const item = document.createElement('div');
|
|
2092
|
+
item.style.cssText = `
|
|
2093
|
+
display: flex;
|
|
2094
|
+
justify-content: space-between;
|
|
2095
|
+
align-items: center;
|
|
2096
|
+
background: rgba(255, 255, 255, 0.02);
|
|
2097
|
+
border: 1px solid var(--panel-border);
|
|
2098
|
+
border-radius: 14px;
|
|
2099
|
+
padding: 0.75rem 1rem;
|
|
2100
|
+
transition: var(--transition-smooth);
|
|
2101
|
+
`;
|
|
2102
|
+
|
|
2103
|
+
let amountColor = 'var(--text-main)';
|
|
2104
|
+
let prefix = '';
|
|
2105
|
+
if (isIncome) {
|
|
2106
|
+
amountColor = 'var(--income-color)';
|
|
2107
|
+
prefix = '+';
|
|
2108
|
+
} else if (t.type === 'expense') {
|
|
2109
|
+
amountColor = 'var(--expense-color)';
|
|
2110
|
+
prefix = '-';
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
item.innerHTML = `
|
|
2114
|
+
<div style="display: flex; flex-direction: column; gap: 2px; max-width: 60%; text-align: left;">
|
|
2115
|
+
<span style="font-size: 0.85rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;" title="${escapeHtml(t.description)}">${escapeHtml(t.description)}</span>
|
|
2116
|
+
<span style="font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
|
2117
|
+
<i class="fa-solid fa-building-columns" style="font-size: 0.65rem;"></i> ${escapeHtml(t.accountName)} |
|
|
2118
|
+
<i class="fa-solid fa-tag" style="font-size: 0.65rem;"></i> ${escapeHtml(t.categoryName || (isTransfer ? 'Transferência' : 'Geral'))}
|
|
2119
|
+
</span>
|
|
2120
|
+
</div>
|
|
2121
|
+
<div style="text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end;">
|
|
2122
|
+
<span style="font-size: 0.88rem; font-weight: 700; color: ${amountColor}">${prefix} ${formatCurrency(t.amount, t.currency || DEFAULT_CURRENCY)}</span>
|
|
2123
|
+
<span class="badge-status ${t.status === 'effective' ? 'status-eff' : 'status-pend'}" style="font-size: 0.6rem; padding: 1px 4px;">
|
|
2124
|
+
${t.status === 'effective' ? 'Efetivado' : 'Pendente'}
|
|
2125
|
+
</span>
|
|
2126
|
+
</div>
|
|
2127
|
+
`;
|
|
2128
|
+
contentEl.appendChild(item);
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
// Widget 1: Render accounts balance
|
|
2133
|
+
function renderAccountsWidget() {
|
|
2134
|
+
const body = document.getElementById('widget-accounts-body');
|
|
2135
|
+
body.innerHTML = '';
|
|
2136
|
+
|
|
2137
|
+
// Filter out credit card accounts and sort: checking first, then by balance desc
|
|
2138
|
+
const sortedAccounts = [...accounts]
|
|
2139
|
+
.filter(acc => acc.type !== 'credit')
|
|
2140
|
+
.sort((a,b) => {
|
|
2141
|
+
if (a.type === 'checking' && b.type !== 'checking') return -1;
|
|
2142
|
+
if (a.type !== 'checking' && b.type === 'checking') return 1;
|
|
2143
|
+
return (b.balance || 0) - (a.balance || 0);
|
|
2144
|
+
});
|
|
2145
|
+
|
|
2146
|
+
const displayList = sortedAccounts.slice(0, 4);
|
|
2147
|
+
|
|
2148
|
+
if (displayList.length === 0) {
|
|
2149
|
+
body.innerHTML = `<div style="margin:auto; font-size:0.85rem; color:var(--text-muted); font-style:italic;">Nenhuma conta bancária.</div>`;
|
|
2150
|
+
return;
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
displayList.forEach(acc => {
|
|
2154
|
+
const typeLabels = {
|
|
2155
|
+
checking: 'Corrente',
|
|
2156
|
+
savings: 'Poupança',
|
|
2157
|
+
wallet: 'Dinheiro',
|
|
2158
|
+
investment: 'Investimento'
|
|
2159
|
+
};
|
|
2160
|
+
|
|
2161
|
+
const item = document.createElement('div');
|
|
2162
|
+
item.className = 'list-item';
|
|
2163
|
+
item.innerHTML = `
|
|
2164
|
+
<div class="list-item-meta">
|
|
2165
|
+
<span class="list-item-title">${escapeHtml(acc.name)}</span>
|
|
2166
|
+
<span class="list-item-subtitle">${typeLabels[acc.type] || acc.type}</span>
|
|
2167
|
+
</div>
|
|
2168
|
+
<span class="list-item-value" style="color: ${(acc.balance || 0) >= 0 ? 'var(--income-color)' : 'var(--expense-color)'}">
|
|
2169
|
+
${formatCurrency(acc.balance || 0, acc.currency || DEFAULT_CURRENCY)}
|
|
2170
|
+
</span>
|
|
2171
|
+
`;
|
|
2172
|
+
body.appendChild(item);
|
|
2173
|
+
});
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
// Render consolidated net worth (home currency) badge inside the accounts widget (ADR-026),
|
|
2177
|
+
// mirroring accounts.html's rendering — never a fabricated number: an "n.a." state when the
|
|
2178
|
+
// balances fetch didn't come back with a consolidatedNetWorth block at all.
|
|
2179
|
+
function renderNetWorth() {
|
|
2180
|
+
const el = document.getElementById('net-worth-summary');
|
|
2181
|
+
if (!el) return;
|
|
2182
|
+
|
|
2183
|
+
if (!consolidatedNetWorth) {
|
|
2184
|
+
el.innerHTML = `
|
|
2185
|
+
<div class="nw-label">${t('net_worth_label')}</div>
|
|
2186
|
+
<div class="nw-total na">${t('net_worth_unavailable')}</div>
|
|
2187
|
+
`;
|
|
2188
|
+
el.style.display = 'block';
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
const totalText = window.formatMoney(consolidatedNetWorth.total, consolidatedNetWorth.baseCurrency);
|
|
2193
|
+
const excludedCount = consolidatedNetWorth.excluded.length;
|
|
2194
|
+
el.innerHTML = `
|
|
2195
|
+
<div class="nw-label">${t('net_worth_label')}</div>
|
|
2196
|
+
<div class="nw-total">${totalText}</div>
|
|
2197
|
+
${excludedCount > 0
|
|
2198
|
+
? `<div class="nw-excluded"><i class="fa-solid fa-triangle-exclamation"></i> ${t('net_worth_excluded').replace('{n}', String(excludedCount))}</div>`
|
|
2199
|
+
: ''}
|
|
2200
|
+
`;
|
|
2201
|
+
el.style.display = 'block';
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
// Widget 2: Render Credit Card bills
|
|
2205
|
+
function renderCardsWidget(cardBills) {
|
|
2206
|
+
const body = document.getElementById('widget-cards-body');
|
|
2207
|
+
body.innerHTML = '';
|
|
2208
|
+
|
|
2209
|
+
if (cardBills.length === 0) {
|
|
2210
|
+
body.innerHTML = `<div style="margin:auto; font-size:0.85rem; color:var(--text-muted); font-style:italic;">Nenhum cartão cadastrado.</div>`;
|
|
2211
|
+
return;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
cardBills.slice(0, 4).forEach(cb => {
|
|
2215
|
+
const cardInfo = creditCards.find(c => c.name === cb.cardName) || { dueDay: 8 };
|
|
2216
|
+
const bill = cb.data ? cb.data.bill : { status: 'open' };
|
|
2217
|
+
const dueDay = cardInfo.dueDay || 8;
|
|
2218
|
+
const amount = cb.data ? (parseFloat(cb.data.total) || 0) : 0;
|
|
2219
|
+
|
|
2220
|
+
// Get cycle month of the fetched bill
|
|
2221
|
+
const billMonth = bill.month || (selectedMonth + 1 === 13 ? 1 : selectedMonth + 1);
|
|
2222
|
+
|
|
2223
|
+
const item = document.createElement('div');
|
|
2224
|
+
item.className = 'list-item';
|
|
2225
|
+
item.innerHTML = `
|
|
2226
|
+
<div class="list-item-meta">
|
|
2227
|
+
<span class="list-item-title">${escapeHtml(cb.cardName)}</span>
|
|
2228
|
+
<span class="list-item-subtitle">Vencimento: Dia ${dueDay}/${String(billMonth).padStart(2, '0')}</span>
|
|
2229
|
+
</div>
|
|
2230
|
+
<div style="text-align:right;">
|
|
2231
|
+
<div class="list-item-value">${formatCurrency(amount, cardInfo.currency || DEFAULT_CURRENCY)}</div>
|
|
2232
|
+
<span class="badge-status ${bill.status === 'paid' ? 'status-eff' : 'status-pend'}" style="font-size:0.6rem; padding:1px 4px;">
|
|
2233
|
+
${bill.status === 'paid' ? 'Paga' : 'Em Aberto'}
|
|
2234
|
+
</span>
|
|
2235
|
+
</div>
|
|
2236
|
+
`;
|
|
2237
|
+
body.appendChild(item);
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
// Widget 3: Render pending transactions of the month
|
|
2242
|
+
function renderPendingWidget() {
|
|
2243
|
+
const container = document.getElementById('pending-items-container');
|
|
2244
|
+
container.innerHTML = '';
|
|
2245
|
+
|
|
2246
|
+
// Filter all pending transactions in selectedMonth, sort by date ascending
|
|
2247
|
+
const pendings = allTransactions.filter(t => t.status === 'pending')
|
|
2248
|
+
.sort((a,b) => a.date.localeCompare(b.date));
|
|
2249
|
+
|
|
2250
|
+
const displayList = pendings.slice(0, 4);
|
|
2251
|
+
|
|
2252
|
+
if (displayList.length === 0) {
|
|
2253
|
+
container.innerHTML = `<div style="margin:auto; text-align:center; font-size:0.85rem; color:var(--text-muted); font-style:italic; padding-top:4rem;">Nenhum lançamento pendente.</div>`;
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
displayList.forEach(t => {
|
|
2258
|
+
const isIncome = t.type === 'income';
|
|
2259
|
+
const isTransfer = t.type === 'transfer';
|
|
2260
|
+
|
|
2261
|
+
const item = document.createElement('div');
|
|
2262
|
+
item.className = 'pending-item';
|
|
2263
|
+
|
|
2264
|
+
const dtObj = new Date(t.date + 'T12:00:00');
|
|
2265
|
+
const dtFmt = dtObj.toLocaleDateString('pt-BR', { day: '2-digit', month: '2-digit' });
|
|
2266
|
+
|
|
2267
|
+
item.innerHTML = `
|
|
2268
|
+
<div class="pending-meta">
|
|
2269
|
+
<span class="pending-desc">${escapeHtml(t.description)}</span>
|
|
2270
|
+
<span class="pending-date-cat">
|
|
2271
|
+
<i class="fa-solid fa-calendar" style="font-size:0.65rem;"></i> ${dtFmt} |
|
|
2272
|
+
<i class="fa-solid fa-tag" style="font-size:0.65rem;"></i> ${escapeHtml(t.categoryName || (isTransfer ? 'Transferência' : 'Geral'))}
|
|
2273
|
+
</span>
|
|
2274
|
+
</div>
|
|
2275
|
+
<div class="pending-action-area">
|
|
2276
|
+
<span class="pending-value ${isIncome ? 'income' : ''}">
|
|
2277
|
+
${isIncome ? '+' : isTransfer ? '' : '-'} ${formatCurrency(t.amount, t.currency || DEFAULT_CURRENCY)}
|
|
2278
|
+
</span>
|
|
2279
|
+
<button class="btn-action-confirm" onclick="confirmPendingTransaction('${t.id}', '${escapeJsAttr(t.description)}')">
|
|
2280
|
+
Efetivar
|
|
2281
|
+
</button>
|
|
2282
|
+
</div>
|
|
2283
|
+
`;
|
|
2284
|
+
container.appendChild(item);
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
// Action: Confirm pending transaction directly from widget
|
|
2289
|
+
async function confirmPendingTransaction(id, description) {
|
|
2290
|
+
const widgetLoading = document.getElementById('pending-widget-loading');
|
|
2291
|
+
if (widgetLoading) widgetLoading.classList.add('active');
|
|
2292
|
+
|
|
2293
|
+
try {
|
|
2294
|
+
const res = await fetch(`/api/transactions/${id}/confirm`, {
|
|
2295
|
+
method: 'POST'
|
|
2296
|
+
});
|
|
2297
|
+
|
|
2298
|
+
if (!res.ok) throw new Error("Falha ao confirmar transação no servidor.");
|
|
2299
|
+
|
|
2300
|
+
showToast(`Lançamento "${description}" efetivado com sucesso!`, 'success');
|
|
2301
|
+
// Reload dashboard data
|
|
2302
|
+
await loadDashboardData();
|
|
2303
|
+
} catch (err) {
|
|
2304
|
+
console.error("Error confirming transaction:", err);
|
|
2305
|
+
showToast(`Erro: ${err.message}`, 'error');
|
|
2306
|
+
} finally {
|
|
2307
|
+
if (widgetLoading) widgetLoading.classList.remove('active');
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
// Widget 4: Render Expense Categories Chart via Chart.js
|
|
2312
|
+
function renderCategoryChart() {
|
|
2313
|
+
// Group expenses of selectedMonth by category name (excluding transfers), per currency
|
|
2314
|
+
const expenseSums = {}; // catName -> {currency: amount}
|
|
2315
|
+
const totalExpenses = {};
|
|
2316
|
+
|
|
2317
|
+
allTransactions.forEach(t => {
|
|
2318
|
+
if (t.type === 'expense') {
|
|
2319
|
+
const amount = parseFloat(t.amount) || 0;
|
|
2320
|
+
const currency = t.currency || DEFAULT_CURRENCY;
|
|
2321
|
+
const catName = t.categoryName || 'Sem Categoria';
|
|
2322
|
+
if (!expenseSums[catName]) expenseSums[catName] = {};
|
|
2323
|
+
addMultiCurrency(expenseSums[catName], currency, amount);
|
|
2324
|
+
addMultiCurrency(totalExpenses, currency, amount);
|
|
2325
|
+
}
|
|
2326
|
+
});
|
|
2327
|
+
|
|
2328
|
+
// Chart.js needs a single numeric series, so it shows ONE real currency (never a
|
|
2329
|
+
// blended/converted total) — the KPI cards above already show every currency correctly.
|
|
2330
|
+
const chartCurrency = primaryCurrencyOf(totalExpenses);
|
|
2331
|
+
|
|
2332
|
+
// Convert to array and sort descending
|
|
2333
|
+
const dataList = Object.entries(expenseSums)
|
|
2334
|
+
.map(([name, sums]) => ({ name, val: valueIn(sums, chartCurrency) }))
|
|
2335
|
+
.filter(item => item.val > 0)
|
|
2336
|
+
.sort((a,b) => b.val - a.val);
|
|
2337
|
+
|
|
2338
|
+
// Destroy previous chart instance
|
|
2339
|
+
if (expensePieChartInstance) {
|
|
2340
|
+
expensePieChartInstance.destroy();
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
const canvas = document.getElementById('expensePieChart');
|
|
2344
|
+
const ctx = canvas.getContext('2d');
|
|
2345
|
+
|
|
2346
|
+
if (dataList.length === 0) {
|
|
2347
|
+
// Render placeholder text
|
|
2348
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
2349
|
+
ctx.font = "12px sans-serif";
|
|
2350
|
+
ctx.fillStyle = "#9ca3af";
|
|
2351
|
+
ctx.textAlign = "center";
|
|
2352
|
+
ctx.fillText(t("no_expenses_month"), canvas.width / 2, canvas.height / 2);
|
|
2353
|
+
return;
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
const labels = dataList.map(item => item.name);
|
|
2357
|
+
const values = dataList.map(item => item.val);
|
|
2358
|
+
const palette = ['#8b5cf6', '#ec4899', '#3b82f6', '#f97316', '#f59e0b', '#ef4444', '#06b6d4', '#a855f7', '#f43f5e'];
|
|
2359
|
+
|
|
2360
|
+
expensePieChartInstance = new Chart(ctx, {
|
|
2361
|
+
type: 'doughnut',
|
|
2362
|
+
data: {
|
|
2363
|
+
labels: labels,
|
|
2364
|
+
datasets: [{
|
|
2365
|
+
data: values,
|
|
2366
|
+
backgroundColor: palette.slice(0, Math.max(values.length, palette.length)),
|
|
2367
|
+
borderWidth: 1,
|
|
2368
|
+
borderColor: '#111322'
|
|
2369
|
+
}]
|
|
2370
|
+
},
|
|
2371
|
+
options: {
|
|
2372
|
+
responsive: true,
|
|
2373
|
+
maintainAspectRatio: false,
|
|
2374
|
+
plugins: {
|
|
2375
|
+
legend: { display: false }, // Hide legend for premium look
|
|
2376
|
+
tooltip: {
|
|
2377
|
+
callbacks: {
|
|
2378
|
+
label: function(ctx) {
|
|
2379
|
+
return `${ctx.label}: ${formatCurrency(ctx.raw, chartCurrency)}`;
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
},
|
|
2384
|
+
cutout: '70%'
|
|
2385
|
+
}
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
// ADR-027 Live-update listener. Declared here (hoisted) but only wired to window.onAppDataChanged
|
|
2390
|
+
// once locale detection resolves — see the initOverview IIFE above.
|
|
2391
|
+
function handleAppDataChanged(entities) {
|
|
2392
|
+
// currency_rate/userSettings included because the net-worth badge's consolidatedNetWorth is
|
|
2393
|
+
// computed from the base currency (user_settings.base_currency) and every stored exchange rate
|
|
2394
|
+
// (ADR-026) — omitting them would leave the badge stale after a rate or home-currency update
|
|
2395
|
+
// until some unrelated entity change happened to trigger a refetch.
|
|
2396
|
+
var affected = entities.some(function(tag) {
|
|
2397
|
+
return ['transaction', 'account', 'category', 'recurring', 'currency_rate', 'userSettings', 'creditCard', 'bill'].indexOf(tag) !== -1;
|
|
2398
|
+
});
|
|
2399
|
+
if (affected) {
|
|
2400
|
+
console.log("overview refetching due to entity change:", entities);
|
|
2401
|
+
loadDashboardData();
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
</script>
|