namespace backend\controllers; | namespace backend\controllers; | ||||
use common\helpers\Price; | |||||
use common\models\DeliveryNote; | use common\models\DeliveryNote; | ||||
use common\models\Invoice; | use common\models\Invoice; | ||||
use common\models\PointSale; | use common\models\PointSale; | ||||
$price = $productOrder->getInvoicePrice() ; | $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[] = [ | $datas[] = [ | ||||
$document->reference, // N° facture externe * | $document->reference, // N° facture externe * | ||||
date('d/m/Y', strtotime($document->date)), // Date facture * | date('d/m/Y', strtotime($document->date)), // Date facture * | ||||
$price, // PU HT * | $price, // PU HT * | ||||
'', // Remise | '', // Remise | ||||
$productOrder->taxRate->value * 100, // TVA | $productOrder->taxRate->value * 100, // TVA | ||||
'', // Total TVA | |||||
'', // Total HT | |||||
$tva, // Total TVA | |||||
$priceTotal, // Total HT | |||||
'', // Créateur | '', // Créateur | ||||
]; | ]; | ||||
} | } |
* @param string $processCredit | * @param string $processCredit | ||||
*/ | */ | ||||
public function actionAjaxCreate( | 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; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
} | } | ||||
$order = Order::searchOne(['id' => $order->id]); | $order = Order::searchOne(['id' => $order->id]); | ||||
if ($order && $processCredit) { | |||||
if ($order && $order->isCreditAutoPayment()) { | |||||
$order->processCredit(); | $order->processCredit(); | ||||
} | } | ||||
$order->save(); | $order->save(); | ||||
$order = Order::searchOne(['id' => $order->id]); | $order = Order::searchOne(['id' => $order->id]); | ||||
if ($order && $processCredit) { | |||||
if($order && $order->isCreditAutoPayment()) { | |||||
// Si changement d'user : on rembourse l'ancien user | // Si changement d'user : on rembourse l'ancien user | ||||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | $amountPaid = $order->getAmount(Order::AMOUNT_PAID); | ||||
if($oldIdUser != $idUser && $amountPaid > 0) { | if($oldIdUser != $idUser && $amountPaid > 0) { |
</div> | </div> | ||||
<div slot="footer"> | <div slot="footer"> | ||||
<div class="actions-form"> | <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="submitFormUpdate" v-if="order.id">Modifier</button> | ||||
<button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id">Créer</button> | <button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id">Créer</button> |
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK => 'Jours de la semaine', | Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK => 'Jours de la semaine', | ||||
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir', | Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir', | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'option_point_sale_wording') ?> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
username: this.order.username, | username: this.order.username, | ||||
meanPayment: this.order.mean_payment, | meanPayment: this.order.mean_payment, | ||||
products: app.getProductOrderArrayRequest(), | products: app.getProductOrderArrayRequest(), | ||||
comment: this.order.comment, | |||||
processCredit: processCredit | |||||
comment: this.order.comment | |||||
}}) | }}) | ||||
.then(function(response) { | .then(function(response) { | ||||
app.order.id_point_sale = 0 ; | app.order.id_point_sale = 0 ; |
getProductById: function(idProduct) { | getProductById: function(idProduct) { | ||||
var app = this; | 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) { | if(app.productsArray[i] && app.productsArray[i].id == idProduct) { | ||||
return app.productsArray[i]; | return app.productsArray[i]; | ||||
} | } |
return ''; | return ''; | ||||
} | } | ||||
public function isValidClass($typeDocument) | |||||
public static function isValidClass($typeDocument) | |||||
{ | { | ||||
return in_array($typeDocument, ['Invoice', 'DeliveryNote', 'Quotation']); | return in_array($typeDocument, ['Invoice', 'DeliveryNote', 'Quotation']); | ||||
} | } |
|| ($this->quotation && $this->quotation->isStatusValid()) | || ($this->quotation && $this->quotation->isStatusValid()) | ||||
|| ($this->invoice && $this->invoice->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; | |||||
} | |||||
} | } |
'option_online_payment_type', | 'option_online_payment_type', | ||||
'option_tax_calculation_method', | 'option_tax_calculation_method', | ||||
'latest_version_opendistrib', | 'latest_version_opendistrib', | ||||
'option_csv_separator' | |||||
'option_csv_separator', | |||||
'option_point_sale_wording' | |||||
], | ], | ||||
'string' | 'string' | ||||
], | ], | ||||
'document_delivery_note_first_reference', | 'document_delivery_note_first_reference', | ||||
'option_billing_type', | 'option_billing_type', | ||||
'option_billing_frequency', | 'option_billing_frequency', | ||||
'option_point_sale_wording' | |||||
], | ], | ||||
'string', | 'string', | ||||
'max' => 255 | 'max' => 255 | ||||
'option_billing_reduction_percentage' => 'Réduction : pourcentage', | 'option_billing_reduction_percentage' => 'Réduction : pourcentage', | ||||
'option_billing_permanent_transfer' => 'Virement permanent', | 'option_billing_permanent_transfer' => 'Virement permanent', | ||||
'option_billing_permanent_transfer_amount' => 'Virement permanent : montant', | 'option_billing_permanent_transfer_amount' => 'Virement permanent : montant', | ||||
'option_point_sale_wording' => 'Libellé points de vente' | |||||
]; | ]; | ||||
} | } | ||||
return $onlinePaymentMinimumAmount; | 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'; | |||||
} | |||||
} | } | ||||
$pointSale = PointSale::findOne($this->id_point_sale); | $pointSale = PointSale::findOne($this->id_point_sale); | ||||
if ($pointSale) { | if ($pointSale) { | ||||
$creditFunctioning = $pointSale->getCreditFunctioning(); | |||||
$order->auto_payment = 0; | $order->auto_payment = 0; | ||||
if($this->auto_payment == self::AUTO_PAYMENT_DEDUCTED) { | 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) { | elseif($this->auto_payment == self::AUTO_PAYMENT_YES) { | ||||
$order->auto_payment = 1; | $order->auto_payment = 1; | ||||
$order->auto_payment = 0; | $order->auto_payment = 0; | ||||
} | } | ||||
$order->tiller_synchronization = $order->auto_payment; | $order->tiller_synchronization = $order->auto_payment; | ||||
$userPointSale = UserPointSale::searchOne([ | $userPointSale = UserPointSale::searchOne([ |
<?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'); | |||||
} | |||||
} |
<script type="text/x-template" id="template-step-point-sale"> | <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' : '')"> | <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')"> | <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> | </button> | ||||
<div class="info-step" v-if="pointSaleActive"> | <div class="info-step" v-if="pointSaleActive"> | ||||
{{ pointSaleActive.name }} | {{ pointSaleActive.name }} |
<section id="points-sale"> | <section id="points-sale"> | ||||
<h3><span>Points de vente</span></h3> | |||||
<h3><span><?= $producer->getPointSaleWording(); ?></span></h3> | |||||
<?= GridView::widget([ | <?= GridView::widget([ | ||||
'dataProvider' => $dataProviderPointsSale, | 'dataProvider' => $dataProviderPointsSale, | ||||
'summary' => '', | 'summary' => '', |