Browse Source

[Administration] Distributions > Tiller : affichage du montant total des commandes à synchroniser

develop
Guillaume Bourgeois 3 weeks ago
parent
commit
1d472392e4
4 changed files with 34 additions and 1 deletions
  1. +1
    -0
      backend/controllers/DistributionController.php
  2. +8
    -1
      backend/views/distribution/index.php
  3. +2
    -0
      backend/web/js/vuejs/distribution-index.js
  4. +23
    -0
      domain/Order/Order/TillerManager.php

+ 1
- 0
backend/controllers/DistributionController.php View File

@@ -134,6 +134,7 @@ class DistributionController extends BackendController
$json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date);
$json['tiller_is_authenticated'] = $this->getOrderModule()->getTillerManager()->isAuthenticated();
$json['tiller_url_authorize_code'] = $this->getOrderModule()->getTillerManager()->getUrlAuthorizeCode();
$json['tiller_total_amount_orders'] = $this->getOrderModule()->getTillerManager()->getTotalAmountOrdersByDate($date, true);
$json['missing_subscriptions'] = $this->buildAjaxInfosResponseMissingSubscriptions($date, $distribution, $ordersArrayObject);
}


+ 8
- 1
backend/views/distribution/index.php View File

@@ -321,7 +321,10 @@ $this->setPageTitle('Distributions') ;
<button id="btn-tiller" class="btn btn-xs btn-default" disabled><span class="glyphicon glyphicon-refresh"></span> Synchroniser avec Tiller</button>
</span>
</template>
<button v-else id="btn-tiller" class="btn btn-xs btn-default" @click="synchroTiller"><span class="glyphicon glyphicon-refresh"></span> Synchroniser avec Tiller</button>
<button v-else id="btn-tiller" class="btn btn-xs btn-default" @click="synchroTiller">
<span class="glyphicon glyphicon-refresh"></span>
Synchroniser avec Tiller
</button>
</template>
<template v-else>
<a :href="tillerUrlAuthorizeCode" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-refresh"></span> Connexion Tiller</a>
@@ -344,6 +347,10 @@ $this->setPageTitle('Distributions') ;
</span>
</div>

<div class="alert alert-info" v-if="producer && producer.tiller == true && orders.length > 0 && tillerTotalAmountOrders">
Montant total commandes Tiller : {{ tillerTotalAmountOrders }}
</div>

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

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

@@ -79,6 +79,7 @@ if($(selector).length) {
tillerIsAuthenticated: false,
tillerUrlAuthorizeCode: '#',
tillerIsSynchro: false,
tillerTotalAmountOrders: false,
checkboxSelectAllOrders: false,
messageGenerateDeliveryNoteDisplayed: false,
missingSubscriptions: false,
@@ -211,6 +212,7 @@ if($(selector).length) {
app.tillerUrlAuthorizeCode = response.data.tiller_url_authorize_code;
app.tillerIsAuthenticated = response.data.tiller_is_authenticated;
app.tillerIsSynchro = response.data.tiller_is_synchro;
app.tillerTotalAmountOrders = response.data.tiller_total_amount_orders;

app.calendar.attrs = [];
var distributions = response.data.distributions;

+ 23
- 0
domain/Order/Order/TillerManager.php View File

@@ -41,6 +41,7 @@ use common\components\Tiller\TillerClientInterface;
use common\components\Tiller\TillerClientV2;
use common\components\Tiller\TillerClientV3;
use common\helpers\MeanPayment;
use common\helpers\Price;
use domain\Order\OrderStatus\OrderStatus;
use domain\Order\ProductOrder\ProductOrderSolver;
use domain\Producer\Producer\ProducerSolver;
@@ -308,4 +309,26 @@ class TillerManager extends AbstractManager

return false;
}

public function getTotalAmountOrdersByDate(string $date, bool $format = false)
{
$totalAmount = 0;
$ordersArray = Order::searchAll([
'distribution.date' => $date,
'order.tiller_synchronization' => 1,
], [
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid()
]);

foreach($ordersArray as $order) {
$this->orderBuilder->initOrder($order);
$totalAmount += $this->orderSolver->getOrderAmountWithTax($order);
}

if($format) {
return Price::format($totalAmount);
}

return $totalAmount;
}
}

Loading…
Cancel
Save