<?php

function billing_sales_modules(): array
{
    return [
        'quotes' => [
            'nav' => 'quotes',
            'table' => 'quotes',
            'list_title' => 'All Quotes',
            'new_title' => 'New Quote',
            'number_field' => 'quote_number',
            'number_label' => 'Quote#',
            'number_prefix' => 'QT-',
            'date_field' => 'quote_date',
            'date_label' => 'Quote Date',
            'secondary_date_field' => 'expiry_date',
            'secondary_date_label' => 'Expiry Date',
            'reference_field' => 'reference_number',
            'reference_label' => 'Reference#',
            'extra_field' => 'project_name',
            'extra_label' => 'Project Name',
            'subject_label' => 'Subject',
            'notes_field' => 'customer_notes',
            'notes_label' => 'Customer Notes',
            'terms_field' => 'terms_text',
            'terms_label' => 'Terms & Conditions',
            'template_field' => 'pdf_template_name',
            'default_template' => 'Spreadsheet Template',
            'list_fn' => 'billing_get_quotes',
            'get_fn' => 'billing_get_quote',
            'save_fn' => 'billing_save_quote',
            'new_path' => 'quote_new.php',
            'list_path' => 'quotes.php',
            'empty_title' => 'Seal the deal.',
            'empty_copy' => 'With quotes, give your customers an offer they cannot refuse.',
            'list_columns' => ['date', 'number', 'reference', 'customer', 'status', 'amount'],
        ],
        'invoices' => [
            'nav' => 'invoices',
            'table' => 'invoices',
            'list_title' => 'All Invoices',
            'new_title' => 'New Invoice',
            'number_field' => 'invoice_number',
            'number_label' => 'Invoice#',
            'number_prefix' => 'INV-',
            'date_field' => 'invoice_date',
            'date_label' => 'Invoice Date',
            'secondary_date_field' => 'due_date',
            'secondary_date_label' => 'Due Date',
            'reference_field' => 'order_number',
            'reference_label' => 'Order Number',
            'extra_field' => 'salesperson_name',
            'extra_label' => 'Salesperson',
            'subject_label' => 'Subject',
            'notes_field' => 'notes_text',
            'notes_label' => 'Customer Notes',
            'terms_field' => 'terms_text',
            'terms_label' => 'Terms & Conditions',
            'template_field' => 'pdf_template_name',
            'default_template' => 'Spreadsheet Template',
            'list_fn' => 'billing_get_invoices',
            'get_fn' => 'billing_get_invoice',
            'save_fn' => 'billing_save_invoice',
            'new_path' => 'invoice_new.php',
            'list_path' => 'invoices.php',
            'empty_title' => "It's time to get paid!",
            'empty_copy' => 'Create invoices and collect payments from your customers.',
            'list_columns' => ['date', 'number', 'customer', 'email', 'status', 'secondary_date', 'amount', 'balance'],
        ],
        'subscriptions' => [
            'nav' => 'subscriptions',
            'table' => 'subscriptions',
            'list_title' => 'All Subscriptions',
            'new_title' => 'New Subscription',
            'number_field' => 'subscription_number',
            'number_label' => 'Subscription#',
            'number_prefix' => 'SUB-',
            'date_field' => 'start_date',
            'date_label' => 'Start Date',
            'secondary_date_field' => 'next_billing_date',
            'secondary_date_label' => 'Next Billing Date',
            'reference_field' => 'reference_number',
            'reference_label' => 'Reference#',
            'extra_field' => 'salesperson_name',
            'extra_label' => 'Salesperson',
            'subject_label' => '',
            'notes_field' => 'customer_notes',
            'notes_label' => 'Customer Notes',
            'terms_field' => 'terms_text',
            'terms_label' => 'Terms & Conditions',
            'template_field' => 'invoice_template_name',
            'default_template' => 'Spreadsheet Template',
            'list_fn' => 'billing_get_subscriptions',
            'get_fn' => 'billing_get_subscription',
            'save_fn' => 'billing_save_subscription',
            'new_path' => 'subscription_new.php',
            'list_path' => 'subscriptions.php',
            'empty_title' => 'Create Your First Subscription',
            'empty_copy' => 'Automate recurring billing with reusable subscription plans and item schedules.',
            'list_columns' => ['customer', 'secondary_date', 'status', 'amount'],
        ],
        'delivery_challans' => [
            'nav' => 'delivery_challans',
            'table' => 'delivery_challans',
            'list_title' => 'All Delivery Challans',
            'new_title' => 'New Delivery Challan',
            'number_field' => 'delivery_challan_number',
            'number_label' => 'Delivery Challan#',
            'number_prefix' => 'DC-',
            'date_field' => 'challan_date',
            'date_label' => 'Delivery Challan Date',
            'secondary_date_field' => '',
            'secondary_date_label' => '',
            'reference_field' => 'reference_number',
            'reference_label' => 'Reference#',
            'extra_field' => 'challan_type',
            'extra_label' => 'Challan Type',
            'extra_options' => ['Supply on Approval', 'Supply of Liquid Gas', 'Job Work', 'Others'],
            'subject_label' => '',
            'notes_field' => 'customer_notes',
            'notes_label' => 'Customer Notes',
            'terms_field' => 'terms_text',
            'terms_label' => 'Terms & Conditions',
            'template_field' => 'pdf_template_name',
            'default_template' => 'Standard Template',
            'list_fn' => 'billing_get_delivery_challans',
            'get_fn' => 'billing_get_delivery_challan',
            'save_fn' => 'billing_save_delivery_challan',
            'new_path' => 'delivery_challan_new.php',
            'list_path' => 'delivery_challans.php',
            'empty_title' => 'Deliver goods effectively!',
            'empty_copy' => 'Create, customize and print professional delivery challans.',
            'list_columns' => ['date', 'number', 'reference', 'customer', 'amount'],
        ],
        'credit_notes' => [
            'nav' => 'credit_notes',
            'table' => 'credit_notes',
            'list_title' => 'All Credit Notes',
            'new_title' => 'New Credit Note',
            'number_field' => 'credit_note_number',
            'number_label' => 'Credit Note#',
            'number_prefix' => 'CN-',
            'date_field' => 'credit_note_date',
            'date_label' => 'Credit Note Date',
            'secondary_date_field' => '',
            'secondary_date_label' => '',
            'reference_field' => 'reference_number',
            'reference_label' => 'Reference#',
            'extra_field' => 'salesperson_name',
            'extra_label' => 'Salesperson',
            'subject_label' => 'Subject',
            'notes_field' => 'customer_notes',
            'notes_label' => 'Customer Notes',
            'terms_field' => 'terms_text',
            'terms_label' => 'Terms & Conditions',
            'template_field' => 'pdf_template_name',
            'default_template' => 'Spreadsheet Template',
            'list_fn' => 'billing_get_credit_notes',
            'get_fn' => 'billing_get_credit_note',
            'save_fn' => 'billing_save_credit_note',
            'new_path' => 'credit_note_new.php',
            'list_path' => 'credit_notes.php',
            'empty_title' => 'Adjust balances with credit notes.',
            'empty_copy' => 'Create credits for returns, overpayments, or invoice corrections.',
            'list_columns' => ['date', 'number', 'customer', 'status', 'amount'],
        ],
    ];
}

function billing_sales_module(string $key): ?array
{
    $modules = billing_sales_modules();
    return $modules[$key] ?? null;
}
