<?php

declare(strict_types=1);

namespace BookiFlex\Extensions\Taxation\Admin;

use BookiFlex\Core\Admin\Field\SectionNotice;
use Carbon_Fields\Field;

defined( 'ABSPATH' ) || exit;

/**
 * Settings for Taxation extension.
 */
class TaxationSettings
{
    // Taxation — VAT
    public const VAT_ENABLED  = 'bflex__taxation__vat__enabled';
    public const VAT_RATE     = 'bflex__taxation__vat__rate';
    public const VAT_STRATEGY = 'bflex__taxation__vat__strategy';

    // Taxation — City tax
    public const CITY_ENABLED  = 'bflex__taxation__city__enabled';
    public const CITY_RATE     = 'bflex__taxation__city__rate';
    public const CITY_STRATEGY = 'bflex__taxation__city__strategy';

    // Taxation constants — strategy values
    public const INCLUSIVE                  = 'INC'; // inclusive
    public const EXCLUSIVE                  = 'EXC'; // exclusive
    public const FIXED_PER_RESERVATION      = 'fixed_per_reservation';
    public const FIXED_PER_PERSON           = 'fixed_per_person';
    public const FIXED_PER_NIGHT            = 'fixed_per_night';
    public const FIXED_PER_PERSON_PER_NIGHT = 'fixed_per_person_per_night';

    public function getTabName(): string
    {
        return __('Taxation', 'bookiflex');
    }

    public function __invoke(): array
    {
        return [
            Field::make('separator', 'bflex__taxation__vat__separator', __('VAT (Value-Added Tax)', 'bookiflex')),
            SectionNotice::make(
                'bflex__taxation__vat__description',
                __('A percentage-based tax applied to the booking total. Enable VAT if your local regulations require it, then set the rate and choose whether it is added on top of the booking amount (exclusive) or already included in the rate (inclusive).', 'bookiflex'),
            ),
            Field::make('checkbox', self::VAT_ENABLED, __('Enabled', 'bookiflex'))
                ->set_autoload(true)
                ->set_default_value(false)
                ->set_help_text(__('Toggle to activate or deactivate VAT.', 'bookiflex')),
            Field::make('text', self::VAT_RATE, __('Rate', 'bookiflex'))
                ->set_autoload(true)
                ->set_default_value(20)
                ->set_attribute('type', 'number')
                ->set_attribute('step', '.1')
                ->set_attribute('min', '0')
                ->set_attribute('max', '100')
                ->set_width(50)
                ->set_help_text(__('VAT percentage (0–100%). For example, enter 20 for 20% VAT.', 'bookiflex')),
            Field::make('select', self::VAT_STRATEGY, __('Strategy', 'bookiflex'))
                ->set_autoload(true)
                ->set_options([
                    self::EXCLUSIVE => __('Exclusive', 'bookiflex'),
                    self::INCLUSIVE => __('Inclusive', 'bookiflex'),
                ])
                ->set_default_value(self::EXCLUSIVE)
                ->set_help_text(__('<b>Exclusive:</b> tax is added on top of the base rate. <b>Inclusive:</b> tax is included in the rate plan amount.', 'bookiflex'))
                ->set_width(50),

//            Field::make('separator', 'bflex__taxation__city__separator', __('City Fee', 'bookiflex')),
//            Field::make('html', 'bflex__taxation__city__description')
//                ->set_html(sprintf('<p>%s</p>', __('A local tourist or municipal fee, charged as a fixed value or per night/person.', 'bookiflex'))),
//            Field::make('checkbox', self::CITY_ENABLED, __('Enabled', 'bookiflex'))
//                ->set_autoload(true)
//                ->set_default_value(false)
//                ->set_help_text(__('Toggle to activate or deactivate this fee.', 'bookiflex')),
//            Field::make('text', self::CITY_RATE, __('Rate', 'bookiflex'))
//                ->set_autoload(true)
//                ->set_default_value(10)
//                ->set_attribute('type', 'number')
//                ->set_attribute('step', '.1')
//                ->set_attribute('min', '0')
//                ->set_width(50)
//                ->set_help_text(__('Fee amount in the default currency or percentage (depending on strategy).', 'bookiflex')),
//            Field::make('select', self::CITY_STRATEGY, __('Strategy', 'bookiflex'))
//                ->set_autoload(true)
//                ->set_options([
//                    self::FIXED_PER_RESERVATION      => __('Fixed per reservation'),
//                    self::FIXED_PER_PERSON           => __('Fixed per person'),
//                    self::FIXED_PER_NIGHT            => __('Fixed per night'),
//                    self::FIXED_PER_PERSON_PER_NIGHT => __('Fixed per person per night'),
//                ])
//                ->set_width(50)
        ];
    }
}
