using SolutionErp.Application.Budgets.Dtos;
using SolutionErp.Domain.Contracts;
using SolutionErp.Domain.PurchaseEvaluations;

namespace SolutionErp.Application.PurchaseEvaluations.Dtos;

public record PurchaseEvaluationListItemDto(
    Guid Id,
    string? MaPhieu,
    string TenGoiThau,
    PurchaseEvaluationType Type,
    PurchaseEvaluationPhase Phase,
    Guid ProjectId,
    string ProjectName,
    Guid? SelectedSupplierId,
    string? SelectedSupplierName,
    Guid? ContractId,
    DateTime? SlaDeadline,
    DateTime CreatedAt);

public record PurchaseEvaluationSupplierDto(
    Guid Id,
    Guid SupplierId,
    string SupplierName,
    string? DisplayName,
    string? ContactName,
    string? ContactEmail,
    string? ContactPhone,
    string? PaymentTermText,
    string? Note,
    int Order);

public record PurchaseEvaluationQuoteDto(
    Guid Id,
    Guid PurchaseEvaluationDetailId,
    Guid PurchaseEvaluationSupplierId,
    decimal BgVat,
    decimal ChuaVat,
    decimal ThanhTien,
    bool IsSelected,
    string? Note);

public record PurchaseEvaluationDetailDto(
    Guid Id,
    string GroupCode,
    string GroupName,
    string? ItemCode,
    string NoiDung,
    string? DonViTinh,
    decimal KhoiLuongNganSach,
    decimal KhoiLuongThiCong,
    decimal DonGiaNganSach,
    decimal ThanhTienNganSach,
    int Order,
    string? GhiChu,
    List<PurchaseEvaluationQuoteDto> Quotes);

public record PurchaseEvaluationApprovalDto(
    Guid Id,
    PurchaseEvaluationPhase FromPhase,
    PurchaseEvaluationPhase ToPhase,
    Guid? ApproverUserId,
    string? ApproverName,
    ApprovalDecision Decision,
    string? Comment,
    DateTime ApprovedAt);

public record PurchaseEvaluationChangelogDto(
    Guid Id,
    PurchaseEvaluationEntityType EntityType,
    Guid? EntityId,
    ChangelogAction Action,
    PurchaseEvaluationPhase? PhaseAtChange,
    Guid? UserId,
    string? UserName,
    string? Summary,
    string? FieldChangesJson,
    string? ContextNote,
    DateTime CreatedAt);

public record PurchaseEvaluationWorkflowSummaryDto(
    string PolicyName,
    string PolicyDescription,
    List<PurchaseEvaluationPhase> ActivePhases,
    List<PurchaseEvaluationPhase> NextPhases);

public record PurchaseEvaluationAttachmentDto(
    Guid Id,
    Guid? PurchaseEvaluationSupplierId,
    string FileName,
    string StoragePath,
    long FileSize,
    string ContentType,
    PurchaseEvaluationAttachmentPurpose Purpose,
    string? Note,
    DateTime CreatedAt);

public record PurchaseEvaluationDepartmentOpinionDto(
    Guid Id,
    PeDepartmentKind Kind,
    string KindLabel,
    string? Opinion,
    DateTime? SignedAt,
    Guid? UserId,
    string? UserName);

public record PurchaseEvaluationDetailBundleDto(
    Guid Id,
    string? MaPhieu,
    PurchaseEvaluationType Type,
    PurchaseEvaluationPhase Phase,
    string TenGoiThau,
    string? DiaDiem,
    string? MoTa,
    Guid ProjectId,
    string ProjectName,
    Guid? DepartmentId,
    string? DepartmentName,
    Guid? DrafterUserId,
    string? DrafterName,
    Guid? SelectedSupplierId,
    string? SelectedSupplierName,
    Guid? ContractId,
    string? PaymentTerms,
    DateTime? SlaDeadline,
    DateTime CreatedAt,
    DateTime? UpdatedAt,
    Guid? BudgetId,
    BudgetSummaryDto? Budget,
    string? BudgetManualName,
    decimal? BudgetManualAmount,
    List<PurchaseEvaluationSupplierDto> Suppliers,
    List<PurchaseEvaluationDetailDto> Details,
    List<PurchaseEvaluationApprovalDto> Approvals,
    List<PurchaseEvaluationAttachmentDto> Attachments,
    List<PurchaseEvaluationDepartmentOpinionDto> DepartmentOpinions,
    PurchaseEvaluationWorkflowSummaryDto Workflow);
