currentJalaliYear(); $tariff = $service->getId() !== null ? $this->tariffRepo->findForServiceYear($service->getId(), $year) : null; return $tariff?->getPriceRials() ?? $service->getPriceRials(); } public function upsert(int $serviceItemId, int $year, int $priceRials): Tariff { $tariff = $this->tariffRepo->findForServiceYear($serviceItemId, $year); if ($tariff === null) { $tariff = new Tariff($serviceItemId, $year, $priceRials); } else { $tariff->setPriceRials($priceRials)->setActive(true); } $this->tariffRepo->save($tariff); return $tariff; } public function currentJalaliYear(): int { $fmt = new \IntlDateFormatter( 'en_US@calendar=persian', \IntlDateFormatter::FULL, \IntlDateFormatter::NONE, 'Asia/Tehran', \IntlDateFormatter::TRADITIONAL, 'yyyy' ); return (int) $fmt->format(time()); } }