Skip to content

EspoCRM – Open Source CRM Application

rate entry as of date method

Yurii711c1f75924f
diff --git a/application/Espo/Tools/Currency/RateEntryProvider.php b/application/Espo/Tools/Currency/RateEntryProvider.php
index 77a4c02a15..146cbb5472 100644
--- a/application/Espo/Tools/Currency/RateEntryProvider.php
+++ b/application/Espo/Tools/Currency/RateEntryProvider.php
@@ -142,6 +142,26 @@ class RateEntryProvider
->findOne();
}
+ /**
+ * @since 9.3.0
+ * @throws NotEnabled
+ * @noinspection PhpUnused
+ */
+ public function getRateEntryOnAsOfDate(string $code, Date $date): ?CurrencyRecordRate
+ {
+ $record = $this->getRecordByCode($code);
+
+ return $this->entityManager
+ ->getRDBRepositoryByClass(CurrencyRecordRate::class)
+ ->where([
+ CurrencyRecordRate::ATTR_RECORD_ID => $record->getId(),
+ CurrencyRecordRate::FIELD_BASE_CODE => $this->configDataProvider->getBaseCurrency(),
+ CurrencyRecordRate::FIELD_DATE . '<=' => $date->toString(),
+ ])
+ ->order(CurrencyRecordRate::FIELD_DATE, Order::DESC)
+ ->findOne();
+ }
+
/**
* @throws NotEnabled
*/