Skip to content

Commit

Permalink
Added coupons to analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
simba77 committed Aug 11, 2024
1 parent a6a4f7d commit 87cfa68
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Services/Deals/ClosedDealsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Services\Deals;

use App\Entity\User;
use App\Repository\CouponRepository;
use App\Repository\DealRepository;
use App\Repository\DividendRepository;
use App\Request\DTO\Deals\DealsFilterRequestDTO;
Expand All @@ -17,6 +18,7 @@ public function __construct(
private readonly DealRepository $dealRepository,
private readonly CurrencyService $currencyService,
private readonly DividendRepository $dividendRepository,
private readonly CouponRepository $couponRepository,
) {
}

Expand Down Expand Up @@ -84,6 +86,16 @@ public function getMonthlyDealsStat(User $user, ?DealsFilterRequestDTO $filterRe
}
}

$coupons = $this->couponRepository->findAll();
foreach ($coupons as $coupon) {
$date = $coupon->getDate()?->format('Y.m') ?? '0';
if (isset($profitByMonths[$date])) {
$profitByMonths[$date] = bcadd($profitByMonths[$date], $coupon->getAmount(), 2);
} else {
$profitByMonths[$date] = $coupon->getAmount();
}
}

ksort($profitByMonths);

return ['profitByMonths' => $profitByMonths];
Expand Down

0 comments on commit 87cfa68

Please sign in to comment.