Config.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <?php
  2. /**
  3. * @copyright Vertex. All rights reserved. https://www.vertexinc.com/
  4. * @author Mediotype https://www.mediotype.com/
  5. */
  6. namespace Vertex\Tax\Model;
  7. use Magento\Framework\App\Config\ScopeConfigInterface;
  8. use Magento\Store\Model\ScopeInterface;
  9. use Magento\Tax\Model\Config as TaxConfig;
  10. use Vertex\Tax\Model\Config\DeliveryTerm;
  11. /**
  12. * Configuration retrieval tool
  13. */
  14. class Config
  15. {
  16. /**
  17. * @var string
  18. * @deprecated This will be removed in the near future as we stop using a calculation method to determine if enabled
  19. */
  20. const CALC_UNIT_VERTEX = 'VERTEX_UNIT_BASE_CALCULATION';
  21. const CONFIG_XML_PATH_ROTATION_ACTION = 'tax/vertex_logging/rotation_action';
  22. const CONFIG_XML_PATH_DEFAULT_CUSTOMER_CODE = 'tax/classes/default_customer_code';
  23. const CONFIG_XML_PATH_DEFAULT_TAX_CALCULATION_ADDRESS_TYPE = 'tax/calculation/based_on';
  24. const CONFIG_XML_PATH_ENABLE_VERTEX = 'tax/vertex_settings/enable_vertex';
  25. const CONFIG_XML_PATH_ENABLE_TAX_CALCULATION = 'tax/vertex_settings/use_for_calculation';
  26. const CONFIG_XML_PATH_LOGGING_ENABLED = 'tax/vertex_logging/enable_logging';
  27. const CONFIG_XML_PATH_PRINTED_CARD_PRICE = 'sales/gift_options/printed_card_price';
  28. const CONFIG_XML_PATH_SHIPPING_TAX_CLASS = 'tax/classes/shipping_tax_class';
  29. const CONFIG_XML_PATH_TAX_APPLY_ON = 'tax/calculation/apply_tax_on';
  30. const CONFIG_XML_PATH_TAX_DISPLAY_IN_CATALOG = 'tax/display/type';
  31. const CONFIG_XML_PATH_VERTEX_API_KEY = 'tax/vertex_settings/password';
  32. const CONFIG_XML_PATH_VERTEX_API_TRUSTED_ID = 'tax/vertex_settings/trustedId';
  33. const CONFIG_XML_PATH_VERTEX_API_USER = 'tax/vertex_settings/login';
  34. const CONFIG_XML_PATH_VERTEX_CITY = 'tax/vertex_seller_info/city';
  35. const CONFIG_XML_PATH_VERTEX_COMPANY_CODE = 'tax/vertex_seller_info/company';
  36. const CONFIG_XML_PATH_VERTEX_COUNTRY = 'tax/vertex_seller_info/country_id';
  37. const CONFIG_XML_PATH_VERTEX_ENABLE_LOG_ROTATION = 'tax/vertex_logging/enable_rotation';
  38. const CONFIG_XML_PATH_VERTEX_INVOICE_DATE = 'tax/vertex_settings/invoice_tax_date';
  39. const CONFIG_XML_PATH_VERTEX_INVOICE_ORDER = 'tax/vertex_settings/invoice_order';
  40. const CONFIG_XML_PATH_VERTEX_DELIVERY_TERM_DEFAULT = 'tax/vertex_delivery_terms/default_term';
  41. const CONFIG_XML_PATH_VERTEX_DELIVERY_TERM_OVERRIDE = 'tax/vertex_delivery_terms/override';
  42. const CONFIG_XML_PATH_VERTEX_INVOICE_ORDER_STATUS = 'tax/vertex_settings/invoice_order_status';
  43. const CONFIG_XML_PATH_VERTEX_LOCATION_CODE = 'tax/vertex_seller_info/location_code';
  44. const CONFIG_XML_PATH_VERTEX_LOG_ROTATION_FREQUENCY = 'tax/vertex_logging/rotation_frequency';
  45. const CONFIG_XML_PATH_VERTEX_LOG_ROTATION_RUNTIME = 'tax/vertex_logging/rotation_runtime';
  46. const CONFIG_XML_PATH_VERTEX_POSTAL_CODE = 'tax/vertex_seller_info/postalCode';
  47. const CONFIG_XML_PATH_VERTEX_REGION = 'tax/vertex_seller_info/region_id';
  48. const CONFIG_XML_PATH_VERTEX_STREET1 = 'tax/vertex_seller_info/streetAddress1';
  49. const CONFIG_XML_PATH_VERTEX_STREET2 = 'tax/vertex_seller_info/streetAddress2';
  50. const CRON_STRING_PATH = 'crontab/default/jobs/vertex_log_rotation/schedule/cron_expr';
  51. const MAX_CHAR_PRODUCT_CODE_ALLOWED = 40;
  52. const VALUE_APPLY_ON_CUSTOM = 0;
  53. const VALUE_APPLY_ON_ORIGINAL_ONLY = 1;
  54. const VERTEX_ADDRESS_API_HOST = 'tax/vertex_settings/address_api_url';
  55. const VERTEX_COUNTRY_SORT_REGION = 'tax/vertex_settings/country_sort_by_region';
  56. const VERTEX_ALLOWED_COUNTRIES = 'tax/vertex_settings/allowed_countries';
  57. const VERTEX_SUMMARIZE_TAX = 'tax/vertex_settings/summarize_tax';
  58. const VERTEX_API_HOST = 'tax/vertex_settings/api_url';
  59. const VERTEX_CREDITMEMO_ADJUSTMENT_CLASS = 'tax/classes/creditmemo_adjustment_class';
  60. const VERTEX_CREDITMEMO_ADJUSTMENT_NEGATIVE_CODE = 'tax/classes/creditmemo_adjustment_negative_code';
  61. const VERTEX_CREDITMEMO_ADJUSTMENT_POSITIVE_CODE = 'tax/classes/creditmemo_adjustment_positive_code';
  62. const VERTEX_GIFTWRAP_ITEM_CLASS = 'tax/classes/giftwrap_item_class';
  63. const VERTEX_GIFTWRAP_ITEM_CODE_PREFIX = 'tax/classes/giftwrap_item_code';
  64. const VERTEX_GIFTWRAP_ORDER_CLASS = 'tax/classes/giftwrap_order_class';
  65. const VERTEX_GIFTWRAP_ORDER_CODE = 'tax/classes/giftwrap_order_code';
  66. const VERTEX_LOG_LIFETIME_DAYS = 'tax/vertex_logging/entry_lifetime';
  67. const VERTEX_PRINTED_GIFTCARD_CLASS = 'tax/classes/printed_giftcard_class';
  68. const VERTEX_PRINTED_GIFTCARD_CODE = 'tax/classes/printed_giftcard_code';
  69. /** @var DeliveryTerm */
  70. private $deliveryTermConfig;
  71. /** @var ScopeConfigInterface */
  72. private $scopeConfig;
  73. /**
  74. * @param ScopeConfigInterface $scopeConfig
  75. * @param DeliveryTerm $deliveryTermConfig
  76. */
  77. public function __construct(ScopeConfigInterface $scopeConfig, DeliveryTerm $deliveryTermConfig)
  78. {
  79. $this->scopeConfig = $scopeConfig;
  80. $this->deliveryTermConfig = $deliveryTermConfig;
  81. }
  82. /**
  83. * Retrieve which price we should be applying tax to
  84. *
  85. * @param null $store
  86. * @param string $scope
  87. * @return string
  88. */
  89. public function getApplyTaxOn($store = null, $scope = ScopeInterface::SCOPE_STORE)
  90. {
  91. return $this->getConfigValue(self::CONFIG_XML_PATH_TAX_APPLY_ON, $store, $scope);
  92. }
  93. /**
  94. * Get the City of the Company Address
  95. *
  96. * @param string|null $store
  97. * @param string $scope
  98. * @return float|null
  99. */
  100. public function getCompanyCity($store = null, $scope = ScopeInterface::SCOPE_STORE)
  101. {
  102. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_CITY, $store, $scope);
  103. }
  104. /**
  105. * Retrieve the Company Code
  106. *
  107. * @param string|null $store
  108. * @param string $scope
  109. * @return float|null
  110. */
  111. public function getCompanyCode($store = null, $scope = ScopeInterface::SCOPE_STORE)
  112. {
  113. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_COMPANY_CODE, $store, $scope);
  114. }
  115. /**
  116. * Get the Country of the Company Address
  117. *
  118. * @param string|null $store
  119. * @param string $scope
  120. * @return bool|float|null
  121. */
  122. public function getCompanyCountry($store = null, $scope = ScopeInterface::SCOPE_STORE)
  123. {
  124. $country = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_COUNTRY, $store, $scope);
  125. return $country !== null ? $country : false;
  126. }
  127. /**
  128. * Get the Postal Code of the Company Address
  129. *
  130. * @param string|null $store
  131. * @param string $scope
  132. * @return float|null
  133. */
  134. public function getCompanyPostalCode($store = null, $scope = ScopeInterface::SCOPE_STORE)
  135. {
  136. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_POSTAL_CODE, $store, $scope);
  137. }
  138. /**
  139. * Get the Region ID of the Company Address
  140. *
  141. * @param string|null $store
  142. * @param string $scope
  143. * @return bool|float|null
  144. */
  145. public function getCompanyRegionId($store = null, $scope = ScopeInterface::SCOPE_STORE)
  146. {
  147. $region = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_REGION, $store, $scope);
  148. return $region !== null ? $region : false;
  149. }
  150. /**
  151. * Get Line 1 of the Company Street Address
  152. *
  153. * @param string|null $store
  154. * @param string $scope
  155. * @return float|null
  156. */
  157. public function getCompanyStreet1($store = null, $scope = ScopeInterface::SCOPE_STORE)
  158. {
  159. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_STREET1, $store, $scope);
  160. }
  161. /**
  162. * Get Line 2 of the Company Street Address
  163. *
  164. * @param string|null $store
  165. * @param string $scope
  166. * @return float|null
  167. */
  168. public function getCompanyStreet2($store = null, $scope = ScopeInterface::SCOPE_STORE)
  169. {
  170. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_STREET2, $store, $scope);
  171. }
  172. /**
  173. * Retrieve a value from the configuration within a scope
  174. *
  175. * @param string $value
  176. * @param string|null $scopeId
  177. * @param string|null $scope
  178. * @return mixed
  179. */
  180. public function getConfigValue($value, $scopeId = null, $scope = ScopeInterface::SCOPE_STORE)
  181. {
  182. return $this->scopeConfig->getValue($value, $scope, $scopeId);
  183. }
  184. /**
  185. * Get the Tax class for a creditmemo adjustment fee
  186. *
  187. * @param string|null $store
  188. * @param string $scope
  189. * @return float|null
  190. */
  191. public function getCreditmemoAdjustmentFeeClass($store = null, $scope = ScopeInterface::SCOPE_STORE)
  192. {
  193. return $this->getConfigValue(self::VERTEX_CREDITMEMO_ADJUSTMENT_CLASS, $store, $scope);
  194. }
  195. /**
  196. * Get the code for a creditmemo adjustment fee
  197. *
  198. * @param string|null $store
  199. * @param string $scope
  200. * @return float|null
  201. */
  202. public function getCreditmemoAdjustmentFeeCode($store = null, $scope = ScopeInterface::SCOPE_STORE)
  203. {
  204. return $this->getConfigValue(self::VERTEX_CREDITMEMO_ADJUSTMENT_NEGATIVE_CODE, $store, $scope);
  205. }
  206. /**
  207. * Get the tax class for a positive adjustment on a creditmemo
  208. *
  209. * @param string|null $store
  210. * @param string $scope
  211. * @return float|null
  212. */
  213. public function getCreditmemoAdjustmentPositiveClass($store = null, $scope = ScopeInterface::SCOPE_STORE)
  214. {
  215. return $this->getConfigValue(self::VERTEX_CREDITMEMO_ADJUSTMENT_CLASS, $store, $scope);
  216. }
  217. /**
  218. * Get the positive adjustment code for a creditmemo
  219. *
  220. * @param string|null $store
  221. * @param string $scope
  222. * @return float|null
  223. */
  224. public function getCreditmemoAdjustmentPositiveCode($store = null, $scope = ScopeInterface::SCOPE_STORE)
  225. {
  226. return $this->getConfigValue(self::VERTEX_CREDITMEMO_ADJUSTMENT_POSITIVE_CODE, $store, $scope);
  227. }
  228. /**
  229. * Retrieve the frequency at which the cron should run
  230. *
  231. * @return string
  232. */
  233. public function getCronRotationFrequency()
  234. {
  235. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_LOG_ROTATION_FREQUENCY);
  236. }
  237. /**
  238. * Retrieve the time of day logs should be rotated
  239. *
  240. * @return string
  241. */
  242. public function getCronRotationTime()
  243. {
  244. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_LOG_ROTATION_RUNTIME);
  245. }
  246. /**
  247. * Retrieve the lifetime of logs, in days, before they are rotated
  248. *
  249. * @return string
  250. */
  251. public function getCronLogLifetime()
  252. {
  253. return $this->getConfigValue(self::VERTEX_LOG_LIFETIME_DAYS);
  254. }
  255. /**
  256. * Get the Default Customer Code
  257. *
  258. * @param string|null $store
  259. * @param string $scope
  260. * @return float|null
  261. */
  262. public function getDefaultCustomerCode($store = null, $scope = ScopeInterface::SCOPE_STORE)
  263. {
  264. return $this->getConfigValue(self::CONFIG_XML_PATH_DEFAULT_CUSTOMER_CODE, $store, $scope);
  265. }
  266. /**
  267. * Get the default Delivery Term
  268. *
  269. * @param string|null $store
  270. * @param string $scope
  271. * @return string
  272. */
  273. public function getDefaultDeliveryTerm($store = null, $scope = ScopeInterface::SCOPE_WEBSITE)
  274. {
  275. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_DELIVERY_TERM_DEFAULT, $store, $scope);
  276. }
  277. /**
  278. * Get the Delivery Term to Override
  279. *
  280. * @param string|null $store
  281. * @param string $scope
  282. * @return array
  283. */
  284. public function getDeliveryTermOverride($store = null, $scope = ScopeInterface::SCOPE_WEBSITE)
  285. {
  286. $configValue = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_DELIVERY_TERM_OVERRIDE, $store, $scope);
  287. return $this->deliveryTermConfig->unserializeValue($configValue);
  288. }
  289. /**
  290. * Get the Tax Class for Item-level Giftwrapping
  291. *
  292. * @param string|null $store
  293. * @param string $scope
  294. * @return float|null
  295. */
  296. public function getGiftWrappingItemClass($store = null, $scope = ScopeInterface::SCOPE_STORE)
  297. {
  298. return $this->getConfigValue(self::VERTEX_GIFTWRAP_ITEM_CLASS, $store, $scope);
  299. }
  300. /**
  301. * Get the code prefix for Item-level Giftwrapping
  302. *
  303. * @param string|null $store
  304. * @param string $scope
  305. * @return float|null
  306. */
  307. public function getGiftWrappingItemCodePrefix($store = null, $scope = ScopeInterface::SCOPE_STORE)
  308. {
  309. return $this->getConfigValue(self::VERTEX_GIFTWRAP_ITEM_CODE_PREFIX, $store, $scope);
  310. }
  311. /**
  312. * Get the Tax Class for Order-level Giftwrapping
  313. *
  314. * @param string|null $store
  315. * @param string $scope
  316. * @return float|null
  317. */
  318. public function getGiftWrappingOrderClass($store = null, $scope = ScopeInterface::SCOPE_STORE)
  319. {
  320. return $this->getConfigValue(self::VERTEX_GIFTWRAP_ORDER_CLASS, $store, $scope);
  321. }
  322. /**
  323. * Get the code for Order-level Giftwrapping
  324. *
  325. * @param string|null $store
  326. * @param string $scope
  327. * @return float|null
  328. */
  329. public function getGiftWrappingOrderCode($store = null, $scope = ScopeInterface::SCOPE_STORE)
  330. {
  331. return $this->getConfigValue(self::VERTEX_GIFTWRAP_ORDER_CODE, $store, $scope);
  332. }
  333. /**
  334. * Retrieve the Location Code
  335. *
  336. * @param string|null $store
  337. * @param string $scope
  338. * @return float|null
  339. */
  340. public function getLocationCode($store = null, $scope = ScopeInterface::SCOPE_STORE)
  341. {
  342. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_LOCATION_CODE, $store, $scope);
  343. }
  344. /**
  345. * Retrieve the price of a Printed Gift Card
  346. *
  347. * @param string|null $store
  348. * @param string $scope
  349. * @return mixed
  350. */
  351. public function getPrintedCardPrice($store = null, $scope = ScopeInterface::SCOPE_STORE)
  352. {
  353. return $this->getConfigValue(self::CONFIG_XML_PATH_PRINTED_CARD_PRICE, $store, $scope);
  354. }
  355. /**
  356. * Get the Tax Class for a Printed Gift Card
  357. *
  358. * @param string|null $store
  359. * @param string $scope
  360. * @return float|null
  361. */
  362. public function getPrintedGiftcardClass($store = null, $scope = ScopeInterface::SCOPE_STORE)
  363. {
  364. return $this->getConfigValue(self::VERTEX_PRINTED_GIFTCARD_CLASS, $store, $scope);
  365. }
  366. /**
  367. * Get the code for a Printed Gift Card
  368. *
  369. * @param string|null $store
  370. * @param string $scope
  371. * @return float|null
  372. */
  373. public function getPrintedGiftcardCode($store = null, $scope = ScopeInterface::SCOPE_STORE)
  374. {
  375. return $this->getConfigValue(self::VERTEX_PRINTED_GIFTCARD_CODE, $store, $scope);
  376. }
  377. /**
  378. * Retrieve the type of action to take to logs when rotating
  379. *
  380. * @return string|null
  381. */
  382. public function getRotationAction()
  383. {
  384. return $this->getConfigValue(self::CONFIG_XML_PATH_ROTATION_ACTION);
  385. }
  386. /**
  387. * Get the Tax Class ID to be used for Shipping
  388. *
  389. * @param string|null $store
  390. * @param string $scope
  391. * @return float|null
  392. */
  393. public function getShippingTaxClassId($store = null, $scope = ScopeInterface::SCOPE_STORE)
  394. {
  395. return $this->getConfigValue(self::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $store, $scope);
  396. }
  397. /**
  398. * Get the Trusted ID for the Vertex Integration
  399. *
  400. * @param string|null $store
  401. * @param string $scope
  402. * @return float|null
  403. */
  404. public function getTrustedId($store = null, $scope = ScopeInterface::SCOPE_STORE)
  405. {
  406. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_API_TRUSTED_ID, $store, $scope);
  407. }
  408. /**
  409. * Get the URL of the Tax Area Lookup API Endpoint
  410. *
  411. * @param string|null $store
  412. * @param string $scope
  413. * @return float|null
  414. */
  415. public function getVertexAddressHost($store = null, $scope = ScopeInterface::SCOPE_STORE)
  416. {
  417. return $this->getConfigValue(self::VERTEX_ADDRESS_API_HOST, $store, $scope);
  418. }
  419. /**
  420. * Get the URL of the Quotation and Invoicing API Endpoint
  421. *
  422. * @param string|null $store
  423. * @param string $scope
  424. * @return float|null
  425. */
  426. public function getVertexHost($store = null, $scope = ScopeInterface::SCOPE_STORE)
  427. {
  428. return $this->getConfigValue(self::VERTEX_API_HOST, $store, $scope);
  429. }
  430. /**
  431. * Grab the Order Status during which we should commit to the Tax Log
  432. *
  433. * @param string|null $store
  434. * @param string $scope
  435. * @return string
  436. */
  437. public function invoiceOrderStatus($store = null, $scope = ScopeInterface::SCOPE_STORE)
  438. {
  439. return $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER_STATUS, $store, $scope);
  440. }
  441. /**
  442. * Determine if Vertex Logging has been enabled
  443. *
  444. * @param string|null $scopeCode
  445. * @param string $scope
  446. * @return bool
  447. */
  448. public function isLoggingEnabled($scopeCode = null, $scope = ScopeInterface::SCOPE_STORE)
  449. {
  450. return $this->scopeConfig->isSetFlag(self::CONFIG_XML_PATH_LOGGING_ENABLED, $scope, $scopeCode);
  451. }
  452. /**
  453. * Retrieve a list of countries grouped by Vertex region
  454. *
  455. * @param string|null $store
  456. * @param string $scope
  457. * @return array A multi-dimensional array where the top level key is the Vertex region the country is associated
  458. * with and the value is an array of country codes
  459. */
  460. public function getListForAllowedCountrySort($store = null, $scope = ScopeInterface::SCOPE_STORE)
  461. {
  462. $returnArray = json_decode($this->getConfigValue(self::VERTEX_COUNTRY_SORT_REGION, $store, $scope), true);
  463. return $returnArray ?: [];
  464. }
  465. /**
  466. * Retrieve list of countries Vertex should be used for
  467. *
  468. * @param string|null $store
  469. * @param string $scope
  470. * @return string[] of two character ISO country codes
  471. */
  472. public function getAllowedCountries($store = null, $scope = ScopeInterface::SCOPE_STORE)
  473. {
  474. return explode(',', $this->getConfigValue(self::VERTEX_ALLOWED_COUNTRIES, $store, $scope));
  475. }
  476. /**
  477. * Determine whether or not tax is turned on to display in the catalog
  478. *
  479. * @param string|null $store
  480. * @param string $scope
  481. * @return bool
  482. */
  483. public function isDisplayPriceInCatalogEnabled($store = null, $scope = ScopeInterface::SCOPE_STORE)
  484. {
  485. $configValue = $this->getConfigValue(self::CONFIG_XML_PATH_TAX_DISPLAY_IN_CATALOG, $store, $scope);
  486. return (int)$configValue !== TaxConfig::DISPLAY_TYPE_EXCLUDING_TAX;
  487. }
  488. /**
  489. * Determine if Vertex has been enabled
  490. *
  491. * @param string|null $scopeId
  492. * @param string $scope
  493. * @return bool
  494. */
  495. public function isVertexActive($scopeId = null, $scope = ScopeInterface::SCOPE_STORE)
  496. {
  497. return $this->scopeConfig->isSetFlag(self::CONFIG_XML_PATH_ENABLE_VERTEX, $scope, $scopeId);
  498. }
  499. /**
  500. * Determine if tax calculation is enabled
  501. *
  502. * @param string|null $scopeId
  503. * @param string $scope
  504. * @return bool
  505. */
  506. public function isTaxCalculationEnabled($scopeId = null, $scope = ScopeInterface::SCOPE_STORE)
  507. {
  508. return $this->scopeConfig->isSetFlag(self::CONFIG_XML_PATH_ENABLE_TAX_CALCULATION, $scope, $scopeId);
  509. }
  510. /**
  511. * Determine if Vertex Archiving has been enabled.
  512. *
  513. * @return bool
  514. */
  515. public function isLogRotationEnabled()
  516. {
  517. return $this->scopeConfig->isSetFlag(
  518. self::CONFIG_XML_PATH_VERTEX_ENABLE_LOG_ROTATION,
  519. ScopeConfigInterface::SCOPE_TYPE_DEFAULT
  520. );
  521. }
  522. /**
  523. * Determine if we commit to the Tax Log during Invoice Creation or not
  524. *
  525. * @param string|null $store
  526. * @param string $scope
  527. * @return bool
  528. */
  529. public function requestByInvoiceCreation($store = null, $scope = ScopeInterface::SCOPE_STORE)
  530. {
  531. $vertexInvoiceEvent = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER, $store, $scope);
  532. return $vertexInvoiceEvent === 'invoice_created';
  533. }
  534. /**
  535. * Determine if we commit to the Tax Log during an Order Status change or not
  536. *
  537. * @param string|null $store
  538. * @param string $scope
  539. * @return bool
  540. */
  541. public function requestByOrderStatus($store = null, $scope = ScopeInterface::SCOPE_STORE)
  542. {
  543. $vertexInvoiceEvent = $this->getConfigValue(self::CONFIG_XML_PATH_VERTEX_INVOICE_ORDER, $store, $scope);
  544. return $vertexInvoiceEvent === 'order_status';
  545. }
  546. /**
  547. * Determine how customer receive their tax summaries
  548. *
  549. * @param string|null $store
  550. * @param string $scope
  551. * @return string
  552. */
  553. public function getSummarizeTax($store = null, $scope = ScopeInterface::SCOPE_STORE)
  554. {
  555. return $this->getConfigValue(self::VERTEX_SUMMARIZE_TAX, $store, $scope);
  556. }
  557. }