import { type ProductRow } from "../products/products.service.js";
import { createIncident } from "../repairs/repairs.service.js";
export type PurchaseDocumentStatus = "pending" | "processed" | "needs_review" | "failed";
export type PurchaseLineStatus = "detected" | "confirmed" | "ignored" | "converted_to_product";
export interface PurchaseDocumentLineRow {
    id: number;
    document_id: number;
    user_id: number;
    line_number: number;
    raw_text: string;
    name_raw: string;
    brand_raw: string;
    model_raw: string;
    serial_number: string;
    imei: string;
    sku: string;
    category: string;
    quantity: number;
    unit_price: string | null;
    total_price: string | null;
    canonical_brand_id: number | null;
    canonical_product_id: number | null;
    linked_product_id: number | null;
    line_status: PurchaseLineStatus;
    confidence: string;
    metadata: Record<string, unknown>;
    created_at: string;
    updated_at: string;
}
export interface PurchaseDocumentRow {
    id: number;
    user_id: number;
    canonical_store_id: number | null;
    group_id: number | null;
    vendor_raw: string;
    vendor_canonical: string;
    document_number: string;
    purchase_date: string | null;
    total_amount: string | null;
    currency: string;
    file_url: string;
    file_name: string;
    mime_type: string;
    ocr_text: string;
    extraction_status: PurchaseDocumentStatus;
    extraction_confidence: string;
    document_fingerprint: string;
    extraction_started_at: string | null;
    metadata: Record<string, unknown>;
    created_at: string;
    updated_at: string;
}
export interface PurchaseDocumentGroupRow {
    id: number;
    user_id: number;
    name: string;
    slug: string;
    notes: string;
    created_at: string;
    updated_at: string;
}
export interface PurchaseDocumentGroupSummary extends PurchaseDocumentGroupRow {
    document_count: number;
    total_amount: string | null;
}
export interface PurchaseDocumentListItem extends PurchaseDocumentRow {
    line_count: number;
    confirmed_line_count: number;
    duplicate_count: number;
    purchase_summary: string;
    group_name: string;
    group_slug: string;
}
export interface PurchaseDocumentDetail extends PurchaseDocumentRow {
    lines: PurchaseDocumentLineRow[];
    line_count?: number;
    confirmed_line_count?: number;
    duplicate_count?: number;
    purchase_summary?: string;
    group_name?: string;
    group_slug?: string;
}
export interface PurchaseProductCandidate {
    document_id: number;
    document_number: string;
    vendor_raw: string;
    vendor_canonical: string;
    purchase_date: string | null;
    total_amount: string | null;
    currency: string;
    file_url: string;
    file_name: string;
    mime_type: string;
    line_id: number;
    line_number: number;
    raw_text: string;
    name_raw: string;
    brand_raw: string;
    model_raw: string;
    serial_number: string;
    imei: string;
    sku: string;
    category: string;
    quantity: number;
    unit_price: string | null;
    total_price: string | null;
    linked_product_id: number | null;
    line_status: PurchaseLineStatus;
    confidence: string;
}
export interface CreatePurchaseDocumentInput {
    vendorRaw: string;
    documentNumber?: string;
    purchaseDate?: string | null;
    totalAmount?: string | number | null;
    currency?: string;
    groupId?: number | null;
    fileUrl: string;
    fileName: string;
    mimeType: string;
    ocrText: string;
    metadata?: Record<string, unknown>;
}
export interface UpdatePurchaseDocumentInput {
    vendorRaw?: string;
    documentNumber?: string;
    purchaseDate?: string | null;
    totalAmount?: string | number | null;
    currency?: string;
    groupId?: number | null;
    fileUrl?: string;
    fileName?: string;
    mimeType?: string;
    ocrText?: string;
    metadata?: Record<string, unknown>;
}
export interface CreatePurchaseDocumentGroupInput {
    name: string;
    notes?: string;
}
export interface UpdatePurchaseLineInput {
    lineStatus?: PurchaseLineStatus;
    linkedProductId?: number | null;
    canonicalBrandId?: number | null;
    canonicalProductId?: number | null;
    nameRaw?: string;
    brandRaw?: string;
    modelRaw?: string;
    serialNumber?: string;
    imei?: string;
    sku?: string;
    category?: string;
    quantity?: number;
    unitPrice?: string | number | null;
    totalPrice?: string | number | null;
    rawText?: string;
    confidence?: string | number | null;
}
export interface CreateProductFromPurchaseLineResult {
    product: ProductRow;
    line: PurchaseDocumentLineRow;
}
export interface CreateIncidentFromPurchaseLineResult {
    incident: Awaited<ReturnType<typeof createIncident>>;
    product: ProductRow;
    line: PurchaseDocumentLineRow;
}
export declare function listPurchaseDocuments(userId: number): Promise<PurchaseDocumentListItem[]>;
export declare function listPurchaseProductCandidates(userId: number, options?: {
    documentId?: number | null;
    includeConverted?: boolean;
}): Promise<PurchaseProductCandidate[]>;
export declare function getPurchaseDocument(userId: number, id: number): Promise<PurchaseDocumentDetail | null>;
export declare function createPurchaseDocument(userId: number, input: CreatePurchaseDocumentInput): Promise<PurchaseDocumentDetail>;
export declare function listPurchaseDocumentGroups(userId: number): Promise<PurchaseDocumentGroupSummary[]>;
export declare function createPurchaseDocumentGroup(userId: number, input: CreatePurchaseDocumentGroupInput): Promise<PurchaseDocumentGroupSummary>;
export declare function updatePurchaseDocument(userId: number, id: number, input: UpdatePurchaseDocumentInput): Promise<PurchaseDocumentDetail | null>;
export declare function processPendingPurchaseDocuments(limit?: number): Promise<number>;
export declare function reprocessPurchaseDocument(userId: number, id: number): Promise<PurchaseDocumentDetail | null>;
export declare function updatePurchaseLine(userId: number, documentId: number, lineId: number, input: UpdatePurchaseLineInput): Promise<PurchaseDocumentLineRow | null>;
export declare function createProductFromPurchaseLine(userId: number, documentId: number, lineId: number): Promise<CreateProductFromPurchaseLineResult | null>;
export declare function createIncidentFromPurchaseLine(userId: number, documentId: number, lineId: number): Promise<CreateIncidentFromPurchaseLineResult | null>;
//# sourceMappingURL=purchases.service.d.ts.map