import {
    CLIENT_ACCOUNT_MOVEMENT_TYPES,
    CLIENT_ACCOUNT_PAYMENT_METHODS,
} from "./ClientAccountMovements.model";
import { PAYMENT_METHODS_CLIENT_ACCOUNT, PAYMENT_PROCCESS_DATE } from "./Payments.model";

export type FindCashFlowParams = {
    id?: string;
    companyId: string;
    paymentId?: string;
    clientId?: string;
    clientAccountMovementId?: string;
    appointmentId?: string;
    employeeId?: string;
    type?: CLIENT_ACCOUNT_MOVEMENT_TYPES;
    paymentMethod?: CLIENT_ACCOUNT_PAYMENT_METHODS | PAYMENT_METHODS_CLIENT_ACCOUNT;
    startDate?: Date;
    endDate?: Date;
    year?: number;
    month?: number;
    reference?: string;
    sessionUser: string;
};

export type PaginateCashFlowParams = FindCashFlowParams & {
    page: number;
    limit: number;
};

export type PaginateCashFlowResults = {
    data: ICashFlow[];
    balance: number;
    page: number;
    pages: number;
};

export type CreateCashFlowParams = {
    companyId: string;
    paymentId?: string;
    clientId?: string;
    clientAccountMovenemtId?: string;
    appointmentId?: string;
    employeeId?: string;
    amount: number;
    description: string;
    reference: string;
    year: number;
    month: number;
    type: CLIENT_ACCOUNT_MOVEMENT_TYPES;
    paymentMethod: CLIENT_ACCOUNT_PAYMENT_METHODS | PAYMENT_METHODS_CLIENT_ACCOUNT;
    proccessDate: PAYMENT_PROCCESS_DATE;
    sessionUser: string;
};

export type DeleteMovementByPaymentParams = {
    companyId: string;
    paymentId: string;
    sessionUser: string;
};

export type DeleteMovementParams = {
    id: string;
    companyId: string;
    sessionUser: string;
};

export type DeleteByClientAccountMovementParams = {
    companyId: string;
    clientAccountMovementId: string;
    sessionUser: string;
};

export interface ICashFlow {
    id: string;
    companyId: string;
    paymentId?: string;
    clientId?: string;
    clientAccountMovementId?: string;
    appointmentId?: string;
    employeeId?: string;
    amount: number;
    description: string;
    reference: string;
    year: number;
    month: number;
    type: CLIENT_ACCOUNT_MOVEMENT_TYPES;
    paymentMethod: CLIENT_ACCOUNT_PAYMENT_METHODS | PAYMENT_METHODS_CLIENT_ACCOUNT;
    createdAt: Date;
}

export type FindCashFlowBalanceParams = {
    companyId: string;
    year: number;
    month: number;
    sessionUser: string;
};

export type CreateCashFlowBalanceParams = {
    companyId: string;
    amount: number;
    year: number;
    month: number;
    updatedAt: Date;
};

export type CalculateCashFlowBalanceParams = {
    companyId: string;
    year: number;
    month: number;
    sessionUser: string;
};

export interface ICashFlowBalance {
    id?: string;
    companyId: string;
    amount: number;
    year: number;
    month: number;
    updatedAt: Date;
}

export interface CashFlowHistoryItem {
    amount: number;
    month: number;
    year: number;
}

export interface CashFlowHistoryView {
    companyId: string;
    data: CashFlowHistoryItem[];
    total: number;
}
