package com.nebula.erp.reports.documents;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

public class TaxSwagger {

    // Summaries and Descriptions
    public static final String GET_TAX_REPORT_SUMMARY = "Retrieve Tax Report";
    public static final String GET_TAX_REPORT_DESCRIPTION = "Generates a tax report based on the provided sales request and report type.";

    // Request and Response Examples
    public static final String GET_TAX_REPORT_REQUEST_EXAMPLE = """
        {
                    "startDate": "2025-01-01",
                    "endDate": "2025-12-31",
                    "conditions": [],
                    "page": 0,
                    "size": 10
         }
    """;

    public static final String GET_TAX_REPORT_RESPONSE_EXAMPLE = """
        {
                     "status": "Success",
                     "meta": {
                         "code": 200,
                         "details": "Data retrieved.",
                         "timestamp": "2025-01-28T20:19:08.1445849"
                     },
                     "data": {
                         "module": "tax",
                         "reportType": "gstVatSummary",
                         "startDate": "2025-01-01",
                         "endDate": "2025-12-31",
                         "reportData": [
                             {
                                 "sale_id": 38,
                                 "tax_type": "GST",
                                 "tax_collected": 74.340,
                                 "sale_date": "2025-01-12T16:06:17.296751"
                             }
                         ],
                         "column": {
                             "sale_id": "SALES ID",
                             "tax_type": "TAX TYPE",
                             "tax_collected": "TAX COLLECTED",
                             "sale_date": "SALE DATE"
                         },
                         "pagination": {
                             "currentPage": 1,
                             "totalPages": 5,
                             "pageSize": 10,
                             "totalRecords": 49
                         },
                         "summary": {
                             "totalTaxesCollected": 5267.520,
                             "gstCollected": 5267.520,
                             "vatCollected": 0
                         }
                     }
                 }
    """;

    public static final String INTERNAL_SERVER_ERROR_RESPONSE = """
        {
            "status": "error",
            "meta": {
                "code": 500,
                "message": "Internal Server Error"
            }
        }
    """;

    // Global Error Response Annotation
    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    @ApiResponse(
            responseCode = "500",
            description = "Internal Server Error",
            content = @Content(
                    mediaType = "application/json",
                    examples = @ExampleObject(value = INTERNAL_SERVER_ERROR_RESPONSE)
            )
    )
    public @interface GlobalErrorResponse {}

    // Annotation for Tax Report API
    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    @Operation(
            summary = GET_TAX_REPORT_SUMMARY,
            description = GET_TAX_REPORT_DESCRIPTION,
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = com.nebula.erp.reports.requestmodel.SalesRequest.class),
                            examples = @ExampleObject(value = GET_TAX_REPORT_REQUEST_EXAMPLE)
                    )
            ),
            responses = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Tax report generated successfully",
                            content = @Content(
                                    mediaType = "application/json",
                                    examples = @ExampleObject(value = GET_TAX_REPORT_RESPONSE_EXAMPLE)
                            )
                    )
            }
    )
    public @interface GetTaxReportOperation {}
}
