@rfc0/patty 0.0.0-stage → 1.0.0
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 +493 -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 +1716 -0
- package/ui/dashboards/cards.html +4032 -0
- package/ui/dashboards/categories.html +4694 -0
- package/ui/dashboards/comparative.html +2464 -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 +2517 -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,3189 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
.dashboard-container {
|
|
3
|
+
max-width: 1400px;
|
|
4
|
+
margin: 0 auto;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: 1.5rem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.controls-area {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
gap: 1rem;
|
|
14
|
+
background: var(--panel-bg);
|
|
15
|
+
border: 1px solid var(--panel-border);
|
|
16
|
+
padding: 0.5rem 1rem;
|
|
17
|
+
border-radius: 14px;
|
|
18
|
+
backdrop-filter: blur(12px);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.controls-area label {
|
|
22
|
+
font-size: 0.85rem;
|
|
23
|
+
font-weight: 600;
|
|
24
|
+
color: var(--text-muted);
|
|
25
|
+
text-transform: uppercase;
|
|
26
|
+
letter-spacing: 0.05em;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.select-custom {
|
|
30
|
+
background: rgba(255, 255, 255, 0.05);
|
|
31
|
+
border: 1px solid var(--panel-border);
|
|
32
|
+
color: var(--text-main);
|
|
33
|
+
padding: 0.5rem 1.5rem 0.5rem 0.75rem;
|
|
34
|
+
border-radius: 8px;
|
|
35
|
+
font-family: var(--font-family);
|
|
36
|
+
font-weight: 500;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
outline: none;
|
|
39
|
+
transition: var(--transition-smooth);
|
|
40
|
+
appearance: none;
|
|
41
|
+
background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
|
42
|
+
background-repeat: no-repeat;
|
|
43
|
+
background-position: right 8px center;
|
|
44
|
+
background-size: 16px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.select-custom:focus {
|
|
48
|
+
border-color: var(--accent-primary);
|
|
49
|
+
box-shadow: 0 0 0 2px var(--accent-primary-glow);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* 2-Column Sidebar Layout */
|
|
53
|
+
.workspace-grid-contas {
|
|
54
|
+
display: grid;
|
|
55
|
+
grid-template-columns: 360px 1fr;
|
|
56
|
+
gap: 1.5rem;
|
|
57
|
+
align-items: start;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@media (max-width: 1024px) {
|
|
61
|
+
.workspace-grid-contas {
|
|
62
|
+
grid-template-columns: 1fr;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.accounts-sidebar-panel {
|
|
67
|
+
background: var(--panel-bg);
|
|
68
|
+
border: 1px solid var(--panel-border);
|
|
69
|
+
border-radius: 24px;
|
|
70
|
+
padding: 1.5rem;
|
|
71
|
+
box-shadow: var(--card-shadow);
|
|
72
|
+
backdrop-filter: blur(16px);
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
gap: 1.25rem;
|
|
76
|
+
position: relative;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.sidebar-header {
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: 0.5rem;
|
|
83
|
+
font-size: 1.1rem;
|
|
84
|
+
font-weight: 600;
|
|
85
|
+
color: var(--text-main);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* Type filter pills */
|
|
89
|
+
.type-filter-pills {
|
|
90
|
+
display: flex;
|
|
91
|
+
gap: 0.35rem;
|
|
92
|
+
overflow-x: auto;
|
|
93
|
+
padding-bottom: 0.25rem;
|
|
94
|
+
scrollbar-width: none;
|
|
95
|
+
}
|
|
96
|
+
.type-filter-pills::-webkit-scrollbar {
|
|
97
|
+
display: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.pill-btn {
|
|
101
|
+
flex-shrink: 0;
|
|
102
|
+
background: rgba(255, 255, 255, 0.04);
|
|
103
|
+
border: 1px solid var(--panel-border);
|
|
104
|
+
color: var(--text-muted);
|
|
105
|
+
padding: 0.35rem 0.75rem;
|
|
106
|
+
border-radius: 20px;
|
|
107
|
+
font-family: var(--font-family);
|
|
108
|
+
font-size: 0.75rem;
|
|
109
|
+
font-weight: 600;
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
transition: var(--transition-smooth);
|
|
112
|
+
border: 1px solid var(--panel-border);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.pill-btn:hover {
|
|
116
|
+
background: rgba(255, 255, 255, 0.08);
|
|
117
|
+
color: var(--text-main);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.pill-btn.active {
|
|
121
|
+
background: var(--accent-primary);
|
|
122
|
+
color: #fff;
|
|
123
|
+
border-color: var(--accent-primary);
|
|
124
|
+
box-shadow: 0 2px 8px var(--accent-primary-glow);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* Accounts vertical list */
|
|
128
|
+
.accounts-list-vertical {
|
|
129
|
+
display: flex;
|
|
130
|
+
flex-direction: column;
|
|
131
|
+
gap: 0.75rem;
|
|
132
|
+
overflow-y: auto;
|
|
133
|
+
padding-right: 0.25rem;
|
|
134
|
+
max-height: calc(100vh - 280px);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.accounts-list-vertical::-webkit-scrollbar {
|
|
138
|
+
width: 4px;
|
|
139
|
+
}
|
|
140
|
+
.accounts-list-vertical::-webkit-scrollbar-track {
|
|
141
|
+
background: transparent;
|
|
142
|
+
}
|
|
143
|
+
.accounts-list-vertical::-webkit-scrollbar-thumb {
|
|
144
|
+
background: var(--panel-border);
|
|
145
|
+
border-radius: 4px;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* Account Card compact design */
|
|
149
|
+
.account-card {
|
|
150
|
+
border-radius: 12px;
|
|
151
|
+
padding: 1rem;
|
|
152
|
+
display: flex;
|
|
153
|
+
justify-content: space-between;
|
|
154
|
+
align-items: center;
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
157
|
+
transition: var(--transition-smooth);
|
|
158
|
+
border: 2px solid transparent;
|
|
159
|
+
user-select: none;
|
|
160
|
+
min-height: auto;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.account-card:hover {
|
|
164
|
+
transform: translateX(4px);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.account-card.active {
|
|
168
|
+
border-color: rgba(255, 255, 255, 0.45);
|
|
169
|
+
box-shadow: 0 0 15px rgba(139, 92, 246, 0.25);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.acc-info-left {
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-direction: column;
|
|
175
|
+
gap: 0.15rem;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.acc-name-title {
|
|
179
|
+
font-size: 0.9rem;
|
|
180
|
+
font-weight: 700;
|
|
181
|
+
color: #fff;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.acc-sub-type {
|
|
185
|
+
font-size: 0.65rem;
|
|
186
|
+
color: var(--text-muted);
|
|
187
|
+
text-transform: uppercase;
|
|
188
|
+
letter-spacing: 0.05em;
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
gap: 0.25rem;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.acc-info-right {
|
|
195
|
+
text-align: right;
|
|
196
|
+
display: flex;
|
|
197
|
+
flex-direction: column;
|
|
198
|
+
gap: 0.1rem;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.acc-current-bal {
|
|
202
|
+
font-size: 0.95rem;
|
|
203
|
+
font-weight: 800;
|
|
204
|
+
color: #fff;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.acc-projected-bal {
|
|
208
|
+
font-size: 0.7rem;
|
|
209
|
+
color: var(--text-muted);
|
|
210
|
+
}
|
|
211
|
+
.acc-projected-bal span {
|
|
212
|
+
color: var(--income-color);
|
|
213
|
+
font-weight: 600;
|
|
214
|
+
}
|
|
215
|
+
.acc-projected-bal.negative span {
|
|
216
|
+
color: var(--expense-color);
|
|
217
|
+
font-weight: 600;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.acc-converted-bal {
|
|
221
|
+
font-size: 0.65rem;
|
|
222
|
+
color: var(--text-muted);
|
|
223
|
+
}
|
|
224
|
+
.acc-converted-bal.stale {
|
|
225
|
+
color: var(--warning-color);
|
|
226
|
+
}
|
|
227
|
+
.acc-converted-bal.na {
|
|
228
|
+
font-style: italic;
|
|
229
|
+
opacity: 0.7;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/* .net-worth-summary/.nw-* base: ui/app.css (shared with overview.html) */
|
|
233
|
+
|
|
234
|
+
/* Account Gradient themes */
|
|
235
|
+
.acc-checking {
|
|
236
|
+
background: linear-gradient(135deg, #101524 0%, #1c233a 100%);
|
|
237
|
+
border: 1px solid rgba(139, 92, 246, 0.15);
|
|
238
|
+
}
|
|
239
|
+
.acc-checking.active { border-color: var(--accent-primary); }
|
|
240
|
+
|
|
241
|
+
.acc-savings {
|
|
242
|
+
background: linear-gradient(135deg, #051c14 0%, #0d3829 100%);
|
|
243
|
+
border: 1px solid rgba(16, 185, 129, 0.15);
|
|
244
|
+
}
|
|
245
|
+
.acc-savings.active { border-color: var(--income-color); }
|
|
246
|
+
|
|
247
|
+
.acc-investment {
|
|
248
|
+
background: linear-gradient(135deg, #241108 0%, #442211 100%);
|
|
249
|
+
border: 1px solid rgba(245, 158, 11, 0.15);
|
|
250
|
+
}
|
|
251
|
+
.acc-investment.active { border-color: var(--warning-color); }
|
|
252
|
+
|
|
253
|
+
.acc-wallet {
|
|
254
|
+
background: linear-gradient(135deg, #190c28 0%, #311452 100%);
|
|
255
|
+
border: 1px solid rgba(236, 72, 153, 0.15);
|
|
256
|
+
}
|
|
257
|
+
.acc-wallet.active { border-color: #ec4899; }
|
|
258
|
+
|
|
259
|
+
/* Detail Panel */
|
|
260
|
+
/* base: ui/app.css (#164) */
|
|
261
|
+
.panel {
|
|
262
|
+
padding: 1.75rem;
|
|
263
|
+
display: flex;
|
|
264
|
+
flex-direction: column;
|
|
265
|
+
gap: 1.5rem;
|
|
266
|
+
position: relative;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.panel-header {
|
|
270
|
+
display: flex;
|
|
271
|
+
justify-content: space-between;
|
|
272
|
+
align-items: center;
|
|
273
|
+
flex-wrap: wrap;
|
|
274
|
+
gap: 1rem;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.panel-title {
|
|
278
|
+
display: flex;
|
|
279
|
+
align-items: center;
|
|
280
|
+
gap: 0.5rem;
|
|
281
|
+
font-size: 1.1rem;
|
|
282
|
+
font-weight: 600;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.panel-title i {
|
|
286
|
+
color: var(--accent-primary);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.panel-actions-group {
|
|
290
|
+
display: flex;
|
|
291
|
+
gap: 0.75rem;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.btn-panel-action {
|
|
295
|
+
padding: 0.5rem 1rem;
|
|
296
|
+
border-radius: 10px;
|
|
297
|
+
font-family: var(--font-family);
|
|
298
|
+
font-size: 0.85rem;
|
|
299
|
+
font-weight: 600;
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
transition: var(--transition-smooth);
|
|
302
|
+
display: flex;
|
|
303
|
+
align-items: center;
|
|
304
|
+
gap: 0.5rem;
|
|
305
|
+
border: 1px solid transparent;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.btn-action-income {
|
|
309
|
+
background: rgba(16, 185, 129, 0.12);
|
|
310
|
+
border-color: rgba(16, 185, 129, 0.25);
|
|
311
|
+
color: var(--income-color);
|
|
312
|
+
}
|
|
313
|
+
.btn-action-income:hover {
|
|
314
|
+
background: rgba(16, 185, 129, 0.25);
|
|
315
|
+
transform: translateY(-2px);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.btn-action-transfer {
|
|
319
|
+
background: rgba(139, 92, 246, 0.12);
|
|
320
|
+
border-color: rgba(139, 92, 246, 0.25);
|
|
321
|
+
color: var(--accent-primary);
|
|
322
|
+
}
|
|
323
|
+
.btn-action-transfer:hover {
|
|
324
|
+
background: rgba(139, 92, 246, 0.25);
|
|
325
|
+
transform: translateY(-2px);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/* base: ui/app.css (#164) */
|
|
329
|
+
.btn-action-primary {
|
|
330
|
+
font-family: var(--font-family);
|
|
331
|
+
display: inline-flex;
|
|
332
|
+
justify-content: center;
|
|
333
|
+
box-shadow: 0 4px 12px var(--accent-primary-glow);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.btn-action-primary:hover {
|
|
337
|
+
transform: translateY(-2px);
|
|
338
|
+
background: #9d76fd;
|
|
339
|
+
box-shadow: 0 6px 16px rgba(139, 92, 246, 0.45);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.btn-action-secondary {
|
|
343
|
+
background: rgba(255, 255, 255, 0.04);
|
|
344
|
+
border: 1px solid var(--panel-border);
|
|
345
|
+
color: var(--text-main);
|
|
346
|
+
padding: 0.6rem 1.25rem;
|
|
347
|
+
border-radius: 10px;
|
|
348
|
+
font-family: var(--font-family);
|
|
349
|
+
font-weight: 600;
|
|
350
|
+
cursor: pointer;
|
|
351
|
+
transition: var(--transition-smooth);
|
|
352
|
+
display: inline-flex;
|
|
353
|
+
justify-content: center;
|
|
354
|
+
align-items: center;
|
|
355
|
+
gap: 0.5rem;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.btn-action-secondary:hover {
|
|
359
|
+
background: rgba(255, 255, 255, 0.08);
|
|
360
|
+
border-color: rgba(255, 255, 255, 0.15);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* Statement Filter Search Bar */
|
|
364
|
+
.filter-bar {
|
|
365
|
+
display: flex;
|
|
366
|
+
gap: 1rem;
|
|
367
|
+
flex-wrap: wrap;
|
|
368
|
+
background: rgba(0, 0, 0, 0.15);
|
|
369
|
+
border: 1px solid var(--panel-border);
|
|
370
|
+
border-radius: 14px;
|
|
371
|
+
padding: 0.75rem;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.filter-item {
|
|
375
|
+
flex: 1;
|
|
376
|
+
min-width: 200px;
|
|
377
|
+
display: flex;
|
|
378
|
+
flex-direction: column;
|
|
379
|
+
gap: 0.35rem;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.filter-item label {
|
|
383
|
+
font-size: 0.7rem;
|
|
384
|
+
font-weight: 600;
|
|
385
|
+
color: var(--text-muted);
|
|
386
|
+
text-transform: uppercase;
|
|
387
|
+
letter-spacing: 0.05em;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.filter-control {
|
|
391
|
+
background: rgba(255, 255, 255, 0.04);
|
|
392
|
+
border: 1px solid var(--panel-border);
|
|
393
|
+
color: var(--text-main);
|
|
394
|
+
padding: 0.45rem 0.75rem;
|
|
395
|
+
border-radius: 8px;
|
|
396
|
+
font-family: var(--font-family);
|
|
397
|
+
outline: none;
|
|
398
|
+
font-size: 0.85rem;
|
|
399
|
+
transition: var(--transition-smooth);
|
|
400
|
+
}
|
|
401
|
+
.filter-control:focus {
|
|
402
|
+
border-color: var(--accent-primary);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/* Table & Statement */
|
|
406
|
+
.table-container {
|
|
407
|
+
overflow-x: auto;
|
|
408
|
+
border-radius: 14px;
|
|
409
|
+
border: 1px solid var(--panel-border);
|
|
410
|
+
background: rgba(0, 0, 0, 0.1);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
table {
|
|
414
|
+
width: 100%;
|
|
415
|
+
border-collapse: collapse;
|
|
416
|
+
text-align: left;
|
|
417
|
+
font-size: 0.9rem;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
th {
|
|
421
|
+
background: rgba(255, 255, 255, 0.02);
|
|
422
|
+
color: var(--text-muted);
|
|
423
|
+
font-weight: 600;
|
|
424
|
+
padding: 1rem;
|
|
425
|
+
border-bottom: 1px solid var(--panel-border);
|
|
426
|
+
text-transform: uppercase;
|
|
427
|
+
font-size: 0.75rem;
|
|
428
|
+
letter-spacing: 0.05em;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
th.sortable {
|
|
432
|
+
cursor: pointer;
|
|
433
|
+
user-select: none;
|
|
434
|
+
transition: var(--transition-smooth);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
th.sortable:hover {
|
|
438
|
+
color: var(--text-main);
|
|
439
|
+
background: rgba(255, 255, 255, 0.04);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
th i {
|
|
443
|
+
margin-left: 0.35rem;
|
|
444
|
+
font-size: 0.8rem;
|
|
445
|
+
transition: var(--transition-smooth);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
td {
|
|
449
|
+
padding: 0.9rem 1rem;
|
|
450
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.03);
|
|
451
|
+
vertical-align: middle;
|
|
452
|
+
color: var(--text-main);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
tr:hover td {
|
|
456
|
+
background: rgba(255, 255, 255, 0.02);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
tr:last-child td {
|
|
460
|
+
border-bottom: none;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.col-date { color: var(--text-muted); white-space: nowrap; }
|
|
464
|
+
.col-desc { font-weight: 500; }
|
|
465
|
+
.badge-cat {
|
|
466
|
+
background: rgba(255, 255, 255, 0.04);
|
|
467
|
+
border: 1px solid var(--panel-border);
|
|
468
|
+
padding: 0.25rem 0.6rem;
|
|
469
|
+
border-radius: 6px;
|
|
470
|
+
font-size: 0.8rem;
|
|
471
|
+
color: var(--text-muted);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
.badge-type-icon {
|
|
475
|
+
font-size: 1rem;
|
|
476
|
+
display: inline-flex;
|
|
477
|
+
align-items: center;
|
|
478
|
+
justify-content: center;
|
|
479
|
+
}
|
|
480
|
+
.type-income { color: var(--income-color); }
|
|
481
|
+
.type-expense { color: var(--expense-color); }
|
|
482
|
+
.type-transfer { color: var(--accent-primary); }
|
|
483
|
+
|
|
484
|
+
.amount-cell {
|
|
485
|
+
font-weight: 700;
|
|
486
|
+
text-align: right;
|
|
487
|
+
white-space: nowrap;
|
|
488
|
+
}
|
|
489
|
+
.amount-cell.income { color: var(--income-color); }
|
|
490
|
+
.amount-cell.expense { color: var(--expense-color); }
|
|
491
|
+
.amount-cell.transfer { color: var(--text-main); }
|
|
492
|
+
|
|
493
|
+
.actions-cell {
|
|
494
|
+
display: flex;
|
|
495
|
+
justify-content: center;
|
|
496
|
+
align-items: center;
|
|
497
|
+
gap: 0.75rem;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.action-btn {
|
|
501
|
+
background: transparent;
|
|
502
|
+
border: none;
|
|
503
|
+
cursor: pointer;
|
|
504
|
+
font-size: 1rem;
|
|
505
|
+
display: inline-flex;
|
|
506
|
+
align-items: center;
|
|
507
|
+
justify-content: center;
|
|
508
|
+
width: 28px;
|
|
509
|
+
height: 28px;
|
|
510
|
+
border-radius: 6px;
|
|
511
|
+
transition: var(--transition-smooth);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
.btn-edit-icon { color: var(--accent-primary); opacity: 0.65; }
|
|
515
|
+
.btn-edit-icon:hover { opacity: 1; transform: scale(1.25); }
|
|
516
|
+
|
|
517
|
+
.btn-delete-icon { color: var(--expense-color); opacity: 0.65; }
|
|
518
|
+
.btn-delete-icon:hover { opacity: 1; transform: scale(1.25); }
|
|
519
|
+
|
|
520
|
+
.action-btn[disabled] {
|
|
521
|
+
opacity: 0.15 !important;
|
|
522
|
+
cursor: not-allowed !important;
|
|
523
|
+
pointer-events: none !important;
|
|
524
|
+
transform: none !important;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/* Loader (.loading-overlay/.spinner base: ui/app.css, #164) */
|
|
528
|
+
.loading-overlay {
|
|
529
|
+
width: 100%; height: 100%;
|
|
530
|
+
border-radius: 24px;
|
|
531
|
+
opacity: 0; pointer-events: none;
|
|
532
|
+
transition: opacity 0.25s ease;
|
|
533
|
+
}
|
|
534
|
+
.loading-overlay.active { opacity: 1; pointer-events: all; }
|
|
535
|
+
|
|
536
|
+
.no-data-msg {
|
|
537
|
+
text-align: center;
|
|
538
|
+
padding: 3rem;
|
|
539
|
+
color: var(--text-dark);
|
|
540
|
+
font-weight: 500;
|
|
541
|
+
}
|
|
542
|
+
.no-data-msg i {
|
|
543
|
+
font-size: 2.5rem;
|
|
544
|
+
margin-bottom: 0.75rem;
|
|
545
|
+
display: block;
|
|
546
|
+
opacity: 0.5;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/* Modal Dialog systems (.modal-overlay/.modal-box/.modal-title base: ui/app.css, #164) */
|
|
550
|
+
.modal-overlay {
|
|
551
|
+
width: 100%; height: 100%;
|
|
552
|
+
}
|
|
553
|
+
.modal-overlay.open {
|
|
554
|
+
display: flex;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/* Split modal container rules */
|
|
558
|
+
.modal-box.split-modal {
|
|
559
|
+
max-width: 780px;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.modal-split-body {
|
|
563
|
+
display: grid;
|
|
564
|
+
grid-template-columns: 1.1fr 1fr;
|
|
565
|
+
gap: 1.5rem;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.modal-column-left {
|
|
569
|
+
display: flex;
|
|
570
|
+
flex-direction: column;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.modal-column-right {
|
|
574
|
+
display: flex;
|
|
575
|
+
flex-direction: column;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.textarea-large {
|
|
579
|
+
width: 100%;
|
|
580
|
+
flex: 1;
|
|
581
|
+
min-height: 250px;
|
|
582
|
+
background: rgba(255, 255, 255, 0.04);
|
|
583
|
+
border: 1px solid var(--panel-border);
|
|
584
|
+
color: var(--text-main);
|
|
585
|
+
padding: 0.75rem;
|
|
586
|
+
border-radius: 8px;
|
|
587
|
+
font-family: var(--font-family);
|
|
588
|
+
outline: none;
|
|
589
|
+
transition: var(--transition-smooth);
|
|
590
|
+
resize: none;
|
|
591
|
+
font-size: 0.9rem;
|
|
592
|
+
}
|
|
593
|
+
.textarea-large:focus {
|
|
594
|
+
border-color: var(--accent-primary);
|
|
595
|
+
box-shadow: 0 0 0 2px var(--accent-primary-glow);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.modal-close-btn {
|
|
599
|
+
position: absolute;
|
|
600
|
+
top: 1.25rem;
|
|
601
|
+
right: 1.25rem;
|
|
602
|
+
background: none;
|
|
603
|
+
border: none;
|
|
604
|
+
color: var(--text-dark);
|
|
605
|
+
cursor: pointer;
|
|
606
|
+
font-size: 1.2rem;
|
|
607
|
+
transition: var(--transition-smooth);
|
|
608
|
+
}
|
|
609
|
+
.modal-close-btn:hover {
|
|
610
|
+
color: var(--text-main);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
.modal-title {
|
|
614
|
+
margin-bottom: 1.5rem;
|
|
615
|
+
color: #fff;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.form-group {
|
|
619
|
+
margin-bottom: 1rem;
|
|
620
|
+
display: flex;
|
|
621
|
+
flex-direction: column;
|
|
622
|
+
gap: 0.35rem;
|
|
623
|
+
position: relative;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/* .form-group label / .form-control base: ui/app.css (#164) */
|
|
627
|
+
.form-control {
|
|
628
|
+
outline: none;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/* Searchable autocomplete select CSS styling */
|
|
632
|
+
.searchable-select-wrapper {
|
|
633
|
+
position: relative;
|
|
634
|
+
width: 100%;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.searchable-select-input-container {
|
|
638
|
+
position: relative;
|
|
639
|
+
display: flex;
|
|
640
|
+
align-items: center;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
.searchable-select-input-container i {
|
|
644
|
+
position: absolute;
|
|
645
|
+
right: 12px;
|
|
646
|
+
color: var(--text-muted);
|
|
647
|
+
pointer-events: none;
|
|
648
|
+
font-size: 0.85rem;
|
|
649
|
+
transition: transform 0.25s ease;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.searchable-select-wrapper.open .searchable-select-input-container i {
|
|
653
|
+
transform: rotate(180deg);
|
|
654
|
+
color: var(--accent-primary);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
.searchable-select-dropdown {
|
|
658
|
+
position: absolute;
|
|
659
|
+
top: 100%;
|
|
660
|
+
left: 0;
|
|
661
|
+
right: 0;
|
|
662
|
+
z-index: 120;
|
|
663
|
+
background: #141727;
|
|
664
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
665
|
+
border-radius: 8px;
|
|
666
|
+
max-height: 180px;
|
|
667
|
+
overflow-y: auto;
|
|
668
|
+
box-shadow: 0 10px 25px rgba(0,0,0,0.6);
|
|
669
|
+
display: none;
|
|
670
|
+
margin-top: 4px;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
.searchable-select-dropdown::-webkit-scrollbar {
|
|
674
|
+
width: 4px;
|
|
675
|
+
}
|
|
676
|
+
.searchable-select-dropdown::-webkit-scrollbar-thumb {
|
|
677
|
+
background: rgba(255, 255, 255, 0.1);
|
|
678
|
+
border-radius: 4px;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.searchable-select-option {
|
|
682
|
+
padding: 0.6rem 0.85rem;
|
|
683
|
+
color: var(--text-main);
|
|
684
|
+
font-size: 0.85rem;
|
|
685
|
+
cursor: pointer;
|
|
686
|
+
transition: var(--transition-smooth);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.searchable-select-option:hover {
|
|
690
|
+
background: rgba(139, 92, 246, 0.18);
|
|
691
|
+
color: #fff;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.searchable-select-option.no-results {
|
|
695
|
+
color: var(--text-dark);
|
|
696
|
+
cursor: default;
|
|
697
|
+
font-style: italic;
|
|
698
|
+
text-align: center;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/* Dark datepicker input custom style overrides */
|
|
702
|
+
input[type="date"]::-webkit-calendar-picker-indicator {
|
|
703
|
+
filter: invert(0.9) sepia(1) saturate(5) hue-rotate(240deg);
|
|
704
|
+
cursor: pointer;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.modal-footer {
|
|
708
|
+
display: flex;
|
|
709
|
+
justify-content: flex-end;
|
|
710
|
+
gap: 0.75rem;
|
|
711
|
+
margin-top: 1.5rem;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/* Toast system (.toast-container/.toast base: ui/app.css, #164) */
|
|
715
|
+
.toast {
|
|
716
|
+
color: var(--text-main);
|
|
717
|
+
border-left: 4px solid var(--accent-primary);
|
|
718
|
+
backdrop-filter: blur(12px);
|
|
719
|
+
min-width: 300px;
|
|
720
|
+
animation: slideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
|
|
721
|
+
position: relative;
|
|
722
|
+
}
|
|
723
|
+
.toast.success { border-left-color: var(--income-color); }
|
|
724
|
+
.toast.error { border-left-color: var(--expense-color); }
|
|
725
|
+
|
|
726
|
+
.toast-close {
|
|
727
|
+
position: absolute; right: 10px; top: 50%;
|
|
728
|
+
transform: translateY(-50%);
|
|
729
|
+
color: var(--text-dark); cursor: pointer; font-size: 0.8rem;
|
|
730
|
+
}
|
|
731
|
+
.toast-close:hover { color: var(--text-main); }
|
|
732
|
+
|
|
733
|
+
@keyframes slideIn {
|
|
734
|
+
from { transform: translateX(100%); opacity: 0; }
|
|
735
|
+
to { transform: translateX(0); opacity: 1; }
|
|
736
|
+
}
|
|
737
|
+
@keyframes fadeOut {
|
|
738
|
+
to { opacity: 0; transform: translateY(20px); }
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/* Segmented control for type selections (Receita/Despesa) */
|
|
742
|
+
.segmented-control {
|
|
743
|
+
display: flex;
|
|
744
|
+
background: rgba(255, 255, 255, 0.04);
|
|
745
|
+
border: 1px solid var(--panel-border);
|
|
746
|
+
border-radius: 8px;
|
|
747
|
+
padding: 2px;
|
|
748
|
+
width: 100%;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
.segmented-btn {
|
|
752
|
+
flex: 1;
|
|
753
|
+
background: transparent;
|
|
754
|
+
border: none;
|
|
755
|
+
color: var(--text-muted);
|
|
756
|
+
padding: 0.6rem;
|
|
757
|
+
border-radius: 6px;
|
|
758
|
+
font-family: var(--font-family);
|
|
759
|
+
font-size: 0.85rem;
|
|
760
|
+
font-weight: 600;
|
|
761
|
+
cursor: pointer;
|
|
762
|
+
transition: var(--transition-smooth);
|
|
763
|
+
display: flex;
|
|
764
|
+
justify-content: center;
|
|
765
|
+
align-items: center;
|
|
766
|
+
gap: 0.35rem;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
.segmented-btn:hover {
|
|
770
|
+
color: var(--text-main);
|
|
771
|
+
background: rgba(255, 255, 255, 0.02);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
.segmented-btn.active.expense {
|
|
775
|
+
background: var(--expense-color);
|
|
776
|
+
color: #fff;
|
|
777
|
+
box-shadow: 0 2px 8px var(--expense-glow);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
.segmented-btn.active.income {
|
|
781
|
+
background: var(--income-color);
|
|
782
|
+
color: #fff;
|
|
783
|
+
box-shadow: 0 2px 8px var(--income-glow);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/* Custom Flatpickr styling overrides to match theme */
|
|
787
|
+
.flatpickr-calendar {
|
|
788
|
+
background: #111322 !important;
|
|
789
|
+
border: 1px solid var(--panel-border) !important;
|
|
790
|
+
box-shadow: 0 10px 25px rgba(0,0,0,0.6) !important;
|
|
791
|
+
font-family: var(--font-family) !important;
|
|
792
|
+
border-radius: 12px !important;
|
|
793
|
+
}
|
|
794
|
+
.flatpickr-day.selected,
|
|
795
|
+
.flatpickr-day.startRange,
|
|
796
|
+
.flatpickr-day.endRange,
|
|
797
|
+
.flatpickr-day.selected.inRange,
|
|
798
|
+
.flatpickr-day.startRange.inRange,
|
|
799
|
+
.flatpickr-day.endRange.inRange,
|
|
800
|
+
.flatpickr-day.selected:focus,
|
|
801
|
+
.flatpickr-day.startRange:focus,
|
|
802
|
+
.flatpickr-day.endRange:focus,
|
|
803
|
+
.flatpickr-day.selected:hover,
|
|
804
|
+
.flatpickr-day.startRange:hover,
|
|
805
|
+
.flatpickr-day.endRange:hover,
|
|
806
|
+
.flatpickr-day.prevMonthDay.selected,
|
|
807
|
+
.flatpickr-day.nextMonthDay.selected {
|
|
808
|
+
background: var(--accent-primary) !important;
|
|
809
|
+
border-color: var(--accent-primary) !important;
|
|
810
|
+
}
|
|
811
|
+
.flatpickr-months .flatpickr-month {
|
|
812
|
+
color: #fff !important;
|
|
813
|
+
}
|
|
814
|
+
.flatpickr-current-month .flatpickr-monthDropdown-months {
|
|
815
|
+
background: #111322 !important;
|
|
816
|
+
color: #fff !important;
|
|
817
|
+
}
|
|
818
|
+
.flatpickr-day {
|
|
819
|
+
color: var(--text-main) !important;
|
|
820
|
+
}
|
|
821
|
+
.flatpickr-day:hover {
|
|
822
|
+
background: rgba(255, 255, 255, 0.08) !important;
|
|
823
|
+
}
|
|
824
|
+
.flatpickr-day.flatpickr-disabled,
|
|
825
|
+
.flatpickr-day.flatpickr-disabled:hover {
|
|
826
|
+
color: var(--text-dark) !important;
|
|
827
|
+
background: transparent !important;
|
|
828
|
+
}
|
|
829
|
+
.flatpickr-weekday {
|
|
830
|
+
color: var(--text-muted) !important;
|
|
831
|
+
}
|
|
832
|
+
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month {
|
|
833
|
+
color: var(--text-muted) !important;
|
|
834
|
+
fill: var(--text-muted) !important;
|
|
835
|
+
}
|
|
836
|
+
.flatpickr-calendar.arrowTop:before, .flatpickr-calendar.arrowTop:after {
|
|
837
|
+
border-bottom-color: #111322 !important;
|
|
838
|
+
}
|
|
839
|
+
.flatpickr-calendar.arrowBottom:before, .flatpickr-calendar.arrowBottom:after {
|
|
840
|
+
border-top-color: #111322 !important;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/* Custom Select component styling */
|
|
844
|
+
.select-container-custom {
|
|
845
|
+
position: relative;
|
|
846
|
+
display: inline-block;
|
|
847
|
+
min-width: 120px;
|
|
848
|
+
user-select: none;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
.select-trigger-custom {
|
|
852
|
+
background: rgba(255, 255, 255, 0.05);
|
|
853
|
+
border: 1px solid var(--panel-border);
|
|
854
|
+
color: var(--text-main);
|
|
855
|
+
padding: 0.5rem 2.2rem 0.5rem 0.75rem;
|
|
856
|
+
border-radius: 8px;
|
|
857
|
+
cursor: pointer;
|
|
858
|
+
font-size: 0.85rem;
|
|
859
|
+
font-weight: 600;
|
|
860
|
+
display: flex;
|
|
861
|
+
align-items: center;
|
|
862
|
+
justify-content: space-between;
|
|
863
|
+
transition: var(--transition-smooth);
|
|
864
|
+
min-height: 36px;
|
|
865
|
+
box-sizing: border-box;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
.select-trigger-custom:hover {
|
|
869
|
+
border-color: rgba(255, 255, 255, 0.15);
|
|
870
|
+
background: rgba(255, 255, 255, 0.08);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.select-container-custom.open .select-trigger-custom {
|
|
874
|
+
border-color: var(--accent-primary);
|
|
875
|
+
box-shadow: 0 0 0 2px var(--accent-primary-glow);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
.select-trigger-custom::after {
|
|
879
|
+
content: '\f078';
|
|
880
|
+
font-family: 'Font Awesome 6 Free';
|
|
881
|
+
font-weight: 900;
|
|
882
|
+
font-size: 0.7rem;
|
|
883
|
+
color: var(--text-muted);
|
|
884
|
+
position: absolute;
|
|
885
|
+
right: 12px;
|
|
886
|
+
transition: transform 0.3s ease;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
.select-container-custom.open .select-trigger-custom::after {
|
|
890
|
+
transform: rotate(180deg);
|
|
891
|
+
color: var(--accent-primary);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
.select-options-custom {
|
|
895
|
+
display: none;
|
|
896
|
+
position: absolute;
|
|
897
|
+
top: calc(100% + 6px);
|
|
898
|
+
left: 0;
|
|
899
|
+
width: 100%;
|
|
900
|
+
background: rgba(22, 22, 34, 0.98); /* Opaque dark background to prevent bleed-through */
|
|
901
|
+
border: 1px solid var(--panel-border);
|
|
902
|
+
border-radius: 12px;
|
|
903
|
+
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
|
|
904
|
+
z-index: 1000;
|
|
905
|
+
max-height: 250px;
|
|
906
|
+
overflow-y: auto;
|
|
907
|
+
padding: 4px;
|
|
908
|
+
backdrop-filter: blur(20px);
|
|
909
|
+
box-sizing: border-box;
|
|
910
|
+
animation: selectFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
@keyframes selectFadeIn {
|
|
914
|
+
from { opacity: 0; transform: translateY(-8px); }
|
|
915
|
+
to { opacity: 1; transform: translateY(0); }
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
.select-container-custom.open .select-options-custom {
|
|
919
|
+
display: block;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
.select-option-custom {
|
|
923
|
+
padding: 0.5rem 0.75rem;
|
|
924
|
+
color: var(--text-muted); /* Highly readable text color on dark backgrounds */
|
|
925
|
+
font-size: 0.82rem;
|
|
926
|
+
font-weight: 500;
|
|
927
|
+
border-radius: 6px;
|
|
928
|
+
cursor: pointer;
|
|
929
|
+
transition: var(--transition-smooth);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
.select-option-custom:hover {
|
|
933
|
+
background: rgba(255, 255, 255, 0.08);
|
|
934
|
+
color: #fff;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
.select-option-custom.selected {
|
|
938
|
+
background: var(--accent-primary-glow);
|
|
939
|
+
color: var(--accent-primary);
|
|
940
|
+
font-weight: 700;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
.select-options-custom::-webkit-scrollbar {
|
|
944
|
+
width: 6px;
|
|
945
|
+
}
|
|
946
|
+
.select-options-custom::-webkit-scrollbar-track {
|
|
947
|
+
background: transparent;
|
|
948
|
+
}
|
|
949
|
+
.select-options-custom::-webkit-scrollbar-thumb {
|
|
950
|
+
background: rgba(255, 255, 255, 0.1);
|
|
951
|
+
border-radius: 3px;
|
|
952
|
+
}
|
|
953
|
+
</style>
|
|
954
|
+
|
|
955
|
+
<div class="dashboard-container">
|
|
956
|
+
<!-- Header -->
|
|
957
|
+
<header>
|
|
958
|
+
<div class="header-title-area">
|
|
959
|
+
<h1><i class="fa-solid fa-building-columns"></i> Contas & Fluxo de Caixa</h1>
|
|
960
|
+
<p>Monitore saldos atuais e projetados, extratos de movimentações e realize transferências</p>
|
|
961
|
+
</div>
|
|
962
|
+
<div class="controls-area">
|
|
963
|
+
<label for="month-select" data-i18n="reference_label">Reference:</label>
|
|
964
|
+
<select id="month-select" class="select-custom">
|
|
965
|
+
<option value="1">Janeiro</option>
|
|
966
|
+
<option value="2">Fevereiro</option>
|
|
967
|
+
<option value="3">Março</option>
|
|
968
|
+
<option value="4">Abril</option>
|
|
969
|
+
<option value="5">Maio</option>
|
|
970
|
+
<option value="6">Junho</option>
|
|
971
|
+
<option value="7" selected>Julho</option>
|
|
972
|
+
<option value="8">Agosto</option>
|
|
973
|
+
<option value="9">Setembro</option>
|
|
974
|
+
<option value="10">Outubro</option>
|
|
975
|
+
<option value="11">Novembro</option>
|
|
976
|
+
<option value="12">Dezembro</option>
|
|
977
|
+
</select>
|
|
978
|
+
<select id="year-select" class="select-custom">
|
|
979
|
+
<option value="2025">2025</option>
|
|
980
|
+
<option value="2026" selected>2026</option>
|
|
981
|
+
<option value="2027">2027</option>
|
|
982
|
+
</select>
|
|
983
|
+
</div>
|
|
984
|
+
</header>
|
|
985
|
+
|
|
986
|
+
<!-- 2-Column Sidebar Layout -->
|
|
987
|
+
<div class="workspace-grid-contas">
|
|
988
|
+
<!-- Sidebar: Accounts list and type tabs -->
|
|
989
|
+
<aside class="accounts-sidebar-panel">
|
|
990
|
+
<div class="loading-overlay" id="accounts-loading">
|
|
991
|
+
<div class="spinner"></div>
|
|
992
|
+
</div>
|
|
993
|
+
<div class="sidebar-header">
|
|
994
|
+
<i class="fa-solid fa-wallet" style="color: var(--accent-primary);"></i>
|
|
995
|
+
<span data-i18n="accounts_title">Bank Accounts</span>
|
|
996
|
+
</div>
|
|
997
|
+
<!-- Consolidated net worth (ADR-026 Phase 3) -->
|
|
998
|
+
<div class="net-worth-summary" id="net-worth-summary" style="display:none;"></div>
|
|
999
|
+
<!-- Account Type Pills -->
|
|
1000
|
+
<div class="type-filter-pills" id="type-pills">
|
|
1001
|
+
<button class="pill-btn" data-filter="all" onclick="selectAccountTypeFilter('all')">
|
|
1002
|
+
<i class="fa-solid fa-border-all"></i>
|
|
1003
|
+
</button>
|
|
1004
|
+
<button class="pill-btn active" data-filter="checking" onclick="selectAccountTypeFilter('checking')">
|
|
1005
|
+
<i class="fa-solid fa-building-columns"></i> Corrente
|
|
1006
|
+
</button>
|
|
1007
|
+
<button class="pill-btn" data-filter="savings" onclick="selectAccountTypeFilter('savings')">
|
|
1008
|
+
<i class="fa-solid fa-piggy-bank"></i> Poupança
|
|
1009
|
+
</button>
|
|
1010
|
+
<button class="pill-btn" data-filter="investment" onclick="selectAccountTypeFilter('investment')">
|
|
1011
|
+
<i class="fa-solid fa-chart-line"></i> Invest.
|
|
1012
|
+
</button>
|
|
1013
|
+
<button class="pill-btn" data-filter="wallet" onclick="selectAccountTypeFilter('wallet')">
|
|
1014
|
+
<i class="fa-solid fa-wallet"></i> Carteira
|
|
1015
|
+
</button>
|
|
1016
|
+
</div>
|
|
1017
|
+
<!-- Accounts vertical scrollable list -->
|
|
1018
|
+
<div class="accounts-list-vertical" id="accounts-container">
|
|
1019
|
+
<!-- Dynamic compact cards -->
|
|
1020
|
+
</div>
|
|
1021
|
+
</aside>
|
|
1022
|
+
|
|
1023
|
+
<!-- Main: Statement / Extrato Workspace Panel -->
|
|
1024
|
+
<section class="panel" style="position: relative;">
|
|
1025
|
+
<div class="loading-overlay" id="tx-loading">
|
|
1026
|
+
<div class="spinner"></div>
|
|
1027
|
+
</div>
|
|
1028
|
+
|
|
1029
|
+
<div class="panel-header">
|
|
1030
|
+
<div class="panel-title">
|
|
1031
|
+
<i class="fa-solid fa-list-ul"></i>
|
|
1032
|
+
<span id="active-account-title" data-i18n="active_account_statement">Account Statement</span>
|
|
1033
|
+
</div>
|
|
1034
|
+
<div class="panel-actions-group">
|
|
1035
|
+
<button class="btn-panel-action btn-action-income" onclick="openAddTxModal()">
|
|
1036
|
+
<i class="fa-solid fa-plus"></i> Novo Lançamento
|
|
1037
|
+
</button>
|
|
1038
|
+
<button class="btn-panel-action btn-action-transfer" onclick="openAddTransferModal()">
|
|
1039
|
+
<i class="fa-solid fa-right-arrow-left"></i> Nova Transferência
|
|
1040
|
+
</button>
|
|
1041
|
+
</div>
|
|
1042
|
+
</div>
|
|
1043
|
+
|
|
1044
|
+
<!-- Filter Search Bar -->
|
|
1045
|
+
<div class="filter-bar">
|
|
1046
|
+
<div class="filter-item">
|
|
1047
|
+
<label for="filter-text" data-i18n="search_description_placeholder">Type to search...</label>
|
|
1048
|
+
<input type="text" id="filter-text" class="filter-control" placeholder="Digite para filtrar..." oninput="handleFiltersChange()">
|
|
1049
|
+
</div>
|
|
1050
|
+
<div class="filter-item">
|
|
1051
|
+
<label for="filter-type" data-i18n="filter_type_label">Type</label>
|
|
1052
|
+
<select id="filter-type" class="filter-control select-custom" style="background-image:none; padding-right:0.75rem;" onchange="handleFiltersChange()">
|
|
1053
|
+
<option value="all">Todos</option>
|
|
1054
|
+
<option value="income">Receitas</option>
|
|
1055
|
+
<option value="expense">Despesas</option>
|
|
1056
|
+
<option value="transfer">Transferências</option>
|
|
1057
|
+
</select>
|
|
1058
|
+
</div>
|
|
1059
|
+
<div class="filter-item">
|
|
1060
|
+
<label for="filter-category">Categoria</label>
|
|
1061
|
+
<select id="filter-category" class="filter-control select-custom" style="background-image:none; padding-right:0.75rem;" onchange="handleFiltersChange()">
|
|
1062
|
+
<option value="all">Todas</option>
|
|
1063
|
+
<!-- Dynamic list -->
|
|
1064
|
+
</select>
|
|
1065
|
+
</div>
|
|
1066
|
+
</div>
|
|
1067
|
+
|
|
1068
|
+
<!-- Transactions list -->
|
|
1069
|
+
<div class="table-container">
|
|
1070
|
+
<table id="txs-table">
|
|
1071
|
+
<thead>
|
|
1072
|
+
<tr>
|
|
1073
|
+
<th class="sortable" onclick="toggleSort('date')">Data <i class="fa-solid fa-sort" id="sort-icon-date"></i></th>
|
|
1074
|
+
<th class="sortable" onclick="toggleSort('description')">Descrição <i class="fa-solid fa-sort" id="sort-icon-description"></i></th>
|
|
1075
|
+
<th class="sortable" onclick="toggleSort('category')">Categoria / Destino <i class="fa-solid fa-sort" id="sort-icon-category"></i></th>
|
|
1076
|
+
<th style="text-align: center;">Tipo</th>
|
|
1077
|
+
<th class="sortable" onclick="toggleSort('amount')" style="text-align: right;">Valor <i class="fa-solid fa-sort" id="sort-icon-amount"></i></th>
|
|
1078
|
+
<th style="text-align: center;">Ações</th>
|
|
1079
|
+
</tr>
|
|
1080
|
+
</thead>
|
|
1081
|
+
<tbody id="table-body">
|
|
1082
|
+
<!-- Populated dynamically -->
|
|
1083
|
+
</tbody>
|
|
1084
|
+
</table>
|
|
1085
|
+
<div id="no-tx-msg" class="no-data-msg" style="display: none;">
|
|
1086
|
+
<i class="fa-regular fa-folder-open"></i>
|
|
1087
|
+
Nenhuma transação encontrada para os filtros selecionados.
|
|
1088
|
+
</div>
|
|
1089
|
+
</div>
|
|
1090
|
+
</section>
|
|
1091
|
+
</div>
|
|
1092
|
+
</div>
|
|
1093
|
+
|
|
1094
|
+
<!-- MODAL: ADD TRANSACTION -->
|
|
1095
|
+
<div class="modal-overlay" id="modal-add-tx">
|
|
1096
|
+
<div class="modal-box split-modal">
|
|
1097
|
+
<button class="modal-close-btn" onclick="closeModal('modal-add-tx')"><i class="fa-solid fa-xmark"></i></button>
|
|
1098
|
+
<div class="modal-title">
|
|
1099
|
+
<i class="fa-solid fa-circle-plus"></i>
|
|
1100
|
+
<span>Novo Lançamento</span>
|
|
1101
|
+
</div>
|
|
1102
|
+
<form id="form-add-tx" onsubmit="handleAddTxSubmit(event)">
|
|
1103
|
+
<div class="modal-split-body">
|
|
1104
|
+
<!-- Left Column: Fields -->
|
|
1105
|
+
<div class="modal-column-left">
|
|
1106
|
+
<div class="form-group">
|
|
1107
|
+
<label for="add-desc">Descrição</label>
|
|
1108
|
+
<input type="text" id="add-desc" class="form-control" placeholder="Ex: Salário" required>
|
|
1109
|
+
</div>
|
|
1110
|
+
<div class="form-group" style="display:grid; grid-template-columns: 1fr 1fr; gap:0.75rem;">
|
|
1111
|
+
<div>
|
|
1112
|
+
<label for="add-amount">Valor</label>
|
|
1113
|
+
<input type="number" step="0.01" min="0.01" id="add-amount" class="form-control" placeholder="0,00" required>
|
|
1114
|
+
</div>
|
|
1115
|
+
<div>
|
|
1116
|
+
<label for="add-date">Data</label>
|
|
1117
|
+
<input type="date" id="add-date" class="form-control" required>
|
|
1118
|
+
</div>
|
|
1119
|
+
</div>
|
|
1120
|
+
<div class="form-group">
|
|
1121
|
+
<label>Tipo</label>
|
|
1122
|
+
<div class="segmented-control" id="add-type-control">
|
|
1123
|
+
<button type="button" class="segmented-btn expense active" onclick="setTransactionType('add', 'expense')">
|
|
1124
|
+
<i class="fa-solid fa-arrow-trend-down"></i> Despesa
|
|
1125
|
+
</button>
|
|
1126
|
+
<button type="button" class="segmented-btn income" onclick="setTransactionType('add', 'income')">
|
|
1127
|
+
<i class="fa-solid fa-arrow-trend-up"></i> Receita
|
|
1128
|
+
</button>
|
|
1129
|
+
</div>
|
|
1130
|
+
<input type="hidden" id="add-type" value="expense">
|
|
1131
|
+
</div>
|
|
1132
|
+
<div class="form-group">
|
|
1133
|
+
<label>Conta</label>
|
|
1134
|
+
<div class="searchable-select-wrapper" id="add-account-wrapper">
|
|
1135
|
+
<div class="searchable-select-input-container">
|
|
1136
|
+
<input type="text" id="add-account-search" class="form-control" placeholder="Selecione ou digite..." autocomplete="off">
|
|
1137
|
+
<i class="fa-solid fa-chevron-down"></i>
|
|
1138
|
+
</div>
|
|
1139
|
+
<input type="hidden" id="add-account">
|
|
1140
|
+
<div class="searchable-select-dropdown"></div>
|
|
1141
|
+
</div>
|
|
1142
|
+
</div>
|
|
1143
|
+
<div class="form-group">
|
|
1144
|
+
<label>Categoria</label>
|
|
1145
|
+
<div class="searchable-select-wrapper" id="add-category-wrapper">
|
|
1146
|
+
<div class="searchable-select-input-container">
|
|
1147
|
+
<input type="text" id="add-category-search" class="form-control" placeholder="Selecione ou digite..." autocomplete="off">
|
|
1148
|
+
<i class="fa-solid fa-chevron-down"></i>
|
|
1149
|
+
</div>
|
|
1150
|
+
<input type="hidden" id="add-category">
|
|
1151
|
+
<div class="searchable-select-dropdown"></div>
|
|
1152
|
+
</div>
|
|
1153
|
+
</div>
|
|
1154
|
+
</div>
|
|
1155
|
+
|
|
1156
|
+
<!-- Right Column: Observações -->
|
|
1157
|
+
<div class="modal-column-right">
|
|
1158
|
+
<div class="form-group" style="height: 100%; display:flex; flex-direction:column;">
|
|
1159
|
+
<label for="add-note">Observação / Notas da Transação</label>
|
|
1160
|
+
<textarea id="add-note" class="textarea-large" placeholder="Escreva observações sobre este lançamento..."></textarea>
|
|
1161
|
+
</div>
|
|
1162
|
+
</div>
|
|
1163
|
+
</div>
|
|
1164
|
+
<div class="modal-footer">
|
|
1165
|
+
<button type="button" class="btn-action-secondary" onclick="closeModal('modal-add-tx')">
|
|
1166
|
+
<i class="fa-solid fa-ban"></i> Cancelar
|
|
1167
|
+
</button>
|
|
1168
|
+
<button type="submit" class="btn-action-primary">
|
|
1169
|
+
<i class="fa-solid fa-check"></i> Criar Lançamento
|
|
1170
|
+
</button>
|
|
1171
|
+
</div>
|
|
1172
|
+
</form>
|
|
1173
|
+
</div>
|
|
1174
|
+
</div>
|
|
1175
|
+
|
|
1176
|
+
<!-- MODAL: ADD TRANSFER -->
|
|
1177
|
+
<div class="modal-overlay" id="modal-add-transfer">
|
|
1178
|
+
<div class="modal-box">
|
|
1179
|
+
<button class="modal-close-btn" onclick="closeModal('modal-add-transfer')"><i class="fa-solid fa-xmark"></i></button>
|
|
1180
|
+
<div class="modal-title">
|
|
1181
|
+
<i class="fa-solid fa-right-arrow-left"></i>
|
|
1182
|
+
<span>Nova Transferência</span>
|
|
1183
|
+
</div>
|
|
1184
|
+
<form id="form-add-transfer" onsubmit="handleAddTransferSubmit(event)">
|
|
1185
|
+
<div class="form-group">
|
|
1186
|
+
<label>Conta Origem (De)</label>
|
|
1187
|
+
<div class="searchable-select-wrapper" id="tf-from-wrapper">
|
|
1188
|
+
<div class="searchable-select-input-container">
|
|
1189
|
+
<input type="text" id="tf-from-search" class="form-control" placeholder="Selecione conta origem..." autocomplete="off">
|
|
1190
|
+
<i class="fa-solid fa-chevron-down"></i>
|
|
1191
|
+
</div>
|
|
1192
|
+
<input type="hidden" id="tf-from">
|
|
1193
|
+
<div class="searchable-select-dropdown"></div>
|
|
1194
|
+
</div>
|
|
1195
|
+
</div>
|
|
1196
|
+
<div class="form-group">
|
|
1197
|
+
<label>Conta Destino (Para)</label>
|
|
1198
|
+
<div class="searchable-select-wrapper" id="tf-to-wrapper">
|
|
1199
|
+
<div class="searchable-select-input-container">
|
|
1200
|
+
<input type="text" id="tf-to-search" class="form-control" placeholder="Selecione conta destino..." autocomplete="off">
|
|
1201
|
+
<i class="fa-solid fa-chevron-down"></i>
|
|
1202
|
+
</div>
|
|
1203
|
+
<input type="hidden" id="tf-to">
|
|
1204
|
+
<div class="searchable-select-dropdown"></div>
|
|
1205
|
+
</div>
|
|
1206
|
+
</div>
|
|
1207
|
+
<div class="form-group" style="display:grid; grid-template-columns: 1fr 1fr; gap:0.75rem;">
|
|
1208
|
+
<div>
|
|
1209
|
+
<label for="tf-amount">Valor</label>
|
|
1210
|
+
<input type="number" step="0.01" min="0.01" id="tf-amount" class="form-control" placeholder="0,00" required>
|
|
1211
|
+
</div>
|
|
1212
|
+
<div>
|
|
1213
|
+
<label for="tf-date">Data</label>
|
|
1214
|
+
<input type="date" id="tf-date" class="form-control" required>
|
|
1215
|
+
</div>
|
|
1216
|
+
</div>
|
|
1217
|
+
<div class="form-group">
|
|
1218
|
+
<label for="tf-desc">Descrição / Nota</label>
|
|
1219
|
+
<input type="text" id="tf-desc" class="form-control" placeholder="Ex: Aporte mensal poupança">
|
|
1220
|
+
</div>
|
|
1221
|
+
<div class="modal-footer">
|
|
1222
|
+
<button type="button" class="btn-action-secondary" onclick="closeModal('modal-add-transfer')">
|
|
1223
|
+
<i class="fa-solid fa-ban"></i> Cancelar
|
|
1224
|
+
</button>
|
|
1225
|
+
<button type="submit" class="btn-action-primary">
|
|
1226
|
+
<i class="fa-solid fa-paper-plane"></i> Efetuar Transferência
|
|
1227
|
+
</button>
|
|
1228
|
+
</div>
|
|
1229
|
+
</form>
|
|
1230
|
+
</div>
|
|
1231
|
+
</div>
|
|
1232
|
+
|
|
1233
|
+
<!-- MODAL: EDIT TRANSACTION -->
|
|
1234
|
+
<div class="modal-overlay" id="modal-edit-tx">
|
|
1235
|
+
<div class="modal-box split-modal">
|
|
1236
|
+
<button class="modal-close-btn" onclick="closeModal('modal-edit-tx')"><i class="fa-solid fa-xmark"></i></button>
|
|
1237
|
+
<div class="modal-title">
|
|
1238
|
+
<i class="fa-solid fa-pen-to-square"></i>
|
|
1239
|
+
<span>Editar Lançamento</span>
|
|
1240
|
+
</div>
|
|
1241
|
+
<form id="form-edit-tx" onsubmit="handleEditTxSubmit(event)">
|
|
1242
|
+
<input type="hidden" id="edit-id">
|
|
1243
|
+
<div class="modal-split-body">
|
|
1244
|
+
<!-- Left Column: fields -->
|
|
1245
|
+
<div class="modal-column-left">
|
|
1246
|
+
<div class="form-group">
|
|
1247
|
+
<label for="edit-desc">Descrição</label>
|
|
1248
|
+
<input type="text" id="edit-desc" class="form-control" placeholder="Descrição" required>
|
|
1249
|
+
</div>
|
|
1250
|
+
<div class="form-group" style="display:grid; grid-template-columns: 1fr 1fr; gap:0.75rem;">
|
|
1251
|
+
<div>
|
|
1252
|
+
<label for="edit-amount">Valor</label>
|
|
1253
|
+
<input type="number" step="0.01" min="0.01" id="edit-amount" class="form-control" placeholder="0,00" required>
|
|
1254
|
+
</div>
|
|
1255
|
+
<div>
|
|
1256
|
+
<label for="edit-date">Data</label>
|
|
1257
|
+
<input type="date" id="edit-date" class="form-control" required>
|
|
1258
|
+
</div>
|
|
1259
|
+
</div>
|
|
1260
|
+
<div class="form-group" id="edit-type-container">
|
|
1261
|
+
<label>Tipo</label>
|
|
1262
|
+
<div class="segmented-control" id="edit-type-control">
|
|
1263
|
+
<button type="button" class="segmented-btn expense" onclick="setTransactionType('edit', 'expense')">
|
|
1264
|
+
<i class="fa-solid fa-arrow-trend-down"></i> Despesa
|
|
1265
|
+
</button>
|
|
1266
|
+
<button type="button" class="segmented-btn income" onclick="setTransactionType('edit', 'income')">
|
|
1267
|
+
<i class="fa-solid fa-arrow-trend-up"></i> Receita
|
|
1268
|
+
</button>
|
|
1269
|
+
</div>
|
|
1270
|
+
<input type="hidden" id="edit-type">
|
|
1271
|
+
</div>
|
|
1272
|
+
<div class="form-group" id="edit-account-container">
|
|
1273
|
+
<label>Conta</label>
|
|
1274
|
+
<div class="searchable-select-wrapper" id="edit-account-wrapper">
|
|
1275
|
+
<div class="searchable-select-input-container">
|
|
1276
|
+
<input type="text" id="edit-account-search" class="form-control" placeholder="Selecione conta..." autocomplete="off">
|
|
1277
|
+
<i class="fa-solid fa-chevron-down"></i>
|
|
1278
|
+
</div>
|
|
1279
|
+
<input type="hidden" id="edit-account">
|
|
1280
|
+
<div class="searchable-select-dropdown"></div>
|
|
1281
|
+
</div>
|
|
1282
|
+
</div>
|
|
1283
|
+
<div class="form-group" id="edit-category-container">
|
|
1284
|
+
<label>Categoria</label>
|
|
1285
|
+
<div class="searchable-select-wrapper" id="edit-category-wrapper">
|
|
1286
|
+
<div class="searchable-select-input-container">
|
|
1287
|
+
<input type="text" id="edit-category-search" class="form-control" placeholder="Selecione categoria..." autocomplete="off">
|
|
1288
|
+
<i class="fa-solid fa-chevron-down"></i>
|
|
1289
|
+
</div>
|
|
1290
|
+
<input type="hidden" id="edit-category">
|
|
1291
|
+
<div class="searchable-select-dropdown"></div>
|
|
1292
|
+
</div>
|
|
1293
|
+
</div>
|
|
1294
|
+
<div id="edit-transfer-note" style="display:none; font-size:0.8rem; color:var(--text-muted); background:rgba(255,255,255,0.03); padding:0.75rem; border-radius:8px; border:1px solid var(--panel-border); margin-top:0.5rem;">
|
|
1295
|
+
<i class="fa-solid fa-circle-info"></i> Lançamento de transferência. Lógica de alteração de contas e categoria é restrita.
|
|
1296
|
+
</div>
|
|
1297
|
+
</div>
|
|
1298
|
+
|
|
1299
|
+
<!-- Right Column: Note -->
|
|
1300
|
+
<div class="modal-column-right">
|
|
1301
|
+
<div class="form-group" style="height: 100%; display:flex; flex-direction:column;">
|
|
1302
|
+
<label for="edit-note">Observação / Notas da Transação</label>
|
|
1303
|
+
<textarea id="edit-note" class="textarea-large" placeholder="Escreva observações sobre este lançamento..."></textarea>
|
|
1304
|
+
</div>
|
|
1305
|
+
</div>
|
|
1306
|
+
</div>
|
|
1307
|
+
<div class="modal-footer">
|
|
1308
|
+
<button type="button" class="btn-action-secondary" onclick="closeModal('modal-edit-tx')">
|
|
1309
|
+
<i class="fa-solid fa-ban"></i> Cancelar
|
|
1310
|
+
</button>
|
|
1311
|
+
<button type="submit" class="btn-action-primary">
|
|
1312
|
+
<i class="fa-solid fa-check"></i> Salvar Lançamento
|
|
1313
|
+
</button>
|
|
1314
|
+
</div>
|
|
1315
|
+
</form>
|
|
1316
|
+
</div>
|
|
1317
|
+
</div>
|
|
1318
|
+
|
|
1319
|
+
<!-- Toast Container -->
|
|
1320
|
+
<div class="toast-container" id="toast-box"></div>
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
<script>
|
|
1325
|
+
// State
|
|
1326
|
+
var accounts = []; // Filtered accounts (non-credit cards)
|
|
1327
|
+
var activeAccount = null; // Current Account Object
|
|
1328
|
+
var accountBalances = {}; // name -> balance info
|
|
1329
|
+
var consolidatedNetWorth = null; // { baseCurrency, total, excluded } from get_account_balances (ADR-026)
|
|
1330
|
+
var transactions = [];
|
|
1331
|
+
var categories = [];
|
|
1332
|
+
var selectedTypeFilter = 'checking'; // 'all' | 'checking' | 'savings' | 'investment' | 'wallet'
|
|
1333
|
+
|
|
1334
|
+
// Sorting state
|
|
1335
|
+
var sortColumn = 'date';
|
|
1336
|
+
var sortDirection = 'desc';
|
|
1337
|
+
|
|
1338
|
+
// Elements
|
|
1339
|
+
var monthSelect = document.getElementById('month-select');
|
|
1340
|
+
var yearSelect = document.getElementById('year-select');
|
|
1341
|
+
var accountsContainer = document.getElementById('accounts-container');
|
|
1342
|
+
var tableBody = document.getElementById('table-body');
|
|
1343
|
+
var noTxMsg = document.getElementById('no-tx-msg');
|
|
1344
|
+
var accountsLoading = document.getElementById('accounts-loading');
|
|
1345
|
+
var txLoading = document.getElementById('tx-loading');
|
|
1346
|
+
|
|
1347
|
+
// Initial setup
|
|
1348
|
+
var now = new Date();
|
|
1349
|
+
var params = new URLSearchParams(window.location.search);
|
|
1350
|
+
var defaultMonth = parseInt(params.get('month')) || (now.getMonth() + 1);
|
|
1351
|
+
var defaultYear = parseInt(params.get('year')) || now.getFullYear();
|
|
1352
|
+
monthSelect.value = String(defaultMonth);
|
|
1353
|
+
yearSelect.value = String(defaultYear);
|
|
1354
|
+
|
|
1355
|
+
// Toast system helper
|
|
1356
|
+
function showToast(message, type = 'info') {
|
|
1357
|
+
const toastBox = document.getElementById('toast-box');
|
|
1358
|
+
const toast = document.createElement('div');
|
|
1359
|
+
toast.className = `toast ${type}`;
|
|
1360
|
+
|
|
1361
|
+
let iconClass = 'fa-circle-info';
|
|
1362
|
+
if (type === 'success') iconClass = 'fa-circle-check';
|
|
1363
|
+
if (type === 'error') iconClass = 'fa-circle-exclamation';
|
|
1364
|
+
|
|
1365
|
+
toast.innerHTML = `
|
|
1366
|
+
<i class="fa-solid ${iconClass}"></i>
|
|
1367
|
+
<span>${escapeHtml(message)}</span>
|
|
1368
|
+
<i class="fa-solid fa-xmark toast-close"></i>
|
|
1369
|
+
`;
|
|
1370
|
+
|
|
1371
|
+
toast.querySelector('.toast-close').addEventListener('click', () => {
|
|
1372
|
+
toast.style.animation = 'fadeOut 0.3s forwards';
|
|
1373
|
+
setTimeout(() => toast.remove(), 300);
|
|
1374
|
+
});
|
|
1375
|
+
|
|
1376
|
+
toastBox.appendChild(toast);
|
|
1377
|
+
setTimeout(() => {
|
|
1378
|
+
if (toast.parentNode) {
|
|
1379
|
+
toast.style.animation = 'fadeOut 0.3s forwards';
|
|
1380
|
+
setTimeout(() => toast.remove(), 300);
|
|
1381
|
+
}
|
|
1382
|
+
}, 4000);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
// Modals management
|
|
1386
|
+
function openModal(id) {
|
|
1387
|
+
document.getElementById(id).classList.add('open');
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
function closeModal(id) {
|
|
1391
|
+
document.getElementById(id).classList.remove('open');
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
// Close modal on ESC key
|
|
1395
|
+
document.addEventListener('keydown', (e) => {
|
|
1396
|
+
if (e.key === 'Escape') {
|
|
1397
|
+
const activeModal = document.querySelector('.modal-overlay.open');
|
|
1398
|
+
if (activeModal) {
|
|
1399
|
+
closeModal(activeModal.id);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
|
|
1404
|
+
// Setup Month/Year tabs dates
|
|
1405
|
+
function getLastDayOfMonth(year, month) {
|
|
1406
|
+
return new Date(year, month, 0).getDate();
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
// Selection of account
|
|
1410
|
+
function selectAccount(accName) {
|
|
1411
|
+
const accObj = accounts.find(a => a.name === accName);
|
|
1412
|
+
if (!accObj) return;
|
|
1413
|
+
|
|
1414
|
+
activeAccount = accObj;
|
|
1415
|
+
|
|
1416
|
+
document.querySelectorAll('.account-card').forEach(c => {
|
|
1417
|
+
c.classList.remove('active');
|
|
1418
|
+
if (c.dataset.name === accName) {
|
|
1419
|
+
c.classList.add('active');
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
|
|
1423
|
+
document.getElementById('active-account-title').innerHTML = `
|
|
1424
|
+
<i class="fa-solid ${getAccountIconClass(activeAccount.type)}"></i>
|
|
1425
|
+
Extrato de ${escapeHtml(activeAccount.name)}
|
|
1426
|
+
`;
|
|
1427
|
+
|
|
1428
|
+
loadTransactions();
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
function getAccountIconClass(type) {
|
|
1432
|
+
switch(type) {
|
|
1433
|
+
case 'checking': return 'fa-building-columns';
|
|
1434
|
+
case 'savings': return 'fa-piggy-bank';
|
|
1435
|
+
case 'investment': return 'fa-chart-line';
|
|
1436
|
+
case 'wallet': return 'fa-wallet';
|
|
1437
|
+
default: return 'fa-wallet';
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
// Account type sidebar filter selection
|
|
1442
|
+
function selectAccountTypeFilter(type) {
|
|
1443
|
+
selectedTypeFilter = type;
|
|
1444
|
+
|
|
1445
|
+
// Update active pill button
|
|
1446
|
+
document.querySelectorAll('#type-pills .pill-btn').forEach(btn => {
|
|
1447
|
+
btn.classList.remove('active');
|
|
1448
|
+
if (btn.dataset.filter === type) {
|
|
1449
|
+
btn.classList.add('active');
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
|
|
1453
|
+
renderAccountsGrid();
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// Searchable Custom Autocomplete Combobox Initialization
|
|
1457
|
+
function initSearchableSelect(wrapperId, optionsList, onSelectCallback) {
|
|
1458
|
+
const wrapper = document.getElementById(wrapperId);
|
|
1459
|
+
if (!wrapper) return;
|
|
1460
|
+
|
|
1461
|
+
const searchInput = wrapper.querySelector('input[type="text"]');
|
|
1462
|
+
const hiddenInput = wrapper.querySelector('input[type="hidden"]');
|
|
1463
|
+
const dropdown = wrapper.querySelector('.searchable-select-dropdown');
|
|
1464
|
+
|
|
1465
|
+
let currentOptions = [...optionsList];
|
|
1466
|
+
|
|
1467
|
+
function renderOptions(filteredOptions) {
|
|
1468
|
+
dropdown.innerHTML = '';
|
|
1469
|
+
if (filteredOptions.length === 0) {
|
|
1470
|
+
const div = document.createElement('div');
|
|
1471
|
+
div.className = 'searchable-select-option no-results';
|
|
1472
|
+
div.textContent = 'Nenhum resultado encontrado';
|
|
1473
|
+
dropdown.appendChild(div);
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
filteredOptions.forEach(opt => {
|
|
1478
|
+
const div = document.createElement('div');
|
|
1479
|
+
div.className = 'searchable-select-option';
|
|
1480
|
+
div.textContent = opt;
|
|
1481
|
+
div.onclick = () => {
|
|
1482
|
+
searchInput.value = opt;
|
|
1483
|
+
hiddenInput.value = opt;
|
|
1484
|
+
dropdown.style.display = 'none';
|
|
1485
|
+
wrapper.classList.remove('open');
|
|
1486
|
+
if (onSelectCallback) onSelectCallback(opt);
|
|
1487
|
+
};
|
|
1488
|
+
dropdown.appendChild(div);
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
// Register options update hook on the wrapper object
|
|
1493
|
+
wrapper.updateOptionsList = function(newList) {
|
|
1494
|
+
currentOptions = [...newList];
|
|
1495
|
+
renderOptions(currentOptions);
|
|
1496
|
+
};
|
|
1497
|
+
|
|
1498
|
+
// Initial render
|
|
1499
|
+
renderOptions(currentOptions);
|
|
1500
|
+
|
|
1501
|
+
searchInput.addEventListener('focus', () => {
|
|
1502
|
+
// Close all other open searchable select dropdowns
|
|
1503
|
+
document.querySelectorAll('.searchable-select-wrapper').forEach(w => {
|
|
1504
|
+
if (w.id !== wrapperId) {
|
|
1505
|
+
w.classList.remove('open');
|
|
1506
|
+
w.querySelector('.searchable-select-dropdown').style.display = 'none';
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
dropdown.style.display = 'block';
|
|
1510
|
+
wrapper.classList.add('open');
|
|
1511
|
+
renderOptions(currentOptions); // Reset options to full list
|
|
1512
|
+
});
|
|
1513
|
+
|
|
1514
|
+
searchInput.addEventListener('input', (e) => {
|
|
1515
|
+
const term = e.target.value.toLowerCase();
|
|
1516
|
+
const filtered = currentOptions.filter(opt => opt.toLowerCase().includes(term));
|
|
1517
|
+
renderOptions(filtered);
|
|
1518
|
+
dropdown.style.display = 'block';
|
|
1519
|
+
wrapper.classList.add('open');
|
|
1520
|
+
});
|
|
1521
|
+
|
|
1522
|
+
// Close dropdown click away handler
|
|
1523
|
+
document.addEventListener('click', (e) => {
|
|
1524
|
+
if (!wrapper.contains(e.target)) {
|
|
1525
|
+
dropdown.style.display = 'none';
|
|
1526
|
+
wrapper.classList.remove('open');
|
|
1527
|
+
|
|
1528
|
+
const currentValue = searchInput.value;
|
|
1529
|
+
const match = currentOptions.find(opt => opt.toLowerCase() === currentValue.toLowerCase());
|
|
1530
|
+
if (match) {
|
|
1531
|
+
searchInput.value = match;
|
|
1532
|
+
hiddenInput.value = match;
|
|
1533
|
+
} else {
|
|
1534
|
+
if (currentValue === '') {
|
|
1535
|
+
hiddenInput.value = '';
|
|
1536
|
+
} else if (hiddenInput.value) {
|
|
1537
|
+
// Revert input to last set valid hidden value
|
|
1538
|
+
searchInput.value = hiddenInput.value;
|
|
1539
|
+
} else {
|
|
1540
|
+
searchInput.value = '';
|
|
1541
|
+
hiddenInput.value = '';
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
// Helper to set Combobox value
|
|
1549
|
+
function setSearchableSelectValue(wrapperId, value) {
|
|
1550
|
+
const wrapper = document.getElementById(wrapperId);
|
|
1551
|
+
if (!wrapper) return;
|
|
1552
|
+
const searchInput = wrapper.querySelector('input[type="text"]');
|
|
1553
|
+
const hiddenInput = wrapper.querySelector('input[type="hidden"]');
|
|
1554
|
+
searchInput.value = value || '';
|
|
1555
|
+
hiddenInput.value = value || '';
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
// Helper to set Flatpickr Date value safely
|
|
1559
|
+
function setDateInputValue(id, value) {
|
|
1560
|
+
const el = document.getElementById(id);
|
|
1561
|
+
if (!el) return;
|
|
1562
|
+
if (el._flatpickr) {
|
|
1563
|
+
el._flatpickr.setDate(value || '', true);
|
|
1564
|
+
} else {
|
|
1565
|
+
el.value = value || '';
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
// Fetch initial list of accounts and categories
|
|
1570
|
+
async function fetchInitialData() {
|
|
1571
|
+
accountsLoading.classList.add('active');
|
|
1572
|
+
try {
|
|
1573
|
+
const [accsRes, catsRes] = await Promise.all([
|
|
1574
|
+
fetch('/api/accounts'),
|
|
1575
|
+
fetch('/api/categories')
|
|
1576
|
+
]);
|
|
1577
|
+
|
|
1578
|
+
if (accsRes.ok) {
|
|
1579
|
+
const rawAccs = await accsRes.json();
|
|
1580
|
+
// Filter out credit card accounts
|
|
1581
|
+
accounts = rawAccs.filter(a => a.type !== 'credit');
|
|
1582
|
+
|
|
1583
|
+
// Sort accounts by type priority (checking, savings, investment, wallet), then by name
|
|
1584
|
+
const typePriority = {
|
|
1585
|
+
'checking': 1,
|
|
1586
|
+
'savings': 2,
|
|
1587
|
+
'investment': 3,
|
|
1588
|
+
'wallet': 4
|
|
1589
|
+
};
|
|
1590
|
+
accounts.sort((a, b) => {
|
|
1591
|
+
const prioA = typePriority[a.type] || 99;
|
|
1592
|
+
const prioB = typePriority[b.type] || 99;
|
|
1593
|
+
if (prioA !== prioB) return prioA - prioB;
|
|
1594
|
+
return a.name.localeCompare(b.name);
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
if (catsRes.ok) {
|
|
1599
|
+
categories = await catsRes.json();
|
|
1600
|
+
categories.sort((a,b) => a.name.localeCompare(b.name));
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
// Populate filter categories
|
|
1604
|
+
const filterCat = document.getElementById('filter-category');
|
|
1605
|
+
filterCat.innerHTML = '<option value="all">Todas</option>';
|
|
1606
|
+
categories.forEach(c => {
|
|
1607
|
+
const opt = document.createElement('option');
|
|
1608
|
+
opt.value = c.name;
|
|
1609
|
+
opt.textContent = c.name;
|
|
1610
|
+
filterCat.appendChild(opt);
|
|
1611
|
+
});
|
|
1612
|
+
|
|
1613
|
+
// Initialize Searchable selects
|
|
1614
|
+
const accountNamesList = accounts.map(a => a.name);
|
|
1615
|
+
const categoryNamesList = categories.map(c => c.name);
|
|
1616
|
+
|
|
1617
|
+
initSearchableSelect('add-account-wrapper', accountNamesList);
|
|
1618
|
+
initSearchableSelect('add-category-wrapper', categoryNamesList);
|
|
1619
|
+
|
|
1620
|
+
initSearchableSelect('edit-account-wrapper', accountNamesList);
|
|
1621
|
+
initSearchableSelect('edit-category-wrapper', categoryNamesList);
|
|
1622
|
+
|
|
1623
|
+
initSearchableSelect('tf-from-wrapper', accountNamesList, handleTransferSourceChange);
|
|
1624
|
+
initSearchableSelect('tf-to-wrapper', []); // Populated dynamically in handleTransferSourceChange
|
|
1625
|
+
|
|
1626
|
+
// Set initial default account
|
|
1627
|
+
if (accounts.length > 0) {
|
|
1628
|
+
activeAccount = accounts[0];
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
await loadBalances();
|
|
1632
|
+
} catch (err) {
|
|
1633
|
+
console.error("Error loading initial data", err);
|
|
1634
|
+
showToast("Erro ao carregar dados de contas e categorias.", "error");
|
|
1635
|
+
} finally {
|
|
1636
|
+
accountsLoading.classList.remove('active');
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// Load account balances (Actual & Projected)
|
|
1641
|
+
async function loadBalances() {
|
|
1642
|
+
if (accounts.length === 0) return;
|
|
1643
|
+
|
|
1644
|
+
accountsLoading.classList.add('active');
|
|
1645
|
+
|
|
1646
|
+
const month = parseInt(monthSelect.value);
|
|
1647
|
+
const year = parseInt(yearSelect.value);
|
|
1648
|
+
const lastDay = getLastDayOfMonth(year, month);
|
|
1649
|
+
const projectedAsOfStr = `${year}-${String(month).padStart(2, '0')}-${String(lastDay).padStart(2, '0')}`;
|
|
1650
|
+
|
|
1651
|
+
try {
|
|
1652
|
+
const res = await fetch(`/api/accounts/balances?projectedAsOf=${projectedAsOfStr}`);
|
|
1653
|
+
if (!res.ok) throw new Error("Erro ao carregar saldos das contas");
|
|
1654
|
+
|
|
1655
|
+
const data = await res.json();
|
|
1656
|
+
accountBalances = {};
|
|
1657
|
+
data.balances.forEach(b => {
|
|
1658
|
+
accountBalances[b.name] = b;
|
|
1659
|
+
});
|
|
1660
|
+
consolidatedNetWorth = data.consolidatedNetWorth;
|
|
1661
|
+
|
|
1662
|
+
renderAccountsGrid();
|
|
1663
|
+
renderNetWorth();
|
|
1664
|
+
|
|
1665
|
+
// Keep active account selected or fallback
|
|
1666
|
+
if (activeAccount) {
|
|
1667
|
+
selectAccount(activeAccount.name);
|
|
1668
|
+
}
|
|
1669
|
+
} catch (err) {
|
|
1670
|
+
console.error("Error loading balances", err);
|
|
1671
|
+
showToast("Erro ao carregar saldos das contas.", "error");
|
|
1672
|
+
} finally {
|
|
1673
|
+
accountsLoading.classList.remove('active');
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
// Render consolidated net worth summary (ADR-026)
|
|
1678
|
+
function renderNetWorth() {
|
|
1679
|
+
const el = document.getElementById('net-worth-summary');
|
|
1680
|
+
if (!consolidatedNetWorth) {
|
|
1681
|
+
el.style.display = 'none';
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
const totalText = window.formatMoney(consolidatedNetWorth.total, consolidatedNetWorth.baseCurrency);
|
|
1685
|
+
const excludedCount = consolidatedNetWorth.excluded.length;
|
|
1686
|
+
el.innerHTML = `
|
|
1687
|
+
<div class="nw-label">Patrimônio Consolidado</div>
|
|
1688
|
+
<div class="nw-total">${totalText}</div>
|
|
1689
|
+
${excludedCount > 0
|
|
1690
|
+
? `<div class="nw-excluded"><i class="fa-solid fa-triangle-exclamation"></i> ${excludedCount} conta(s) sem cotação</div>`
|
|
1691
|
+
: ''}
|
|
1692
|
+
`;
|
|
1693
|
+
el.style.display = 'block';
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
// Render Accounts Grid inside Sidebar (Compact list cards)
|
|
1697
|
+
function renderAccountsGrid() {
|
|
1698
|
+
accountsContainer.innerHTML = '';
|
|
1699
|
+
|
|
1700
|
+
// Filter accounts by type filter
|
|
1701
|
+
const filteredAccounts = selectedTypeFilter === 'all'
|
|
1702
|
+
? accounts
|
|
1703
|
+
: accounts.filter(a => a.type === selectedTypeFilter);
|
|
1704
|
+
|
|
1705
|
+
if (filteredAccounts.length === 0) {
|
|
1706
|
+
accountsContainer.innerHTML = '<div style="text-align:center; color:var(--text-dark); font-size:0.85rem; padding: 2rem 0;">Nenhuma conta encontrada.</div>';
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
// Fallback selection if current active account is hidden by filter
|
|
1711
|
+
if (activeAccount) {
|
|
1712
|
+
const isActiveVisible = filteredAccounts.some(a => a.name === activeAccount.name);
|
|
1713
|
+
if (!isActiveVisible && filteredAccounts.length > 0) {
|
|
1714
|
+
selectAccount(filteredAccounts[0].name);
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
filteredAccounts.forEach(a => {
|
|
1719
|
+
const balInfo = accountBalances[a.name] || { balance: a.initialBalance, projectedBalance: a.initialBalance };
|
|
1720
|
+
|
|
1721
|
+
let cardClass = 'acc-checking';
|
|
1722
|
+
if (a.type === 'savings') cardClass = 'acc-savings';
|
|
1723
|
+
if (a.type === 'investment') cardClass = 'acc-investment';
|
|
1724
|
+
if (a.type === 'wallet') cardClass = 'acc-wallet';
|
|
1725
|
+
|
|
1726
|
+
const div = document.createElement('div');
|
|
1727
|
+
div.className = `account-card ${cardClass} ${activeAccount && activeAccount.name === a.name ? 'active' : ''}`;
|
|
1728
|
+
div.dataset.name = a.name;
|
|
1729
|
+
div.onclick = () => selectAccount(a.name);
|
|
1730
|
+
|
|
1731
|
+
const currentBalText = window.formatMoney(balInfo.balance, a.currency);
|
|
1732
|
+
const projBalText = window.formatMoney(balInfo.projectedBalance, a.currency);
|
|
1733
|
+
const isProjNegative = balInfo.projectedBalance < 0;
|
|
1734
|
+
|
|
1735
|
+
// Hidden when the account is already in the base currency — native stays primary (ADR-026).
|
|
1736
|
+
let convertedHtml = '';
|
|
1737
|
+
if (consolidatedNetWorth && a.currency !== consolidatedNetWorth.baseCurrency) {
|
|
1738
|
+
if (balInfo.converted) {
|
|
1739
|
+
const convertedText = window.formatMoney(balInfo.converted.value, consolidatedNetWorth.baseCurrency);
|
|
1740
|
+
convertedHtml = `
|
|
1741
|
+
<div class="acc-converted-bal ${balInfo.converted.stale ? 'stale' : ''}">
|
|
1742
|
+
≈ ${convertedText}${balInfo.converted.stale ? ' <i class="fa-solid fa-triangle-exclamation" title="Cotação desatualizada"></i>' : ''}
|
|
1743
|
+
</div>`;
|
|
1744
|
+
} else {
|
|
1745
|
+
convertedHtml = '<div class="acc-converted-bal na">Sem cotação</div>';
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
div.innerHTML = `
|
|
1750
|
+
<div class="acc-info-left">
|
|
1751
|
+
<div class="acc-name-title">${escapeHtml(a.name)}</div>
|
|
1752
|
+
<div class="acc-sub-type">
|
|
1753
|
+
<i class="fa-solid ${getAccountIconClass(a.type)}"></i>
|
|
1754
|
+
${escapeHtml(a.typeLabel)}
|
|
1755
|
+
</div>
|
|
1756
|
+
</div>
|
|
1757
|
+
<div class="acc-info-right">
|
|
1758
|
+
<div class="acc-current-bal">${currentBalText}</div>
|
|
1759
|
+
<div class="acc-projected-bal ${isProjNegative ? 'negative' : ''}">
|
|
1760
|
+
Proj: <span>${projBalText}</span>
|
|
1761
|
+
</div>
|
|
1762
|
+
${convertedHtml}
|
|
1763
|
+
</div>
|
|
1764
|
+
`;
|
|
1765
|
+
accountsContainer.appendChild(div);
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
// Load active account transactions
|
|
1770
|
+
async function loadTransactions() {
|
|
1771
|
+
if (!activeAccount) return;
|
|
1772
|
+
|
|
1773
|
+
txLoading.classList.add('active');
|
|
1774
|
+
|
|
1775
|
+
const month = parseInt(monthSelect.value);
|
|
1776
|
+
const year = parseInt(yearSelect.value);
|
|
1777
|
+
|
|
1778
|
+
try {
|
|
1779
|
+
async function fetchMonthTransactions(year, month, accountName) {
|
|
1780
|
+
let allItems = [];
|
|
1781
|
+
let cursor = null;
|
|
1782
|
+
|
|
1783
|
+
while (true) {
|
|
1784
|
+
const queryParams = new URLSearchParams({
|
|
1785
|
+
month: String(month),
|
|
1786
|
+
year: String(year),
|
|
1787
|
+
account: accountName,
|
|
1788
|
+
sort: 'date',
|
|
1789
|
+
dir: 'desc'
|
|
1790
|
+
});
|
|
1791
|
+
if (cursor) {
|
|
1792
|
+
queryParams.set('cursor', cursor);
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
const url = `/api/transactions?${queryParams.toString()}`;
|
|
1796
|
+
const res = await fetch(url);
|
|
1797
|
+
if (!res.ok) throw new Error(`HTTP error ${res.status}`);
|
|
1798
|
+
|
|
1799
|
+
const data = await res.json();
|
|
1800
|
+
|
|
1801
|
+
let items = [];
|
|
1802
|
+
let nextCursor = null;
|
|
1803
|
+
if (data && typeof data === 'object') {
|
|
1804
|
+
if (Array.isArray(data.items)) {
|
|
1805
|
+
items = data.items;
|
|
1806
|
+
nextCursor = data.nextCursor;
|
|
1807
|
+
} else if (Array.isArray(data)) {
|
|
1808
|
+
items = data;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
allItems.push(...items);
|
|
1813
|
+
|
|
1814
|
+
if (!nextCursor) {
|
|
1815
|
+
break;
|
|
1816
|
+
}
|
|
1817
|
+
cursor = nextCursor;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
return allItems;
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
transactions = await fetchMonthTransactions(year, month, activeAccount.name);
|
|
1824
|
+
renderTransactionsTable();
|
|
1825
|
+
} catch (err) {
|
|
1826
|
+
console.error("Error loading transactions", err);
|
|
1827
|
+
showToast("Erro ao carregar lançamentos da conta.", "error");
|
|
1828
|
+
} finally {
|
|
1829
|
+
txLoading.classList.remove('active');
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
// Handle local searches and drop-downs
|
|
1834
|
+
function handleFiltersChange() {
|
|
1835
|
+
renderTransactionsTable();
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
// Toggle table sorting
|
|
1839
|
+
function toggleSort(col) {
|
|
1840
|
+
if (sortColumn === col) {
|
|
1841
|
+
sortDirection = sortDirection === 'asc' ? 'desc' : 'asc';
|
|
1842
|
+
} else {
|
|
1843
|
+
sortColumn = col;
|
|
1844
|
+
sortDirection = 'asc';
|
|
1845
|
+
}
|
|
1846
|
+
updateSortHeaders();
|
|
1847
|
+
renderTransactionsTable();
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
function updateSortHeaders() {
|
|
1851
|
+
const columns = ['date', 'description', 'category', 'amount'];
|
|
1852
|
+
columns.forEach(col => {
|
|
1853
|
+
const icon = document.getElementById(`sort-icon-${col}`);
|
|
1854
|
+
if (!icon) return;
|
|
1855
|
+
|
|
1856
|
+
if (sortColumn === col) {
|
|
1857
|
+
icon.className = `fa-solid fa-sort-${sortDirection === 'asc' ? 'up' : 'down'}`;
|
|
1858
|
+
icon.style.opacity = '1';
|
|
1859
|
+
icon.style.color = 'var(--accent-primary)';
|
|
1860
|
+
} else {
|
|
1861
|
+
icon.className = 'fa-solid fa-sort';
|
|
1862
|
+
icon.style.opacity = '0.3';
|
|
1863
|
+
icon.style.color = 'inherit';
|
|
1864
|
+
}
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
// Render transactions list
|
|
1869
|
+
function renderTransactionsTable() {
|
|
1870
|
+
tableBody.innerHTML = '';
|
|
1871
|
+
|
|
1872
|
+
const filterTextVal = document.getElementById('filter-text').value.toLowerCase();
|
|
1873
|
+
const filterTypeVal = document.getElementById('filter-type').value;
|
|
1874
|
+
const filterCategoryVal = document.getElementById('filter-category').value;
|
|
1875
|
+
|
|
1876
|
+
// Local filters
|
|
1877
|
+
let filteredTxs = transactions.filter(t => {
|
|
1878
|
+
// Description search
|
|
1879
|
+
if (filterTextVal && !t.description.toLowerCase().includes(filterTextVal)) {
|
|
1880
|
+
return false;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
// Type filter
|
|
1884
|
+
if (filterTypeVal !== 'all' && t.type !== filterTypeVal) {
|
|
1885
|
+
return false;
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
// Category filter
|
|
1889
|
+
if (filterCategoryVal !== 'all') {
|
|
1890
|
+
if (t.type === 'transfer') return false; // Transfers don't have categories
|
|
1891
|
+
if ((t.categoryName || 'Sem Categoria') !== filterCategoryVal) {
|
|
1892
|
+
return false;
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
return true;
|
|
1897
|
+
});
|
|
1898
|
+
|
|
1899
|
+
if (filteredTxs.length === 0) {
|
|
1900
|
+
noTxMsg.style.display = 'block';
|
|
1901
|
+
document.getElementById('txs-table').style.display = 'none';
|
|
1902
|
+
return;
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
noTxMsg.style.display = 'none';
|
|
1906
|
+
document.getElementById('txs-table').style.display = 'table';
|
|
1907
|
+
|
|
1908
|
+
// Sorting logic
|
|
1909
|
+
filteredTxs.sort((a, b) => {
|
|
1910
|
+
let valA, valB;
|
|
1911
|
+
|
|
1912
|
+
if (sortColumn === 'date') {
|
|
1913
|
+
valA = a.date;
|
|
1914
|
+
valB = b.date;
|
|
1915
|
+
} else if (sortColumn === 'description') {
|
|
1916
|
+
valA = a.description.toLowerCase();
|
|
1917
|
+
valB = b.description.toLowerCase();
|
|
1918
|
+
} else if (sortColumn === 'category') {
|
|
1919
|
+
if (a.type === 'transfer') {
|
|
1920
|
+
valA = (a.fromAccount === activeAccount.name ? 'transferência para ' + a.toAccount : 'transferência de ' + a.fromAccount).toLowerCase();
|
|
1921
|
+
} else {
|
|
1922
|
+
valA = (a.categoryName || 'Sem Categoria').toLowerCase();
|
|
1923
|
+
}
|
|
1924
|
+
if (b.type === 'transfer') {
|
|
1925
|
+
valB = (b.fromAccount === activeAccount.name ? 'transferência para ' + b.toAccount : 'transferência de ' + b.fromAccount).toLowerCase();
|
|
1926
|
+
} else {
|
|
1927
|
+
valB = (b.categoryName || 'Sem Categoria').toLowerCase();
|
|
1928
|
+
}
|
|
1929
|
+
} else if (sortColumn === 'amount') {
|
|
1930
|
+
valA = a.amount;
|
|
1931
|
+
valB = b.amount;
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
if (valA < valB) return sortDirection === 'asc' ? -1 : 1;
|
|
1935
|
+
if (valA > valB) return sortDirection === 'asc' ? 1 : -1;
|
|
1936
|
+
|
|
1937
|
+
if (sortColumn !== 'date') {
|
|
1938
|
+
return a.date.localeCompare(b.date);
|
|
1939
|
+
}
|
|
1940
|
+
return 0;
|
|
1941
|
+
});
|
|
1942
|
+
|
|
1943
|
+
filteredTxs.forEach(t => {
|
|
1944
|
+
const tr = document.createElement('tr');
|
|
1945
|
+
|
|
1946
|
+
// Date
|
|
1947
|
+
const dateObj = new Date(t.date + 'T12:00:00');
|
|
1948
|
+
const dateStr = dateObj.toLocaleDateString('pt-BR', { day: '2-digit', month: '2-digit' });
|
|
1949
|
+
|
|
1950
|
+
// Category or Destination
|
|
1951
|
+
let catDestHtml = '';
|
|
1952
|
+
if (t.type === 'transfer') {
|
|
1953
|
+
if (t.fromAccount === activeAccount.name) {
|
|
1954
|
+
catDestHtml = `<span style="font-weight: 500; color:var(--text-muted);"><i class="fa-solid fa-arrow-right-long" style="margin-right:4px;"></i> ${escapeHtml(t.toAccount)}</span>`;
|
|
1955
|
+
} else {
|
|
1956
|
+
catDestHtml = `<span style="font-weight: 500; color:var(--text-muted);"><i class="fa-solid fa-arrow-left-long" style="margin-right:4px;"></i> ${escapeHtml(t.fromAccount)}</span>`;
|
|
1957
|
+
}
|
|
1958
|
+
} else {
|
|
1959
|
+
const catName = t.categoryName || 'Sem Categoria';
|
|
1960
|
+
catDestHtml = `<span class="badge-cat">${escapeHtml(catName)}</span>`;
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
// Type details
|
|
1964
|
+
let typeIcon = 'fa-arrow-trend-down';
|
|
1965
|
+
let typeClass = 'type-expense';
|
|
1966
|
+
let amtClass = 'expense';
|
|
1967
|
+
let prefixSymbol = '-';
|
|
1968
|
+
|
|
1969
|
+
if (t.type === 'income') {
|
|
1970
|
+
typeIcon = 'fa-arrow-trend-up';
|
|
1971
|
+
typeClass = 'type-income';
|
|
1972
|
+
amtClass = 'income';
|
|
1973
|
+
prefixSymbol = '+';
|
|
1974
|
+
} else if (t.type === 'transfer') {
|
|
1975
|
+
typeIcon = 'fa-right-arrow-left';
|
|
1976
|
+
typeClass = 'type-transfer';
|
|
1977
|
+
|
|
1978
|
+
// Determine if it was a debit or credit for the active account
|
|
1979
|
+
if (t.fromAccount === activeAccount.name) {
|
|
1980
|
+
amtClass = 'expense';
|
|
1981
|
+
prefixSymbol = '-';
|
|
1982
|
+
} else {
|
|
1983
|
+
amtClass = 'income';
|
|
1984
|
+
prefixSymbol = '+';
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
// Currency formatting
|
|
1989
|
+
const rawAmt = t.amount;
|
|
1990
|
+
const amtFormatted = window.formatMoney(rawAmt, t.currency);
|
|
1991
|
+
|
|
1992
|
+
// Check if it's a credit card bill payment
|
|
1993
|
+
const isBillPayment = t.type === 'transfer' && (t.billId || (t.idempotencyKey && t.idempotencyKey.startsWith('billpay-')) || (t.description && t.description.startsWith('Bill payment:')));
|
|
1994
|
+
|
|
1995
|
+
// Edit function call
|
|
1996
|
+
const editCall = `openEditTxModal('${t.id}')`;
|
|
1997
|
+
|
|
1998
|
+
tr.innerHTML = `
|
|
1999
|
+
<td class="col-date">${dateStr}</td>
|
|
2000
|
+
<td class="col-desc">
|
|
2001
|
+
<div>${escapeHtml(t.description)}</div>
|
|
2002
|
+
${t.tags && t.tags.length > 0 ? `<div style="margin-top: 4px; display:flex; gap: 4px; flex-wrap:wrap;">${t.tags.map(tag => `<span class="badge-cat" style="font-size:0.7rem; padding:1px 4px; border-radius:4px; color:#c084fc; border-color:rgba(192, 132, 252, 0.2); background:rgba(192, 132, 252, 0.05);"><i class="fa-solid fa-tag" style="font-size:0.6rem;"></i> ${escapeHtml(tag)}</span>`).join('')}</div>` : ''}
|
|
2003
|
+
</td>
|
|
2004
|
+
<td>${catDestHtml}</td>
|
|
2005
|
+
<td style="text-align: center;">
|
|
2006
|
+
<span class="badge-type-icon ${typeClass}" title="${t.type === 'income' ? 'Receita' : (t.type === 'transfer' ? 'Transferência' : 'Despesa')}">
|
|
2007
|
+
<i class="fa-solid ${typeIcon}"></i>
|
|
2008
|
+
</span>
|
|
2009
|
+
</td>
|
|
2010
|
+
<td class="amount-cell ${amtClass}">${prefixSymbol} ${amtFormatted}</td>
|
|
2011
|
+
<td style="text-align: center;">
|
|
2012
|
+
<div class="actions-cell">
|
|
2013
|
+
<button class="action-btn btn-edit-icon" title="${isBillPayment ? 'Pagamento de fatura não editável' : 'Editar'}" onclick="${editCall}" ${isBillPayment ? 'disabled' : ''}>
|
|
2014
|
+
<i class="fa-solid fa-pen-to-square"></i>
|
|
2015
|
+
</button>
|
|
2016
|
+
<button class="action-btn btn-delete-icon" title="${isBillPayment ? 'Pagamento de fatura não excluível por aqui' : 'Excluir'}" onclick="deleteTx('${t.id}', '${escapeJsAttr(t.description)}')" ${isBillPayment ? 'disabled' : ''}>
|
|
2017
|
+
<i class="fa-solid fa-trash-can"></i>
|
|
2018
|
+
</button>
|
|
2019
|
+
</div>
|
|
2020
|
+
</td>
|
|
2021
|
+
`;
|
|
2022
|
+
tableBody.appendChild(tr);
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
// Helper to update active segmented button control
|
|
2027
|
+
function setTransactionType(prefix, type) {
|
|
2028
|
+
document.getElementById(`${prefix}-type`).value = type;
|
|
2029
|
+
const control = document.getElementById(`${prefix}-type-control`);
|
|
2030
|
+
if (control) {
|
|
2031
|
+
control.querySelectorAll('.segmented-btn').forEach(btn => {
|
|
2032
|
+
btn.classList.remove('active');
|
|
2033
|
+
if (btn.classList.contains(type)) {
|
|
2034
|
+
btn.classList.add('active');
|
|
2035
|
+
}
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
// Open modal to Add transaction
|
|
2041
|
+
function openAddTxModal() {
|
|
2042
|
+
document.getElementById('form-add-tx').reset();
|
|
2043
|
+
|
|
2044
|
+
// Set transaction type back to default
|
|
2045
|
+
setTransactionType('add', 'expense');
|
|
2046
|
+
|
|
2047
|
+
// Set default date to 1st of selected reference month
|
|
2048
|
+
const month = parseInt(monthSelect.value);
|
|
2049
|
+
const year = parseInt(yearSelect.value);
|
|
2050
|
+
setDateInputValue('add-date', `${year}-${String(month).padStart(2,'0')}-01`);
|
|
2051
|
+
|
|
2052
|
+
// Default autocomplete comboboxes value pre-selection
|
|
2053
|
+
if (activeAccount) {
|
|
2054
|
+
setSearchableSelectValue('add-account-wrapper', activeAccount.name);
|
|
2055
|
+
} else {
|
|
2056
|
+
setSearchableSelectValue('add-account-wrapper', '');
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
setSearchableSelectValue('add-category-wrapper', '');
|
|
2060
|
+
document.getElementById('add-note').value = '';
|
|
2061
|
+
|
|
2062
|
+
openModal('modal-add-tx');
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
// Add Transaction submit
|
|
2066
|
+
async function handleAddTxSubmit(e) {
|
|
2067
|
+
e.preventDefault();
|
|
2068
|
+
|
|
2069
|
+
const desc = document.getElementById('add-desc').value;
|
|
2070
|
+
const amt = parseFloat(document.getElementById('add-amount').value);
|
|
2071
|
+
const dt = document.getElementById('add-date').value;
|
|
2072
|
+
const type = document.getElementById('add-type').value;
|
|
2073
|
+
|
|
2074
|
+
// Read from hidden fields
|
|
2075
|
+
const accName = document.getElementById('add-account').value;
|
|
2076
|
+
const cat = document.getElementById('add-category').value;
|
|
2077
|
+
const note = document.getElementById('add-note').value;
|
|
2078
|
+
|
|
2079
|
+
if (!accName) {
|
|
2080
|
+
showToast("Por favor, selecione uma conta válida.", "error");
|
|
2081
|
+
return;
|
|
2082
|
+
}
|
|
2083
|
+
if (!cat) {
|
|
2084
|
+
showToast("Por favor, selecione uma categoria válida.", "error");
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
const payload = {
|
|
2089
|
+
description: desc,
|
|
2090
|
+
amount: amt,
|
|
2091
|
+
date: dt,
|
|
2092
|
+
account: accName,
|
|
2093
|
+
category: cat,
|
|
2094
|
+
note: note,
|
|
2095
|
+
idempotencyKey: `${type}-${dt}-${desc}-${amt}-${Math.random().toString(36).substr(2, 9)}`
|
|
2096
|
+
};
|
|
2097
|
+
|
|
2098
|
+
closeModal('modal-add-tx');
|
|
2099
|
+
txLoading.classList.add('active');
|
|
2100
|
+
accountsLoading.classList.add('active');
|
|
2101
|
+
|
|
2102
|
+
const endpoint = type === 'income' ? '/api/accounts/income' : '/api/accounts/expenses';
|
|
2103
|
+
|
|
2104
|
+
try {
|
|
2105
|
+
const res = await fetch(endpoint, {
|
|
2106
|
+
method: 'POST',
|
|
2107
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2108
|
+
body: JSON.stringify(payload)
|
|
2109
|
+
});
|
|
2110
|
+
|
|
2111
|
+
if (!res.ok) {
|
|
2112
|
+
const errRes = await res.json();
|
|
2113
|
+
throw new Error(errRes.error?.message || "Falha ao criar transação");
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
showToast(`Lançamento "${desc}" criado com sucesso!`, 'success');
|
|
2117
|
+
await loadBalances();
|
|
2118
|
+
} catch (err) {
|
|
2119
|
+
console.error("Add transaction error", err);
|
|
2120
|
+
showToast(`Erro ao adicionar: ${err.message}`, 'error');
|
|
2121
|
+
} finally {
|
|
2122
|
+
txLoading.classList.remove('active');
|
|
2123
|
+
accountsLoading.classList.remove('active');
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
// Open Transfer Modal
|
|
2128
|
+
function openAddTransferModal() {
|
|
2129
|
+
document.getElementById('form-add-transfer').reset();
|
|
2130
|
+
|
|
2131
|
+
// Default date
|
|
2132
|
+
const month = parseInt(monthSelect.value);
|
|
2133
|
+
const year = parseInt(yearSelect.value);
|
|
2134
|
+
setDateInputValue('tf-date', `${year}-${String(month).padStart(2,'0')}-01`);
|
|
2135
|
+
|
|
2136
|
+
if (activeAccount) {
|
|
2137
|
+
setSearchableSelectValue('tf-from-wrapper', activeAccount.name);
|
|
2138
|
+
} else {
|
|
2139
|
+
setSearchableSelectValue('tf-from-wrapper', '');
|
|
2140
|
+
}
|
|
2141
|
+
setSearchableSelectValue('tf-to-wrapper', '');
|
|
2142
|
+
document.getElementById('tf-desc').value = '';
|
|
2143
|
+
|
|
2144
|
+
handleTransferSourceChange();
|
|
2145
|
+
openModal('modal-add-transfer');
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
// Restrict Destination Account (To) dropdown based on Source Account (From) currency
|
|
2149
|
+
function handleTransferSourceChange() {
|
|
2150
|
+
const sourceName = document.getElementById('tf-from').value;
|
|
2151
|
+
const sourceAcc = accounts.find(a => a.name === sourceName);
|
|
2152
|
+
const toWrapper = document.getElementById('tf-to-wrapper');
|
|
2153
|
+
|
|
2154
|
+
if (!sourceAcc || !toWrapper) return;
|
|
2155
|
+
|
|
2156
|
+
// Only accounts sharing the SAME currency and not source account itself
|
|
2157
|
+
const validDestinations = accounts
|
|
2158
|
+
.filter(a => a.name !== sourceName && a.currency === sourceAcc.currency)
|
|
2159
|
+
.map(a => a.name);
|
|
2160
|
+
|
|
2161
|
+
// Update searchable select autocomplete options dynamically
|
|
2162
|
+
if (toWrapper.updateOptionsList) {
|
|
2163
|
+
toWrapper.updateOptionsList(validDestinations);
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
// Clear destination text if it doesn't match the new valid list
|
|
2167
|
+
const currentToVal = document.getElementById('tf-to').value;
|
|
2168
|
+
if (!validDestinations.includes(currentToVal)) {
|
|
2169
|
+
setSearchableSelectValue('tf-to-wrapper', '');
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
// Add Transfer Submit
|
|
2174
|
+
async function handleAddTransferSubmit(e) {
|
|
2175
|
+
e.preventDefault();
|
|
2176
|
+
|
|
2177
|
+
const fromAcc = document.getElementById('tf-from').value;
|
|
2178
|
+
const toAcc = document.getElementById('tf-to').value;
|
|
2179
|
+
const amount = parseFloat(document.getElementById('tf-amount').value);
|
|
2180
|
+
const date = document.getElementById('tf-date').value;
|
|
2181
|
+
const desc = document.getElementById('tf-desc').value;
|
|
2182
|
+
|
|
2183
|
+
if (!fromAcc) {
|
|
2184
|
+
showToast("Por favor, selecione uma conta de origem.", "error");
|
|
2185
|
+
return;
|
|
2186
|
+
}
|
|
2187
|
+
if (!toAcc) {
|
|
2188
|
+
showToast("Por favor, selecione uma conta de destino válida sharing a mesma moeda.", "error");
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
const payload = {
|
|
2193
|
+
from: fromAcc,
|
|
2194
|
+
to: toAcc,
|
|
2195
|
+
amount: amount,
|
|
2196
|
+
date: date,
|
|
2197
|
+
description: desc || `Transferência de ${fromAcc} para ${toAcc}`,
|
|
2198
|
+
idempotencyKey: `transfer_${Date.now()}`
|
|
2199
|
+
};
|
|
2200
|
+
|
|
2201
|
+
closeModal('modal-add-transfer');
|
|
2202
|
+
txLoading.classList.add('active');
|
|
2203
|
+
accountsLoading.classList.add('active');
|
|
2204
|
+
|
|
2205
|
+
try {
|
|
2206
|
+
const res = await fetch('/api/transfers', {
|
|
2207
|
+
method: 'POST',
|
|
2208
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2209
|
+
body: JSON.stringify(payload)
|
|
2210
|
+
});
|
|
2211
|
+
|
|
2212
|
+
if (!res.ok) {
|
|
2213
|
+
const errRes = await res.json();
|
|
2214
|
+
throw new Error(errRes.error?.message || "Erro ao efetuar transferência");
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
showToast(`Transferência efetuada com sucesso!`, 'success');
|
|
2218
|
+
await loadBalances();
|
|
2219
|
+
} catch (err) {
|
|
2220
|
+
console.error("Transfer error", err);
|
|
2221
|
+
showToast(`Erro ao transferir: ${err.message}`, 'error');
|
|
2222
|
+
} finally {
|
|
2223
|
+
txLoading.classList.remove('active');
|
|
2224
|
+
accountsLoading.classList.remove('active');
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
// Open edit transaction modal
|
|
2229
|
+
function openEditTxModal(id) {
|
|
2230
|
+
document.getElementById('form-edit-tx').reset();
|
|
2231
|
+
|
|
2232
|
+
const t = transactions.find(tx => tx.id === id);
|
|
2233
|
+
if (!t) return;
|
|
2234
|
+
|
|
2235
|
+
document.getElementById('edit-id').value = t.id;
|
|
2236
|
+
document.getElementById('edit-desc').value = t.description;
|
|
2237
|
+
document.getElementById('edit-amount').value = t.amount;
|
|
2238
|
+
setDateInputValue('edit-date', t.date);
|
|
2239
|
+
document.getElementById('edit-note').value = t.note || '';
|
|
2240
|
+
|
|
2241
|
+
const editTypeSel = document.getElementById('edit-type');
|
|
2242
|
+
|
|
2243
|
+
if (t.type === 'transfer') {
|
|
2244
|
+
// Simplify for transfer: hide account and category selection fields since transfers link multiple accounts
|
|
2245
|
+
document.getElementById('edit-type-container').style.display = 'none';
|
|
2246
|
+
document.getElementById('edit-account-container').style.display = 'none';
|
|
2247
|
+
document.getElementById('edit-category-container').style.display = 'none';
|
|
2248
|
+
document.getElementById('edit-transfer-note').style.display = 'block';
|
|
2249
|
+
} else {
|
|
2250
|
+
document.getElementById('edit-type-container').style.display = 'flex';
|
|
2251
|
+
document.getElementById('edit-account-container').style.display = 'flex';
|
|
2252
|
+
document.getElementById('edit-category-container').style.display = 'flex';
|
|
2253
|
+
document.getElementById('edit-transfer-note').style.display = 'none';
|
|
2254
|
+
|
|
2255
|
+
// Pre-select type
|
|
2256
|
+
setTransactionType('edit', t.type);
|
|
2257
|
+
|
|
2258
|
+
// Pre-select searchable values
|
|
2259
|
+
setSearchableSelectValue('edit-account-wrapper', t.accountName || activeAccount.name);
|
|
2260
|
+
setSearchableSelectValue('edit-category-wrapper', t.categoryName || '');
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
openModal('modal-edit-tx');
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
// Edit Transaction Submit
|
|
2267
|
+
async function handleEditTxSubmit(e) {
|
|
2268
|
+
e.preventDefault();
|
|
2269
|
+
|
|
2270
|
+
const txId = document.getElementById('edit-id').value;
|
|
2271
|
+
const desc = document.getElementById('edit-desc').value;
|
|
2272
|
+
const amt = parseFloat(document.getElementById('edit-amount').value);
|
|
2273
|
+
const dt = document.getElementById('edit-date').value;
|
|
2274
|
+
const note = document.getElementById('edit-note').value;
|
|
2275
|
+
|
|
2276
|
+
// Find current type in state
|
|
2277
|
+
const targetTx = transactions.find(t => t.id === txId);
|
|
2278
|
+
const isTransfer = targetTx && targetTx.type === 'transfer';
|
|
2279
|
+
|
|
2280
|
+
const payload = {
|
|
2281
|
+
id: txId,
|
|
2282
|
+
description: desc,
|
|
2283
|
+
amount: amt,
|
|
2284
|
+
date: dt,
|
|
2285
|
+
note: note
|
|
2286
|
+
};
|
|
2287
|
+
|
|
2288
|
+
if (!isTransfer) {
|
|
2289
|
+
const accVal = document.getElementById('edit-account').value;
|
|
2290
|
+
const catVal = document.getElementById('edit-category').value;
|
|
2291
|
+
|
|
2292
|
+
if (!accVal) {
|
|
2293
|
+
showToast("Por favor, selecione uma conta válida.", "error");
|
|
2294
|
+
return;
|
|
2295
|
+
}
|
|
2296
|
+
if (!catVal) {
|
|
2297
|
+
showToast("Por favor, selecione uma categoria válida.", "error");
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
payload.type = document.getElementById('edit-type').value;
|
|
2302
|
+
payload.category = catVal;
|
|
2303
|
+
payload.account = accVal;
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
closeModal('modal-edit-tx');
|
|
2307
|
+
txLoading.classList.add('active');
|
|
2308
|
+
accountsLoading.classList.add('active');
|
|
2309
|
+
|
|
2310
|
+
try {
|
|
2311
|
+
const res = await fetch(`/api/accounts/transactions/${txId}`, {
|
|
2312
|
+
method: 'PATCH',
|
|
2313
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2314
|
+
body: JSON.stringify(payload)
|
|
2315
|
+
});
|
|
2316
|
+
|
|
2317
|
+
if (!res.ok) {
|
|
2318
|
+
const errRes = await res.json();
|
|
2319
|
+
throw new Error(errRes.error?.message || "Erro ao salvar alterações");
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
showToast("Lançamento atualizado com sucesso!", "success");
|
|
2323
|
+
await loadBalances();
|
|
2324
|
+
} catch (err) {
|
|
2325
|
+
console.error("Edit transaction error", err);
|
|
2326
|
+
showToast(`Erro ao editar: ${err.message}`, "error");
|
|
2327
|
+
} finally {
|
|
2328
|
+
txLoading.classList.remove('active');
|
|
2329
|
+
accountsLoading.classList.remove('active');
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
// Delete Transaction
|
|
2334
|
+
async function deleteTx(id, description) {
|
|
2335
|
+
if (!confirm(`Deseja realmente excluir permanentemente a movimentação "${description}"?`)) {
|
|
2336
|
+
return;
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
txLoading.classList.add('active');
|
|
2340
|
+
accountsLoading.classList.add('active');
|
|
2341
|
+
|
|
2342
|
+
try {
|
|
2343
|
+
const res = await fetch(`/api/accounts/transactions/${id}?confirm=true`, {
|
|
2344
|
+
method: 'DELETE'
|
|
2345
|
+
});
|
|
2346
|
+
|
|
2347
|
+
if (!res.ok) throw new Error("Erro ao deletar transação do servidor");
|
|
2348
|
+
|
|
2349
|
+
showToast(`Lançamento "${description}" removido com sucesso!`, 'success');
|
|
2350
|
+
await loadBalances();
|
|
2351
|
+
} catch (err) {
|
|
2352
|
+
console.error("Deletion error:", err);
|
|
2353
|
+
showToast(`Erro ao excluir: ${err.message}`, 'error');
|
|
2354
|
+
} finally {
|
|
2355
|
+
txLoading.classList.remove('active');
|
|
2356
|
+
accountsLoading.classList.remove('active');
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
// HTML escaping
|
|
2361
|
+
function escapeHtml(str) {
|
|
2362
|
+
if (!str) return '';
|
|
2363
|
+
return str.replace(/&/g, "&")
|
|
2364
|
+
.replace(/</g, "<")
|
|
2365
|
+
.replace(/>/g, ">")
|
|
2366
|
+
.replace(/"/g, """)
|
|
2367
|
+
.replace(/'/g, "'");
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
// Escapes a value for safe embedding as a single-quoted JS string literal *inside* an
|
|
2371
|
+
// HTML attribute (e.g. onclick="fn('${escapeJsAttr(value)}')"). JS-escaping backslash+quote
|
|
2372
|
+
// alone is not enough: the outer onclick="..." attribute is double-quoted, and the HTML
|
|
2373
|
+
// parser (which finds the attribute's closing quote before any JS is parsed) doesn't
|
|
2374
|
+
// understand a JS \" escape — a raw '"' still ends the attribute early. HTML-escaping the
|
|
2375
|
+
// JS-escaped result closes that gap too.
|
|
2376
|
+
function escapeJsAttr(str) {
|
|
2377
|
+
if (!str) return '';
|
|
2378
|
+
return escapeHtml(String(str).replace(/\\/g, '\\\\').replace(/'/g, "\\'"));
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
// Event listeners
|
|
2382
|
+
monthSelect.addEventListener('change', loadBalances);
|
|
2383
|
+
yearSelect.addEventListener('change', loadBalances);
|
|
2384
|
+
|
|
2385
|
+
// Initialize flatpickr on date inputs
|
|
2386
|
+
|
|
2387
|
+
// Translation engine and dictionaries
|
|
2388
|
+
var TRANSLATIONS = {
|
|
2389
|
+
en: {
|
|
2390
|
+
// Sidebar Menu
|
|
2391
|
+
tooltip_overview: "Overview",
|
|
2392
|
+
tooltip_pending: "Pending",
|
|
2393
|
+
tooltip_comparative: "Comparative",
|
|
2394
|
+
tooltip_projections: "Projections",
|
|
2395
|
+
tooltip_accounts: "Bank Accounts",
|
|
2396
|
+
tooltip_cards: "Credit Cards",
|
|
2397
|
+
menu_categories: "Categories",
|
|
2398
|
+
menu_dashboards: "Dashboards",
|
|
2399
|
+
|
|
2400
|
+
// Month names
|
|
2401
|
+
january: "January", february: "February", march: "March", april: "April", may: "May", june: "June",
|
|
2402
|
+
july: "July", august: "August", september: "September", october: "October", november: "November", december: "December",
|
|
2403
|
+
|
|
2404
|
+
// General UI terms
|
|
2405
|
+
reference_label: "Reference:",
|
|
2406
|
+
day_sun: "Sun", day_mon: "Mon", day_tue: "Tue", day_wed: "Wed", day_thu: "Thu", day_fri: "Fri", day_sat: "Sat",
|
|
2407
|
+
paid: "Paid", unpaid: "Unpaid", active: "Active", inactive: "Inactive",
|
|
2408
|
+
|
|
2409
|
+
// Overview Dashboard
|
|
2410
|
+
overview_title: "Overview",
|
|
2411
|
+
overview_subtitle: "Monthly financial summary, calendar, and quick shortcuts",
|
|
2412
|
+
accounts_balance: "Accounts Balance",
|
|
2413
|
+
expenses_month: "Expenses this Month",
|
|
2414
|
+
card_bills: "Credit Card Bills",
|
|
2415
|
+
incomes_month: "Incomes this Month",
|
|
2416
|
+
final_projection: "Final Projection:",
|
|
2417
|
+
recent_transactions: "Recent Transactions",
|
|
2418
|
+
due_calendar: "Daily Flow & Dues",
|
|
2419
|
+
expenses_distribution: "Expenses Distribution",
|
|
2420
|
+
quick_shortcuts: "Quick Shortcuts",
|
|
2421
|
+
new_transaction: "New Transaction",
|
|
2422
|
+
new_transfer: "New Transfer",
|
|
2423
|
+
new_category: "New Category",
|
|
2424
|
+
new_card: "New Card",
|
|
2425
|
+
new_account: "New Account",
|
|
2426
|
+
no_expenses_month: "No expenses recorded this month.",
|
|
2427
|
+
no_recent_transactions: "No recent transactions found.",
|
|
2428
|
+
no_dues_period: "No transactions due in this period.",
|
|
2429
|
+
income: "Income",
|
|
2430
|
+
expense: "Expense",
|
|
2431
|
+
paid_reconciled: "Paid / Reconciled",
|
|
2432
|
+
|
|
2433
|
+
// Projections / Heatmap Dashboard
|
|
2434
|
+
projections_title: "Recurring & Installment Projections",
|
|
2435
|
+
projections_subtitle: "Advanced visual mapping and projection of active recurrences and installments for the next months",
|
|
2436
|
+
projection_label: "Projection:",
|
|
2437
|
+
months_3: "3 Months",
|
|
2438
|
+
months_6: "6 Months",
|
|
2439
|
+
months_9: "9 Months",
|
|
2440
|
+
months_12: "12 Months",
|
|
2441
|
+
heatmap_income_title: "Recurrent / Installment Incomes",
|
|
2442
|
+
heatmap_expense_title: "Recurrent / Installment Expenses",
|
|
2443
|
+
total: "Total",
|
|
2444
|
+
no_recurrent_incomes: "No active recurrent or installment incomes in the selected semester.",
|
|
2445
|
+
no_recurrent_expenses: "No active recurrent or installment expenses in the selected semester.",
|
|
2446
|
+
modal_details_title: "Projection Breakdown",
|
|
2447
|
+
modal_details_subtitle: "Details of projected transactions for the category and month",
|
|
2448
|
+
col_date: "Date",
|
|
2449
|
+
col_desc: "Description",
|
|
2450
|
+
col_value: "Value",
|
|
2451
|
+
col_status: "Status",
|
|
2452
|
+
btn_close: "Close",
|
|
2453
|
+
|
|
2454
|
+
// Comparative Dashboard
|
|
2455
|
+
comparative_title: "Comparative Dashboard",
|
|
2456
|
+
comparative_subtitle: "Analysis and comparison of monthly incomes vs expenses, and category limits",
|
|
2457
|
+
month_summary_title: "Month Summary",
|
|
2458
|
+
cat_spending_title: "Spending by Category",
|
|
2459
|
+
card_limits_title: "Category Budgets & Limits",
|
|
2460
|
+
col_category: "Category",
|
|
2461
|
+
col_limit: "Budget Limit",
|
|
2462
|
+
col_spent: "Spent",
|
|
2463
|
+
col_status_limit: "Status",
|
|
2464
|
+
col_percentage: "Percentage",
|
|
2465
|
+
within_limit: "Within Limit",
|
|
2466
|
+
exceeded: "Exceeded",
|
|
2467
|
+
reception: "Incomes",
|
|
2468
|
+
deduction: "Expenses",
|
|
2469
|
+
net_balance: "Net Balance",
|
|
2470
|
+
performance: "Financial Health",
|
|
2471
|
+
no_spending_month: "No category spend recorded this month.",
|
|
2472
|
+
|
|
2473
|
+
// Accounts Dashboard
|
|
2474
|
+
accounts_title: "Bank Accounts",
|
|
2475
|
+
accounts_subtitle: "Manage accounts, checking balances, and reviewing statements",
|
|
2476
|
+
active_account_statement: "Account Statement",
|
|
2477
|
+
btn_new_transaction: "New Transaction",
|
|
2478
|
+
btn_new_transfer: "New Transfer",
|
|
2479
|
+
search_description_placeholder: "Type to search...",
|
|
2480
|
+
filter_type_label: "Type",
|
|
2481
|
+
filter_type_all: "All",
|
|
2482
|
+
filter_type_income: "Incomes",
|
|
2483
|
+
filter_type_expense: "Expenses",
|
|
2484
|
+
col_actions: "Actions",
|
|
2485
|
+
action_confirm: "Confirm",
|
|
2486
|
+
action_edit: "Edit",
|
|
2487
|
+
action_delete: "Delete",
|
|
2488
|
+
no_transactions_account: "No transactions recorded for this account in the selected month.",
|
|
2489
|
+
confirm_delete_title: "Are you sure you want to permanently delete this transaction?",
|
|
2490
|
+
modal_new_tx_title: "New Transaction",
|
|
2491
|
+
modal_new_transfer_title: "New Transfer",
|
|
2492
|
+
label_account: "Account",
|
|
2493
|
+
label_description: "Description",
|
|
2494
|
+
label_value: "Value",
|
|
2495
|
+
label_date: "Date",
|
|
2496
|
+
label_category: "Category / Subcategory",
|
|
2497
|
+
label_type: "Type",
|
|
2498
|
+
label_status: "Status",
|
|
2499
|
+
status_pending: "Pending",
|
|
2500
|
+
status_confirmed: "Paid / Confirmed",
|
|
2501
|
+
btn_cancel: "Cancel",
|
|
2502
|
+
btn_save: "Save",
|
|
2503
|
+
label_origin: "Origin Account",
|
|
2504
|
+
label_destination: "Destination Account",
|
|
2505
|
+
|
|
2506
|
+
// Pending Dashboard
|
|
2507
|
+
pending_title: "Pending Transactions",
|
|
2508
|
+
pending_subtitle: "Monitoring and quick confirmation of pending or future transactions",
|
|
2509
|
+
pending_kpi_total: "Total Pending",
|
|
2510
|
+
pending_kpi_incomes: "Pending Incomes",
|
|
2511
|
+
pending_kpi_expenses: "Pending Expenses",
|
|
2512
|
+
pending_chart_incomes: "Pending Incomes Trend",
|
|
2513
|
+
pending_chart_expenses: "Pending Expenses Trend",
|
|
2514
|
+
btn_confirm: "Confirm",
|
|
2515
|
+
btn_edit: "Edit",
|
|
2516
|
+
btn_delete: "Delete",
|
|
2517
|
+
no_pending_transactions: "No pending transactions found for this period.",
|
|
2518
|
+
toast_success_confirm: "Transaction confirmed successfully!",
|
|
2519
|
+
|
|
2520
|
+
// Categories Dashboard
|
|
2521
|
+
categories_title: "Category Management",
|
|
2522
|
+
categories_subtitle: "Visualize, search, and manage categories and subcategories in a clean tree list",
|
|
2523
|
+
btn_new_category: "New Category",
|
|
2524
|
+
search_category_placeholder: "Search categories...",
|
|
2525
|
+
col_type: "Type",
|
|
2526
|
+
col_actions_cat: "Actions",
|
|
2527
|
+
subcategories_label: "Subcategories",
|
|
2528
|
+
no_subcategories: "No subcategories registered.",
|
|
2529
|
+
modal_new_cat_title: "New Category",
|
|
2530
|
+
modal_new_subcat_title: "New Subcategory",
|
|
2531
|
+
label_name: "Name",
|
|
2532
|
+
label_color: "Color",
|
|
2533
|
+
label_parent_category: "Parent Category (Read-Only)",
|
|
2534
|
+
toast_success_cat: "Category created successfully!",
|
|
2535
|
+
toast_success_subcat: "Subcategory created successfully!",
|
|
2536
|
+
|
|
2537
|
+
// Cards Dashboard
|
|
2538
|
+
cards_title: "Credit Cards",
|
|
2539
|
+
cards_subtitle: "Manage credit cards, credit limits, and statement history",
|
|
2540
|
+
card_bill_details: "Card Bill Details",
|
|
2541
|
+
btn_pay_bill: "Pay Bill",
|
|
2542
|
+
btn_revert_payment: "Revert Payment",
|
|
2543
|
+
bill_status: "Bill Status:",
|
|
2544
|
+
status_open: "Open",
|
|
2545
|
+
status_closed: "Closed",
|
|
2546
|
+
status_paid: "Paid",
|
|
2547
|
+
no_card_transactions: "No transactions recorded for this card bill in the selected cycle.",
|
|
2548
|
+
|
|
2549
|
+
// Dashboards Manager Dashboard
|
|
2550
|
+
dashboards_title: "Dashboards Monitor",
|
|
2551
|
+
dashboards_subtitle: "List, view source, and upload patty dashboards",
|
|
2552
|
+
col_dashboard: "Dashboard",
|
|
2553
|
+
col_last_update: "Last Updated",
|
|
2554
|
+
btn_view_source: "View Source",
|
|
2555
|
+
btn_download: "Download",
|
|
2556
|
+
upload_new_dashboard: "Upload New Dashboard",
|
|
2557
|
+
placeholder_dashboard_name: "Dashboard Name (e.g. pending)",
|
|
2558
|
+
upload_instructions: "Select or drop HTML file here to upload",
|
|
2559
|
+
btn_upload: "Upload",
|
|
2560
|
+
modal_source_title: "HTML Source Code",
|
|
2561
|
+
|
|
2562
|
+
// Tags Management
|
|
2563
|
+
menu_tags: "Tags",
|
|
2564
|
+
tags_title: "Tag Management",
|
|
2565
|
+
tags_subtitle: "Manage tags to label and organize your transactions",
|
|
2566
|
+
panel_title_tags: "Active Tags",
|
|
2567
|
+
btn_new_tag: "New Tag",
|
|
2568
|
+
label_tag_name: "Tag Name",
|
|
2569
|
+
placeholder_tag_name: "E.g. work, travel, refund",
|
|
2570
|
+
empty_tags_message: "No tags registered.",
|
|
2571
|
+
btn_save: "Save",
|
|
2572
|
+
btn_cancel: "Cancel",
|
|
2573
|
+
toast_success_tag_created: 'Tag "{name}" created successfully!',
|
|
2574
|
+
toast_success_tag_deleted: 'Tag "{name}" deleted successfully!',
|
|
2575
|
+
confirm_delete_tag: 'Are you sure you want to delete tag "{name}"?\n(This action will remove the tag from all linked transactions)'
|
|
2576
|
+
},
|
|
2577
|
+
pt: {
|
|
2578
|
+
// Sidebar Menu
|
|
2579
|
+
tooltip_overview: "Visão Geral",
|
|
2580
|
+
tooltip_pending: "Pendentes",
|
|
2581
|
+
tooltip_comparative: "Comparativo",
|
|
2582
|
+
tooltip_projections: "Projeções",
|
|
2583
|
+
tooltip_accounts: "Contas Bancárias",
|
|
2584
|
+
tooltip_cards: "Cartões de Crédito",
|
|
2585
|
+
menu_categories: "Categorias",
|
|
2586
|
+
menu_dashboards: "Dashboards",
|
|
2587
|
+
|
|
2588
|
+
// Month names
|
|
2589
|
+
january: "Janeiro", february: "Fevereiro", march: "Março", april: "Abril", may: "Maio", june: "Junho",
|
|
2590
|
+
july: "Julho", august: "Agosto", september: "Setembro", october: "Outubro", november: "Novembro", december: "Dezembro",
|
|
2591
|
+
|
|
2592
|
+
// General UI terms
|
|
2593
|
+
reference_label: "Referência:",
|
|
2594
|
+
day_sun: "Dom", day_mon: "Seg", day_tue: "Ter", day_wed: "Qua", day_thu: "Qui", day_fri: "Sex", day_sat: "Sáb",
|
|
2595
|
+
paid: "Pago", unpaid: "Não Pago", active: "Ativo", inactive: "Inativo",
|
|
2596
|
+
|
|
2597
|
+
// Overview Dashboard
|
|
2598
|
+
overview_title: "Visão Geral",
|
|
2599
|
+
overview_subtitle: "Consolidado financeiro mensal, calendário e atalhos rápidos",
|
|
2600
|
+
accounts_balance: "Saldo em Contas",
|
|
2601
|
+
expenses_month: "Despesas do Mês",
|
|
2602
|
+
card_bills: "Faturas de Cartão",
|
|
2603
|
+
incomes_month: "Receitas do Mês",
|
|
2604
|
+
final_projection: "Projeção Final:",
|
|
2605
|
+
recent_transactions: "Lançamentos Recentes",
|
|
2606
|
+
due_calendar: "Fluxo Diário",
|
|
2607
|
+
expenses_distribution: "Distribuição de Despesas",
|
|
2608
|
+
quick_shortcuts: "Atalhos Rápidos",
|
|
2609
|
+
new_transaction: "Novo Lançamento",
|
|
2610
|
+
new_transfer: "Nova Transferência",
|
|
2611
|
+
new_category: "Nova Categoria",
|
|
2612
|
+
new_card: "Novo Cartão",
|
|
2613
|
+
new_account: "Nova Conta",
|
|
2614
|
+
no_expenses_month: "Sem despesas registradas neste mês.",
|
|
2615
|
+
no_recent_transactions: "Nenhuma transação recente encontrada.",
|
|
2616
|
+
no_dues_period: "Sem vencimentos neste período.",
|
|
2617
|
+
income: "Receita",
|
|
2618
|
+
expense: "Despesa",
|
|
2619
|
+
paid_reconciled: "Pago / Conciliado",
|
|
2620
|
+
|
|
2621
|
+
// Projections / Heatmap Dashboard
|
|
2622
|
+
projections_title: "Projeção de Recorrências e Parcelas",
|
|
2623
|
+
projections_subtitle: "Mapeamento visual avançado e projeção de recorrências e parcelas ativas para os próximos meses",
|
|
2624
|
+
projection_label: "Projeção:",
|
|
2625
|
+
months_3: "3 Meses",
|
|
2626
|
+
months_6: "6 Meses",
|
|
2627
|
+
months_9: "9 Meses",
|
|
2628
|
+
months_12: "12 Meses",
|
|
2629
|
+
heatmap_income_title: "Receitas Recorrentes / Parceladas",
|
|
2630
|
+
heatmap_expense_title: "Despesas Recorrentes / Parceladas",
|
|
2631
|
+
total: "Total",
|
|
2632
|
+
no_recurrent_incomes: "Nenhuma receita recorrente/parcelada ativa no semestre.",
|
|
2633
|
+
no_recurrent_expenses: "Nenhuma despesa recorrente/parcelada ativa no semestre.",
|
|
2634
|
+
modal_details_title: "Detalhamento de Projeções",
|
|
2635
|
+
modal_details_subtitle: "Detalhes das transações projetadas para a categoria e mês",
|
|
2636
|
+
col_date: "Data",
|
|
2637
|
+
col_desc: "Descrição",
|
|
2638
|
+
col_value: "Valor",
|
|
2639
|
+
col_status: "Status",
|
|
2640
|
+
btn_close: "Fechar",
|
|
2641
|
+
|
|
2642
|
+
// Comparative Dashboard
|
|
2643
|
+
comparative_title: "Dashboard Comparativo",
|
|
2644
|
+
comparative_subtitle: "Análise e comparação mensal de receitas vs despesas e limites por categoria",
|
|
2645
|
+
month_summary_title: "Resumo do Mês",
|
|
2646
|
+
cat_spending_title: "Gastos por Categoria",
|
|
2647
|
+
card_limits_title: "Orçamentos e Limites de Categorias",
|
|
2648
|
+
col_category: "Categoria",
|
|
2649
|
+
col_limit: "Limite de Orçamento",
|
|
2650
|
+
col_spent: "Gasto",
|
|
2651
|
+
col_status_limit: "Status",
|
|
2652
|
+
col_percentage: "Porcentagem",
|
|
2653
|
+
within_limit: "Dentro do Limite",
|
|
2654
|
+
exceeded: "Excedido",
|
|
2655
|
+
reception: "Receitas",
|
|
2656
|
+
deduction: "Despesas",
|
|
2657
|
+
net_balance: "Saldo Líquido",
|
|
2658
|
+
performance: "Saúde Financeira",
|
|
2659
|
+
no_spending_month: "Sem despesas registradas por categoria neste mês.",
|
|
2660
|
+
|
|
2661
|
+
// Accounts Dashboard
|
|
2662
|
+
accounts_title: "Minhas Contas",
|
|
2663
|
+
accounts_subtitle: "Gerencie contas, consulte saldos e revise extratos",
|
|
2664
|
+
active_account_statement: "Extrato de Conta",
|
|
2665
|
+
btn_new_transaction: "Novo Lançamento",
|
|
2666
|
+
btn_new_transfer: "Nova Transferência",
|
|
2667
|
+
search_description_placeholder: "Digite para filtrar...",
|
|
2668
|
+
filter_type_label: "Tipo",
|
|
2669
|
+
filter_type_all: "Todos",
|
|
2670
|
+
filter_type_income: "Receitas",
|
|
2671
|
+
filter_type_expense: "Despesas",
|
|
2672
|
+
col_actions: "Ações",
|
|
2673
|
+
action_confirm: "Confirmar",
|
|
2674
|
+
action_edit: "Editar",
|
|
2675
|
+
action_delete: "Excluir",
|
|
2676
|
+
no_transactions_account: "Nenhum lançamento nesta conta para o mês selecionado.",
|
|
2677
|
+
confirm_delete_title: "Deseja excluir definitivamente a transação?",
|
|
2678
|
+
modal_new_tx_title: "Novo Lançamento",
|
|
2679
|
+
modal_new_transfer_title: "Nova Transferência",
|
|
2680
|
+
label_account: "Conta",
|
|
2681
|
+
label_description: "Descrição",
|
|
2682
|
+
label_value: "Valor",
|
|
2683
|
+
label_date: "Data",
|
|
2684
|
+
label_category: "Categoria / Subcategoria",
|
|
2685
|
+
label_type: "Tipo",
|
|
2686
|
+
label_status: "Status",
|
|
2687
|
+
status_pending: "Pendente",
|
|
2688
|
+
status_confirmed: "Pago / Confirmado",
|
|
2689
|
+
btn_cancel: "Cancelar",
|
|
2690
|
+
btn_save: "Salvar",
|
|
2691
|
+
label_origin: "Conta Origem",
|
|
2692
|
+
label_destination: "Conta Destino",
|
|
2693
|
+
|
|
2694
|
+
// Pending Dashboard
|
|
2695
|
+
pending_title: "Transações Pendentes",
|
|
2696
|
+
pending_subtitle: "Monitoramento e confirmação rápida de lançamentos pendentes ou futuros",
|
|
2697
|
+
pending_kpi_total: "Total Pendente",
|
|
2698
|
+
pending_kpi_incomes: "Receitas Pendentes",
|
|
2699
|
+
pending_kpi_expenses: "Despesas Pendentes",
|
|
2700
|
+
pending_chart_incomes: "Tendência de Receitas Pendentes",
|
|
2701
|
+
pending_chart_expenses: "Tendência de Despesas Pendentes",
|
|
2702
|
+
btn_confirm: "Confirmar",
|
|
2703
|
+
btn_edit: "Editar",
|
|
2704
|
+
btn_delete: "Excluir",
|
|
2705
|
+
no_pending_transactions: "Nenhuma transação pendente encontrada para este período.",
|
|
2706
|
+
toast_success_confirm: "Transação confirmada com sucesso!",
|
|
2707
|
+
|
|
2708
|
+
// Categories Dashboard
|
|
2709
|
+
categories_title: "Gerenciamento de Categorias",
|
|
2710
|
+
categories_subtitle: "Visualize, pesquise e gerencie categorias e subcategorias em árvore",
|
|
2711
|
+
btn_new_category: "Nova Categoria",
|
|
2712
|
+
search_category_placeholder: "Pesquisar categorias...",
|
|
2713
|
+
col_type: "Tipo",
|
|
2714
|
+
col_actions_cat: "Ações",
|
|
2715
|
+
subcategories_label: "Subcategorias",
|
|
2716
|
+
no_subcategories: "Nenhuma subcategoria cadastrada.",
|
|
2717
|
+
modal_new_cat_title: "Nova Categoria",
|
|
2718
|
+
modal_new_subcat_title: "Nova Subcategoria",
|
|
2719
|
+
label_name: "Nome",
|
|
2720
|
+
label_color: "Cor",
|
|
2721
|
+
label_parent_category: "Categoria Pai (Somente Leitura)",
|
|
2722
|
+
toast_success_cat: "Categoria criada com sucesso!",
|
|
2723
|
+
toast_success_subcat: "Subcategoria criada com sucesso!",
|
|
2724
|
+
|
|
2725
|
+
// Cards Dashboard
|
|
2726
|
+
cards_title: "Cartões de Crédito",
|
|
2727
|
+
cards_subtitle: "Gerencie cartões de crédito, limites e histórico de faturas",
|
|
2728
|
+
card_bill_details: "Detalhamento de Fatura",
|
|
2729
|
+
btn_pay_bill: "Pagar Fatura",
|
|
2730
|
+
btn_revert_payment: "Estornar Pagamento",
|
|
2731
|
+
bill_status: "Status da Fatura:",
|
|
2732
|
+
status_open: "Aberta",
|
|
2733
|
+
status_closed: "Fechada",
|
|
2734
|
+
status_paid: "Paga",
|
|
2735
|
+
no_card_transactions: "Nenhuma transação registrada nesta fatura para o ciclo selecionado.",
|
|
2736
|
+
|
|
2737
|
+
// Dashboards Manager Dashboard
|
|
2738
|
+
dashboards_title: "Monitor de Dashboards",
|
|
2739
|
+
dashboards_subtitle: "Liste, visualize o código fonte e envie dashboards para o servidor do patty",
|
|
2740
|
+
col_dashboard: "Dashboard",
|
|
2741
|
+
col_last_update: "Última Atualização",
|
|
2742
|
+
btn_view_source: "Ver Código",
|
|
2743
|
+
btn_download: "Baixar HTML",
|
|
2744
|
+
upload_new_dashboard: "Enviar Novo Dashboard",
|
|
2745
|
+
placeholder_dashboard_name: "Nome do Dashboard (ex: pending)",
|
|
2746
|
+
upload_instructions: "Selecione ou solte o arquivo HTML aqui para upload",
|
|
2747
|
+
btn_upload: "Fazer Upload",
|
|
2748
|
+
modal_source_title: "Código Fonte HTML",
|
|
2749
|
+
|
|
2750
|
+
// Tags Management
|
|
2751
|
+
menu_tags: "Tags",
|
|
2752
|
+
tags_title: "Gerenciar Tags",
|
|
2753
|
+
tags_subtitle: "Gerencie as tags utilizadas para rotular e categorizar suas transações",
|
|
2754
|
+
panel_title_tags: "Tags Ativas",
|
|
2755
|
+
btn_new_tag: "Nova Tag",
|
|
2756
|
+
label_tag_name: "Nome da Tag",
|
|
2757
|
+
placeholder_tag_name: "Ex: trabalho, viagem, reembolso",
|
|
2758
|
+
empty_tags_message: "Nenhuma tag cadastrada.",
|
|
2759
|
+
btn_save: "Salvar",
|
|
2760
|
+
btn_cancel: "Cancelar",
|
|
2761
|
+
toast_success_tag_created: 'Tag "{name}" criada com sucesso!',
|
|
2762
|
+
toast_success_tag_deleted: 'Tag "{name}" excluída com sucesso!',
|
|
2763
|
+
confirm_delete_tag: 'Deseja realmente excluir a tag "{name}"?\n(Esta ação removerá a tag de todas as transações vinculadas)'
|
|
2764
|
+
},
|
|
2765
|
+
es: {
|
|
2766
|
+
// Sidebar Menu
|
|
2767
|
+
tooltip_overview: "Vista General",
|
|
2768
|
+
tooltip_pending: "Pendientes",
|
|
2769
|
+
tooltip_comparative: "Comparativo",
|
|
2770
|
+
tooltip_projections: "Proyecciones",
|
|
2771
|
+
tooltip_accounts: "Cuentas Bancárias",
|
|
2772
|
+
tooltip_cards: "Tarjetas de Crédito",
|
|
2773
|
+
menu_categories: "Categorías",
|
|
2774
|
+
menu_dashboards: "Dashboards",
|
|
2775
|
+
|
|
2776
|
+
// Month names
|
|
2777
|
+
january: "Enero", february: "Febrero", march: "Marzo", april: "Abril", may: "Mayo", june: "Junio",
|
|
2778
|
+
july: "Julio", august: "Agosto", september: "Septiembre", october: "Octubre", november: "Noviembre", december: "Diciembre",
|
|
2779
|
+
|
|
2780
|
+
// General UI terms
|
|
2781
|
+
reference_label: "Referencia:",
|
|
2782
|
+
day_sun: "Dom", day_mon: "Lun", day_tue: "Mar", day_wed: "Mié", day_thu: "Jue", day_fri: "Vie", day_sat: "Sáb",
|
|
2783
|
+
paid: "Pagado", unpaid: "No Pagado", active: "Activo", inactive: "Inactivo",
|
|
2784
|
+
|
|
2785
|
+
// Overview Dashboard
|
|
2786
|
+
overview_title: "Vista General",
|
|
2787
|
+
overview_subtitle: "Resumen financiero mensual, calendario y accesos rápidos",
|
|
2788
|
+
accounts_balance: "Saldo en Cuentas",
|
|
2789
|
+
expenses_month: "Gastos del Mes",
|
|
2790
|
+
card_bills: "Facturas de Tarjeta",
|
|
2791
|
+
incomes_month: "Ingresos del Mes",
|
|
2792
|
+
final_projection: "Proyección Final:",
|
|
2793
|
+
recent_transactions: "Transacciones Recientes",
|
|
2794
|
+
due_calendar: "Calendario de Pagos",
|
|
2795
|
+
expenses_distribution: "Distribución de Gastos",
|
|
2796
|
+
quick_shortcuts: "Accesos Rápidos",
|
|
2797
|
+
new_transaction: "Nueva Transacción",
|
|
2798
|
+
new_transfer: "Nueva Transferencia",
|
|
2799
|
+
new_category: "Nueva Categoría",
|
|
2800
|
+
new_card: "Nueva Tarjeta",
|
|
2801
|
+
new_account: "Nueva Cuenta",
|
|
2802
|
+
no_expenses_month: "No hay gastos registrados este mes.",
|
|
2803
|
+
no_recent_transactions: "No se encontraron transacciones recientes.",
|
|
2804
|
+
no_dues_period: "Sin vencimientos en este período.",
|
|
2805
|
+
income: "Ingreso",
|
|
2806
|
+
expense: "Gasto",
|
|
2807
|
+
paid_reconciled: "Pagado / Conciliado",
|
|
2808
|
+
|
|
2809
|
+
// Projections / Heatmap Dashboard
|
|
2810
|
+
projections_title: "Proyección de Recurrencias y Cuotas",
|
|
2811
|
+
projections_subtitle: "Mapeo visual avanzado y proyección de recurrencias y cuotas activas para los próximos meses",
|
|
2812
|
+
projection_label: "Proyección:",
|
|
2813
|
+
months_3: "3 Meses",
|
|
2814
|
+
months_6: "6 Meses",
|
|
2815
|
+
months_9: "9 Meses",
|
|
2816
|
+
months_12: "12 Meses",
|
|
2817
|
+
heatmap_income_title: "Ingresos Recurrentes / Cuotas",
|
|
2818
|
+
heatmap_expense_title: "Gastos Recurrentes / Cuotas",
|
|
2819
|
+
total: "Total",
|
|
2820
|
+
no_recurrent_incomes: "Ningún ingreso recurrente o en cuotas activo en el semestre seleccionado.",
|
|
2821
|
+
no_recurrent_expenses: "Ningún gasto recurrente o en cuotas activo en el semestre seleccionado.",
|
|
2822
|
+
modal_details_title: "Detalle de Proyecciones",
|
|
2823
|
+
modal_details_subtitle: "Detalles de transacciones proyectadas para la categoría y mes",
|
|
2824
|
+
col_date: "Fecha",
|
|
2825
|
+
col_desc: "Descripción",
|
|
2826
|
+
col_value: "Valor",
|
|
2827
|
+
col_status: "Estado",
|
|
2828
|
+
btn_close: "Cerrar",
|
|
2829
|
+
|
|
2830
|
+
// Comparative Dashboard
|
|
2831
|
+
comparative_title: "Dashboard Comparativo",
|
|
2832
|
+
comparative_subtitle: "Análisis y comparación mensual de ingresos vs gastos y límites por categoría",
|
|
2833
|
+
month_summary_title: "Resumen del Mes",
|
|
2834
|
+
cat_spending_title: "Gastos por Categoría",
|
|
2835
|
+
card_limits_title: "Presupuestos y Límites de Categorías",
|
|
2836
|
+
col_category: "Categoría",
|
|
2837
|
+
col_limit: "Límite de Presupuesto",
|
|
2838
|
+
col_spent: "Gastado",
|
|
2839
|
+
col_status_limit: "Estado",
|
|
2840
|
+
col_percentage: "Porcentaje",
|
|
2841
|
+
within_limit: "Dentro del Límite",
|
|
2842
|
+
exceeded: "Excedido",
|
|
2843
|
+
reception: "Ingresos",
|
|
2844
|
+
deduction: "Gastos",
|
|
2845
|
+
net_balance: "Saldo Neto",
|
|
2846
|
+
performance: "Salud Financiera",
|
|
2847
|
+
no_spending_month: "No hay gastos registrados por categoría este mes.",
|
|
2848
|
+
|
|
2849
|
+
// Accounts Dashboard
|
|
2850
|
+
accounts_title: "Cuentas Bancarias",
|
|
2851
|
+
accounts_subtitle: "Administre cuentas, consulte saldos y revise extractos",
|
|
2852
|
+
active_account_statement: "Extracto de Cuenta",
|
|
2853
|
+
btn_new_transaction: "Nueva Transacción",
|
|
2854
|
+
btn_new_transfer: "Nueva Transferencia",
|
|
2855
|
+
search_description_placeholder: "Escriba para filtrar...",
|
|
2856
|
+
filter_type_label: "Tipo",
|
|
2857
|
+
filter_type_all: "Todos",
|
|
2858
|
+
filter_type_income: "Ingresos",
|
|
2859
|
+
filter_type_expense: "Gastos",
|
|
2860
|
+
col_actions: "Acciones",
|
|
2861
|
+
action_confirm: "Confirmar",
|
|
2862
|
+
action_edit: "Editar",
|
|
2863
|
+
action_delete: "Eliminar",
|
|
2864
|
+
no_transactions_account: "No hay transacciones registradas en esta cuenta en el mes seleccionado.",
|
|
2865
|
+
confirm_delete_title: "¿Está seguro de eliminar definitivamente esta transacción?",
|
|
2866
|
+
modal_new_tx_title: "Nueva Transacción",
|
|
2867
|
+
modal_new_transfer_title: "Nueva Transferencia",
|
|
2868
|
+
label_account: "Cuenta",
|
|
2869
|
+
label_description: "Descripción",
|
|
2870
|
+
label_value: "Valor",
|
|
2871
|
+
label_date: "Fecha",
|
|
2872
|
+
label_category: "Categoría / Subcategoría",
|
|
2873
|
+
label_type: "Tipo",
|
|
2874
|
+
label_status: "Estado",
|
|
2875
|
+
status_pending: "Pendiente",
|
|
2876
|
+
status_confirmed: "Pagado / Confirmado",
|
|
2877
|
+
btn_cancel: "Cancelar",
|
|
2878
|
+
btn_save: "Guardar",
|
|
2879
|
+
label_origin: "Cuenta Origen",
|
|
2880
|
+
label_destination: "Cuenta Destino",
|
|
2881
|
+
|
|
2882
|
+
// Pending Dashboard
|
|
2883
|
+
pending_title: "Transacciones Pendientes",
|
|
2884
|
+
pending_subtitle: "Monitoreo y confirmación rápida de transacciones pendientes o futuras",
|
|
2885
|
+
pending_kpi_total: "Total Pendiente",
|
|
2886
|
+
pending_kpi_incomes: "Ingresos Pendientes",
|
|
2887
|
+
pending_kpi_expenses: "Gastos Pendientes",
|
|
2888
|
+
pending_chart_incomes: "Tendencia de Ingresos Pendientes",
|
|
2889
|
+
pending_chart_expenses: "Tendencia de Gastos Pendientes",
|
|
2890
|
+
btn_confirm: "Confirmar",
|
|
2891
|
+
btn_edit: "Editar",
|
|
2892
|
+
btn_delete: "Eliminar",
|
|
2893
|
+
no_pending_transactions: "No se encontraron transacciones pendientes en este período.",
|
|
2894
|
+
toast_success_confirm: "¡Transacción confirmada con éxito!",
|
|
2895
|
+
|
|
2896
|
+
// Categories Dashboard
|
|
2897
|
+
categories_title: "Gestión de Categorías",
|
|
2898
|
+
categories_subtitle: "Visualice, busque y gestione categorías y subcategorías en árbol",
|
|
2899
|
+
btn_new_category: "Nueva Categoría",
|
|
2900
|
+
search_category_placeholder: "Buscar categorías...",
|
|
2901
|
+
col_type: "Tipo",
|
|
2902
|
+
col_actions_cat: "Acciones",
|
|
2903
|
+
subcategories_label: "Subcategorías",
|
|
2904
|
+
no_subcategories: "Ninguna subcategoría registrada.",
|
|
2905
|
+
modal_new_cat_title: "Nueva Categoría",
|
|
2906
|
+
modal_new_subcat_title: "Nueva Subcategoría",
|
|
2907
|
+
label_name: "Nombre",
|
|
2908
|
+
label_color: "Color",
|
|
2909
|
+
label_parent_category: "Categoría Padre (Solo Lectura)",
|
|
2910
|
+
toast_success_cat: "¡Categoría creada con éxito!",
|
|
2911
|
+
toast_success_subcat: "¡Subcategoría creada con éxito!",
|
|
2912
|
+
|
|
2913
|
+
// Cards Dashboard
|
|
2914
|
+
cards_title: "Tarjetas de Crédito",
|
|
2915
|
+
cards_subtitle: "Gestione tarjetas de crédito, límites y facturas",
|
|
2916
|
+
card_bill_details: "Detalle de Factura",
|
|
2917
|
+
btn_pay_bill: "Pagar Factura",
|
|
2918
|
+
btn_revert_payment: "Revertir Pago",
|
|
2919
|
+
bill_status: "Estado de la Factura:",
|
|
2920
|
+
status_open: "Abierta",
|
|
2921
|
+
status_closed: "Cerrada",
|
|
2922
|
+
status_paid: "Pagada",
|
|
2923
|
+
no_card_transactions: "Ninguna transacción registrada en esta factura para el ciclo seleccionado.",
|
|
2924
|
+
|
|
2925
|
+
// Dashboards Manager Dashboard
|
|
2926
|
+
dashboards_title: "Gestor de Dashboards",
|
|
2927
|
+
dashboards_subtitle: "Liste, vea el código fuente y suba dashboards al servidor de patty",
|
|
2928
|
+
col_dashboard: "Dashboard",
|
|
2929
|
+
col_last_update: "Última Actualización",
|
|
2930
|
+
btn_view_source: "Ver Código",
|
|
2931
|
+
btn_download: "Descargar HTML",
|
|
2932
|
+
upload_new_dashboard: "Subir Nuevo Dashboard",
|
|
2933
|
+
placeholder_dashboard_name: "Nombre del Dashboard (ej: pending)",
|
|
2934
|
+
upload_instructions: "Seleccione o arrastre el archivo HTML aquí para subir",
|
|
2935
|
+
btn_upload: "Subir Dashboard",
|
|
2936
|
+
modal_source_title: "Código Fuente HTML",
|
|
2937
|
+
|
|
2938
|
+
// Tags Management
|
|
2939
|
+
menu_tags: "Etiquetas",
|
|
2940
|
+
tags_title: "Administrar Etiquetas",
|
|
2941
|
+
tags_subtitle: "Administre las etiquetas utilizadas para etiquetar y organizar sus transacciones",
|
|
2942
|
+
panel_title_tags: "Etiquetas Activas",
|
|
2943
|
+
btn_new_tag: "Nueva Etiqueta",
|
|
2944
|
+
label_tag_name: "Nombre de la Etiqueta",
|
|
2945
|
+
placeholder_tag_name: "Ej: trabajo, viaje, reembolso",
|
|
2946
|
+
empty_tags_message: "No hay etiquetas registradas.",
|
|
2947
|
+
btn_save: "Guardar",
|
|
2948
|
+
btn_cancel: "Cancelar",
|
|
2949
|
+
toast_success_tag_created: '¡Etiqueta "{name}" creada con éxito!',
|
|
2950
|
+
toast_success_tag_deleted: '¡Etiqueta "{name}" eliminada con éxito!',
|
|
2951
|
+
confirm_delete_tag: '¿Realmente deseja eliminar la etiqueta "{name}"?\n(Esta acción eliminará la etiqueta de todas las transacciones vinculadas)'
|
|
2952
|
+
}
|
|
2953
|
+
};
|
|
2954
|
+
|
|
2955
|
+
var currentLocale = 'en'; // English as default
|
|
2956
|
+
|
|
2957
|
+
// Helper to translate in JS
|
|
2958
|
+
function t(key) {
|
|
2959
|
+
const tDict = TRANSLATIONS[currentLocale] || TRANSLATIONS['en'];
|
|
2960
|
+
return tDict[key] || key;
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
async function checkLocale() {
|
|
2964
|
+
try {
|
|
2965
|
+
const res = await fetch('/api/status');
|
|
2966
|
+
if (res.ok) {
|
|
2967
|
+
const data = await res.json();
|
|
2968
|
+
if (data.locale && TRANSLATIONS[data.locale]) {
|
|
2969
|
+
currentLocale = data.locale;
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
} catch (err) {
|
|
2973
|
+
console.error("Failed to read locale preferences:", err);
|
|
2974
|
+
}
|
|
2975
|
+
translatePage();
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
function translatePage() {
|
|
2979
|
+
const tDict = TRANSLATIONS[currentLocale] || TRANSLATIONS['en'];
|
|
2980
|
+
|
|
2981
|
+
// 1. Static texts
|
|
2982
|
+
document.querySelectorAll('[data-i18n]').forEach(el => {
|
|
2983
|
+
const key = el.getAttribute('data-i18n');
|
|
2984
|
+
if (tDict[key]) {
|
|
2985
|
+
const icon = el.querySelector('i');
|
|
2986
|
+
if (icon) {
|
|
2987
|
+
const iconOuter = icon.outerHTML;
|
|
2988
|
+
el.innerHTML = iconOuter + ' ' + tDict[key];
|
|
2989
|
+
} else {
|
|
2990
|
+
el.textContent = tDict[key];
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
});
|
|
2994
|
+
|
|
2995
|
+
// 2. Placeholders
|
|
2996
|
+
document.querySelectorAll('[data-i18n-placeholder]').forEach(el => {
|
|
2997
|
+
const key = el.getAttribute('data-i18n-placeholder');
|
|
2998
|
+
if (tDict[key]) {
|
|
2999
|
+
el.placeholder = tDict[key];
|
|
3000
|
+
}
|
|
3001
|
+
});
|
|
3002
|
+
|
|
3003
|
+
// 3. Tooltips
|
|
3004
|
+
document.querySelectorAll('[data-i18n-tooltip]').forEach(el => {
|
|
3005
|
+
const key = el.getAttribute('data-i18n-tooltip');
|
|
3006
|
+
if (tDict[key]) {
|
|
3007
|
+
el.setAttribute('data-tooltip', tDict[key]);
|
|
3008
|
+
}
|
|
3009
|
+
});
|
|
3010
|
+
|
|
3011
|
+
// 4. Document title translation
|
|
3012
|
+
if (tDict['overview_title'] && document.title.includes("Overview") || document.title.includes("Visão")) {
|
|
3013
|
+
// dynamic title update fallback if needed
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
// 5. Translate select months
|
|
3017
|
+
const monthSelects = [
|
|
3018
|
+
document.getElementById('month-select'),
|
|
3019
|
+
document.getElementById('start-month-select')
|
|
3020
|
+
];
|
|
3021
|
+
monthSelects.forEach(monthSelect => {
|
|
3022
|
+
if (monthSelect) {
|
|
3023
|
+
const monthKeys = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
|
|
3024
|
+
Array.from(monthSelect.options).forEach((opt, idx) => {
|
|
3025
|
+
const key = monthKeys[idx];
|
|
3026
|
+
if (tDict[key]) {
|
|
3027
|
+
opt.textContent = tDict[key];
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
3031
|
+
});
|
|
3032
|
+
|
|
3033
|
+
// 6. Translate projection months select options (3, 6, 9, 12 months)
|
|
3034
|
+
const hmSelect = document.getElementById('heatmap-months-select');
|
|
3035
|
+
if (hmSelect) {
|
|
3036
|
+
Array.from(hmSelect.options).forEach(opt => {
|
|
3037
|
+
const val = opt.value;
|
|
3038
|
+
const key = `months_${val}`;
|
|
3039
|
+
if (tDict[key]) {
|
|
3040
|
+
opt.textContent = tDict[key];
|
|
3041
|
+
}
|
|
3042
|
+
});
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
// Automatically initialize/refresh custom selects on all pages
|
|
3046
|
+
if (typeof initCustomSelects === 'function') {
|
|
3047
|
+
initCustomSelects();
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
// Custom Select Component implementation
|
|
3052
|
+
function initCustomSelects() {
|
|
3053
|
+
document.querySelectorAll('select.select-custom').forEach(select => {
|
|
3054
|
+
if (select.nextElementSibling && select.nextElementSibling.classList.contains('select-container-custom')) {
|
|
3055
|
+
// Already initialized, just sync selected value
|
|
3056
|
+
const container = select.nextElementSibling;
|
|
3057
|
+
const triggerSpan = container.querySelector('.select-trigger-custom span');
|
|
3058
|
+
const selectedOpt = select.options[select.selectedIndex];
|
|
3059
|
+
if (selectedOpt && triggerSpan) {
|
|
3060
|
+
triggerSpan.textContent = selectedOpt.textContent;
|
|
3061
|
+
}
|
|
3062
|
+
return;
|
|
3063
|
+
}
|
|
3064
|
+
select.style.display = 'none';
|
|
3065
|
+
const container = document.createElement('div');
|
|
3066
|
+
container.className = 'select-container-custom';
|
|
3067
|
+
|
|
3068
|
+
// Match specific element custom min-widths
|
|
3069
|
+
if (select.id === 'heatmap-months-select') {
|
|
3070
|
+
container.style.minWidth = '110px';
|
|
3071
|
+
} else if (select.id === 'year-select') {
|
|
3072
|
+
container.style.minWidth = '90px';
|
|
3073
|
+
} else if (select.id === 'filter-type') {
|
|
3074
|
+
container.style.minWidth = '130px';
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
const trigger = document.createElement('div');
|
|
3078
|
+
trigger.className = 'select-trigger-custom';
|
|
3079
|
+
const triggerSpan = document.createElement('span');
|
|
3080
|
+
trigger.appendChild(triggerSpan);
|
|
3081
|
+
container.appendChild(trigger);
|
|
3082
|
+
const optionsContainer = document.createElement('div');
|
|
3083
|
+
optionsContainer.className = 'select-options-custom';
|
|
3084
|
+
container.appendChild(optionsContainer);
|
|
3085
|
+
|
|
3086
|
+
function syncSelected() {
|
|
3087
|
+
const selectedOpt = select.options[select.selectedIndex] || select.options[0];
|
|
3088
|
+
if (selectedOpt) {
|
|
3089
|
+
triggerSpan.textContent = selectedOpt.textContent;
|
|
3090
|
+
Array.from(optionsContainer.children).forEach(child => {
|
|
3091
|
+
if (child.getAttribute('data-value') === select.value) {
|
|
3092
|
+
child.classList.add('selected');
|
|
3093
|
+
} else {
|
|
3094
|
+
child.classList.remove('selected');
|
|
3095
|
+
}
|
|
3096
|
+
});
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
function populateOptions() {
|
|
3101
|
+
optionsContainer.innerHTML = '';
|
|
3102
|
+
Array.from(select.options).forEach(opt => {
|
|
3103
|
+
const optDiv = document.createElement('div');
|
|
3104
|
+
optDiv.className = 'select-option-custom';
|
|
3105
|
+
optDiv.textContent = opt.textContent;
|
|
3106
|
+
optDiv.setAttribute('data-value', opt.value);
|
|
3107
|
+
optDiv.addEventListener('click', (e) => {
|
|
3108
|
+
e.stopPropagation();
|
|
3109
|
+
select.value = opt.value;
|
|
3110
|
+
select.dispatchEvent(new Event('change'));
|
|
3111
|
+
syncSelected();
|
|
3112
|
+
container.classList.remove('open');
|
|
3113
|
+
});
|
|
3114
|
+
optionsContainer.appendChild(optDiv);
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3118
|
+
populateOptions();
|
|
3119
|
+
syncSelected();
|
|
3120
|
+
|
|
3121
|
+
trigger.addEventListener('click', (e) => {
|
|
3122
|
+
e.stopPropagation();
|
|
3123
|
+
const isOpen = container.classList.contains('open');
|
|
3124
|
+
document.querySelectorAll('.select-container-custom').forEach(el => {
|
|
3125
|
+
el.classList.remove('open');
|
|
3126
|
+
});
|
|
3127
|
+
if (!isOpen) {
|
|
3128
|
+
populateOptions();
|
|
3129
|
+
syncSelected();
|
|
3130
|
+
container.classList.add('open');
|
|
3131
|
+
setTimeout(() => {
|
|
3132
|
+
const selectedEl = optionsContainer.querySelector('.select-option-custom.selected');
|
|
3133
|
+
if (selectedEl) {
|
|
3134
|
+
const itemHeight = selectedEl.offsetHeight || 36;
|
|
3135
|
+
optionsContainer.scrollTop = Math.max(0, selectedEl.offsetTop - itemHeight);
|
|
3136
|
+
}
|
|
3137
|
+
}, 10);
|
|
3138
|
+
}
|
|
3139
|
+
});
|
|
3140
|
+
|
|
3141
|
+
select.parentNode.insertBefore(container, select.nextSibling);
|
|
3142
|
+
select.addEventListener('change', syncSelected);
|
|
3143
|
+
|
|
3144
|
+
// Watch for dynamic options updates
|
|
3145
|
+
const observer = new MutationObserver(() => {
|
|
3146
|
+
syncSelected();
|
|
3147
|
+
});
|
|
3148
|
+
observer.observe(select, { childList: true, subtree: true });
|
|
3149
|
+
|
|
3150
|
+
setTimeout(syncSelected, 200);
|
|
3151
|
+
setTimeout(syncSelected, 1000);
|
|
3152
|
+
});
|
|
3153
|
+
|
|
3154
|
+
// Global click listener to close options dropdowns when clicking outside
|
|
3155
|
+
if (!window.customSelectGlobalBound) {
|
|
3156
|
+
window.customSelectGlobalBound = true;
|
|
3157
|
+
document.addEventListener('click', () => {
|
|
3158
|
+
document.querySelectorAll('.select-container-custom').forEach(el => {
|
|
3159
|
+
el.classList.remove('open');
|
|
3160
|
+
});
|
|
3161
|
+
});
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
|
|
3166
|
+
checkLocale();
|
|
3167
|
+
flatpickr("input[type='date']", {
|
|
3168
|
+
locale: "pt",
|
|
3169
|
+
dateFormat: "Y-m-d",
|
|
3170
|
+
altInput: true,
|
|
3171
|
+
altFormat: "d/m/Y",
|
|
3172
|
+
allowInput: true,
|
|
3173
|
+
disableMobile: true
|
|
3174
|
+
});
|
|
3175
|
+
checkLocale();
|
|
3176
|
+
fetchInitialData();
|
|
3177
|
+
|
|
3178
|
+
// ADR-027 Live-update listener
|
|
3179
|
+
window.onAppDataChanged = function(entities) {
|
|
3180
|
+
var affected = entities.some(function(tag) {
|
|
3181
|
+
return ['account', 'transaction'].indexOf(tag) !== -1;
|
|
3182
|
+
});
|
|
3183
|
+
if (affected) {
|
|
3184
|
+
console.log("accounts refetching due to entity change:", entities);
|
|
3185
|
+
fetchInitialData();
|
|
3186
|
+
}
|
|
3187
|
+
};
|
|
3188
|
+
|
|
3189
|
+
</script>
|