diff --git a/application/Espo/Modules/Crm/Services/Opportunity.php b/application/Espo/Modules/Crm/Services/Opportunity.php index 05b201e410..1b4a0c5c36 100644 --- a/application/Espo/Modules/Crm/Services/Opportunity.php +++ b/application/Espo/Modules/Crm/Services/Opportunity.php @@ -207,7 +207,14 @@ class Opportunity extends \Espo\Services\Record $dt = new \DateTime($dateFrom); $dtTo = new \DateTime($dateTo); - $dtTo->setDate($dtTo->format('Y'), $dtTo->format('m'), 1); + + if (intval($dtTo->format('d')) !== 1) { + $dtTo->setDate($dtTo->format('Y'), $dtTo->format('m'), 1); + $dtTo->modify('+ 1 month'); + } else { + $dtTo->setDate($dtTo->format('Y'), $dtTo->format('m'), 1); + } + if ($dt && $dtTo) { $interval = new \DateInterval('P1M'); while ($dt->getTimestamp() <= $dtTo->getTimestamp()) {