if (abs($order->amount - $amountPaid) < 0.0001) { | if (abs($order->amount - $amountPaid) < 0.0001) { | ||||
$html .= '<span class="label label-success">Payé</span>'; | $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) { | } elseif ($order->amount > $amountPaid) { | ||||
$amountToPay = $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) { | } elseif ($order->amount < $amountPaid) { | ||||
$amountToRefund = $amountPaid - $order->amount; | $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">' | $html .= '<span class="buttons-credit">' |
</div> | </div> | ||||
<div class="alert alert-danger" v-if="distribution && !distribution.active && orders && orders.length > 0"> | <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. | Attention, ce jour de distribution n'est pas activé et vous avez quand même des commandes enregistrées. | ||||
</div> | </div> | ||||
], []); ?> | ], []); ?> | ||||
<h4>Divers</h4> | <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') | <?= $form->field($model, 'option_order_reference_type') | ||||
->dropDownList([ | ->dropDownList([ | ||||
Producer::ORDER_REFERENCE_TYPE_NONE => '--', | Producer::ORDER_REFERENCE_TYPE_NONE => '--', |
); | ); | ||||
appAlerts.alert( | appAlerts.alert( | ||||
'info', | '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 | 6000 | ||||
); | ); | ||||
} else { | } else { |
/** | /** | ||||
* Active ou désactive la distribution. | * Active ou désactive la distribution. | ||||
*/ | */ | ||||
// active | |||||
public function activeDistribution(Distribution $distribution, bool $active = true): void | public function activeDistribution(Distribution $distribution, bool $active = true): void | ||||
{ | { | ||||
$distribution->active = (int) $active; | $distribution->active = (int) $active; | ||||
$distribution->trigger(Distribution::EVENT_ACTIVE, $distributionActiveEvent); | $distribution->trigger(Distribution::EVENT_ACTIVE, $distributionActiveEvent); | ||||
} | } | ||||
} | } | ||||
public function activeDistributionByDate(\DateTime $date): void | |||||
{ | |||||
$distribution = $this->createDistributionIfNotExist($date->format('Y-m-d')); | |||||
$this->activeDistribution($distribution); | |||||
} | |||||
} | } |
'option_document_price_decimals', | 'option_document_price_decimals', | ||||
'option_billing_reduction_percentage', | 'option_billing_reduction_percentage', | ||||
'dolibarr_socid', | 'dolibarr_socid', | ||||
'dolibarr_product_id' | |||||
'dolibarr_product_id', | |||||
'option_weeks_distributions_activated_in_advance' | |||||
], | ], | ||||
'integer' | 'integer' | ||||
], | ], | ||||
'dolibarr_socid' => 'Dolibarr : id user', | 'dolibarr_socid' => 'Dolibarr : id user', | ||||
'dolibarr_product_id' => 'Dolibarr : id produit', | 'dolibarr_product_id' => 'Dolibarr : id produit', | ||||
'option_export_display_column_delivery_note' => "Récapitulatif PDF : afficher une colonne bon de livraison", | '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", | |||||
]; | ]; | ||||
} | } | ||||
{ | { | ||||
if (strlen($config)) { | if (strlen($config)) { | ||||
if (!$idProducer) { | if (!$idProducer) { | ||||
$idProducer = GlobalParam::getCurrentProducerId(); | |||||
$idProducer = $this->getProducerContextId(); | |||||
} | } | ||||
$producer = $this->findOneProducerById($idProducer); | $producer = $this->findOneProducerById($idProducer); |
<?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); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
?> |
<?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'); | |||||
} | |||||
} |