<commit_before><?php
/**
 * Model for Vrac
 *
 */

class Vrac extends BaseVrac {
    
    public function constructId() {
        $this->set('_id', 'VRAC-'.$this->numero_contrat);

        if(!$this->date_signature) {
            $this->date_signature = date('d/m/Y');
        }
        
        if(!$this->date_stats) {
            $this->date_stats = date('d/m/Y');
        }
    }
    
    public function setBouteillesContenanceLibelle($c) {
        $this->_set('bouteilles_contenance_libelle', $c);
        if ($c) {
            $this->setBouteillesContenanceVolume(VracClient::$contenance[$c]);
        }
    }
    
    public function update($params = array()) {
        
         $this->prix_total = null;

        switch ($this->type_transaction)
        {
            case 'raisins' :
            {
                $this->prix_total = $this->raisin_quantite * $this->prix_unitaire;
                $this->bouteilles_contenance_libelle = '';
                $this->bouteilles_contenance_volume = null;
                $this->volume_propose = $this->getDensite() * $this->raisin_quantite;
                break;
            }
            case 'vin_bouteille' :
            {
                $this->prix_total = $this->bouteilles_quantite * $this->prix_unitaire;
                $this->volume_propose = $this->bouteilles_quantite * $this->bouteilles_contenance_volume;
                break;
            }
            
            case 'mouts' :
            case 'vin_vrac' :
            {
                $this->prix_total = $this->jus_quantite * $this->prix_unitaire;              
                $this->bouteilles_contenance_libelle = '';
                $this->bouteilles_contenance_volume = null;
                $this->volume_propose = $this->jus_quantite;
            }              
        }        
    }

    public function setInformations() 
    {        
        $this->setAcheteurInformations();
        $this->setVendeurInformations();
        if($this->mandataire_identifiant!=null && $this->mandataire_exist)
        {
            $this->setMandataireInformations();
            
        }
    }

    private function setAcheteurInformations() 
    {
       $acheteurObj = $this->getAcheteurObject();
       $this->acheteur->nom = $acheteurObj->nom;
       $this->acheteur->cvi = $acheteurObj->cvi;
       $this->acheteur->commune = $acheteurObj->siege->commune;
       $this->acheteur->code_postal = $acheteurObj->siege->code_postal;
    }
    
    private function setMandataireInformations() 
    {
       $mandataireObj = $this->getMandataireObject();
       $this->mandataire->nom = $mandataireObj->nom;
       //TODO : surement à changer
       $this->mandataire->carte_pro = $mandataireObj->identifiant;
       $this->mandataire->adresse = $mandataireObj->siege->commune.'  '.$mandataireObj->siege->code_postal;
    }
    
    private function setVendeurInformations() 
    {
       $vendeurObj = $this->getVendeurObject();
       $this->vendeur->nom = $vendeurObj->nom;
       $this->vendeur->cvi = $vendeurObj->cvi;
       $this->vendeur->commune = $vendeurObj->siege->commune;
       $this->vendeur->code_postal = $vendeurObj->siege->code_postal;       
    }

    public function getProduitObject() 
    {
      return ConfigurationClient::getCurrent()->get($this->produit);
    }

    public function getVendeurObject() 
    {
        return EtablissementClient::getInstance()->find($this->vendeur_identifiant,acCouchdbClient::HYDRATE_DOCUMENT);
    }
    
    public function getAcheteurObject() 
    {
        return EtablissementClient::getInstance()->find($this->acheteur_identifiant,acCouchdbClient::HYDRATE_DOCUMENT);
    }
    
    public function getMandataireObject() 
    {
        return EtablissementClient::getInstance()->find($this->mandataire_identifiant,acCouchdbClient::HYDRATE_DOCUMENT);
    }
    
    public function getSoussigneObjectById($soussigneId) 
    {
        return EtablissementClient::getInstance()->find($soussigneId,acCouchdbClient::HYDRATE_DOCUMENT);
    }

    private function getDensite() 
    {
        return 1.3;
    }   
}<commit_msg>Méthode toString du vrac<commit_after><?php
/**
 * Model for Vrac
 *
 */

class Vrac extends BaseVrac {
    
