<?php
namespace Modules\Additional\Specifique\Client153\Modules\Facture\Service;

use Helpers\ChampsSupplementaire\ChampSupp;
use Helpers\Outil\Sql;

// phpcs:ignore
class TypeTVASpecifique
{
    /**
     * @return null|string
     */
    public static function getTypeTVA(\PDO $pdo, ?string $codeFou = null, ?string $codeSte = null)
    {
        if (!$codeFou || $codeSte) {
            return null;
        }

        $numFixSociete = Sql::dilispec($pdo, 'PARNCS0153', 'NCS_SOCIETE_NUMCSFOUTYPETVA');
        $numFixTauxTva = ChampSupp::getValueCS('SOCIETE', $codeSte, $numFixSociete, $pdo);

        if (!$numFixTauxTva) {
            return null;
        }

        $typeTva = ChampSupp::getValueCS('FOURNISS', $codeFou, $numFixTauxTva, $pdo);

        if (!$typeTva) {
            return null;
        }
    
        return $typeTva;
    }
}
