Explorar el Código

Gestion partielle du mode de vente (poids ou unité)

Le but de l'opération est d'éliminer le bug du calcul des montants des commandes qui fait exploser les stats dans le cas d'une vente au poids considéré comme une vente à l'unité.
master
keun hace 7 años
padre
commit
d717cdcf57
Se han modificado 3 ficheros con 30 adiciones y 11 borrados
  1. +3
    -0
      backend/controllers/StatsController.php
  2. +8
    -11
      common/models/Commande.php
  3. +19
    -0
      console/migrations/m170426_143226_add_champs_mode_vente_commandeProduit.php

+ 3
- 0
backend/controllers/StatsController.php Ver fichero

@@ -70,6 +70,9 @@ class StatsController extends BackendController {
$mois = date('m/Y',strtotime($c->production->date)) ;
if(isset($data_pain[$mois]))
{
if($mois == '06/2016') {
//print_r($c) ;
}
$data_pain[$mois] += $c->montant_pain ;
}
}

+ 8
- 11
common/models/Commande.php Ver fichero

@@ -50,17 +50,14 @@ class Commande extends \yii\db\ActiveRecord
{
foreach($this->commandeProduits as $p)
{
if(isset($p->produit) && $p->produit->vrac)
{
$this->montant_vrac += $p->prix * $p->quantite/1000 ;
$this->poids_vrac += $p->quantite/1000 ;
}
else {
$this->montant_pain += $p->prix * $p->quantite ;
if(isset($p->produit))
$this->poids_pain += $p->quantite * $p->produit->poids/1000 ;
}
if($p->mode_vente == 'unite')
{
$this->montant_pain += $p->prix * $p->quantite ;
}
elseif($p->mode_vente == 'poids')
{
$this->montant_pain += $p->prix * $p->quantite/1000 ;
}
}
$this->montant = $this->montant_vrac + $this->montant_pain ;

+ 19
- 0
console/migrations/m170426_143226_add_champs_mode_vente_commandeProduit.php Ver fichero

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

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

class m170426_143226_add_champs_mode_vente_commandeProduit extends Migration
{
public function up()
{
$this->addColumn('produit', 'mode_vente', Schema::TYPE_STRING.' DEFAULT \'unite\'') ;
$this->addColumn('commande_produit', 'mode_vente', Schema::TYPE_STRING.' DEFAULT \'unite\'') ;
}

public function down()
{
$this->dropColumn('produit', 'mode_vente') ;
$this->dropColumn('commande_produit', 'mode_vente') ;
}
}

Cargando…
Cancelar
Guardar