Преглед на файлове

[Administration] Distributions : activation automatique de X semaines à l'avance #1187

feature/souke
Guillaume Bourgeois преди 1 година
родител
ревизия
1ea8502b4e
променени са 9 файла, в които са добавени 79 реда и са изтрити 10 реда
  1. +5
    -5
      backend/controllers/OrderController.php
  2. +0
    -1
      backend/views/distribution/index.php
  3. +9
    -0
      backend/views/producer/update.php
  4. +1
    -1
      backend/web/js/vuejs/distribution-index.js
  5. +6
    -1
      common/logic/Distribution/Distribution/Service/DistributionBuilder.php
  6. +3
    -1
      common/logic/Producer/Producer/Model/Producer.php
  7. +1
    -1
      common/logic/Producer/Producer/Repository/ProducerRepository.php
  8. +28
    -0
      console/commands/ActiveDistributionsInAdvanceController.php
  9. +26
    -0
      console/migrations/m230908_085432_add_column_producer_option_weeks_distributions_activated_in_advance.php

+ 5
- 5
backend/controllers/OrderController.php Целия файл

@@ -1035,15 +1035,15 @@ class OrderController extends BackendController

if (abs($order->amount - $amountPaid) < 0.0001) {
$html .= '<span class="label label-success">Payé</span>';
$buttonsCredit = Html::a('Rembourser ' . $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $order->amount, 'data-type' => 'refund']);
$buttonsCredit = Html::a('Recréditer ' . $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true), 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $order->amount, 'data-type' => 'refund']);
} elseif ($order->amount > $amountPaid) {
$amountToPay = $order->amount - $amountPaid;
$html .= '<span class="label label-danger">Non payé</span> reste <strong>' . number_format($amountToPay, 2) . ' €</strong> à payer';
$buttonsCredit = Html::a('Payer ' . number_format($amountToPay, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs payer', 'data-montant' => $amountToPay, 'data-type' => 'payment']);
$html .= '<span class="label label-danger">Non payé</span> reste <strong>' . number_format($amountToPay, 2) . ' €</strong> à débiter';
$buttonsCredit = Html::a('Débiter ' . number_format($amountToPay, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs payer', 'data-montant' => $amountToPay, 'data-type' => 'payment']);
} elseif ($order->amount < $amountPaid) {
$amountToRefund = $amountPaid - $order->amount;
$html .= ' <span class="label label-success">Payé</span> <strong>' . number_format($amountToRefund, 2) . ' €</strong> à rembourser';
$buttonsCredit = Html::a('Rembourser ' . number_format($amountToRefund, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $amountToRefund, 'data-type' => 'refund']);
$html .= ' <span class="label label-success">Payé</span> <strong>' . number_format($amountToRefund, 2) . ' €</strong> à recréditer';
$buttonsCredit = Html::a('Recréditer ' . number_format($amountToRefund, 2) . ' €', 'javascript:void(0);', ['class' => 'btn btn-default btn-xs rembourser', 'data-montant' => $amountToRefund, 'data-type' => 'refund']);
}

$html .= '<span class="buttons-credit">'

+ 0
- 1
backend/views/distribution/index.php Целия файл

@@ -303,7 +303,6 @@ $this->setPageTitle('Distributions') ;
</div>

<div class="alert alert-danger" v-if="distribution && !distribution.active && orders && orders.length > 0">
{{ distribution }}
Attention, ce jour de distribution n'est pas activé et vous avez quand même des commandes enregistrées.
</div>


+ 9
- 0
backend/views/producer/update.php Целия файл

@@ -313,6 +313,15 @@ $this->addBreadcrumb($this->getTitle());
], []); ?>

<h4>Divers</h4>
<?php
$choicesWeeksDistributionsActivatedInAdvanceArray = [null => '--'];
for($i = 1; $i < 13; $i++) {
$choicesWeeksDistributionsActivatedInAdvanceArray[$i] = $i.' semaine'.(($i > 1) ? 's' : '');
}
?>
<?= $form->field($model, 'option_weeks_distributions_activated_in_advance')
->dropDownList($choicesWeeksDistributionsActivatedInAdvanceArray)
->hint("Attention, les premières semaines doivent être activées manuellement."); ?>
<?= $form->field($model, 'option_order_reference_type')
->dropDownList([
Producer::ORDER_REFERENCE_TYPE_NONE => '--',

+ 1
- 1
backend/web/js/vuejs/distribution-index.js Целия файл

@@ -403,7 +403,7 @@ var app = new Vue({
);
appAlerts.alert(
'info',
'Pensez à bien rembourser les clients qui auraient passé commande en utilisant leur crédit.',
'Pensez à bien recréditer les clients qui auraient passé commande en utilisant leur crédit.',
6000
);
} else {

+ 6
- 1
common/logic/Distribution/Distribution/Service/DistributionBuilder.php Целия файл

@@ -182,7 +182,6 @@ class DistributionBuilder extends AbstractBuilder
/**
* Active ou désactive la distribution.
*/
// active
public function activeDistribution(Distribution $distribution, bool $active = true): void
{
$distribution->active = (int) $active;
@@ -196,4 +195,10 @@ class DistributionBuilder extends AbstractBuilder
$distribution->trigger(Distribution::EVENT_ACTIVE, $distributionActiveEvent);
}
}

public function activeDistributionByDate(\DateTime $date): void
{
$distribution = $this->createDistributionIfNotExist($date->format('Y-m-d'));
$this->activeDistribution($distribution);
}
}

+ 3
- 1
common/logic/Producer/Producer/Model/Producer.php Целия файл

@@ -152,7 +152,8 @@ class Producer extends ActiveRecordCommon
'option_document_price_decimals',
'option_billing_reduction_percentage',
'dolibarr_socid',
'dolibarr_product_id'
'dolibarr_product_id',
'option_weeks_distributions_activated_in_advance'
],
'integer'
],
@@ -422,6 +423,7 @@ class Producer extends ActiveRecordCommon
'dolibarr_socid' => 'Dolibarr : id user',
'dolibarr_product_id' => 'Dolibarr : id produit',
'option_export_display_column_delivery_note' => "Récapitulatif PDF : afficher une colonne bon de livraison",
'option_weeks_distributions_activated_in_advance' => "Semaines de distributions à activer à l'avance",
];
}


