using CashLineERP.Application.External.Views;
using CashLineERP.Domain.IslamicFinance.Disbursements;
using CashLineERP.Domain.IslamicFinance.Murabaha;
using CashLineERP.Domain.IslamicFinance.ReceivablesFinance;
using CashLineERP.Domain.IslamicFinance.Requests;
using CashLineERP.Domain.IslamicFinance.Settlements;
using CashLineERP.Application.Procurement;
using CashLineERP.Application.Suppliers;

namespace CashLineERP.Application.External;

public interface IExternalPortalRepository
{
    IReadOnlyCollection<ExternalRfqInvitationView> GetRfqInvitations(long partyId);

    ExternalRfqInvitationDetailView? GetRfqInvitation(long partyId, long rfqId);

    ExternalRfqInvitationDetailView RespondToRfqInvitation(long partyId, long rfqId, string responseStatusCode, string? declineReason);

    IReadOnlyCollection<ExternalQuotationView> GetQuotations(long partyId);

    SupplierQuotationDetailView? GetQuotation(long partyId, long quotationId);

    SupplierQuotationDetailView CreateQuotation(long partyId, long actorUserId, CreateSupplierQuotationCommand command);

    SupplierQuotationDetailView SubmitQuotation(long partyId, long quotationId, long actorUserId);

    IReadOnlyCollection<ExternalOrderView> GetOrders(long partyId);

    IReadOnlyCollection<ExternalDocumentWorkflowView> GetDocumentWorkflows(long partyId);

    ExternalDocumentWorkflowView? GetDocumentWorkflow(long partyId, long workflowId);

    ExternalDocumentWorkflowView CreateDocumentWorkflow(
        long partyId,
        long actorUserId,
        string partyTypeCode,
        string documentType,
        string fileName,
        string storageReference,
        string? contentType,
        int? fileSizeBytes,
        string? workflowNotes);

    ExternalDocumentWorkflowView SubmitDocumentWorkflow(long partyId, long workflowId, long actorUserId);

    ExternalDocumentWorkflowView ReplaceDocumentWorkflow(
        long partyId,
        long workflowId,
        long actorUserId,
        string fileName,
        string storageReference,
        string? contentType,
        int? fileSizeBytes,
        string? workflowNotes,
        string? replaceReason);

    ExternalDocumentWorkflowView ApproveDocumentWorkflow(long workflowId, long actorUserId, string? reviewNotes);

    ExternalDocumentWorkflowView ReturnDocumentWorkflow(long workflowId, long actorUserId, string? reviewNotes);

    ExternalDocumentWorkflowView RejectDocumentWorkflow(long workflowId, long actorUserId, string? reviewNotes);

    IReadOnlyCollection<ExternalFinancingOfferView> GetFinancingOffers(long partyId, long? financingRequestId = null);

    IReadOnlyCollection<ExternalFinancingNotificationView> GetFinancingNotifications(long partyId, long financingRequestId);

    IReadOnlyCollection<ExternalFinancingTaskView> GetFinancingTasks(long partyId);

    IReadOnlyCollection<ExternalPurchaseOrderView> GetPurchaseOrders(long partyId);

    ExternalPurchaseOrderView AcknowledgePurchaseOrder(long partyId, long purchaseOrderId, long actorUserId, string acknowledgmentStatusCode, string? notes);

    ExternalPurchaseOrderView RaisePurchaseOrderIssue(long partyId, long purchaseOrderId, long actorUserId, string issueCategoryCode, string issueNotes);

    IReadOnlyCollection<ExternalInvoiceView> GetInvoices(long partyId);

    ExternalPaymentView CreateCustomerPaymentRequest(
        long customerPartyId,
        long actorUserId,
        long accountsReceivableInvoiceId,
        string integrationProviderCode,
        string currencyCode,
        decimal amountAmount,
        DateOnly paymentDate,
        string? referenceNumber,
        string? notes);

    IReadOnlyCollection<ExternalPaymentView> GetPayments(long partyId);

    ExternalCustomerPaymentStatusView GetCustomerPaymentStatus(long customerPartyId, long customerPaymentRequestId);

    IReadOnlyCollection<ExternalCustomerDeliveryView> GetCustomerDeliveries(long partyId);

    IReadOnlyCollection<ExternalCustomerServiceRequestView> GetCustomerServiceRequests(long customerPartyId);

    ExternalCustomerServiceRequestView? GetCustomerServiceRequest(long customerPartyId, long serviceRequestId);

    ExternalCustomerServiceRequestView CreateCustomerServiceRequest(
        long customerPartyId,
        long actorUserId,
        string requestTypeCode,
        string subjectText,
        string detailsText,
        string priorityCode,
        string commercialImpactCode,
        string requestedResolutionCode,
        string assignedBackofficeLaneCode,
        string? relatedDocumentType,
        long? relatedDocumentId);

    ExternalCustomerServiceRequestView SubmitCustomerServiceRequest(long customerPartyId, long serviceRequestId, long actorUserId);

    ExternalCustomerServiceRequestView EscalateCustomerServiceRequest(long customerPartyId, long serviceRequestId, long actorUserId, string escalationReason, string? assignedBackofficeLaneCode, string? requestedResolutionCode);

    ExternalCustomerServiceRequestView RouteCustomerServiceRequest(long serviceRequestId, long actorUserId, string assignedBackofficeLaneCode, string? requestedResolutionCode);

    ExternalCustomerServiceRequestView StartCustomerServiceRequestReview(long serviceRequestId, long actorUserId);

    ExternalCustomerServiceRequestView RespondToCustomerServiceRequest(long serviceRequestId, long actorUserId, string responseText);

    ExternalCustomerServiceRequestView RejectCustomerServiceRequest(long serviceRequestId, long actorUserId, string responseText);

    ExternalCustomerServiceRequestView CloseCustomerServiceRequest(long serviceRequestId, long actorUserId, string? resolutionNotes);

    ExternalStatementSummaryView GetStatementSummary(long partyId, DateOnly? dateFrom = null, DateOnly? dateTo = null, string? currencyCode = null);

    IReadOnlyCollection<ExternalStatementLineView> GetStatementLines(long partyId, DateOnly? dateFrom = null, DateOnly? dateTo = null, string? currencyCode = null);

    IReadOnlyCollection<ExternalStatementDocumentView> GetStatementDocuments(long partyId);

    ExternalStatementDetailView? GetStatementDetail(long partyId, long statementId);

    IReadOnlyCollection<ExternalStatementDeliveryLogView> GetStatementDeliveryLogs(long partyId, long statementId);

    IReadOnlyCollection<IslamicFinanceRequest> GetFinancingRequests(long partyId);

    IslamicFinanceRequest? GetFinancingRequest(long partyId, long financingRequestId);

    IReadOnlyCollection<IslamicFinanceReceivablesCase> GetReceivablesCases(long partyId);

    IReadOnlyCollection<IslamicFinanceMurabahaCase> GetMurabahaCases(long partyId);

    IReadOnlyCollection<IslamicFinanceMurabahaDisbursement> GetMurabahaDisbursements(long partyId);

    IReadOnlyCollection<IslamicFinanceSettlementHeader> GetSettlements(long partyId);

    SupplierProfileDetailView? GetSupplierProfileByPartyId(long partyId);
}
