Browse Source

Merge branch 'develop'

prodstable
Guillaume Bourgeois 1 year ago
parent
commit
57d7403cf4
13 changed files with 87 additions and 33 deletions
  1. +11
    -2
      backend/controllers/DocumentController.php
  2. +3
    -3
      backend/controllers/OrderController.php
  3. +2
    -2
      backend/views/distribution/index.php
  4. +1
    -0
      backend/views/producer/update.php
  5. +1
    -2
      backend/web/js/vuejs/distribution-index.js
  6. +1
    -1
      backend/web/js/vuejs/document-form.js
  7. +1
    -1
      common/models/Document.php
  8. +25
    -0
      common/models/Order.php
  9. +13
    -1
      common/models/Producer.php
  10. +1
    -19
      common/models/Subscription.php
  11. +26
    -0
      console/migrations/m230320_080836_producer_add_option_point_sale_wording.php
  12. +1
    -1
      producer/views/order/order.php
  13. +1
    -1
      producer/views/site/index.php

+ 11
- 2
backend/controllers/DocumentController.php View File



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
]; ];
} }

+ 3
- 3
backend/controllers/OrderController.php View File

* @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) {

+ 2
- 2
backend/views/distribution/index.php View File

</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>

+ 1
- 0
backend/views/producer/update.php View File

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>



+ 1
- 2
backend/web/js/vuejs/distribution-index.js View File

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 ;

+ 1
- 1
backend/web/js/vuejs/document-form.js View File

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];
} }

+ 1
- 1
common/models/Document.php View File

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']);
} }

+ 25
- 0
common/models/Order.php View File

|| ($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;
}
} }

+ 13
- 1
common/models/Producer.php View File

'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';
}
} }

+ 1
- 19
common/models/Subscription.php View File

$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([

+ 26
- 0
console/migrations/m230320_080836_producer_add_option_point_sale_wording.php View File

<?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');
}
}

+ 1
- 1
producer/views/order/order.php View File

<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 }}

+ 1
- 1
producer/views/site/index.php View File





<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' => '',

Loading…
Cancel
Save