|
| 1 | +import Controller from '@ember/controller'; |
| 2 | +import { action } from '@ember/object'; |
| 3 | +import { inject as service } from '@ember/service'; |
| 4 | + |
| 5 | +export default class ApplicationController extends Controller { |
| 6 | + @service fetch; |
| 7 | + |
| 8 | + get navigationItems() { |
| 9 | + return [ |
| 10 | + { |
| 11 | + label: 'Dashboard', |
| 12 | + description: 'Ledger dashboard and financial overview.', |
| 13 | + icon: 'chart-simple', |
| 14 | + route: 'console.ledger.home', |
| 15 | + keywords: ['overview', 'metrics', 'finance dashboard'], |
| 16 | + }, |
| 17 | + { |
| 18 | + label: 'Billing', |
| 19 | + description: 'Invoices and reusable invoice templates.', |
| 20 | + icon: 'file-invoice-dollar', |
| 21 | + children: [ |
| 22 | + { |
| 23 | + label: 'Invoices', |
| 24 | + description: 'Create, send, and manage customer invoices.', |
| 25 | + icon: 'file-invoice-dollar', |
| 26 | + route: 'console.ledger.billing.invoices.index', |
| 27 | + keywords: ['receivables', 'customers', 'payments due'], |
| 28 | + }, |
| 29 | + { |
| 30 | + label: 'Invoice Templates', |
| 31 | + description: 'Design reusable invoice templates.', |
| 32 | + icon: 'file-code', |
| 33 | + route: 'console.ledger.billing.invoice-templates.index', |
| 34 | + keywords: ['templates', 'invoice design', 'documents'], |
| 35 | + }, |
| 36 | + ], |
| 37 | + }, |
| 38 | + { |
| 39 | + label: 'Payments', |
| 40 | + description: 'Transactions, wallets, and payment gateways.', |
| 41 | + icon: 'money-bill-transfer', |
| 42 | + children: [ |
| 43 | + { |
| 44 | + label: 'Transactions', |
| 45 | + description: 'Review payment and wallet transaction history.', |
| 46 | + icon: 'money-bill-transfer', |
| 47 | + route: 'console.ledger.payments.transactions.index', |
| 48 | + keywords: ['payments', 'charges', 'refunds', 'settlements'], |
| 49 | + }, |
| 50 | + { |
| 51 | + label: 'Wallets', |
| 52 | + description: 'Manage company, customer, and driver wallets.', |
| 53 | + icon: 'wallet', |
| 54 | + route: 'console.ledger.payments.wallets.index', |
| 55 | + keywords: ['balances', 'top ups', 'payouts'], |
| 56 | + }, |
| 57 | + { |
| 58 | + label: 'Gateways', |
| 59 | + description: 'Configure payment gateway integrations.', |
| 60 | + icon: 'credit-card', |
| 61 | + route: 'console.ledger.payments.gateways.index', |
| 62 | + keywords: ['stripe', 'payment providers', 'checkout'], |
| 63 | + }, |
| 64 | + ], |
| 65 | + }, |
| 66 | + { |
| 67 | + label: 'Accounting', |
| 68 | + description: 'Chart of accounts, journals, and general ledger.', |
| 69 | + icon: 'calculator', |
| 70 | + children: [ |
| 71 | + { |
| 72 | + label: 'Chart of Accounts', |
| 73 | + description: 'Manage the ledger account structure.', |
| 74 | + icon: 'sitemap', |
| 75 | + route: 'console.ledger.accounting.accounts.index', |
| 76 | + keywords: ['accounts', 'coa', 'accounting'], |
| 77 | + }, |
| 78 | + { |
| 79 | + label: 'Journal Entries', |
| 80 | + description: 'Browse and create double-entry journal entries.', |
| 81 | + icon: 'book', |
| 82 | + route: 'console.ledger.accounting.journal.index', |
| 83 | + keywords: ['journals', 'debits', 'credits'], |
| 84 | + }, |
| 85 | + { |
| 86 | + label: 'General Ledger', |
| 87 | + description: 'Review posted activity across accounts.', |
| 88 | + icon: 'scroll', |
| 89 | + route: 'console.ledger.accounting.general-ledger', |
| 90 | + keywords: ['ledger', 'posted transactions', 'account activity'], |
| 91 | + }, |
| 92 | + ], |
| 93 | + }, |
| 94 | + { |
| 95 | + label: 'Reports', |
| 96 | + description: 'Financial statements and operational reports.', |
| 97 | + icon: 'chart-line', |
| 98 | + children: [ |
| 99 | + { |
| 100 | + label: 'Income Statement', |
| 101 | + description: 'Revenue, expenses, and net income.', |
| 102 | + icon: 'chart-line', |
| 103 | + route: 'console.ledger.reports.income-statement', |
| 104 | + keywords: ['profit and loss', 'pnl', 'revenue', 'expenses'], |
| 105 | + }, |
| 106 | + { |
| 107 | + label: 'Balance Sheet', |
| 108 | + description: 'Assets, liabilities, and equity.', |
| 109 | + icon: 'scale-balanced', |
| 110 | + route: 'console.ledger.reports.balance-sheet', |
| 111 | + keywords: ['assets', 'liabilities', 'equity'], |
| 112 | + }, |
| 113 | + { |
| 114 | + label: 'Trial Balance', |
| 115 | + description: 'Debit and credit balances by account.', |
| 116 | + icon: 'list-check', |
| 117 | + route: 'console.ledger.reports.trial-balance', |
| 118 | + keywords: ['debits', 'credits', 'balances'], |
| 119 | + }, |
| 120 | + { |
| 121 | + label: 'Cash Flow', |
| 122 | + description: 'Cash movement over the selected period.', |
| 123 | + icon: 'water', |
| 124 | + route: 'console.ledger.reports.cash-flow', |
| 125 | + keywords: ['cash', 'inflow', 'outflow'], |
| 126 | + }, |
| 127 | + { |
| 128 | + label: 'AR Aging', |
| 129 | + description: 'Outstanding receivables by age bucket.', |
| 130 | + icon: 'clock', |
| 131 | + route: 'console.ledger.reports.ar-aging', |
| 132 | + keywords: ['receivables', 'overdue invoices', 'aging'], |
| 133 | + }, |
| 134 | + { |
| 135 | + label: 'Wallet Summary', |
| 136 | + description: 'Wallet balances and activity summary.', |
| 137 | + icon: 'wallet', |
| 138 | + route: 'console.ledger.reports.wallet-summary', |
| 139 | + keywords: ['wallet report', 'balances'], |
| 140 | + }, |
| 141 | + ], |
| 142 | + }, |
| 143 | + { |
| 144 | + label: 'Settings', |
| 145 | + description: 'Ledger billing, payment, and accounting settings.', |
| 146 | + icon: 'gear', |
| 147 | + children: [ |
| 148 | + { |
| 149 | + label: 'Invoice Settings', |
| 150 | + description: 'Configure invoice numbering, defaults, and templates.', |
| 151 | + icon: 'file-invoice', |
| 152 | + route: 'console.ledger.settings.invoice', |
| 153 | + keywords: ['invoice defaults', 'numbering', 'template'], |
| 154 | + }, |
| 155 | + { |
| 156 | + label: 'Payment Settings', |
| 157 | + description: 'Configure payment defaults and gateway behavior.', |
| 158 | + icon: 'gear', |
| 159 | + route: 'console.ledger.settings.payment', |
| 160 | + keywords: ['payments', 'gateway defaults'], |
| 161 | + }, |
| 162 | + { |
| 163 | + label: 'Accounting Settings', |
| 164 | + description: 'Configure accounting automation and posting behavior.', |
| 165 | + icon: 'calculator', |
| 166 | + route: 'console.ledger.settings.accounting', |
| 167 | + keywords: ['journal automation', 'posting', 'accounts'], |
| 168 | + }, |
| 169 | + ], |
| 170 | + }, |
| 171 | + ]; |
| 172 | + } |
| 173 | + |
| 174 | + @action |
| 175 | + async searchNavigation({ query, limit = 12 }) { |
| 176 | + const trimmedQuery = query?.trim(); |
| 177 | + |
| 178 | + if (!trimmedQuery) { |
| 179 | + return []; |
| 180 | + } |
| 181 | + |
| 182 | + try { |
| 183 | + const response = await this.fetch.get( |
| 184 | + 'search', |
| 185 | + { |
| 186 | + query: trimmedQuery, |
| 187 | + limit, |
| 188 | + }, |
| 189 | + { |
| 190 | + namespace: 'ledger/int/v1', |
| 191 | + } |
| 192 | + ); |
| 193 | + |
| 194 | + return response.results ?? []; |
| 195 | + } catch (_) { |
| 196 | + return []; |
| 197 | + } |
| 198 | + } |
| 199 | +} |
0 commit comments