Pārlūkot izejas kodu

[backend] Distributions : possibilité de sélectionner le moyen de paiement de la commande

refactoring
Guillaume Bourgeois pirms 4 gadiem
vecāks
revīzija
7205c6d1e4
6 mainītis faili ar 52 papildinājumiem un 6 dzēšanām
  1. +2
    -0
      backend/controllers/DistributionController.php
  2. +4
    -2
      backend/controllers/OrderController.php
  3. +12
    -1
      backend/views/distribution/index.php
  4. +5
    -1
      backend/web/js/vuejs/distribution-index.js
  5. +18
    -0
      common/helpers/MeanPayment.php
  6. +11
    -2
      common/models/CreditHistory.php

+ 2
- 0
backend/controllers/DistributionController.php Parādīt failu

@@ -111,6 +111,8 @@ class DistributionController extends BackendController
'tiller' => $producer->tiller
];
$json['means_payment'] = MeanPayment::getAll() ;
$distributionsArray = Distribution::searchAll([
'active' => 1
], [

+ 4
- 2
backend/controllers/OrderController.php Parādīt failu

@@ -810,7 +810,7 @@ class OrderController extends BackendController
* @param string $processCredit
*/
public function actionAjaxCreate(
$date, $idPointSale, $idUser, $username, $products, $comment, $processCredit = 0)
$date, $idPointSale, $idUser, $username, $meanPayment, $products, $comment, $processCredit = 0)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
@@ -829,6 +829,7 @@ class OrderController extends BackendController
$order = new Order;
$order->date = date('Y-m-d H:i:s') ;
$order->id_point_sale = $idPointSale;
$order->mean_payment = $meanPayment ;
$order->id_distribution = $distribution->id;
$order->origin = Order::ORIGIN_ADMIN;
$order->comment = $comment;
@@ -890,7 +891,7 @@ class OrderController extends BackendController
* @param string $comment
*/
public function actionAjaxUpdate(
$date, $idOrder, $idPointSale, $idUser, $username, $products, $comment = '', $processCredit = 0)
$date, $idOrder, $idPointSale, $idUser, $username, $meanPayment, $products, $comment = '', $processCredit = 0)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
@@ -937,6 +938,7 @@ class OrderController extends BackendController

$order->id_point_sale = $idPointSale;
$order->date_update = date('Y-m-d H:i:s');
$order->mean_payment = $meanPayment;
$order->comment = $comment;
if ($idUser) {

+ 12
- 1
backend/views/distribution/index.php Parādīt failu

@@ -18,7 +18,8 @@ En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.
titulaire des de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
droits patrimoniaux et les concédants successifs.

A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, à l'utilisation, à la modification et/ou au
@@ -230,6 +231,7 @@ $this->setPageTitle('Distributions') ;
:date="date"
:order="orderCreate"
:points-sale="pointsSale"
:means-payment="meansPayment"
:users="users"
:products="products"
:producer="producer"
@@ -320,6 +322,7 @@ $this->setPageTitle('Distributions') ;
:date="date"
:id-point-sale="idActivePointSale"
:points-sale="pointsSale"
:means-payment="meansPayment"
:users="users"
:products="products"
:order="ordersUpdate[key]"
@@ -475,9 +478,17 @@ $this->setPageTitle('Distributions') ;
<div class="form-group">
<label class="control-label" for="select-id-point-sale">Point de vente</label>
<select class="form-control" id="select-id-point-sale" v-model="order.id_point_sale">
<option value="0">--</option>
<option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id">{{ pointSale.name }}</option>
</select>
</div>
<div class="form-group">
<label class="control-label" for="select-mean-payment">Moyen de paiement</label>
<select class="form-control" id="select-mean-payment" v-model="order.mean_payment">
<option value="0">--</option>
<option v-for="(wordingMeanPayment, keyMeanPayment) in meansPayment" :value="keyMeanPayment">{{ wordingMeanPayment }}</option>
</select>
</div>
<div class="form-group">
<label class="control-label" for="textarea-comment">Commentaire</label>
<textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea>

+ 5
- 1
backend/web/js/vuejs/distribution-index.js Parādīt failu

@@ -50,6 +50,7 @@ var app = new Vue({
products: [],
countActiveProducts: 0,
pointsSale: [],
meansPayment: [],
idActivePointSale: 0,
idDefaultPointSale: 0,
countActivePointsSale: 0,
@@ -148,6 +149,7 @@ var app = new Vue({
app.producer = response.data.producer ;
app.products = response.data.products ;
app.initCountActiveProducts() ;
app.meansPayment = response.data.means_payment ;
app.oneDistributionWeekActive = response.data.one_distribution_week_active ;
@@ -419,7 +421,7 @@ Vue.component('modal', {
})

Vue.component('order-form',{
props: ['date', 'pointsSale', 'users', 'products', 'order', 'producer'],
props: ['date', 'pointsSale','meansPayment', 'users', 'products', 'order', 'producer'],
data: function() {
return {
errors: [],
@@ -471,6 +473,7 @@ Vue.component('order-form',{
idPointSale: this.order.id_point_sale,
idUser: this.order.id_user,
username: this.order.username,
meanPayment: this.order.mean_payment,
products: JSON.stringify(this.order.productOrder),
comment: this.order.comment,
processCredit: processCredit
@@ -498,6 +501,7 @@ Vue.component('order-form',{
+ ('0' + this.date.getDate()).slice(-2),
idOrder: this.order.id,
idPointSale: this.order.id_point_sale,
meanPayment: this.order.mean_payment,
idUser: this.order.id_user,
username: ''+this.order.username,
products: JSON.stringify(this.order.productOrder),

+ 18
- 0
common/helpers/MeanPayment.php Parādīt failu

@@ -66,4 +66,22 @@ class MeanPayment {
}
}
/**
* etourne tous les moyens de paiement sour forme de tableau.
*
* @return array
*/
public static function getAll()
{
return [
self::CREDIT => self::getStrBy(self::CREDIT),
self::CREDIT_CARD => self::getStrBy(self::CREDIT_CARD),
self::MONEY => self::getStrBy(self::MONEY),
self::CHEQUE => self::getStrBy(self::CHEQUE),
self::TRANSFER => self::getStrBy(self::TRANSFER),
self::OTHER => self::getStrBy(self::OTHER),
self::CREDIT => self::getStrBy(self::CREDIT),
] ;
}
}

+ 11
- 2
common/models/CreditHistory.php Parādīt failu

@@ -191,7 +191,18 @@ class CreditHistory extends ActiveRecordCommon
} elseif ($this->isTypeDebit()) {
$userProducer->credit -= $this->amount;
}
$userProducer->save();
// set mean payment
$order = Order::searchOne(['id' => $this->id_order]) ;
$paymentStatus = $order->getPaymentStatus() ;
if($paymentStatus == Order::PAYMENT_PAID
|| $paymentStatus == Order::PAYMENT_SURPLUS) {
$order->mean_payment = MeanPayment::CREDIT ;
$order->save() ;
}
// seuil limite de crédit
$newCredit = $userProducer->credit ;
if(!is_null($creditLimitReminder) &&
$oldCredit > $creditLimitReminder && $newCredit <= $creditLimitReminder) {
@@ -213,8 +224,6 @@ class CreditHistory extends ActiveRecordCommon
->setSubject('[distrib] Seuil limite de crédit dépassé')
->send();
}
$userProducer->save();
}
}

Notiek ielāde…
Atcelt
Saglabāt