// Fusion Accounting - Sales Report Filters
// Copyright (C) 2026 Nexa Systems Inc.

import { _t } from "@web/core/l10n/translation";

import { AccountReport } from "@fusion_accounting/components/account_report/account_report";
import { AccountReportFilters } from "@fusion_accounting/components/account_report/filters/filters";

export class SalesReportFilters extends AccountReportFilters {
    static template = "fusion_accounting.SalesReportFilters";

    //------------------------------------------------------------------------------------------------------------------
    // Getters
    //------------------------------------------------------------------------------------------------------------------
    get selectedEcTaxName() {
        const selected = this.controller.options.ec_tax_filter_selection.filter(
            (ecTax) => ecTax.selected,
        );

        switch (selected.length) {
            case this.controller.options.ec_tax_filter_selection.length:
                return _t("All");
            case 0:
                return _t("None");
            default:
                return selected.map((s) => s.name.substring(0, 1)).join(", ");
        }
    }
}

AccountReport.registerCustomComponent(SalesReportFilters);
