import { Repository } from 'typeorm';
import { ClsService } from 'nestjs-cls';
import { BookingCashCollectionRepository, type CashCollectionLine } from './repositories/booking-cash-collection.repository';
import { BookingCashCollectionBatchRepository } from './repositories/booking-cash-collection-batch.repository';
import { MdCashCollectionRepository } from './repositories/md-cash-collection.repository';
import { BookingEntity } from '../../entities/booking.entity';
import { QueryEntity } from '../../entities/query.entity';
import { UpsertBookingCashCollectionDto } from './dto/upsert-booking-cash-collection.dto';
import { ConfirmCollectionDto } from './dto/confirm-collection.dto';
import { VoidConfirmationDto } from './dto/void-confirmation.dto';
import { DriverService } from '../driver/driver.service';
import { AuditService } from '../audit/audit.service';
import { PermissionCheckService } from '../../common/permissions/permission-check.service';
import { CollectForMdDto } from '../payment-settlement/dto/collect-for-md.dto';
import { UpdatePaymentHistoryDto } from '../payment-settlement/dto/update-payment-history.dto';
import { PaymentSettlementService, type PaymentHistoryDetail, type PaymentHistoryListMeta, type PaymentHistoryListRow } from '../payment-settlement/payment-settlement.service';
export interface BookingCashCollectionParty {
    source_kind: 'TRANSPORT' | 'ACTIVITY' | 'SPECIAL';
    supplier_id: string;
    supplier_name: string;
    activity_id: string | null;
    activity_name: string | null;
    label: string;
}
export interface BookingCashCollectionView {
    id: string;
    booking_id: string;
    transport_item_id: string | null;
    activity_item_id: string | null;
    special_item_id: string | null;
    currency_id: string;
    currency_code: string;
    destination_id: string | null;
    collection_date: string;
    has_expense: boolean;
    has_cash: boolean;
    collected_by_type: 'OWN' | 'SUPPLIER' | null;
    collector_name: string | null;
    supplier_id: string | null;
    supplier_name: string | null;
    source_kind: 'TRANSPORT' | 'ACTIVITY' | 'SPECIAL' | null;
    activity_id: string | null;
    activity_name: string | null;
    driver_id: string | null;
    driver_name: string | null;
    expected_amount: number;
    notes: string | null;
    status: 'PENDING' | 'COLLECTED' | 'CANCELLED' | null;
    actual_amount: number | null;
    collected_at: string | null;
    difference_reason: string | null;
    collected_by: string | null;
    collected_by_name: string | null;
    cash_expected_amount: number;
    cash_status: 'PENDING' | 'COLLECTED' | null;
    cash_actual_amount: number | null;
    cash_collected_by_type: 'OWN' | 'SUPPLIER' | null;
    cash_collector_name: string | null;
}
export declare class BookingCashCollectionService {
    private readonly repo;
    private readonly batches;
    private readonly mdCash;
    private readonly bookingRepo;
    private readonly queryRepo;
    private readonly drivers;
    private readonly audit;
    private readonly perms;
    private readonly cls;
    private readonly settlementsService;
    constructor(repo: BookingCashCollectionRepository, batches: BookingCashCollectionBatchRepository, mdCash: MdCashCollectionRepository, bookingRepo: Repository<BookingEntity>, queryRepo: Repository<QueryEntity>, drivers: DriverService, audit: AuditService, perms: PermissionCheckService, cls: ClsService, settlementsService: PaymentSettlementService);
    findByLine(bookingId: string, collectionDate: string, line: CashCollectionLine): Promise<BookingCashCollectionView | null>;
    listParties(bookingId: string): Promise<{
        destination_id: string | null;
        default_currency_id: string | null;
        parties: BookingCashCollectionParty[];
    }>;
    upsert(dto: UpsertBookingCashCollectionDto): Promise<BookingCashCollectionView>;
    confirm(id: string, dto: ConfirmCollectionDto): Promise<BookingCashCollectionView>;
    voidLatestConfirmation(id: string, dto: VoidConfirmationDto): Promise<BookingCashCollectionView>;
    cancel(id: string): Promise<BookingCashCollectionView>;
    private resolveCollector;
    private requireLine;
    private lineFks;
    private assertTransportOpenForCollect;
    private assertItemOnBooking;
    private saveRow;
    private requireBooking;
    private assertPartyOnBooking;
    private assertSupplierInTenant;
    private assertDriverBelongsToSupplier;
    private toView;
    private hasExpense;
    stampFromCollect(dto: CollectForMdDto): Promise<BookingCashCollectionView>;
    private mdToView;
    confirmCash(id: string, dto?: {
        route_kind?: 'TRANSPORT' | 'ACTIVITY' | 'SPECIAL';
        route_item_id?: string;
    }): Promise<{
        row: BookingCashCollectionView;
        collection_id: string | null;
    }>;
    listPaymentHistory(query: {
        search?: string;
        customer_mobile?: string;
        source_id?: string;
        page?: number;
        limit?: number;
        date_from?: string;
        date_to?: string;
        currency_id?: string;
    }): Promise<{
        items: PaymentHistoryListRow[];
        meta: PaymentHistoryListMeta;
    }>;
    findPaymentHistoryDetail(id: string): Promise<PaymentHistoryDetail | null>;
    updateFromCollect(id: string, dto: UpdatePaymentHistoryDto): Promise<PaymentHistoryDetail>;
    private enrichMdAllocations;
    listBookingTransports(bookingId: string): Promise<Array<{
        id: string;
        date: string | null;
        label: string;
    }>>;
    private cashCollectorPatch;
    private resolveCashCollector;
    private requireDate;
    private dateKey;
    private tenantId;
    private requireAtLeast;
}
