<?php

namespace Daniv04\HaciendaPackage\Http\Requests;

use Faker\Provider\Base;
use Illuminate\Foundation\Http\FormRequest;
use Daniv04\HaciendaPackage\Services\Validators\BaseReceiptValidatorService;
use Daniv04\HaciendaPackage\Services\Validators\InvoiceSummaryValidator;
use Daniv04\HaciendaPackage\Services\Validators\DetailLinesValidator;
use Daniv04\HaciendaPackage\Services\Validators\TaxesValidator;

use Daniv04\HaciendaPackage\Rules\DetalleServicioRequired;



/**
 * Abastract BaseReceiptRequest for the common validation rules
 * 
 * This class include all common rules for all types of receipts (comprobantes)
 */
abstract class BaseReceiptRequest extends FormRequest
{

    public function authorize(): bool
    {
        return true;
    }

    /** 
     * Validation Rules all receipts must follow
     */
    public function rules(): array
    {
        return (new BaseReceiptValidatorService())->rules($this->all());
    }



    //================Validation functions====================//
    public function withValidator($validator)
    {
        $validator->after(function ($validator) {
            BaseReceiptValidatorService::after($validator, $this->all());
        });
        return $validator;
    }
}
