/** * Tax Report Component * * Displays tax analytics and reporting for admin dashboard * * @package Yatra.Components.Reports * @since 3.0.0 */ import React from "react"; import { taxService } from "../../services/TaxService"; interface TaxReportProps { bookings: any[]; className?: string; } const TaxReport: React.FC = ({ bookings, className = "" }) => { // Calculate tax summary const taxSummary = React.useMemo(() => { return taxService.getTaxSummary(bookings); }, [bookings]); // Format currency const formatCurrency = (amount: number, currency: string = "USD") => { return new Intl.NumberFormat("en-US", { style: "currency", currency: currency, }).format(amount); }; if (taxSummary.total_bookings_with_tax === 0) { return (

Tax Report

No tax data available for the selected period.

Either tax is disabled or no bookings with tax have been made.

); } return (

Tax Report

{/* Summary Cards */}
Total Tax Collected
{formatCurrency(taxSummary.total_tax_collected)}
Bookings with Tax
{taxSummary.total_bookings_with_tax}
Average Tax Rate
{taxSummary.average_tax_rate.toFixed(2)}%
{/* Tax Breakdown */} {Object.keys(taxSummary.tax_breakdown).length > 0 && (

Tax Breakdown by Type

{Object.entries(taxSummary.tax_breakdown).map(([name, data]) => (
{name}
{data.count} bookings • {data.average_rate.toFixed(2)}% avg rate
{formatCurrency(data.total_amount)}
{( (data.total_amount / taxSummary.total_tax_collected) * 100 ).toFixed(1)} % of total
))}
)} {/* Tax Insights */}

Tax Insights

Tax is enabled and actively collected
{taxSummary.total_bookings_with_tax} taxable bookings this period
{taxSummary.average_tax_rate > 0 && (
Average tax rate: {taxSummary.average_tax_rate.toFixed(2)}%
)} {Object.keys(taxSummary.tax_breakdown).length > 1 && (
Multiple tax types configured
)}
); }; export default TaxReport;