瀏覽代碼

[Module BL / devis / factures] Intégration des modifications de la DB dans les modèles existants

dev
Guillaume Bourgeois 4 年之前
父節點
當前提交
caffa7efea
共有 4 個檔案被更改,包括 71 行新增8 行删除
  1. +25
    -1
      common/models/Order.php
  2. +23
    -4
      common/models/Producer.php
  3. +6
    -3
      common/models/ProductOrder.php
  4. +17
    -0
      console/migrations/m200106_143017_module_devis_bl_factures_modification_champs_id_status_order.php

+ 25
- 1
common/models/Order.php 查看文件

@@ -93,7 +93,7 @@ class Order extends ActiveRecordCommon
{
return [
[['id_user', 'date', 'id_point_sale', 'id_distribution'], 'required', 'message' => ''],
[['id_user', 'id_point_sale', 'id_distribution','id_subscription'], 'integer'],
[['id_user', 'id_point_sale', 'id_distribution','id_subscription', 'id_order_status', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'],
[['auto_payment', 'tiller_synchronization'], 'boolean'],
[['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe']
];
@@ -112,6 +112,10 @@ class Order extends ActiveRecordCommon
'id_point_sale' => 'Point de vente',
'id_distribution' => 'Date de distribution',
'id_subscription' => 'Abonnement',
'id_order_status' => 'Statut',
'id_invoice' => 'Facture',
'id_quotation' => 'Devis',
'id_delivery_note' => 'Bon de livraison'
];
}

@@ -152,6 +156,26 @@ class Order extends ActiveRecordCommon
return $this->hasOne(Subscription::className(), ['id' => 'id_subscription'])
->with('productSubscription');
}
public function getOrderOrderStatus()
{
return $this->hasMany(OrderOrderStatus::className(), ['id_order' => 'id'])->with('orderStatus') ;
}
public function getInvoice()
{
return $this->hasOne(Invoice::className(), ['id' => 'id_invoice']) ;
}
public function getQuotation()
{
return $this->hasOne(Quotation::className(), ['id' => 'id_quotation']) ;
}
public function getDeliveryNote()
{
return $this->hasOne(DeliveryNote::className(), ['id' => 'id_delivery_note']) ;
}

/**
* Retourne les options de base nécessaires à la fonction de recherche.

+ 23
- 4
common/models/Producer.php 查看文件

@@ -102,11 +102,11 @@ class Producer extends ActiveRecordCommon
public function rules()
{
return [
[['name','type'], 'required'],
[['name','type','id_tax_rate_default'], 'required'],
[['tiller_provider_token','tiller_restaurant_token'], 'required', 'when' => function($model) {
return $model->tiller == true ;
}],
[['order_deadline', 'order_delay'], 'integer'],
[['order_deadline', 'order_delay', 'id_tax_rate_default', 'document_quotation_duration'], 'integer'],
['order_deadline', 'in', 'range' => [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]],
['order_delay', 'in', 'range' => [1, 2, 3, 4, 5, 6, 7]],
['code', function($attribute, $params) {
@@ -116,9 +116,10 @@ class Producer extends ActiveRecordCommon
$this->addError($attribute, 'Ce code est déjà utilisé par un autre producteur.');
}
}],
[['description','mentions','gcs','order_infos','slug','secret_key_payplug','background_color_logo','option_behavior_cancel_order','tiller_provider_token','tiller_restaurant_token'], 'string'],
[['description','mentions','gcs','order_infos','slug','secret_key_payplug','background_color_logo','option_behavior_cancel_order','tiller_provider_token','tiller_restaurant_token','status',
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note'], 'string'],
[['negative_balance', 'credit', 'active','online_payment','user_manage_subscription', 'option_allow_user_gift','use_credit_checked_default','tiller'], 'boolean'],
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code','type','credit_functioning','option_behavior_cancel_order'], 'string', 'max' => 255],
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code','type','credit_functioning','option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255],
[['free_price', 'credit_limit_reminder','credit_limit'], 'double'],
['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'],
];
@@ -163,6 +164,19 @@ class Producer extends ActiveRecordCommon
'tiller' => 'Tiller',
'tiller_provider_token' => 'Token provider',
'tiller_restaurant_token' => 'Token restaurant',
'status' => 'Statut',
'id_tax_rate_default' => 'Taxe',
'document_quotation_prefix' => 'Préfixe des devis',
'document_quotation_first_reference' => 'Première référence des devis',
'document_quotation_duration' => 'Durée du devis',
'document_invoice_prefix' => 'Préfixe des factures',
'document_invoice_first_reference' => 'Première référence des factures',
'document_delivery_note_prefix' => 'Préfixe des bons de livraison',
'document_delivery_note_first_reference' => 'Première référence des bons de livraison',
'document_infos_bottom' => 'Informations affichées en bas des documents',
'document_infos_quotation' => 'Informations affichées en bas des devis',
'document_infos_invoice' => 'Informations affichées en bas des factures',
'document_infos_delivery_note' => 'Informations affichées en bas des bons de livraison',
];
}

@@ -189,6 +203,11 @@ class Producer extends ActiveRecordCommon
->where(['status' => User::STATUS_PRODUCER]);
}
public function getTaxRate()
{
return $this->hasOne(TaxRate::className(), ['id' => 'id_tax_rate_default']) ;
}
/**
* Retourne les options de base nécessaires à la fonction de recherche.
*

+ 6
- 3
common/models/ProductOrder.php 查看文件

@@ -77,9 +77,10 @@ class ProductOrder extends ActiveRecordCommon
{
return [
[['id_order', 'id_product', 'quantity'], 'required'],
[['id_order', 'id_product'], 'integer'],
[['id_order', 'id_product', 'id_tax_rate'], 'integer'],
[['unit'], 'string', 'max' => 255],
[['quantity'], 'number', 'min' => 0]
[['quantity'], 'number', 'min' => 0],
[['description'], 'safe']
];
}

@@ -93,7 +94,9 @@ class ProductOrder extends ActiveRecordCommon
'id_order' => 'Commande',
'id_product' => 'Product',
'quantity' => 'Quantité',
'unit' => 'Unité'
'unit' => 'Unité',
'id_tax_rate' => 'Taxe',
'description' => 'Description'
];
}

+ 17
- 0
console/migrations/m200106_143017_module_devis_bl_factures_modification_champs_id_status_order.php 查看文件

@@ -0,0 +1,17 @@
<?php

use yii\db\Migration;
use yii\db\Schema;

class m200106_143017_module_devis_bl_factures_modification_champs_id_status_order extends Migration
{
public function safeUp()
{
$this->dropColumn('order', 'id_status') ;
}

public function safeDown()
{
$this->addColumn('order', 'id_status', Schema::TYPE_INTEGER) ;
}
}

Loading…
取消
儲存