<?php

namespace Entity\Model;

use Helpers\Outil\Sql;
use Helpers\QueryBuilder\QueryBuilder;
use Modules\Stock\Helper\StringHelper;
use PDO;

class SbtLign extends QueryBuilder
{
    protected string $table = 'SBT_LIGN with (nolock)';
    protected string $primaryKey = '';

    public function __construct(PDO $pdo)
    {
        parent::__construct($pdo);
        $this->primKey = ['NO_BT', 'NO_LIG'];
    }

    /**
     * @param array<string,mixed> $ligneBonTransfert
     * @return void
     */
    public function processAndMerge(array $ligneBonTransfert): void
    {
        $ligneBonTransfert['REAPPRO_FAIT'] = Sql::toBool($ligneBonTransfert['REAPPRO_FAIT']);
        StringHelper::toFloat($ligneBonTransfert, ['QTE_TRF', 'PRIX']);
        $this->merge($ligneBonTransfert);
    }
}
