<commit_before><?php

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

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

    const MESSAGE_DEFAULT = "";

    public function __construct() {
        parent::__construct();
        $this->initDocuments();
        $this->configuration = ConfigurationClient::getCurrent();
        $config_detail_list = $this->configuration->declaration->getDetailConfiguration();
        foreach ($config_detail_list->sorties as $keyDetail => $detail) {
            $this->config_sortie_array[$keyDetail] = $detail->getLibelle();
        }
    }

    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 (!$configs && !isset($configs['emetteur_libre']) && !isset($configs['emetteur_cvo'])) {
            throw new sfException(sprintf('Config "configuration/facture/emetteur" not found in app.yml'));
        }
        if ($this->hasArgument(FactureClient::TYPE_FACTURE_MOUVEMENT_DIVERS)) {
            $this->emetteur = $configs['emetteur_libre'];
        }
        if ($this->hasArgument(FactureClient::TYPE_FACTURE_MOUVEMENT_DRM)) {
            $this->emetteur = $configs['emetteur_cvo'];
        }
    }

    public function getCoordonneesBancaire() {
        $configs = sfConfig::get('app_configuration_facture');
        if (!$configs && !isset($configs['coordonnees_bancaire'])) {
            throw new sfException(sprintf('Config "configuration/facture/coordonnees_bancaire" not found in app.yml'));
        }
        $appCoordonneesBancaire = $configs['coordonnees_bancaire'];

        $coordonneesBancaires = new stdClass();

        $coordonneesBancaires->banque = $appCoordonneesBancaire['banque'];
        $coordonneesBancaires->bic = $appCoordonneesBancaire['bic'];
        $coordonneesBancaires->iban = $appCoordonneesBancaire['iban'];

        return $coordonneesBancaires;
    }

    public function getInformationsInterpro() {
        $configs = sfConfig::get('app_configuration_facture');
        if (!$configs && !isset($configs['infos_interpro'])) {
            throw new sfException(sprintf('Config "configuration/facture/infos_interpro" not found in app.yml'));
        }
        $appInfosInterpro = $configs['infos_interpro'];

        $infosInterpro = new stdClass();

        $infosInterpro->siret = $appInfosInterpro['siret'];
        $infosInterpro->ape = $appInfosInterpro['ape'];
        $infosInterpro->tva_intracom = $appInfosInterpro['tva_intracom'];

        return $infosInterpro;
    }

    public function storeDatesCampagne($date_facturation = null) {
        $configs = sfConfig::get('app_configuration_facture');
        $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');
	$date_campagne = new DateTime(date('Y-m-d'));
        if (isset($configs['exercice']) && $configs['exercice'] == 'viticole') {
		$date_campagne = $date_campagne->modify('+5 months');
	}
        $this->campagne = $date_campagne->format('Y');
    }

    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);
    }
<commit_msg>Facture campagne pris sur la date de facturation<commit_after><?php

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

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

    const MESSAGE_DEFAULT = "";

    public function __construct() {
        parent::__construct();
        $this->initDocuments();
        $this->configuration = ConfigurationClient::getCurrent();
        $config_detail_list = $this->configuration->declaration->getDetailConfiguration();
        foreach ($config_detail_list->sorties as $keyDetail => $detail) {
            $this->config_sortie_array[$keyDetail] = $detail->getLibelle();
        }
    }

    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 (!$configs && !isset($configs['emetteur_libre']) && !isset($configs['emetteur_cvo'])) {
            throw new sfException(sprintf('Config "configuration/facture/emetteur" not found in app.yml'));
        }
        if ($this->hasArgument(FactureClient::TYPE_FACTURE_MOUVEMENT_DIVERS)) {
            $this->emetteur = $configs['emetteur_libre'];
        }
        if ($this->hasArgument(FactureClient::TYPE_FACTURE_MOUVEMENT_DRM)) {
            $this->emetteur = $configs['emetteur_cvo'];
        }
    }

    public function getCoordonneesBancaire() {
        $configs = sfConfig::get('app_configuration_facture');
        if (!$configs && !isset($configs['coordonnees_bancaire'])) {
            throw new sfException(sprintf('Config "configuration/facture/coordonnees_bancaire" not found in app.yml'));
        }
        $appCoordonneesBancaire = $configs['coordonnees_bancaire'];

        $coordonneesBancaires = new stdClass();

        $coordonneesBancaires->banque = $appCoordonneesBancaire['banque'];
        $coordonneesBancaires->bic = $appCoordonneesBancaire['bic'];
        $coordonneesBancaires->iban = $appCoordonneesBancaire['iban'];

        return $coordonneesBancaires;
    }

    public function getInformationsInterpro() {
        $configs = sfConfig::get('app_configuration_facture');
        if (!$configs && !isset($configs['infos_interpro'])) {
            throw new sfException(sprintf('Config "configuration/facture/infos_interpro" not found in app.yml'));
        }
        $appInfosInterpro = $configs['infos_interpro'];

        $infosInterpro = new stdClass();

        $infosInterpro->siret = $appInfosInterpro['siret'];
        $infosInterpro->ape = $appInfosInterpro['ape'];
        $infosInterpro->tva_intracom = $appInfosInterpro['tva_intracom'];

        return $infosInterpro;
    }

    public function storeDatesCampagne($date_facturation = null) {
        $configs = sfConfig::get('app_configuration_facture');
        $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');
        }
        
	    $date_campagne = new DateTime($this->date_facturation);

        if (isset($configs['exercice']) && $configs['exercice'] == 'viticole') {
		    $date_campagne = $date_campagne->modify('+5 months');
	    }

        $this->campagne = $date_campagne->format('Y');
    }

    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);
    }

{'fraction_non_alphanumeric': 0.1421256258534365, 'fraction_numerical': 0.0006827492034592626, 'mean_word_length': 3.4077231695085257, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 94, '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': '140194', 'n_tokens_mistral': 2742, 'n_tokens_neox': 2670, 'n_words': 415}