Browse Source

Refactoring/traduction modèle Facture > Invoice

dev
Guillaume Bourgeois 6 years ago
parent
commit
338ebed6d3
1 changed files with 42 additions and 28 deletions
  1. +42
    -28
      common/models/Invoice.php

common/models/Facture.php → common/models/Invoice.php View File

* This is the model class for table "facture". * This is the model class for table "facture".
* *
* @property integer $id * @property integer $id
* @property integer $id_etablissement
* @property integer $id_producer
* @property string $date * @property string $date
* @property string $reference * @property string $reference
* @property string $libelle
* @property string $texte
* @property double $montant_ht
* @property integer $paye
* @property string $date_paiement
* @property string $methode_paiement
* @property string $wording
* @property string $text
* @property double $amount_without_tax
* @property integer $paid
* @property string $date_payment
* @property string $means_payment
*/ */
class Facture extends \yii\db\ActiveRecord
class Invoice extends \yii\db\ActiveRecord
{ {


/** /**
*/ */
public static function tableName() public static function tableName()
{ {
return 'facture';
return 'invoice';
} }


/** /**
public function rules() public function rules()
{ {
return [ return [
[['id_etablissement', 'paye'], 'integer'],
[['date', 'date_paiement'], 'safe'],
[['id_producer', 'paye'], 'integer'],
[['date', 'date_payment'], 'safe'],
[['texte'], 'string'], [['texte'], 'string'],
[['montant_ht', 'ca'], 'number'],
[['reference', 'libelle', 'methode_paiement'], 'string', 'max' => 255],
[['amount_without_tax', 'ca'], 'number'],
[['reference', 'wording', 'means_payment'], 'string', 'max' => 255],
]; ];
} }


* Relations * Relations
*/ */
public function getEtablissement()
public function getProducer()
{ {
return $this->hasOne(Etablissement::className(), ['id' => 'id_etablissement']);
return $this->hasOne(Producer::className(), ['id' => 'id_producer']);
} }


/** /**
{ {
return [ return [
'id' => 'ID', 'id' => 'ID',
'id_etablissement' => 'Id Etablissement',
'id_producer' => 'Producteur',
'date' => 'Date', 'date' => 'Date',
'reference' => 'Reference', 'reference' => 'Reference',
'libelle' => 'Libelle',
'texte' => 'Texte',
'montant_ht' => 'Montant Ht',
'paye' => 'Paye',
'date_paiement' => 'Date Paiement',
'methode_paiement' => 'Methode Paiement',
'ca' => 'CA'
'wording' => 'Libellé',
'text' => 'Texte',
'amount_without_tax' => 'Montant Ht',
'paid' => 'Paye',
'date_payment' => 'Date de paiement',
'means_payment' => 'Méthode payment',
'turnover' => 'CA'
]; ];
} }


/**
* Retourne les options de base nécessaires à la fonction de recherche.
*
* @return array
*/
public static function defaultOptionsSearch()
{
return [
'class' => 'Invoice',
'with' => [],
'join_with' => [],
'orderby' => self::tableName().'.date ASc',
'attribute_id_producer' => self::tableName().'.id_producer'
] ;
}
/** /**
* Retourne la dernière facture émise. * Retourne la dernière facture émise.
* *
* @return Facture * @return Facture
*/ */
public static function getLastFacture()
public static function getLastInvoice()
{ {
return Facture::find()
->orderBy('reference DESC')
->one();
return self::searchOne([],['orderby'=>'reference DESC']) ;
} }

} }

Loading…
Cancel
Save