@@ -38,6 +38,7 @@ | |||
namespace backend\controllers; | |||
use common\helpers\Price; | |||
use common\models\DeliveryNote; | |||
use common\models\Invoice; | |||
use common\models\PointSale; | |||
@@ -252,6 +253,14 @@ class DocumentController extends BackendController | |||
$price = $productOrder->getInvoicePrice() ; | |||
} | |||
$typeTotal = $document->isInvoicePrice() ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; | |||
$priceTotal = $productOrder->getPriceByTypeTotal($typeTotal) * $productOrder->quantity; | |||
$tva = Price::getVat( | |||
$priceTotal, | |||
$productOrder->taxRate->value, | |||
$document->tax_calculation_method | |||
); | |||
$datas[] = [ | |||
$document->reference, // N° facture externe * | |||
date('d/m/Y', strtotime($document->date)), // Date facture * | |||
@@ -286,8 +295,8 @@ class DocumentController extends BackendController | |||
$price, // PU HT * | |||
'', // Remise | |||
$productOrder->taxRate->value * 100, // TVA | |||
'', // Total TVA | |||
'', // Total HT | |||
$tva, // Total TVA | |||
$priceTotal, // Total HT | |||
'', // Créateur | |||
]; | |||
} |
@@ -814,7 +814,7 @@ class OrderController extends BackendController | |||
* @param string $processCredit | |||
*/ | |||
public function actionAjaxCreate( | |||
$date, $idPointSale, $idUser, $username, $meanPayment = '', $products, $comment, $processCredit = 0) | |||
$date, $idPointSale, $idUser, $username, $meanPayment = '', $products, $comment) | |||
{ | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
@@ -894,7 +894,7 @@ class OrderController extends BackendController | |||
} | |||
$order = Order::searchOne(['id' => $order->id]); | |||
if ($order && $processCredit) { | |||
if ($order && $order->isCreditAutoPayment()) { | |||
$order->processCredit(); | |||
} | |||
@@ -1024,7 +1024,7 @@ class OrderController extends BackendController | |||
$order->save(); | |||
$order = Order::searchOne(['id' => $order->id]); | |||
if ($order && $processCredit) { | |||
if($order && $order->isCreditAutoPayment()) { | |||
// Si changement d'user : on rembourse l'ancien user | |||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | |||
if($oldIdUser != $idUser && $amountPaid > 0) { |
@@ -684,8 +684,8 @@ $this->setPageTitle('Distributions') ; | |||
</div> | |||
<div slot="footer"> | |||
<div class="actions-form"> | |||
<button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id && order.id_user > 0" data-process-credit="1">Créer et payer</button> | |||
<button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id && order.id_user > 0" data-process-credit="1">Modifier et payer</button> | |||
<!--<button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id && order.id_user > 0" data-process-credit="1">Créer et payer</button> | |||
<button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id && order.id_user > 0" data-process-credit="1">Modifier et payer</button>--> | |||
<button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id">Modifier</button> | |||
<button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id">Créer</button> |
@@ -123,6 +123,7 @@ $this->addBreadcrumb($this->getTitle()); | |||
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK => 'Jours de la semaine', | |||
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir', | |||
]); ?> | |||
<?= $form->field($model, 'option_point_sale_wording') ?> | |||
</div> | |||
</div> | |||
@@ -830,8 +830,7 @@ Vue.component('order-form',{ | |||
username: this.order.username, | |||
meanPayment: this.order.mean_payment, | |||
products: app.getProductOrderArrayRequest(), | |||
comment: this.order.comment, | |||
processCredit: processCredit | |||
comment: this.order.comment | |||
}}) | |||
.then(function(response) { | |||
app.order.id_point_sale = 0 ; |
@@ -98,7 +98,7 @@ var app = new Vue({ | |||
getProductById: function(idProduct) { | |||
var app = this; | |||
for(var i = 0; i <= Object.keys(this.productsArray).length ; i++) { | |||
for(var i = 0; i <= Object.keys(this.productsArray).length + 1 ; i++) { | |||
if(app.productsArray[i] && app.productsArray[i].id == idProduct) { | |||
return app.productsArray[i]; | |||
} |
@@ -247,7 +247,7 @@ class Document extends ActiveRecordCommon | |||
return ''; | |||
} | |||
public function isValidClass($typeDocument) | |||
public static function isValidClass($typeDocument) | |||
{ | |||
return in_array($typeDocument, ['Invoice', 'DeliveryNote', 'Quotation']); | |||
} |
@@ -1099,4 +1099,29 @@ class Order extends ActiveRecordCommon | |||
|| ($this->quotation && $this->quotation->isStatusValid()) | |||
|| ($this->invoice && $this->invoice->isStatusValid()); | |||
} | |||
public function isCreditAutoPayment() | |||
{ | |||
$pointSale = PointSale::findOne($this->id_point_sale); | |||
$distribution = Distribution::findOne($this->id_distribution); | |||
$creditFunctioning = $pointSale->getCreditFunctioning(); | |||
if ($this->id_user && Producer::getConfig('credit') && $pointSale->credit) { | |||
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | |||
return 0; | |||
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { | |||
return 1; | |||
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) { | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $this->id_user, | |||
'id_producer' => $distribution->id_producer | |||
]); | |||
if ($userProducer) { | |||
return $userProducer->credit_active; | |||
} | |||
} | |||
} | |||
return 0; | |||
} | |||
} |
@@ -233,7 +233,8 @@ class Producer extends ActiveRecordCommon | |||
'option_online_payment_type', | |||
'option_tax_calculation_method', | |||
'latest_version_opendistrib', | |||
'option_csv_separator' | |||
'option_csv_separator', | |||
'option_point_sale_wording' | |||
], | |||
'string' | |||
], | |||
@@ -288,6 +289,7 @@ class Producer extends ActiveRecordCommon | |||
'document_delivery_note_first_reference', | |||
'option_billing_type', | |||
'option_billing_frequency', | |||
'option_point_sale_wording' | |||
], | |||
'string', | |||
'max' => 255 | |||
@@ -410,6 +412,7 @@ class Producer extends ActiveRecordCommon | |||
'option_billing_reduction_percentage' => 'Réduction : pourcentage', | |||
'option_billing_permanent_transfer' => 'Virement permanent', | |||
'option_billing_permanent_transfer_amount' => 'Virement permanent : montant', | |||
'option_point_sale_wording' => 'Libellé points de vente' | |||
]; | |||
} | |||
@@ -1002,5 +1005,14 @@ class Producer extends ActiveRecordCommon | |||
return $onlinePaymentMinimumAmount; | |||
} | |||
public function getPointSaleWording() | |||
{ | |||
if($this->option_point_sale_wording && strlen($this->option_point_sale_wording)) { | |||
return Html::encode($this->option_point_sale_wording); | |||
} | |||
return 'Points de vente'; | |||
} | |||
} | |||
@@ -217,26 +217,9 @@ class Subscription extends ActiveRecordCommon | |||
$pointSale = PointSale::findOne($this->id_point_sale); | |||
if ($pointSale) { | |||
$creditFunctioning = $pointSale->getCreditFunctioning(); | |||
$order->auto_payment = 0; | |||
if($this->auto_payment == self::AUTO_PAYMENT_DEDUCTED) { | |||
if ($order->id_user && Producer::getConfig('credit') && $pointSale->credit) { | |||
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | |||
$order->auto_payment = 0; | |||
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { | |||
$order->auto_payment = 1; | |||
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) { | |||
$user = User::findOne($order->id_user); | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $order->id_user, | |||
'id_producer' => $distribution->id_producer | |||
]); | |||
if ($userProducer) { | |||
$order->auto_payment = $userProducer->credit_active; | |||
} | |||
} | |||
} | |||
$order->auto_payment = $order->isCreditAutoPayment(); | |||
} | |||
elseif($this->auto_payment == self::AUTO_PAYMENT_YES) { | |||
$order->auto_payment = 1; | |||
@@ -245,7 +228,6 @@ class Subscription extends ActiveRecordCommon | |||
$order->auto_payment = 0; | |||
} | |||
$order->tiller_synchronization = $order->auto_payment; | |||
$userPointSale = UserPointSale::searchOne([ |
@@ -0,0 +1,26 @@ | |||
<?php | |||
use yii\db\Migration; | |||
use yii\db\Schema; | |||
/** | |||
* Class m230320_080836_producer_add_option_point_sale_wording | |||
*/ | |||
class m230320_080836_producer_add_option_point_sale_wording extends Migration | |||
{ | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeUp() | |||
{ | |||
$this->addColumn('producer', 'option_point_sale_wording', Schema::TYPE_STRING .' DEFAULT NULL'); | |||
} | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeDown() | |||
{ | |||
$this->dropColumn('producer', 'option_point_sale_wording'); | |||
} | |||
} |
@@ -570,7 +570,7 @@ $producer = $this->context->getProducer(); | |||
<script type="text/x-template" id="template-step-point-sale"> | |||
<li id="step-point-sale" :class="'col-md-3'+((step == 'point-sale') ? ' active ' : '')+(first ? ' first' : '')"> | |||
<button @click="changeStep('point-sale')" :class="'btn '+ (step == 'point-sale' ? 'btn-primary' : 'btn-default')" :disabled="producer && (producer.option_order_entry_point == 'date' && step == 'date')"> | |||
<span class="button-content"><span class="glyphicon glyphicon-map-marker"></span> Points de vente</span> | |||
<span class="button-content"><span class="glyphicon glyphicon-map-marker"></span> <?= $producer->getPointSaleWording(); ?></span> | |||
</button> | |||
<div class="info-step" v-if="pointSaleActive"> | |||
{{ pointSaleActive.name }} |
@@ -57,7 +57,7 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ; | |||
<section id="points-sale"> | |||
<h3><span>Points de vente</span></h3> | |||
<h3><span><?= $producer->getPointSaleWording(); ?></span></h3> | |||
<?= GridView::widget([ | |||
'dataProvider' => $dataProviderPointsSale, | |||
'summary' => '', |