    public function constructId() {
        $this->set('_id', 'VRAC-'.$this->numero_contrat);

        if(!$this->date_signature) {
            $this->date_signature = date('d/m/Y');
        }
        
        if(!$this->date_stats) {
            $this->date_stats = date('d/m/Y');
        }
    }
    
    public function setBouteillesContenanceLibelle($c) {
        $this->_set('bouteilles_contenance_libelle', $c);
        if ($c) {
            $this->setBouteillesContenanceVolume(VracClient::$contenance[$c]);
        }
    }
    
    public function update($params = array()) {
        
         $this->prix_total = null;

        switch ($this->type_transaction)
        {
            case 'raisins' :
            {
                $this->prix_total = $this->raisin_quantite * $this->prix_unitaire;
                $this->bouteilles_contenance_libelle = '';
                $this->bouteilles_contenance_volume = null;
                $this->volume_propose = $this->getDensite() * $this->raisin_quantite;
                break;
            }
            case 'vin_bouteille' :
            {
                $this->prix_total = $this->bouteilles_quantite * $this->prix_unitaire;
                $this->volume_propose = $this->bouteilles_quantite * $this->bouteilles_contenance_volume;
                break;
            }
            
            case 'mouts' :
            case 'vin_vrac' :
            {
                $this->prix_total = $this->jus_quantite * $this->prix_unitaire;              
                $this->bouteilles_contenance_libelle = '';
                $this->bouteilles_contenance_volume = null;
                $this->volume_propose = $this->jus_quantite;
            }              
        }        
    }

    public function setInformations() 
    {        
        $this->setAcheteurInformations();
        $this->setVendeurInformations();
        if($this->mandataire_identifiant!=null && $this->mandataire_exist)
        {
            $this->setMandataireInformations();
            
        }
    }

    private function setAcheteurInformations() 
    {
       $acheteurObj = $this->getAcheteurObject();
       $this->acheteur->nom = $acheteurObj->nom;
       $this->acheteur->cvi = $acheteurObj->cvi;
       $this->acheteur->commune = $acheteurObj->siege->commune;
       $this->acheteur->code_postal = $acheteurObj->siege->code_postal;
    }
    
    private function setMandataireInformations() 
    {
       $mandataireObj = $this->getMandataireObject();
       $this->mandataire->nom = $mandataireObj->nom;
       //TODO : surement à changer
       $this->mandataire->carte_pro = $mandataireObj->identifiant;
       $this->mandataire->adresse = $mandataireObj->siege->commune.'  '.$mandataireObj->siege->code_postal;
    }
    
    private function setVendeurInformations() 
    {
       $vendeurObj = $this->getVendeurObject();
       $this->vendeur->nom = $vendeurObj->nom;
       $this->vendeur->cvi = $vendeurObj->cvi;
       $this->vendeur->commune = $vendeurObj->siege->commune;
       $this->vendeur->code_postal = $vendeurObj->siege->code_postal;       
    }

    public function getProduitObject() 
    {
      return ConfigurationClient::getCurrent()->get($this->produit);
    }

    public function getVendeurObject() 
    {
        return EtablissementClient::getInstance()->find($this->vendeur_identifiant,acCouchdbClient::HYDRATE_DOCUMENT);
    }
    
    public function getAcheteurObject() 
    {
        return EtablissementClient::getInstance()->find($this->acheteur_identifiant,acCouchdbClient::HYDRATE_DOCUMENT);
    }
    
    public function getMandataireObject() 
    {
        return EtablissementClient::getInstance()->find($this->mandataire_identifiant,acCouchdbClient::HYDRATE_DOCUMENT);
    }
    
    public function getSoussigneObjectById($soussigneId) 
    {
        return EtablissementClient::getInstance()->find($soussigneId,acCouchdbClient::HYDRATE_DOCUMENT);
    }

    private function getDensite() 
    {
        return 1.3;
    }

    public function __toString() {

        return sprintf("%s", $this->identifiant);
    }
}
{'fraction_non_alphanumeric': 0.13110817625165086, 'fraction_numerical': 0.00048024972985952696, 'mean_word_length': 2.1964696853415195, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 180, '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': '4376547', 'n_tokens_mistral': 2728, 'n_tokens_neox': 2658, 'n_words': 305}