export interface PaymentBatchDTO {
  id: string;
  periodId: number;
  ministryId: string;
  createdAt?: string;
  createdBy?: string;
  status: 'CREATED' | 'SENT_TO_BANK' | 'CONFIRMED' | 'REJECTED';
}

export interface CreatePaymentBatchDTO {
  periodId: number;
  ministryId: string;
}

export interface UpdatePaymentBatchStatusDTO {
  status: 'CREATED' | 'SENT_TO_BANK' | 'CONFIRMED' | 'REJECTED';
}

export interface PaymentOrderDTO {
  id: string;
  paymentBatchId: string;
  payrollRunId?: string;
  agentId?: string;
  bankAccountId?: string;
  budgetLineId?: string;
  grossAmount: number;
  netAmount: number;
  taxAmount?: number;
  taxRetentionType?: string;
  taxCollectionAccountId?: string;
  status: 'CREATED' | 'SENT_TO_BANK' | 'PAID' | 'REJECTED';
}

export interface TreasuryPlanDTO {
  id: string;
  fiscalYear: number;
  referenceMonth: number;
  status: 'DRAFT' | 'APPROVED' | 'CLOSED';
  approvedCeiling: number;
  executedAmount: number;
  availableAmount: number;
  startDate: string;
  endDate: string;
  approvedBy?: string;
  approvedAt?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface CreateTreasuryPlanDTO {
  fiscalYear: number;
  referenceMonth: number;
  approvedCeiling: number;
  startDate?: string;
  endDate?: string;
}

export interface CreatePaymentOrderDTO {
  paymentBatchId: string;
  payrollRunId?: string;
  agentId: string;
  bankAccountId: string;
  grossAmount: number;
  netAmount: number;
  taxAmount?: number;
  taxRetentionType?: string;
  taxCollectionAccountId?: string;
}

export interface UpdatePaymentOrderStatusDTO {
  status: 'CREATED' | 'SENT_TO_BANK' | 'PAID' | 'REJECTED';
}

export interface TreasuryPaymentDTO {
  id: string;
  paymentOrderId: string;
  paidAt?: string;
  transactionRef?: string;
  status: 'PENDING' | 'PAID' | 'REJECTED' | 'CANCELLED';
  message?: string;
}

export interface CreateTreasuryPaymentDTO {
  paymentOrderId: string;
  transactionRef?: string;
  status: 'PENDING' | 'PAID' | 'REJECTED' | 'CANCELLED';
  message?: string;
}

// Arquitetura Completa de Tesouro
export interface CashAccountDTO {
  id: string;
  code: string;
  name: string;
  type: 'CASH' | 'BANK_ACCOUNT';
  orgUnitId: string;
  bankId?: string;
  parentId?: string;
  category?: 'CENTRAL_CUT' | 'SUB_ACCOUNT' | 'TRANSIT' | 'REVENUE';
  accountNumber?: string;
  branchCode?: string;
  iban?: string;
  swiftCode?: string;
  accountingCode?: string;
  accountType?: 'RECEITA' | 'DESPESA' | 'MISTA';
  overdraftLimit?: number;
  currency: string;
  isActive: boolean;
  currentBalance: number;
  availableBalance: number;
  createdAt?: string;
  updatedAt?: string;
}

export interface CreateCashAccountDTO {
  code: string;
  name: string;
  type: 'CASH' | 'BANK_ACCOUNT';
  orgUnitId: string;
  bankId?: string;
  parentId?: string;
  category?: 'CENTRAL_CUT' | 'SUB_ACCOUNT' | 'TRANSIT' | 'REVENUE';
  accountNumber?: string;
  branchCode?: string;
  iban?: string;
  swiftCode?: string;
  accountingCode?: string;
  accountType?: 'RECEITA' | 'DESPESA' | 'MISTA';
  overdraftLimit?: number;
  currency?: string;
  isActive?: boolean;
}

export interface TreasuryEntryDTO {
  id: string;
  type: string;
  amount: number;
  transactionDate: string;
  documentReference?: string;
  description?: string;
  status: 'DRAFT' | 'PENDING_APPROVAL' | 'APPROVED' | 'REJECTED' | 'EXECUTED';
  approvalLevel?: number;
  approvedBy?: string;
  approvedAt?: string;
  cashAccountId: string;
  paymentOrderId?: string;
  paymentBatchId?: string;
  budgetLineId?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface CreateTreasuryEntryDTO {
  type: string;
  amount: number;
  transactionDate: string;
  documentReference: string;
  description?: string;
  status?: string;
  approvalLevel?: number;
  cashAccountId: string;
  paymentOrderId?: string;
  paymentBatchId?: string;
  budgetLineId?: string;
}

export interface PaymentAuthorizationDTO {
  id: string;
  paymentOrderId?: string;
  paymentBatchId?: string;
  requestedBy: string;
  requestedAt: string;
  requiredApprovalLevel: number;
  currentApprovalLevel: number;
  status: 'PENDING' | 'PARTIALLY_APPROVED' | 'APPROVED' | 'REJECTED';
  rejectionReason?: string;
  approvals: ApprovalDTO[];
  createdAt?: string;
  updatedAt?: string;
}

export interface CreatePaymentAuthorizationDTO {
  paymentOrderId?: string;
  paymentBatchId?: string;
  requestedBy: string;
  requiredApprovalLevel: number;
}

export interface ApprovalDTO {
  id: string;
  authorizationId: string;
  level: number;
  approvedBy: string;
  approvedAt: string;
  comments?: string;
  signatureHash?: string;
}

export interface ApprovePaymentDTO {
  approverId: string;
  comments?: string;
}

export interface RejectPaymentDTO {
  approverId: string;
  reason: string;
}

export interface CashFlowDTO {
  id: string;
  cashAccountId: string;
  transactionDate: string;
  type: 'INFLOW' | 'OUTFLOW';
  amount: number;
  description?: string;
  referenceId?: string;
  referenceType?: string;
  balanceAfter: number;
  createdAt?: string;
}

export interface CreateCashFlowDTO {
  cashAccountId: string;
  transactionDate: string;
  type: 'INFLOW' | 'OUTFLOW';
  amount: number;
  description?: string;
  referenceId?: string;
  referenceType?: string;
}

export interface BankReconciliationDTO {
  id: string;
  cashAccountId: string;
  reconciliationDate: string;
  statementBalance: number;
  systemBalance: number;
  difference: number;
  status: 'PENDING' | 'RECONCILED' | 'DISCREPANCY';
  reconciledBy?: string;
  reconciledAt?: string;
  items?: ReconciliationItemDTO[];
  createdAt?: string;
  updatedAt?: string;
}

export interface CreateBankReconciliationDTO {
  cashAccountId: string;
  reconciliationDate: string;
  statementBalance: number;
  reconciliationItems: ReconciliationItemDTO[];
}

export interface ReconciliationItemDTO {
  id?: string;
  reconciliationId?: string;
  transactionDate: string;
  description?: string;
  statementAmount?: number;
  systemAmount?: number;
  matchStatus: 'MATCHED' | 'UNMATCHED' | 'PENDING';
  matchedTransactionId?: string;
}

