Adds expense tracking module
Adds a new module for tracking user expenses. The module includes: - Configuration settings for the LNbits API endpoint and timeouts. - An ExpensesAPI service for fetching accounts and submitting expense entries. - A UI component for adding expenses, including account selection and form input. - Dependency injection for the ExpensesAPI service. This allows users to submit expense entries with account selection and reference data, which will be linked to their wallet.
This commit is contained in:
parent
678ccff694
commit
9ed674d0f3
8 changed files with 975 additions and 1 deletions
58
src/modules/expenses/index.ts
Normal file
58
src/modules/expenses/index.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* Expenses Module
|
||||
*
|
||||
* Provides expense tracking and submission functionality
|
||||
* integrated with castle LNbits extension.
|
||||
*/
|
||||
|
||||
import type { App } from 'vue'
|
||||
import { markRaw } from 'vue'
|
||||
import type { ModulePlugin } from '@/core/types'
|
||||
import { container, SERVICE_TOKENS } from '@/core/di-container'
|
||||
import { ExpensesAPI } from './services/ExpensesAPI'
|
||||
import AddExpense from './components/AddExpense.vue'
|
||||
|
||||
export const expensesModule: ModulePlugin = {
|
||||
name: 'expenses',
|
||||
version: '1.0.0',
|
||||
dependencies: ['base'],
|
||||
|
||||
quickActions: [
|
||||
{
|
||||
id: 'add-expense',
|
||||
label: 'Expense',
|
||||
icon: 'DollarSign',
|
||||
component: markRaw(AddExpense),
|
||||
category: 'finance',
|
||||
order: 10,
|
||||
requiresAuth: true
|
||||
}
|
||||
],
|
||||
|
||||
async install(app: App) {
|
||||
console.log('[Expenses Module] Installing...')
|
||||
|
||||
// 1. Create and register service
|
||||
const expensesAPI = new ExpensesAPI()
|
||||
container.provide(SERVICE_TOKENS.EXPENSES_API, expensesAPI)
|
||||
|
||||
// 2. Initialize service (wait for dependencies)
|
||||
await expensesAPI.initialize({
|
||||
waitForDependencies: true,
|
||||
maxRetries: 3,
|
||||
retryDelay: 1000
|
||||
})
|
||||
|
||||
console.log('[Expenses Module] ExpensesAPI initialized')
|
||||
|
||||
// 3. Register components globally (optional, for use outside quick actions)
|
||||
app.component('AddExpense', AddExpense)
|
||||
|
||||
console.log('[Expenses Module] Installed successfully')
|
||||
}
|
||||
}
|
||||
|
||||
export default expensesModule
|
||||
|
||||
// Export types for use in other modules
|
||||
export type { Account, AccountNode, ExpenseEntry, ExpenseEntryRequest } from './types'
|
||||
Loading…
Add table
Add a link
Reference in a new issue