2026-06-14 21:32:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
2026-11-15 18:10:08 +01:00
|
|
|
use App\Models\Customer;
|
|
|
|
|
use App\Models\Employee;
|
|
|
|
|
use App\Models\Order;
|
|
|
|
|
use App\Models\OrderLine;
|
2026-11-16 20:19:31 +01:00
|
|
|
use App\Models\OrderTunnelAttempt;
|
2026-06-14 21:32:07 +02:00
|
|
|
use Carbon\CarbonInterface;
|
|
|
|
|
use Carbon\CarbonPeriod;
|
|
|
|
|
use Domain\Enums\OrderStatus;
|
2026-06-25 15:33:11 +02:00
|
|
|
use Domain\Enums\StatsCustomerType;
|
|
|
|
|
use Domain\Enums\StatsShopType;
|
2026-11-15 18:10:08 +01:00
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
|
use Illuminate\Support\Facades\Date;
|
|
|
|
|
use Money\Currency;
|
|
|
|
|
use Money\Money;
|
2026-06-14 21:32:07 +02:00
|
|
|
|
|
|
|
|
class StatsService
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
2026-11-15 18:10:08 +01:00
|
|
|
private readonly Currency $currency,
|
2026-06-14 21:32:07 +02:00
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* getStats
|
|
|
|
|
*
|
|
|
|
|
* @param array<int, \Domain\Enums\StatsCustomerType|\Domain\Enums\StatsShopType> $statsType
|
|
|
|
|
* @return array<int, array{previous:int|float,current:int|float,diff:int|float}>
|
2026-07-07 14:30:41 +02:00
|
|
|
*
|
|
|
|
|
* @phpcs:disable Generic.Metrics.CyclomaticComplexity
|
2026-06-14 21:32:07 +02:00
|
|
|
*/
|
|
|
|
|
public function getStats(array $statsType, CarbonInterface $start, CarbonInterface $end): array
|
|
|
|
|
{
|
2026-07-07 14:30:41 +02:00
|
|
|
// phpcs:enable
|
2026-06-14 21:32:07 +02:00
|
|
|
$stats = [];
|
|
|
|
|
foreach ($statsType as $type) {
|
2026-06-25 15:33:11 +02:00
|
|
|
$previousPeriod = $this->getPreviousPeriod($start, $end);
|
|
|
|
|
$previousStart = $previousPeriod->getStartDate();
|
|
|
|
|
$previousEnd = $previousPeriod->getIncludedEndDate();
|
|
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
|
case StatsShopType::canceledRate:
|
|
|
|
|
$previous = $this->getCanceledRate($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getCanceledRate($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::orderFrequency:
|
|
|
|
|
$previous = $this->getOrderFrequency($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getOrderFrequency($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::purchaseFrequency:
|
|
|
|
|
$previous = $this->getPurchaseFrequency($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getPurchaseFrequency($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::averageBasketHt:
|
|
|
|
|
$previous = $this->getAverageBasketHt($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getAverageBasketHt($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::averageProductCountPerOrder:
|
|
|
|
|
$previous = $this->getAverageProductCountPerOrder($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getAverageProductCountPerOrder($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::caHt:
|
|
|
|
|
$previous = $this->getCaHt($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getCaHt($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::caTtc:
|
|
|
|
|
$previous = $this->getCaTtc($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getCaTtc($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::nbCmdWith7DayDelay:
|
|
|
|
|
$previous = $this->getNbCmdWith7DayDelay($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getNbCmdWith7DayDelay($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::nbCmdWith14DayDelay:
|
|
|
|
|
$previous = $this->getNbCmdWith14DayDelay($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getNbCmdWith14DayDelay($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::nbActiveClients:
|
|
|
|
|
$previous = $this->getNbActiveClients($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getNbActiveClients($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::nbValidateCmd:
|
|
|
|
|
$previous = $this->getNbValidateCmd($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getNbValidateCmd($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::nbWaitingCmd:
|
|
|
|
|
$previous = $this->getNbWaitingCmd($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getNbWaitingCmd($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsShopType::nbCanceledCmd:
|
|
|
|
|
$previous = $this->getNbCanceledCmd($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getNbCanceledCmd($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsCustomerType::nbSalarie:
|
|
|
|
|
$previous = $this->getActiveEmployeesCount($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getActiveEmployeesCount($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsCustomerType::nbSalarieWithAccount:
|
|
|
|
|
$previous = $this->getActiveEmployeesCountWithAnAccount($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getActiveEmployeesCountWithAnAccount($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
case StatsCustomerType::membershipRate:
|
|
|
|
|
$previous = $this->getMembershipRate($previousStart, $previousEnd);
|
|
|
|
|
$current = $this->getMembershipRate($start, $end);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2026-11-14 16:06:42 +01:00
|
|
|
throw new \InvalidArgumentException('Unknown stats type: ' . gettype($type));
|
2026-06-25 15:33:11 +02:00
|
|
|
}
|
2026-06-14 21:32:07 +02:00
|
|
|
|
|
|
|
|
$stats[$type->value] = [
|
|
|
|
|
'previous' => $previous,
|
|
|
|
|
'current' => $current,
|
|
|
|
|
'diff' => $current - $previous,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $stats;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-25 15:33:11 +02:00
|
|
|
* Get the percentage of active registered people / people with a generated code
|
2026-06-14 21:32:07 +02:00
|
|
|
*/
|
2026-06-25 15:33:11 +02:00
|
|
|
public function getMembershipRate(CarbonInterface $start, CarbonInterface $end): float
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
2026-06-25 15:33:11 +02:00
|
|
|
$registered = $this->getActiveEmployeesCountWithAnAccount($start, $end);
|
|
|
|
|
$employee = $this->getActiveEmployeesCount($start, $end);
|
2026-06-14 21:32:07 +02:00
|
|
|
|
2026-11-15 18:10:08 +01:00
|
|
|
return $employee !== 0 ? round($registered / $employee * 100, 2) : 0.0;
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-25 15:33:11 +02:00
|
|
|
* Get the previous period of the selected date.
|
2026-06-14 21:32:07 +02:00
|
|
|
*/
|
2026-06-25 15:33:11 +02:00
|
|
|
public function getPreviousPeriod(CarbonInterface $start, CarbonInterface $end): CarbonPeriod
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
2026-06-25 15:33:11 +02:00
|
|
|
$diffDays = $start->copy()->diffInDays($end);
|
|
|
|
|
|
|
|
|
|
return CarbonPeriod::create(
|
|
|
|
|
$start->copy()->subDays($diffDays + 1),
|
|
|
|
|
$start->copy()->subDay()
|
|
|
|
|
);
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-25 15:33:11 +02:00
|
|
|
* Get the percentage of registered people / people with a generated code
|
2026-06-14 21:32:07 +02:00
|
|
|
*/
|
2026-06-25 15:33:11 +02:00
|
|
|
public function getMembershipPercentage(): float
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
$employee = Employee::query()
|
|
|
|
|
->active()
|
|
|
|
|
->count();
|
|
|
|
|
$registered = Employee::query()
|
|
|
|
|
->active()
|
|
|
|
|
->whereHas('customer')
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
return $employee !== 0 ? round($registered / $employee * 100, 2) : 0.0;
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-25 15:33:11 +02:00
|
|
|
* Get the number of active employees within the date range.
|
2026-06-14 21:32:07 +02:00
|
|
|
*/
|
2026-06-25 15:33:11 +02:00
|
|
|
private function getActiveEmployeesCount(CarbonInterface $start, CarbonInterface $end): int
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
return Employee::query()
|
|
|
|
|
->active()
|
|
|
|
|
->whereDate('created_at', '>=', $start)
|
|
|
|
|
->whereDate('created_at', '<=', $end)
|
|
|
|
|
->count();
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-25 15:33:11 +02:00
|
|
|
* Get the number of active registered employees within the date range.
|
2026-06-14 21:32:07 +02:00
|
|
|
*/
|
2026-06-25 15:33:11 +02:00
|
|
|
private function getActiveEmployeesCountWithAnAccount(CarbonInterface $start, CarbonInterface $end): int
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
return Employee::query()
|
|
|
|
|
->active()
|
|
|
|
|
->whereHas('customer')
|
|
|
|
|
->whereDate('created_at', '>=', $start)
|
|
|
|
|
->whereDate('created_at', '<=', $end)
|
|
|
|
|
->count();
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the number of validated command.
|
|
|
|
|
*/
|
|
|
|
|
private function getNbValidateCmd(CarbonInterface $start, CarbonInterface $end): int
|
|
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
return $this->countOrdersByStatus(OrderStatus::VALIDATED, $start, $end);
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the number of waiting command.
|
|
|
|
|
*/
|
|
|
|
|
private function getNbWaitingCmd(CarbonInterface $start, CarbonInterface $end): int
|
|
|
|
|
{
|
2026-11-16 20:19:31 +01:00
|
|
|
$legacyWaiting = $this->countOrdersByStatus(OrderStatus::WAITING, $start, $end);
|
|
|
|
|
$unconvertedAttempts = OrderTunnelAttempt::query()
|
|
|
|
|
->whereNull('converted_at')
|
|
|
|
|
->whereBetween('created_at', [
|
|
|
|
|
$start->copy()->startOfDay()->utc(),
|
|
|
|
|
$end->copy()->endOfDay()->utc(),
|
|
|
|
|
])
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
return $legacyWaiting + $unconvertedAttempts;
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the number of canceled command.
|
|
|
|
|
*/
|
|
|
|
|
private function getNbCanceledCmd(CarbonInterface $start, CarbonInterface $end): int
|
|
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
return $this->countOrdersByStatus(OrderStatus::CANCELED, $start, $end);
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
2026-11-15 18:10:08 +01:00
|
|
|
private function countOrdersByStatus(OrderStatus $status, CarbonInterface $start, CarbonInterface $end): int
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
return Order::query()
|
|
|
|
|
->where('status', $status->value)
|
|
|
|
|
->whereCreatedAtBetween($start, $end)
|
|
|
|
|
->count();
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the canceled command rate.
|
|
|
|
|
*/
|
|
|
|
|
private function getCanceledRate(CarbonInterface $start, CarbonInterface $end): float
|
|
|
|
|
{
|
|
|
|
|
$nbWaitingCmd = $this->getNbWaitingCmd($start, $end);
|
|
|
|
|
$nbCanceledCmd = $this->getNbCanceledCmd($start, $end);
|
|
|
|
|
$nbValidateCmd = $this->getNbValidateCmd($start, $end);
|
|
|
|
|
|
|
|
|
|
// Prevent division by 0.
|
|
|
|
|
if (($nbValidateCmd + $nbWaitingCmd + $nbCanceledCmd) !== 0) {
|
|
|
|
|
return round(
|
|
|
|
|
(($nbWaitingCmd + $nbCanceledCmd) / ($nbValidateCmd + $nbWaitingCmd + $nbCanceledCmd)) * 100,
|
|
|
|
|
2
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the order frequency.
|
|
|
|
|
*/
|
|
|
|
|
private function getOrderFrequency(CarbonInterface $start, CarbonInterface $end): float
|
|
|
|
|
{
|
|
|
|
|
$nbValidateCmd = $this->getNbValidateCmd($start, $end);
|
|
|
|
|
$period = new CarbonPeriod($start, $end)->count();
|
|
|
|
|
|
|
|
|
|
return round($nbValidateCmd / $period, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the order frequency.
|
|
|
|
|
*/
|
|
|
|
|
private function getPurchaseFrequency(CarbonInterface $start, CarbonInterface $end): float
|
|
|
|
|
{
|
|
|
|
|
$activeClients = $this->getNbActiveClients($start, $end);
|
|
|
|
|
if (! $activeClients) {
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
$nbValidateCmd = $this->getNbValidateCmd($start, $end);
|
|
|
|
|
|
|
|
|
|
return round($nbValidateCmd / $activeClients, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-11-17 12:39:18 +01:00
|
|
|
* Get the number of active clients (ordered in the period, excluding technical PENDING/FAILED states).
|
2026-06-14 21:32:07 +02:00
|
|
|
*/
|
|
|
|
|
private function getNbActiveClients(CarbonInterface $start, CarbonInterface $end): int
|
|
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
$matricules = Order::query()
|
2026-11-17 12:39:18 +01:00
|
|
|
->whereNotIn('status', [
|
|
|
|
|
OrderStatus::PENDING->value,
|
|
|
|
|
OrderStatus::FAILED->value,
|
|
|
|
|
])
|
2026-11-15 18:10:08 +01:00
|
|
|
->whereCreatedAtBetween($start, $end)
|
|
|
|
|
->get(['employee'])
|
|
|
|
|
->map(fn (Order $order): string => $order->employee->matricule->value)
|
|
|
|
|
->filter()
|
|
|
|
|
->unique();
|
|
|
|
|
|
|
|
|
|
if ($matricules->isEmpty()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Customer::query()
|
|
|
|
|
->whereHas('employee', function (Builder $query) use ($matricules): void {
|
|
|
|
|
$query->whereIn('matricule', $matricules);
|
|
|
|
|
})->count();
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the number command where the collect day is 7 days after the order.
|
|
|
|
|
*/
|
|
|
|
|
private function getNbCmdWith7DayDelay(CarbonInterface $start, CarbonInterface $end): int
|
|
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
return Order::query()
|
|
|
|
|
->where('status', OrderStatus::VALIDATED->value)
|
|
|
|
|
->whereCreatedAtBetween($start, $end)
|
|
|
|
|
->get()
|
|
|
|
|
->filter(function (Order $order): bool {
|
|
|
|
|
if (is_null($order->pickup_day) || is_null($order->created_at)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $order->pickup_day->lessThanOrEqualTo($order->created_at->modify('+7 day'));
|
|
|
|
|
})->count();
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the number command where the collect day is 14 days after the order.
|
|
|
|
|
*/
|
|
|
|
|
private function getNbCmdWith14DayDelay(CarbonInterface $start, CarbonInterface $end): int
|
|
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
return Order::query()
|
|
|
|
|
->where('status', OrderStatus::VALIDATED->value)
|
|
|
|
|
->whereCreatedAtBetween($start, $end)
|
|
|
|
|
->get()
|
|
|
|
|
->filter(function (Order $order): bool {
|
|
|
|
|
if (is_null($order->pickup_day) || is_null($order->created_at)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Date::create($order->pickup_day)->betweenIncluded(
|
|
|
|
|
Date::create($order->created_at->modify('+8 day')),
|
|
|
|
|
Date::create($order->created_at->modify('+14 day'))
|
|
|
|
|
);
|
|
|
|
|
})->count();
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the CA HT.
|
|
|
|
|
*/
|
|
|
|
|
private function getCaHt(CarbonInterface $start, CarbonInterface $end): float
|
|
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
$totalCaHt = OrderLine::query()->whereHas('order', function (Builder $query) use ($start, $end): void {
|
|
|
|
|
$query->where('status', OrderStatus::VALIDATED->value)
|
|
|
|
|
->whereCreatedAtBetween($start, $end);
|
|
|
|
|
})->sum('total_ht');
|
|
|
|
|
|
|
|
|
|
$amount = is_numeric($totalCaHt) ? (int) $totalCaHt : 0;
|
|
|
|
|
|
|
|
|
|
return ((float) (new Money($amount, $this->currency))->getAmount()) / 100;
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the CA TTC.
|
|
|
|
|
*/
|
|
|
|
|
private function getCaTtc(CarbonInterface $start, CarbonInterface $end): float
|
|
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
$totalCaTtc = OrderLine::query()->whereHas('order', function (Builder $query) use ($start, $end): void {
|
|
|
|
|
$query->where('status', OrderStatus::VALIDATED->value)
|
|
|
|
|
->whereCreatedAtBetween($start, $end);
|
|
|
|
|
})->sum('total_ttc');
|
|
|
|
|
|
|
|
|
|
$amount = is_numeric($totalCaTtc) ? (int) $totalCaTtc : 0;
|
|
|
|
|
|
|
|
|
|
return ((float) (new Money($amount, $this->currency))->getAmount()) / 100;
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the average basket HT.
|
|
|
|
|
*/
|
|
|
|
|
private function getAverageBasketHt(CarbonInterface $start, CarbonInterface $end): float
|
|
|
|
|
{
|
2026-11-15 18:10:08 +01:00
|
|
|
$nbValidateCmd = $this->getNbValidateCmd($start, $end);
|
|
|
|
|
|
2026-06-14 21:32:07 +02:00
|
|
|
// Prevent division by 0.
|
2026-11-15 18:10:08 +01:00
|
|
|
if ($nbValidateCmd !== 0) {
|
|
|
|
|
return round($this->getCaHt($start, $end) / $nbValidateCmd, 2);
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the average product count per order.
|
|
|
|
|
*/
|
|
|
|
|
private function getAverageProductCountPerOrder(CarbonInterface $start, CarbonInterface $end): float
|
|
|
|
|
{
|
|
|
|
|
$nbValidateCmd = $this->getNbValidateCmd($start, $end);
|
|
|
|
|
|
|
|
|
|
// Prevent division by 0.
|
|
|
|
|
if ($nbValidateCmd !== 0) {
|
2026-11-15 18:10:08 +01:00
|
|
|
$totalQty = OrderLine::query()->whereHas('order', function (Builder $query) use ($start, $end): void {
|
|
|
|
|
$query->where('status', OrderStatus::VALIDATED->value)
|
|
|
|
|
->whereCreatedAtBetween($start, $end);
|
|
|
|
|
})->sum('quantity');
|
|
|
|
|
|
|
|
|
|
$qty = is_numeric($totalQty) ? (float) $totalQty : 0.0;
|
2026-06-14 21:32:07 +02:00
|
|
|
|
2026-11-15 18:10:08 +01:00
|
|
|
return round($qty / $nbValidateCmd, 2);
|
2026-06-14 21:32:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
}
|