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
$mois = date('m/Y',strtotime($c->production->date)) ; | $mois = date('m/Y',strtotime($c->production->date)) ; | ||||
if(isset($data_pain[$mois])) | if(isset($data_pain[$mois])) | ||||
{ | { | ||||
if($mois == '06/2016') { | |||||
//print_r($c) ; | |||||
} | |||||
$data_pain[$mois] += $c->montant_pain ; | $data_pain[$mois] += $c->montant_pain ; | ||||
} | } | ||||
} | } |
{ | { | ||||
foreach($this->commandeProduits as $p) | 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 ; | $this->montant = $this->montant_vrac + $this->montant_pain ; |
<?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') ; | |||||
} | |||||
} |