From d27b37d1c3eaa9e06cd350dacbd4183e2e11b09d Mon Sep 17 00:00:00 2001 From: Dave Earley Date: Sat, 16 Nov 2024 18:26:06 -0800 Subject: [PATCH] clean up reports --- .../Report/Reports/ProductSalesReport.php | 4 +++- .../Domain/Report/Reports/PromoCodesReport.php | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/app/Services/Domain/Report/Reports/ProductSalesReport.php b/backend/app/Services/Domain/Report/Reports/ProductSalesReport.php index 12806be8..34547057 100644 --- a/backend/app/Services/Domain/Report/Reports/ProductSalesReport.php +++ b/backend/app/Services/Domain/Report/Reports/ProductSalesReport.php @@ -2,6 +2,7 @@ namespace HiEvents\Services\Domain\Report\Reports; +use HiEvents\DomainObjects\Status\OrderStatus; use HiEvents\Services\Domain\Report\AbstractReportService; use Illuminate\Support\Carbon; @@ -11,6 +12,7 @@ protected function getSqlQuery(Carbon $startDate, Carbon $endDate): string { $startDateString = $startDate->format('Y-m-d H:i:s'); $endDateString = $endDate->format('Y-m-d H:i:s'); + $completedStatus = OrderStatus::COMPLETED->name; return <<format('Y-m-d H:i:s'); $endDateString = $endDate->format('Y-m-d H:i:s'); + $reservedString = OrderStatus::RESERVED->name; + $translatedStringMap = [ + 'Expired' => __('Expired'), + 'Limit Reached' => __('Limit Reached'), + 'Deleted' => __('Deleted'), + 'Active' => __('Active'), + ]; return <<= '$startDateString' AND o.created_at <= '$endDateString' @@ -67,10 +75,10 @@ protected function getSqlQuery(Carbon $startDate, Carbon $endDate): string THEN pc.max_allowed_usages - COUNT(ot.order_id)::integer END as remaining_uses, CASE - WHEN pc.expiry_date < CURRENT_TIMESTAMP THEN 'Expired' - WHEN pc.max_allowed_usages IS NOT NULL AND COUNT(ot.order_id) >= pc.max_allowed_usages THEN 'Limit Reached' - WHEN pc.deleted_at IS NOT NULL THEN 'Deleted' - ELSE 'Active' + WHEN pc.expiry_date < CURRENT_TIMESTAMP THEN '{$translatedStringMap['Expired']}' + WHEN pc.max_allowed_usages IS NOT NULL AND COUNT(ot.order_id) >= pc.max_allowed_usages THEN '{$translatedStringMap['Limit Reached']}' + WHEN pc.deleted_at IS NOT NULL THEN '{$translatedStringMap['Deleted']}' + ELSE '{$translatedStringMap['Active']}' END as status FROM promo_codes pc LEFT JOIN order_totals ot ON pc.id = ot.promo_code_id