fix build

This commit is contained in:
2026-04-15 04:59:05 +03:00
parent 020ffccfd6
commit 973149e974
28 changed files with 2352 additions and 89 deletions
+2
View File
@@ -56,6 +56,7 @@ import { ConfigurationsClient } from "./clients/configurations"
import { AutoGenerateClient } from "./clients/auto-generate"
import { ExpenseItemsClient } from "./clients/expense-items"
import { InventoryCategoriesClient } from "./clients/inventory-categories"
import { DocumentPrintClient } from "./clients/document-print"
export function createApi(options?: ApiClientOptions) {
return {
@@ -116,6 +117,7 @@ export function createApi(options?: ApiClientOptions) {
autoGenerate: new AutoGenerateClient(undefined, options),
expenseItems: new ExpenseItemsClient(undefined, options),
inventoryCategories: new InventoryCategoriesClient(undefined, options),
documentPrint: new DocumentPrintClient(undefined, options),
}
}
@@ -0,0 +1,23 @@
import { ApiClient, type ApiClientOptions } from "../infra/client"
import type { ApiPath } from "../infra/types"
export const DOCUMENT_PRINT_ROUTES = {
INDEX: "/api/document-print",
} as const satisfies Record<string, ApiPath>
export type DocumentPrintType = "job_card" | "invoice" | "estimate" | "purchase_order" | "bill" | string
export type DocumentPrintMode = "print" | "download"
export class DocumentPrintClient extends ApiClient {
constructor(baseUrl?: string, defaultOptions?: ApiClientOptions) {
super(baseUrl, defaultOptions)
}
async print(type: DocumentPrintType, id: number | string, mode: DocumentPrintMode = "print"): Promise<Blob> {
return this.fetchBlob(DOCUMENT_PRINT_ROUTES.INDEX, {
method: "POST",
body: { type, id: Number(id), mode },
})
}
}
+70
View File
@@ -5,6 +5,13 @@ import type { ApiPath } from "../infra/types"
export const ESTIMATE_ROUTES = {
INDEX: "/api/estimates",
BY_ID: "/api/estimates/{id}",
SERVICES: "/api/estimate/{id}/services",
SERVICE_BY_ID: "/api/estimate/{id}/services/{service_id}",
PARTS: "/api/estimate/{id}/parts",
PART_BY_ID: "/api/estimate/{id}/parts/{part_id}",
EXPENSE_ITEMS: "/api/estimate/{id}/expense-items",
EXPENSE_ITEM_BY_ID: "/api/estimate/{id}/expense-items/{expense_item_id}",
STORE_AUTHORISATION: "/api/estimates/{id}/store-authorisation",
} as const satisfies Record<string, ApiPath>
export class EstimatesClient extends CrudClient<
@@ -21,4 +28,67 @@ export class EstimatesClient extends CrudClient<
const data = await this.get(ESTIMATE_ROUTES.INDEX, { query: { id } } as never)
return {...data, data: (data as any)?.data?.[0] ?? null }
}
// ── Estimate Services ──
async listServices(estimateId: string) {
return this.get(ESTIMATE_ROUTES.SERVICES, { params: { id: estimateId } } as never)
}
async addService(estimateId: string, payload: { service_id?: number; rate_type?: string; quantity?: number; rate?: string; description?: string; labor_rate_id?: number; working_hours?: string | number; labor_hours?: string | number; tax?: string; chart_of_account?: string; department_id?: number }) {
return this.post(ESTIMATE_ROUTES.SERVICES, payload as never, { params: { id: estimateId } } as never)
}
async updateService(estimateId: string, serviceId: string, payload: { rate?: string; quantity?: number }) {
return this.put(ESTIMATE_ROUTES.SERVICE_BY_ID, payload as never, { params: { id: estimateId, service_id: serviceId } } as never)
}
async removeService(estimateId: string, serviceId: string) {
return this.delete(ESTIMATE_ROUTES.SERVICE_BY_ID, { params: { id: estimateId, service_id: serviceId } } as never)
}
// ── Estimate Parts ──
async listParts(estimateId: string) {
return this.get(ESTIMATE_ROUTES.PARTS, { params: { id: estimateId } } as never)
}
async addPart(estimateId: string, payload: { part_id?: number; quantity?: number; rate?: string; description?: string }) {
return this.post(ESTIMATE_ROUTES.PARTS, payload as never, { params: { id: estimateId } } as never)
}
async updatePart(estimateId: string, partId: string, payload: { quantity?: number }) {
return this.put(ESTIMATE_ROUTES.PART_BY_ID, payload as never, { params: { id: estimateId, part_id: partId } } as never)
}
async removePart(estimateId: string, partId: string) {
return this.delete(ESTIMATE_ROUTES.PART_BY_ID, { params: { id: estimateId, part_id: partId } } as never)
}
// ── Estimate Expense Items ──
async listExpenseItems(estimateId: string) {
return this.get(ESTIMATE_ROUTES.EXPENSE_ITEMS, { params: { id: estimateId } } as never)
}
async addExpenseItem(estimateId: string, payload: { expense_item_id?: number; quantity?: number; rate?: string; description?: string }) {
return this.post(ESTIMATE_ROUTES.EXPENSE_ITEMS, payload as never, { params: { id: estimateId } } as never)
}
async updateExpenseItem(estimateId: string, expenseItemId: string, payload: { quantity?: number }) {
return this.put(ESTIMATE_ROUTES.EXPENSE_ITEM_BY_ID, payload as never, { params: { id: estimateId, expense_item_id: expenseItemId } } as never)
}
async removeExpenseItem(estimateId: string, expenseItemId: string) {
return this.delete(ESTIMATE_ROUTES.EXPENSE_ITEM_BY_ID, { params: { id: estimateId, expense_item_id: expenseItemId } } as never)
}
// ── Authorisation ──
async storeAuthorisation(estimateId: string, payload: {
estimate_services?: { id: number; status: string }[]
estimate_parts?: { id: number; status: string }[]
estimate_inspections?: { id: number; status: string }[]
estimate_expense_items?: { id: number; status: string }[]
authorisation_method?: string
employee_id?: number
}) {
return this.post(ESTIMATE_ROUTES.STORE_AUTHORISATION, payload as never, { params: { id: estimateId } } as never)
}
}
+1
View File
@@ -38,6 +38,7 @@ export { InvoicesClient, INVOICE_ROUTES } from "./invoices"
export { HomeClient, HOME_ROUTES, type HomeDashboardResponse } from "./home"
export { BillsClient, BILL_ROUTES } from "./bills"
export { ReasonsClient, REASON_ROUTES } from "./reasons"
export { DocumentPrintClient, DOCUMENT_PRINT_ROUTES, type DocumentPrintType, type DocumentPrintMode } from "./document-print"
export { HolidaysClient, HOLIDAY_ROUTES } from "./holidays"
export { MakeAndModelsClient, MAKE_AND_MODEL_ROUTES } from "./make-and-models"
export { TimeSheetsClient, TIME_SHEET_ROUTES } from "./time-sheets"
+1 -1
View File
@@ -109,7 +109,7 @@ export const SellRatesTaxInclusive = ['Tax Inclusive', 'Tax Exclusive'] as const
export type SellRatesTaxInclusive = (typeof SellRatesTaxInclusive)[number];
// Tables
export const Tables= ['bills', 'expenses', 'invoices', 'job_cards', 'credit_notes', 'vendor_credits'] as const;
export const Tables= ['bills', 'expenses', 'invoices', 'job_cards', 'credit_notes', 'vendor_credits', 'estimates'] as const;
export type Tables = (typeof Tables)[number];
export const GiveDiscounts = ['no', 'line_item_level', 'transaction_level'] as const;