mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 09:14:08 +00:00
Create the complete TypeScript foundation for the Vue 3 migration in a parallel scripts-v2/ directory. 72 files, 5430 lines, zero any types, strict mode. - types/ (21 files): Domain interfaces for all 17 entities derived from actual Laravel models and API resources. Enums for all statuses. Generic API response wrappers. - api/ (29 files): Typed axios client with interceptors, endpoint constants from routes/api.php, 25 typed service classes covering every API endpoint. - composables/ (14 files): Vue 3 composition functions for auth, notifications, dialogs, modals, pagination, filters, currency, dates, theme, sidebar, company context, and permissions. - utils/ (5 files): Pure typed utilities for money formatting, date formatting (date-fns), localStorage, and error handling. - config/ (3 files): Typed ability constants, app constants. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
87 lines
1.9 KiB
TypeScript
87 lines
1.9 KiB
TypeScript
import { client } from '../client'
|
|
import { API } from '../endpoints'
|
|
import type { DateRangeParams } from '../../types/api'
|
|
|
|
export interface ReportParams extends DateRangeParams {
|
|
report_type?: string
|
|
}
|
|
|
|
export interface SalesReportResponse {
|
|
data: Array<{
|
|
date: string
|
|
total: number
|
|
count: number
|
|
}>
|
|
total: number
|
|
from_date: string
|
|
to_date: string
|
|
}
|
|
|
|
export interface ProfitLossReportResponse {
|
|
data: {
|
|
income: Array<{
|
|
label: string
|
|
amount: number
|
|
}>
|
|
expenses: Array<{
|
|
label: string
|
|
amount: number
|
|
}>
|
|
net_profit: number
|
|
}
|
|
from_date: string
|
|
to_date: string
|
|
}
|
|
|
|
export interface ExpenseReportResponse {
|
|
data: Array<{
|
|
category: string
|
|
total: number
|
|
count: number
|
|
}>
|
|
total: number
|
|
from_date: string
|
|
to_date: string
|
|
}
|
|
|
|
export interface TaxReportResponse {
|
|
data: Array<{
|
|
tax_name: string
|
|
tax_amount: number
|
|
invoice_count: number
|
|
}>
|
|
total: number
|
|
from_date: string
|
|
to_date: string
|
|
}
|
|
|
|
export const reportService = {
|
|
async getSalesReport(params: ReportParams): Promise<SalesReportResponse> {
|
|
const { data } = await client.get(API.DASHBOARD, {
|
|
params: { ...params, report_type: 'sales' },
|
|
})
|
|
return data
|
|
},
|
|
|
|
async getProfitLossReport(params: ReportParams): Promise<ProfitLossReportResponse> {
|
|
const { data } = await client.get(API.DASHBOARD, {
|
|
params: { ...params, report_type: 'profit_loss' },
|
|
})
|
|
return data
|
|
},
|
|
|
|
async getExpenseReport(params: ReportParams): Promise<ExpenseReportResponse> {
|
|
const { data } = await client.get(API.DASHBOARD, {
|
|
params: { ...params, report_type: 'expenses' },
|
|
})
|
|
return data
|
|
},
|
|
|
|
async getTaxReport(params: ReportParams): Promise<TaxReportResponse> {
|
|
const { data } = await client.get(API.DASHBOARD, {
|
|
params: { ...params, report_type: 'tax' },
|
|
})
|
|
return data
|
|
},
|
|
}
|