// Fusion Accounting - Partner Ledger Line Cell
// Copyright (C) 2026 Nexa Systems Inc.

import { AccountReport } from "@fusion_accounting/components/account_report/account_report";
import { AccountReportLineCell } from "@fusion_accounting/components/account_report/line_cell/line_cell";
const { DateTime } = luxon;

/**
 * PartnerLedgerLineCell - Extended line cell for the partner ledger report.
 * Adds due date awareness and overdue highlighting logic.
 */
export class PartnerLedgerLineCell extends AccountReportLineCell {
    static template = "fusion_accounting.PartnerLedgerLineCell";
    get cellClasses() {
        let superCellClasses = super.cellClasses;
        const cell = this.props.cell;
        if (
            cell.figure_type === 'date'
            && cell.expression_label == 'date_maturity'
            && cell.no_format
            && DateTime.fromISO(cell.no_format) < DateTime.now()
        ) {
            superCellClasses += ' text-danger';
        }
        return superCellClasses;
    }
}

AccountReport.registerCustomComponent(PartnerLedgerLineCell);
