<commit_before><?php

/**
 * Model for Facture
 *
 */
class Facture extends BaseFacture implements InterfaceArchivageDocument {

    private $documents_origine = array();
    protected $declarant_document = null;
    protected $archivage_document = null;

    const MESSAGE_DEFAULT = "";

    public function __construct() {
        parent::__construct();
        $this->initDocuments();
    }

    public function __clone() {
        parent::__clone();
        $this->initDocuments();
    }

    protected function initDocuments() {
        $this->declarant_document = new DeclarantDocument($this);
        $this->archivage_document = new ArchivageDocument($this);
    }

    public function getCampagne() {

        return $this->_get('campagne');
    }

    public function storeEmetteur() {
        $configs = sfConfig::get('app_configuration_facture');
        $emetteur = new stdClass();

        if (!array_key_exists($this->region, $configs['emetteur']))
            throw new sfException(sprintf('Config %s not found in app.yml', $this->region));
        $this->emetteur = $configs['emetteur'][$this->region];
    }

    public function getCoordonneesBancaire() {
        $coordonneesBancaires = new stdClass();
        switch ($this->region) {
            case EtablissementClient::REGION_HORS_CVO:
                $coordonneesBancaires->banque = 'Crédit Agricole IVSO';
                $coordonneesBancaires->bic = ' ABRVFQQQ999';
                $coordonneesBancaires->iban = ' FR76~1111~2222~3333~4444~5555~100';
                break;
        }
        return $coordonneesBancaires;
    }

    public function storeDatesCampagne($date_facturation = null) {
        $this->date_emission = date('Y-m-d');
        $this->date_facturation = $date_facturation;
        $date_facturation_object = new DateTime($this->date_facturation);
        $this->date_echeance = $date_facturation_object->modify('+30 days')->format('Y-m-d');
        if (!$this->date_facturation)
            $this->date_facturation = date('Y-m-d');
        $dateFacturation = explode('-', $this->date_facturation);
        $this->campagne = $dateFacturation[0];
    }

    public function constructIds($doc) {
        if (!$doc)
            throw new sfException('Pas de document attribué');

        $this->region = $doc->getRegionViticole();
        $this->identifiant = $doc->identifiant;
        $this->numero_facture = FactureClient::getInstance()->getNextNoFacture($this->identifiant, date('Ymd'));
        $this->_id = FactureClient::getInstance()->getId($this->identifiant, $this->numero_facture);
    }

    public function getNumeroInterpro() {
        if ($this->_get('numero_interpro')) {

            return $this->_get('numero_interpro');<commit_msg>Plusieurs régions (à mettre en conf ?)<commit_after><?php

/**
 * Model for Facture
 *
 */
class Facture extends BaseFacture implements InterfaceArchivageDocument {

    private $documents_origine = array();
    protected $declarant_document = null;
    protected $archivage_document = null;

    const MESSAGE_DEFAULT = "";

    public function __construct() {
        parent::__construct();
        $this->initDocuments();
    }

    public function __clone() {
        parent::__clone();
        $this->initDocuments();
    }

    protected function initDocuments() {
        $this->declarant_document = new DeclarantDocument($this);
        $this->archivage_document = new ArchivageDocument($this);
    }

    public function getCampagne() {

        return $this->_get('campagne');
    }

    public function storeEmetteur() {
        $configs = sfConfig::get('app_configuration_facture');
        $emetteur = new stdClass();

        if (!array_key_exists($this->region, $configs['emetteur']))
            throw new sfException(sprintf('Config %s not found in app.yml', $this->region));
        $this->emetteur = $configs['emetteur'][$this->region];
    }

    public function getCoordonneesBancaire() {
        $coordonneesBancaires = new stdClass();

        $coordonneesBancaires->banque = 'Crédit Agricole IVSO';
        $coordonneesBancaires->bic = ' ABRVFQQQ999';
        $coordonneesBancaires->iban = ' FR76~1111~2222~3333~4444~5555~100';

        return $coordonneesBancaires;
    }

    public function storeDatesCampagne($date_facturation = null) {
        $this->date_emission = date('Y-m-d');
        $this->date_facturation = $date_facturation;
        $date_facturation_object = new DateTime($this->date_facturation);
        $this->date_echeance = $date_facturation_object->modify('+30 days')->format('Y-m-d');
        if (!$this->date_facturation)
            $this->date_facturation = date('Y-m-d');
        $dateFacturation = explode('-', $this->date_facturation);
        $this->campagne = $dateFacturation[0];
    }

    public function constructIds($doc) {
        if (!$doc)
            throw new sfException('Pas de document attribué');

        $this->region = $doc->getRegionViticole();
        $this->identifiant = $doc->identifiant;
        $this->numero_facture = FactureClient::getInstance()->getNextNoFacture($this->identifiant, date('Ymd'));
        $this->_id = FactureClient::getInstance()->getId($this->identifiant, $this->numero_facture);
    }

    public function getNumeroInterpro() {
        if ($this->_get('numero_interpro')) {

            return $this->_get('numero_interpro');
{'fraction_non_alphanumeric': 0.14078212290502792, 'fraction_numerical': 0.01154562383612663, 'mean_word_length': 3.1031321619556915, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 74, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6203851', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1600, 'n_words': 278}