@@ -390,6 +390,7 @@ class DistributionController extends BackendController | |||
'paymentLabelShort' => $orderManager->getPaymentLabelShort($order), | |||
'isCreditFunctioningMandatory' => $orderManager->isOrderCreditFunctioningMandatory($order), | |||
'isCreditFunctioningUser' => $orderManager->isOrderCreditFunctioningUser($order), | |||
'debitCredit' => false, | |||
]); | |||
} | |||
} |
@@ -766,7 +766,7 @@ class OrderController extends BackendController | |||
* @param string $commentaire | |||
*/ | |||
public function actionAjaxCreate( | |||
$date, $idPointSale, $idUser, $username, $meanPayment = '', $products, $comment) | |||
$date, $idPointSale, $idUser, $username, $meanPayment = '', $products, $comment, $debitCredit = false) | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
@@ -852,7 +852,7 @@ class OrderController extends BackendController | |||
$order = $orderManager->findOneOrderById($order->id); | |||
$orderManager->initOrder($order); | |||
if ($order && $orderManager->isCreditAutoPayment($order)) { | |||
if ($order && $orderManager->isCreditAutoPayment($order, $debitCredit)) { | |||
$orderManager->processCredit($order); | |||
} | |||
@@ -900,6 +900,7 @@ class OrderController extends BackendController | |||
$meanPayment = $request->post('meanPayment'); | |||
$products = $request->post('products'); | |||
$comment = $request->post('comment'); | |||
$debitCredit = $request->post('debitCredit'); | |||
$order = $orderManager->findOneOrderById($idOrder); | |||
$orderManager->initOrder($order); | |||
@@ -1002,7 +1003,7 @@ class OrderController extends BackendController | |||
$order = Order::searchOne(['id' => $order->id]); | |||
$orderManager->initOrder($order); | |||
if ($order && $orderManager->isCreditAutoPayment($order)) { | |||
if ($order && $orderManager->isCreditAutoPayment($order, $debitCredit)) { | |||
$orderManager->processCredit($order); | |||
} | |||
} |
@@ -663,6 +663,10 @@ $this->setPageTitle('Distributions') ; | |||
<label class="control-label" for="textarea-comment">Commentaire</label> | |||
<textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea> | |||
</div> | |||
<div class="form-group" v-if="isPointSaleCreditFunctioningOptional(order.id_point_sale)"> | |||
<input type="checkbox" id="debit-credit" v-model="order.debitCredit" /> | |||
<label class="control-label" for="debit-credit">Débiter le crédit</label> | |||
</div> | |||
</div> | |||
<div class="col-md-8"> | |||
<label class="control-label">Produits</label> |
@@ -1018,10 +1018,26 @@ Vue.component('order-form', { | |||
} | |||
return JSON.stringify(productOrderArrayRequest); | |||
}, | |||
getPointSale: function(idPointSale) { | |||
for(key in this.pointsSale) { | |||
if (this.pointsSale[key].id == idPointSale) { | |||
return this.pointsSale[key]; | |||
} | |||
} | |||
return false; | |||
}, | |||
isPointSaleCreditFunctioningOptional: function(idPointSale) { | |||
var pointSale = this.getPointSale(idPointSale); | |||
if(pointSale && pointSale.credit_functioning == 'optional') { | |||
return true; | |||
} | |||
return false; | |||
}, | |||
submitFormCreate: function (event) { | |||
var app = this; | |||
if (this.checkForm()) { | |||
var processCredit = event.currentTarget.getAttribute('data-process-credit'); | |||
axios.get(UrlManager.getBaseUrlAbsolute() + "order/ajax-create", { | |||
params: { | |||
date: this.date.getFullYear() + '-' | |||
@@ -1032,7 +1048,8 @@ Vue.component('order-form', { | |||
username: this.order.username, | |||
meanPayment: this.order.mean_payment, | |||
products: app.getProductOrderArrayRequest(), | |||
comment: this.order.comment | |||
comment: this.order.comment, | |||
debitCredit: this.order.debitCredit | |||
} | |||
}) | |||
.then(function (response) { | |||
@@ -1051,11 +1068,6 @@ Vue.component('order-form', { | |||
submitFormUpdate: function (event) { | |||
var app = this; | |||
if (this.checkForm()) { | |||
var processCredit = event.currentTarget.getAttribute('data-process-credit'); | |||
if (processCredit == null) { | |||
processCredit = 0; | |||
} | |||
var data = new FormData(); | |||
data.append('date', this.date.getFullYear() + '-' | |||
+ ('0' + (this.date.getMonth() + 1)).slice(-2) + '-' | |||
@@ -1067,7 +1079,7 @@ Vue.component('order-form', { | |||
data.append('username', '' + this.order.username); | |||
data.append('products', app.getProductOrderArrayRequest()); | |||
data.append('comment', this.order.comment && this.order.comment.length ? this.order.comment : ''); | |||
data.append('processCredit', processCredit); | |||
data.append('debitCredit', this.order.debitCredit ? this.order.debitCredit : 0); | |||
axios.post(UrlManager.getBaseUrlAbsolute() + "order/ajax-update", data) | |||
.then(function (response) { |
@@ -330,9 +330,8 @@ class OrderRepository extends AbstractRepository | |||
return $productDistributionArray; | |||
} | |||
public function isCreditAutoPayment(Order $order) | |||
public function isCreditAutoPayment(Order $order, bool $debitCreditOnFunctioningOptional = false) | |||
{ | |||
//$pointSale = $this->pointSaleRepository->findOnePointSaleById($order->id_point_sale); | |||
$pointSale = $order->pointSale; | |||
if($pointSale) { | |||
@@ -343,7 +342,7 @@ class OrderRepository extends AbstractRepository | |||
return true; | |||
} | |||
elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | |||
return false; | |||
return $debitCreditOnFunctioningOptional; | |||
} | |||
elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) { | |||
$userProducer = $this->userProducerRepository->findOneUserProducer($order->user); |
@@ -4,7 +4,9 @@ namespace common\logic\PointSale\PointSale\Service; | |||
use common\helpers\GlobalParam; | |||
use common\logic\AbstractService; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use common\logic\SolverInterface; | |||
use yii\helpers\Html; | |||