Parcourir la source

Refactoring/traduction modèle Facture > Invoice

dev
Guillaume Bourgeois il y a 6 ans
Parent
révision
338ebed6d3
1 fichiers modifiés avec 42 ajouts et 28 suppressions
  1. +42
    -28
      common/models/Invoice.php

common/models/Facture.php → common/models/Invoice.php Voir le fichier

@@ -44,17 +44,17 @@ use Yii;
* This is the model class for table "facture".
*
* @property integer $id
* @property integer $id_etablissement
* @property integer $id_producer
* @property string $date
* @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
{

/**
@@ -62,7 +62,7 @@ class Facture extends \yii\db\ActiveRecord
*/
public static function tableName()
{
return 'facture';
return 'invoice';
}

/**
@@ -71,11 +71,11 @@ class Facture extends \yii\db\ActiveRecord
public function rules()
{
return [
[['id_etablissement', 'paye'], 'integer'],
[['date', 'date_paiement'], 'safe'],
[['id_producer', 'paye'], 'integer'],
[['date', 'date_payment'], 'safe'],
[['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],
];
}

@@ -83,9 +83,9 @@ class Facture extends \yii\db\ActiveRecord
* Relations
*/
public function getEtablissement()
public function getProducer()
{
return $this->hasOne(Etablissement::className(), ['id' => 'id_etablissement']);
return $this->hasOne(Producer::className(), ['id' => 'id_producer']);
}

/**
@@ -95,29 +95,43 @@ class Facture extends \yii\db\ActiveRecord
{
return [
'id' => 'ID',
'id_etablissement' => 'Id Etablissement',
'id_producer' => 'Producteur',
'date' => 'Date',
'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.
*
* @return Facture
*/
public static function getLastFacture()
public static function getLastInvoice()
{
return Facture::find()
->orderBy('reference DESC')
->one();
return self::searchOne([],['orderby'=>'reference DESC']) ;
}

}

Chargement…
Annuler
Enregistrer