+ 1
- 1
common/logic/Producer/Producer/Repository/ProducerRepository.php Целия файл

@@ -247,7 +247,7 @@ class ProducerRepository extends AbstractRepository
{
if (strlen($config)) {
if (!$idProducer) {
$idProducer = GlobalParam::getCurrentProducerId();
$idProducer = $this->getProducerContextId();
}

$producer = $this->findOneProducerById($idProducer);

+ 28
- 0
console/commands/ActiveDistributionsInAdvanceController.php Целия файл

@@ -0,0 +1,28 @@
<?php

namespace console\commands;

use common\logic\Distribution\Distribution\Wrapper\DistributionManager;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use yii\console\Controller;

class ActiveDistributionsInAdvanceController extends Controller
{
public function actionIndex()
{
$producerManager = ProducerManager::getInstance();
$distributionManager = DistributionManager::getInstance();

$producersArray = $producerManager->findProducersActive();
foreach($producersArray as $producer) {
\Yii::$app->logic->setProducerContext($producer);
$weeksDistributionsActivatedInAdvance = $producerManager->getConfig('option_weeks_distributions_activated_in_advance');
if($weeksDistributionsActivatedInAdvance) {
$date = new \DateTime('+'.$weeksDistributionsActivatedInAdvance.' weeks');
$distributionManager->activeDistributionByDate($date);
}
}
}
}

?>

+ 26
- 0
console/migrations/m230908_085432_add_column_producer_option_weeks_distributions_activated_in_advance.php Целия файл

@@ -0,0 +1,26 @@
<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m230908_085432_add_column_producer_option_weeks_distributions_activated_in_advance
*/
class m230908_085432_add_column_producer_option_weeks_distributions_activated_in_advance extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('producer', 'option_weeks_distributions_activated_in_advance', Schema::TYPE_INTEGER);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('producer', 'option_weeks_distributions_activated_in_advance');
}
}

Loading…
Отказ
Запис