<?php

namespace App\Models;

class ChequeFormat extends BaseModel
{
    protected $fillable = [
        'company_id',
        'name',
        'page_width_mm',
        'page_height_mm',
        'layout',
    ];

    protected $casts = [
        'page_width_mm' => 'float',
        'page_height_mm' => 'float',
        'layout' => 'array',
    ];

    public static function defaultLayout(): array
    {
        return [
            'payee' => [
                'label' => 'Payee',
                'sample' => 'John Doe Trading Co.',
                'x' => 40.0,
                'y' => 25.0,
                'font_size' => 12,
            ],
            'date' => [
                'label' => 'Date',
                'sample' => '18/05/2026',
                'x' => 140.0,
                'y' => 10.0,
                'font_size' => 12,
            ],
            'amount' => [
                'label' => 'Amount',
                'sample' => '1,234.56',
                'x' => 145.0,
                'y' => 35.0,
                'font_size' => 12,
            ],
            'amount_words_1' => [
                'label' => 'Amount in Words (line 1)',
                'sample' => 'USD One Thousand Two Hundred',
                'x' => 25.2,
                'y' => 44.4,
                'font_size' => 11,
            ],
            'amount_words_2' => [
                'label' => 'Amount in Words (line 2)',
                'sample' => 'Thirty-Four and 56/100 Only',
                'x' => 10.0,
                'y' => 55.0,
                'font_size' => 11,
            ],
        ];
    }

    public static function sizePresets(): array
    {
        return [
            'standard' => ['label' => 'Standard (180 × 80 mm)', 'width' => 180.0, 'height' => 80.0],
            'common' => ['label' => 'Common (190.5 × 88.9 mm)', 'width' => 190.5, 'height' => 88.9],
        ];
    }
}
