first commit

This commit is contained in:
2026-08-13 15:58:42 +09:00
commit 085bf0a6ee
52 changed files with 19420 additions and 0 deletions

52
composables/useMoney.ts Normal file
View File

@@ -0,0 +1,52 @@
export type TransactionType = 'income' | 'expense'
export type AssetBalanceType = 'cumulative' | 'monthly_reset'
export interface Asset {
id: string
name: string
balanceType: AssetBalanceType
initialBalance: number
active: boolean
sortOrder: number
balance?: number
}
export interface Category {
id: string
type: TransactionType
name: string
parentId: string | null
sortOrder: number
active: boolean
parent?: Category | null
children?: Category[]
}
export interface Transaction {
id: string
type: TransactionType
occurredAt: string
assetId: string
categoryId: string
amount: number
title: string
memo: string | null
latitude: string | null
longitude: string | null
asset: Asset
category: Category & { parent?: Category | null }
}
export function useMoneyApi() {
const refresh = () => refreshNuxtData()
return {
refresh,
assets: () => useFetch<Asset[]>('/api/assets'),
categories: () => useFetch<Category[]>('/api/categories'),
transactions: (month: Ref<string>) =>
useFetch<{ summary: { income: number; expense: number; diff: number }; transactions: Transaction[] }>('/api/transactions', {
query: { month }
})
}
}