parameters:
    oro_pricing.entity.price_list.class: Oro\Bundle\PricingBundle\Entity\PriceList
    oro_pricing.entity.price_rule.class: Oro\Bundle\PricingBundle\Entity\PriceRule
    oro_pricing.entity.price_list_schedule.class: Oro\Bundle\PricingBundle\Entity\PriceListSchedule
    oro_pricing.entity.combined_price_list.class: Oro\Bundle\PricingBundle\Entity\CombinedPriceList

    oro_pricing.entity.price_list_to_account.class: Oro\Bundle\PricingBundle\Entity\PriceListToAccount
    oro_pricing.entity.price_list_to_account_group.class: Oro\Bundle\PricingBundle\Entity\PriceListToAccountGroup
    oro_pricing.entity.price_list_to_website.class: Oro\Bundle\PricingBundle\Entity\PriceListToWebsite

    oro_pricing.entity.price_list_account_fallback.class: Oro\Bundle\PricingBundle\Entity\PriceListAccountFallback
    oro_pricing.entity.price_list_account_group_fallback.class: Oro\Bundle\PricingBundle\Entity\PriceListAccountGroupFallback
    oro_pricing.entity.price_list_website_fallback.class: Oro\Bundle\PricingBundle\Entity\PriceListWebsiteFallback

    oro_pricing.entity.combined_price_list_to_account.class: Oro\Bundle\PricingBundle\Entity\CombinedPriceListToAccount
    oro_pricing.entity.combined_price_list_to_account_group.class: Oro\Bundle\PricingBundle\Entity\CombinedPriceListToAccountGroup
    oro_pricing.entity.combined_price_list_to_website.class: Oro\Bundle\PricingBundle\Entity\CombinedPriceListToWebsite

    oro_pricing.entity.product_price.class: Oro\Bundle\PricingBundle\Entity\ProductPrice
    oro_pricing.entity.combined_product_price.class: Oro\Bundle\PricingBundle\Entity\CombinedProductPrice
    oro_pricing.entity.price_list_currency.class: Oro\Bundle\PricingBundle\Entity\PriceListCurrency
    oro_pricing.entity.minimal_product_price.class: Oro\Bundle\PricingBundle\Entity\MinimalProductPrice
    oro_pricing.entity.price_attribute_price_list.class: Oro\Bundle\PricingBundle\Entity\PriceAttributePriceList
    oro_pricing.entity.price_attribute_currency.class: Oro\Bundle\PricingBundle\Entity\PriceAttributeCurrency
    oro_pricing.entity.price_attribute_product_price.class: Oro\Bundle\PricingBundle\Entity\PriceAttributeProductPrice
    oro_pricing.entity.price_list_to_product.class: Oro\Bundle\PricingBundle\Entity\PriceListToProduct

services:
    oro_pricing.acl.voter.product_list:
        class: 'Oro\Bundle\PricingBundle\Acl\Voter\PriceListVoter'
        public: false
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_pricing.price_list_reference_checker'
        calls:
            - [setClassName, ['%oro_pricing.entity.price_list.class%']]
        tags:
            - { name: security.voter, priority: 10 }

    oro_pricing.datagrid.price_list_permissions_provider:
        class: 'Oro\Bundle\PricingBundle\Datagrid\PriceListPermissionProvider'

    oro_pricing.form.autocomplete.price_list.search_handler:
        public: false
        parent: oro_form.autocomplete.search_handler
        arguments:
            - '%oro_pricing.entity.price_list.class%'
            - ["name"]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: oro_pricing_price_list, acl_resource: oro_pricing_price_list_view }

    oro_pricing.listener.product_unit_precision:
        class: 'Oro\Bundle\PricingBundle\EventListener\ProductUnitPrecisionListener'
        public: false
        calls:
            - [setProductPriceClass, ['%oro_pricing.entity.product_price.class%']]
            - [setEventDispatcher,  ['@event_dispatcher']]
        tags:
            - { name: doctrine.event_listener, event: postRemove }

    oro_pricing.provider.currency:
        class: 'Oro\Bundle\PricingBundle\Provider\CurrencyProvider'
        arguments:
            - '@doctrine'
            - '%oro_pricing.entity.product_price.class%'

    oro_pricing.user_currency_manager:
        class: 'Oro\Bundle\PricingBundle\Manager\UserCurrencyManager'
        arguments:
            - '@session'
            - '@security.token_storage'
            - '@oro_config.manager'
            - '@oro_website.manager'
            - '@oro_account_user.manager'

    oro_pricing.provider.abstract_product_price:
        class: 'Oro\Bundle\PricingBundle\Provider\ProductPriceProvider'
        public: false
        abstract: true
        arguments:
            - '@doctrine'

    oro_pricing.provider.product_price:
        parent: oro_pricing.provider.abstract_product_price
        calls:
            - [setClassName, ['%oro_pricing.entity.product_price.class%']]

    oro_pricing.provider.combined_product_price:
        parent: oro_pricing.provider.abstract_product_price
        calls:
            - [setClassName, ['%oro_pricing.entity.combined_product_price.class%']]

    oro_pricing.provider.combined_price_list:
        class: 'Oro\Bundle\PricingBundle\Provider\CombinedPriceListProvider'
        public: false
        arguments:
            - '@doctrine'
        calls:
            - [setClassName, ['%oro_pricing.entity.combined_price_list.class%']]
            - [setActivationPlanBuilder, ['@oro_pricing.builder.combined_price_list_activation_plan_builder']]

    oro_pricing.provider.price_list_collection:
        class: 'Oro\Bundle\PricingBundle\Provider\PriceListCollectionProvider'
        public: false
        arguments:
            - '@doctrine'
            - '@oro_config.global'
            - '@oro_pricing.system_config_converter'

    oro_pricing.provider.price_rule_fields_provider:
        class: 'Oro\Bundle\PricingBundle\Provider\PriceRuleFieldsProvider'
        arguments:
            - '@oro_entity.entity_field_provider.link'
            - '@oro_entity.doctrine_helper'

    oro_pricing.provider.product_virtual_relation_provider.config:
        class: 'Oro\Bundle\PricingBundle\Provider\ProductVirtualRelationProvider'
        arguments:
            - '@oro_entity.doctrine_helper'
        tags:
            - { name: oro_entity.virtual_relation_provider, priority: 120 }

    oro_pricing.resolver.combined_product_price_resolver:
        class: 'Oro\Bundle\PricingBundle\Resolver\CombinedProductPriceResolver'
        arguments:
            - '@doctrine'
            - '@oro_entity.orm.insert_from_select_query_executor'

    oro_pricing.resolver.combined_product_schedule_resolver:
        class: 'Oro\Bundle\PricingBundle\Resolver\CombinedPriceListScheduleResolver'
        arguments:
            - '@doctrine'
            - '@oro_config.global'
        calls:
            - [addRelationClass, ['%oro_pricing.entity.combined_price_list_to_account.class%']]
            - [addRelationClass, ['%oro_pricing.entity.combined_price_list_to_account_group.class%']]
            - [addRelationClass, ['%oro_pricing.entity.combined_price_list_to_website.class%']]

    oro_pricing.builder.combined_price_list_garbage_collector:
        class: 'Oro\Bundle\PricingBundle\Builder\CombinedPriceListGarbageCollector'
        public: false
        arguments:
            - '@doctrine'
            - '@oro_config.global'
        calls:
            - [setCombinedPriceListClass, ['%oro_pricing.entity.combined_price_list.class%']]

    oro_pricing.builder.abstract_combined_price_list_builder:
        class: 'Oro\Bundle\PricingBundle\Builder\AbstractCombinedPriceListBuilder'
        public: false
        abstract: true
        arguments:
            - '@doctrine'
            - '@oro_pricing.provider.price_list_collection'
            - '@oro_pricing.provider.combined_price_list'
            - '@oro_pricing.builder.combined_price_list_garbage_collector'
            - '@oro_pricing.resolver.combined_product_schedule_resolver'
            - '@oro_pricing.resolver.combined_product_price_resolver'
        calls:
            - [setCombinedPriceListClassName, ['%oro_pricing.entity.combined_price_list.class%']]

    oro_pricing.builder.account_combined_price_list_builder:
        class: 'Oro\Bundle\PricingBundle\Builder\AccountCombinedPriceListsBuilder'

        parent: oro_pricing.builder.abstract_combined_price_list_builder
        calls:
            - [setPriceListToEntityClassName, ['%oro_pricing.entity.price_list_to_account.class%']]
            - [setCombinedPriceListToEntityClassName, ['%oro_pricing.entity.combined_price_list_to_account.class%']]
            - [setFallbackClassName, ['%oro_pricing.entity.price_list_account_fallback.class%']]

    oro_pricing.builder.account_group_combined_price_list_builder:
        class: 'Oro\Bundle\PricingBundle\Builder\AccountGroupCombinedPriceListsBuilder'
        parent: oro_pricing.builder.abstract_combined_price_list_builder
        calls:
            - [setAccountCombinedPriceListsBuilder,  ['@oro_pricing.builder.account_combined_price_list_builder']]
            - [setPriceListToEntityClassName, ['%oro_pricing.entity.price_list_to_account_group.class%']]
            - [setCombinedPriceListToEntityClassName, ['%oro_pricing.entity.combined_price_list_to_account_group.class%']]
            - [setFallbackClassName, ['%oro_pricing.entity.price_list_account_group_fallback.class%']]

    oro_pricing.builder.website_combined_price_list_builder:
        class: 'Oro\Bundle\PricingBundle\Builder\WebsiteCombinedPriceListsBuilder'
        parent: oro_pricing.builder.abstract_combined_price_list_builder
        calls:
            - [setAccountGroupCombinedPriceListsBuilder,  ['@oro_pricing.builder.account_group_combined_price_list_builder']]
            - [setPriceListToEntityClassName, ['%oro_pricing.entity.price_list_to_website.class%']]
            - [setCombinedPriceListToEntityClassName, ['%oro_pricing.entity.combined_price_list_to_website.class%']]
            - [setFallbackClassName, ['%oro_pricing.entity.price_list_website_fallback.class%']]

    oro_pricing.builder.combined_price_list_builder:
        class: 'Oro\Bundle\PricingBundle\Builder\CombinedPriceListsBuilder'
        arguments:
            - '@oro_config.global'
            - '@oro_pricing.provider.price_list_collection'
            - '@oro_pricing.provider.combined_price_list'
            - '@oro_pricing.builder.combined_price_list_garbage_collector'
            - '@oro_pricing.resolver.combined_product_schedule_resolver'
            - '@oro_pricing.resolver.combined_product_price_resolver'
        calls:
            - [setWebsiteCombinedPriceListBuilder,  ['@oro_pricing.builder.website_combined_price_list_builder']]

    oro_pricing.builder.combined_price_list_activation_plan_builder:
        class: 'Oro\Bundle\PricingBundle\Builder\CombinedPriceListActivationPlanBuilder'
        public: false
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_pricing.resolver.price_list_schedule_resolver'
        calls:
            - [setProvider, ['@oro_pricing.provider.combined_price_list']]

    oro_pricing.resolver.price_list_schedule_resolver:
        class: Oro\Bundle\PricingBundle\Resolver\PriceListScheduleResolver
        public: false

    oro_pricing.validator.unique_product_prices:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\UniqueProductPricesValidator'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing_unique_product_prices_validator }

    oro_pricing.event_listener.form_view:
        class: 'Oro\Bundle\PricingBundle\EventListener\FormViewListener'
        arguments:
            - '@request_stack'
            - '@translator'
            - '@oro_entity.doctrine_helper'
        tags:
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.product-view, method: onProductView }
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.product-edit, method: onProductEdit }
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.product-create-step-two, method: onProductEdit }

    oro_pricing.event_listener.account_form_view:
        class: 'Oro\Bundle\PricingBundle\EventListener\AccountFormViewListener'
        arguments:
            - '@request_stack'
            - '@translator'
            - '@oro_entity.doctrine_helper'
            - '@oro_website.website.provider'
        tags:
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.account-view, method: onAccountView }
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.account-edit, method: onEntityEdit }

    oro_pricing.event_listener.account_group_form_view:
        class: 'Oro\Bundle\PricingBundle\EventListener\AccountGroupFormViewListener'
        arguments:
            - '@request_stack'
            - '@translator'
            - '@oro_entity.doctrine_helper'
            - '@oro_website.website.provider'
        tags:
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.account-group-view, method: onAccountGroupView }
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.account-group-edit, method: onEntityEdit }


    oro_pricing.event_listener.datagrid:
        class: 'Oro\Bundle\PricingBundle\EventListener\DatagridListener'
        tags:
# TODO: BB-3826 add correct grid columns
#            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.account-accounts-grid, method: onBuildBeforeAccounts }
#            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.account-groups-grid, method: onBuildBeforeAccountGroups }

    oro_pricing.price_list_change_trigger_factory:
        class: 'Oro\Bundle\PricingBundle\Model\PriceListRelationTriggerFactory'
        arguments:
            - '@doctrine'

    oro_pricing.price_list_relation_trigger_handler:
        class: 'Oro\Bundle\PricingBundle\Model\PriceListRelationTriggerHandler'
        arguments:
            - '@doctrine'
            - '@oro_pricing.price_list_change_trigger_factory'
            - '@oro_message_queue.client.message_producer'
            - '@oro_config.manager'
        tags:
            - { name: kernel.event_listener, event: kernel.terminate, method: sendScheduledTriggers }

    oro_pricing.price_list_trigger_factory:
        class: 'Oro\Bundle\PricingBundle\Model\PriceListTriggerFactory'
        arguments:
            - '@doctrine'

    oro_pricing.price_list_trigger_handler:
        class: 'Oro\Bundle\PricingBundle\Model\PriceListTriggerHandler'
        arguments:
            - '@oro_pricing.price_list_trigger_factory'
            - '@oro_message_queue.client.message_producer'
        tags:
            - { name: kernel.event_listener, event: kernel.terminate, method: sendScheduledTriggers }

    oro_pricing.price_rule_lexeme_trigger_handler:
        class: Oro\Bundle\PricingBundle\Model\PriceRuleLexemeTriggerHandler
        arguments:
            - '@oro_pricing.price_list_trigger_handler'
            - '@doctrine'

    oro_pricing.event_listener.product_price_datagrid:
        class: 'Oro\Bundle\PricingBundle\EventListener\ProductPriceDatagridListener'
        arguments:
            - '@translator'
            - '@oro_pricing.model.price_list_request_handler'
            - '@oro_entity.doctrine_helper'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.products-grid, method: onBuildBefore }
            - { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.after.products-grid, method: onResultAfter }

    oro_pricing.event_listener.price_attribute_product_price_datagrid:
        class: 'Oro\Bundle\PricingBundle\EventListener\PriceAttributeProductPriceDatagridListener'
        arguments:
            - '@oro_pricing.model.price_list_request_handler'
            - '@oro_entity.doctrine_helper'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.products-grid, method: onBuildBefore }
            - { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.after.products-grid, method: onResultAfter }

    oro_pricing.event_listener.abstract_price_list_relation_data_grid_listener:
        class: 'Oro\Bundle\PricingBundle\EventListener\AbstractPriceListRelationDataGridListener'
        abstract: true
        arguments:
            - '@doctrine'

    oro_pricing.event_listener.account_accounts_grid:
        class: 'Oro\Bundle\PricingBundle\EventListener\AccountDataGridListener'
        parent: oro_pricing.event_listener.abstract_price_list_relation_data_grid_listener
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.account-accounts-grid, method: onBuildBefore }
            - { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.after.account-accounts-grid, method: onResultAfter }

    oro_pricing.event_listener.account_groups_grid:
        class: 'Oro\Bundle\PricingBundle\EventListener\AccountGroupDataGridListener'
        parent: oro_pricing.event_listener.abstract_price_list_relation_data_grid_listener
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.account-groups-grid, method: onBuildBefore }
            - { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.after.account-groups-grid, method: onResultAfter }

    oro_pricing.event_listener.price_list_datagrid:
        class: 'Oro\Bundle\PricingBundle\EventListener\PriceListDatagridListener'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.pricing-price-list-select-grid, method: onBuildBefore }

    oro_pricing.event_listener.frontend.product_price_datagrid:
        class: 'Oro\Bundle\PricingBundle\EventListener\FrontendProductPriceDatagridListener'
        arguments:
            - '@translator'
            - '@oro_pricing.model.price_list_request_handler'
            - '@oro_locale.formatter.number'
            - '@oro_product.formatter.product_unit_label'
            - '@oro_product.formatter.product_unit_value'
            - '@oro_pricing.user_currency_manager'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.frontend-products-grid, method: onBuildBefore }
            - { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.after.frontend-products-grid, method: onResultAfter }

    oro_pricing.validator.product_price_allowed_units:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\ProductPriceAllowedUnitsValidator'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing_product_price_allowed_units_validator }

    oro_pricing.validator.product_price_currency:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\ProductPriceCurrencyValidator'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing_product_price_currency_validator }

    oro_pricing.validator.price_list_product_prices_currency:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\PriceListProductPricesCurrencyValidator'
        arguments:
            - '@doctrine'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing_price_list_product_prices_currency_validator }

    oro_pricing.validator.default_currency:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\DefaultCurrencyValidator'
        public: true
        arguments:
            - "@oro_config.manager"
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing_default_currency_validator }

    oro_pricing.validator.dates_chain:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\DatesChainValidator'
        arguments:
            - '@property_accessor'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing_dates_chain_validator }

    oro_pricing.validator.schedules_intersection:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\SchedulesIntersectionValidator'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing_schedules_intersection_validator }

    oro_pricing.model.price_list_request_handler:
        class: 'Oro\Bundle\PricingBundle\Model\PriceListRequestHandler'
        arguments:
            - '@request_stack'
            - '@oro_security.security_facade'
            - '@oro_pricing.model.price_list_tree_handler'
            - '@doctrine'
            - '@oro_account.provider.account_user_relations_provider'
            - '@oro_website.manager'

    oro_pricing.model.price_list_tree_handler:
        class: 'Oro\Bundle\PricingBundle\Model\PriceListTreeHandler'
        arguments:
            - '@doctrine'
            - '@oro_website.manager'
            - '@oro_config.global'

    oro_pricing.model.assign_user_currency:
        class: 'Oro\Bundle\PricingBundle\Model\AssignUserCurrencyAction'
        arguments:
            - '@oro_action.context_accessor'
            - '@oro_pricing.user_currency_manager'
        tags:
            - { name: oro_workflow.action, alias: assign_user_currency }
            - { name: oro_action.action, alias: assign_user_currency }

    oro_pricing.filter.abstract_product_price:
        abstract: true
        class: 'Oro\Bundle\PricingBundle\Filter\ProductPriceFilter'
        arguments:
            - '@form.factory'
            - '@oro_filter.filter_utility'
            - '@oro_product.formatter.product_unit_label'
            - '@oro_pricing.model.price_list_request_handler'

    oro_pricing.filter.price_attribute_product_price:
        parent: oro_pricing.filter.abstract_product_price
        calls:
            - [setProductPriceClass, ['%oro_pricing.entity.price_attribute_product_price.class%']]
        tags:
            - { name: oro_filter.extension.orm_filter.filter, type: price-attribute-product-price }

    oro_pricing.filter.product_price:
        parent: oro_pricing.filter.abstract_product_price
        calls:
            - [setProductPriceClass, ['%oro_pricing.entity.product_price.class%']]
        tags:
            - { name: oro_filter.extension.orm_filter.filter, type: product-price }

    oro_pricing.filter.price_lists:
        class: 'Oro\Bundle\PricingBundle\Filter\PriceListsFilter'
        public: false
        arguments:
            - '@form.factory'
            - '@oro_filter.filter_utility'
        calls:
            - [setRegistry, ['@doctrine']]
        tags:
            - { name: oro_filter.extension.orm_filter.filter, type: price-lists }

    oro_pricing.filter.frontend_product_price:
        class: 'Oro\Bundle\PricingBundle\Filter\FrontendProductPriceFilter'
        parent: oro_pricing.filter.product_price
        calls:
            - [setRegistry, ['@doctrine']]
            - [setProductPriceClass, ['%oro_pricing.entity.combined_product_price.class%']]
        tags:
            - { name: oro_filter.extension.orm_filter.filter, type: frontend-product-price }

    oro_pricing.event_listener.product_duplicate:
        class: 'Oro\Bundle\PricingBundle\EventListener\ProductDuplicateListener'
        calls:
            - [setProductPriceClass, ['%oro_pricing.entity.product_price.class%']]
            - [setDoctrineHelper,  ['@oro_entity.doctrine_helper']]
        tags:
            - { name: kernel.event_listener, event: oro_product.product.duplicate.after, method: onDuplicateAfter }

    oro_pricing.model.frontend_product_list_modifier:
        class: 'Oro\Bundle\PricingBundle\Model\FrontendProductListModifier'
        public: false
        arguments:
            - '@security.token_storage'
            - '@oro_pricing.model.price_list_tree_handler'

    oro_pricing.datagrid.extension.product_selection_grid:
        class: 'Oro\Bundle\PricingBundle\Datagrid\ProductSelectionGridExtension'
        public: false
        arguments:
            - '@request_stack'
            - '@security.token_storage'
            - '@oro_pricing.model.frontend_product_list_modifier'
        tags:
            - { name: oro_datagrid.extension }

    oro_pricing.event_listener.product_select_price_list_aware:
        class: 'Oro\Bundle\PricingBundle\EventListener\ProductSelectPriceListAwareListener'
        arguments:
            - '@oro_pricing.model.frontend_product_list_modifier'
            - '@doctrine'
        tags:
            - { name: kernel.event_listener, event: oro_product.product_select.db.query, method: onDBQuery }

    oro_pricing.event_listener.system_config:
        class: 'Oro\Bundle\PricingBundle\EventListener\PriceListSystemConfigSubscriber'
        arguments:
            - '@oro_pricing.system_config_converter'
            - '@oro_pricing.price_list_relation_trigger_handler'
        tags:
            - { name: kernel.event_listener, event: oro_config.settings_form_preset, method: formPreSet }
            - { name: kernel.event_listener, event: oro_config.settings_before_save, method: beforeSave }
            - { name: kernel.event_listener, event: oro_config.update_after, method: updateAfter }

    oro_pricing.event_listener.price_list:
        class: 'Oro\Bundle\PricingBundle\EventListener\PriceListListener'
        lazy: true
        arguments:
            - '@oro_pricing.builder.combined_price_list_activation_plan_builder'
            - '@oro_pricing.price_list_relation_trigger_handler'
            - '@oro_pricing.hander.price_rule_lexeme_handler'
        tags:
            - { name: kernel.event_listener, event: oro.form.update_handler.before_form_submit.oro_pricing_price_list, method: beforeSubmit }
            - { name: kernel.event_listener, event: oro.form.update_handler.before_entity_flush.oro_pricing_price_list, method: onPostSubmit }
            - { name: kernel.event_listener, event: oro.form.update_handler.after_entity_flush.oro_pricing_price_list, method: afterFlush }

    oro_pricing.system_config_converter:
        class: 'Oro\Bundle\PricingBundle\SystemConfig\PriceListConfigConverter'
        public: false
        arguments:
            - '@doctrine'
            - '%oro_pricing.entity.price_list.class%'

    oro_pricing.validator.unique_price_list:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\UniquePriceListValidator'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing_unique_price_list_validator }

    oro_pricing.validator.price_for_product_unit_exists:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\PriceForProductUnitExistsValidator'
        arguments:
            - '@doctrine'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing_price_for_product_unit_exists_validator }

    oro_pricing.entity_listener.product_price_cpl:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\ProductPriceCPLEntityListener'
        public: false
        arguments:
            - '@oro_b2bentity.extra_insert_entity_storage'
            - '@doctrine'
            - '@oro_pricing.price_list_trigger_handler'
        tags:
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.product_price.class%', event: preUpdate }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.product_price.class%', event: preRemove }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.product_price.class%', event: prePersist }

    oro_pricing.entity_listener.price_list:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\PriceListEntityListener'
        public: false
        arguments:
            - '@oro_pricing.price_list_relation_trigger_handler'
            - '@oro_pricing.cache.rule_cache'
            - '@oro_pricing.price_list_trigger_handler'
            - '@oro_pricing.price_rule_lexeme_trigger_handler'
        tags:
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_list.class%', event: preUpdate }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_list.class%', event: preRemove }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_list.class%', event: prePersist }

    oro_pricing.entity_listener.price_list_currency:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\PriceListCurrencyEntityListener'
        public: false
        arguments:
            - '@oro_pricing.cache.rule_cache'
            - '@oro_pricing.price_list_trigger_handler'
        tags:
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_list_currency.class%', event: preRemove }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_list_currency.class%', event: postPersist }

    oro_pricing.entity_listener.price_rule:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\PriceRuleEntityListener'
        public: false
        arguments:
            - '@oro_pricing.cache.rule_cache'
            - '@oro_pricing.price_list_trigger_handler'
        tags:
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_rule.class%', event: preUpdate }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_rule.class%', event: preRemove }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_rule.class%', event: postPersist }

    oro_pricing.entity_listener.abstract_rule_listener:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\AbstractRuleEntityListener'
        abstract: true
        arguments:
            - '@oro_pricing.price_rule_lexeme_trigger_handler'
            - '@oro_pricing.provider.price_rule_fields_provider'
            - '@doctrine'

    oro_pricing.entity_listener.category:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\CategoryEntityListener'
        parent: oro_pricing.entity_listener.abstract_rule_listener
        public: false
        tags:
            - { name: doctrine.orm.entity_listener, entity: '%oro_catalog.entity.category.class%', event: preUpdate }
            - { name: doctrine.orm.entity_listener, entity: '%oro_catalog.entity.category.class%', event: preRemove }

    oro_pricing.event_listener.category:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\CategoryEntityListener'
        parent: oro_pricing.entity_listener.abstract_rule_listener
        public: false
        tags:
            - { name: doctrine.event_listener, event: onFlush }

    oro_pricing.entity_listener.product:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\ProductEntityListener'
        public: false
        parent: oro_pricing.entity_listener.abstract_rule_listener
        tags:
            - { name: doctrine.orm.entity_listener, entity: '%oro_product.entity.product.class%', event: postPersist }
            - { name: doctrine.orm.entity_listener, entity: '%oro_product.entity.product.class%', event: preUpdate }

    oro_pricing.entity_listener.price_attribute_product_price:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\PriceAttributeProductPriceEntityListener'
        parent: oro_pricing.entity_listener.abstract_rule_listener
        public: false
        tags:
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_attribute_product_price.class%', event: postPersist }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_attribute_product_price.class%', event: preUpdate }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_attribute_product_price.class%', event: preRemove }

    oro_pricing.entity_listener.product_price:
        class: 'Oro\Bundle\PricingBundle\Entity\EntityListener\ProductPriceEntityListener'
        parent: oro_pricing.entity_listener.abstract_rule_listener
        public: false
        tags:
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.product_price.class%', event: postPersist }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.product_price.class%', event: preUpdate }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.product_price.class%', event: preRemove }

    oro_pricing.entity_listener.price_list_to_product:
        class: Oro\Bundle\PricingBundle\Entity\EntityListener\PriceListToProductEntityListener
        arguments:
            - '@oro_pricing.price_list_trigger_handler'
            - '@oro_pricing.price_rule_lexeme_trigger_handler'
        tags:
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_list_to_product.class%', event: postPersist }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_list_to_product.class%', event: preUpdate }
            - { name: doctrine.orm.entity_listener, entity: '%oro_pricing.entity.price_list_to_product.class%', event: postRemove }
            - { name: kernel.event_listener, event: oro_pricing.assignment_rule_builder.build, method: onAssignmentRuleBuilderBuild}

    oro_pricing.provider.matching_price:
        class: 'Oro\Bundle\PricingBundle\Provider\MatchingPriceProvider'
        arguments:
            - '@oro_pricing.provider.combined_product_price'
            - '@oro_entity.doctrine_helper'
            - '%oro_product.entity.product.class%'
            - '%oro_product.entity.product_unit.class%'

    oro_pricing.subtotal_processor.subtotal_provider_registry:
        class: 'Oro\Bundle\PricingBundle\SubtotalProcessor\SubtotalProviderRegistry'
        public: false

    oro_pricing.subtotal_processor.total_processor_provider:
        class: 'Oro\Bundle\PricingBundle\SubtotalProcessor\TotalProcessorProvider'
        arguments:
            - '@oro_pricing.subtotal_processor.subtotal_provider_registry'
            - '@translator'
            - '@oro_currency.rounding.price_rounding_service'
            - '@oro_pricing.user_currency_manager'

    oro_pricing.subtotal_processor.provider.subtotal_line_item:
        class: 'Oro\Bundle\PricingBundle\SubtotalProcessor\Provider\LineItemSubtotalProvider'
        public: false
        arguments:
            - '@translator'
            - '@oro_currency.rounding.price_rounding_service'
            - '@oro_pricing.user_currency_manager'
        tags:
            - { name: oro_pricing.subtotal_provider, priority: 0 }

    oro_pricing.subtotal_processor.provider.subtotal_line_item_not_priced:
        class: 'Oro\Bundle\PricingBundle\SubtotalProcessor\Provider\LineItemNotPricedSubtotalProvider'
        arguments:
            - '@translator'
            - '@oro_currency.rounding.price_rounding_service'
            - '@oro_pricing.provider.combined_product_price'
            - '@oro_entity.doctrine_helper'
            - '@oro_pricing.model.price_list_tree_handler'
            - '@oro_pricing.user_currency_manager'
        calls:
            - [setProductClass, ['%oro_product.entity.product.class%']]
            - [setProductUnitClass, ['%oro_product.entity.product_unit.class%']]
        tags:
            - { name: oro_pricing.subtotal_provider, priority: 0 }

    oro_pricing.price_list_with_priority_collection.handler:
        class: 'Oro\Bundle\PricingBundle\Form\PriceListWithPriorityCollectionHandler'
        public: false
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@property_accessor'

    oro_pricing.entity_listener.account_group:
        class: 'Oro\Bundle\PricingBundle\EventListener\AccountGroupListener'
        arguments:
            - '@oro_pricing.price_list_with_priority_collection.handler'
            - '@oro_entity.doctrine_helper'
            - '@oro_pricing.price_list_relation_trigger_handler'
        tags:
            - { name: kernel.event_listener, event: oro_account.account_group.before_flush, method: onPostSubmit }
            - { name: kernel.event_listener, event: oro_account.account_group.pre_remove, method: onGroupRemove }

    oro_pricing.entity_listener.account:
        class: 'Oro\Bundle\PricingBundle\EventListener\AccountListener'
        arguments:
            - '@oro_pricing.price_list_with_priority_collection.handler'
            - '@oro_entity.doctrine_helper'
            - '@oro_pricing.price_list_relation_trigger_handler'
        tags:
            - { name: kernel.event_listener, event: oro.form.update_handler.before_entity_flush.oro_account_type, method: onPostSubmit }
            - { name: kernel.event_listener, event: oro_account.account.on_account_group_change, method: onAccountGroupChange }

    oro_pricing.subtotal_processor.handler.request_handler:
        class: 'Oro\Bundle\PricingBundle\SubtotalProcessor\Handler\RequestHandler'
        arguments:
            - '@oro_pricing.subtotal_processor.total_processor_provider'
            - '@event_dispatcher'
            - '@oro_security.security_facade'
            - '@oro_entity.routing_helper'
            - '@doctrine'

    oro_pricing.formatter.product_price_formatter:
        class: 'Oro\Bundle\PricingBundle\Formatter\ProductPriceFormatter'
        public: false
        arguments:
            - '@oro_locale.formatter.number'
            - '@oro_product.formatter.product_unit_label'
            - '@oro_product.formatter.product_unit_value'

    oro_pricing.duplicator.schedule:
        class: 'Oro\Bundle\PricingBundle\Duplicator\ScheduleDuplicator'

    oro_pricing.duplicator.product_price_duplicator:
        class: 'Oro\Bundle\PricingBundle\Duplicator\ProductPriceDuplicator'
        arguments:
            - '@doctrine'
            - '@oro_entity.orm.insert_from_select_query_executor'
        calls:
            - [setPriceListClass, ['%oro_pricing.entity.product_price.class%']]

    oro_pricing.compiler.abstract_rule_compiler:
        class: 'Oro\Bundle\PricingBundle\Compiler\AbstractRuleCompiler'
        abstract: true
        arguments:
            - '@oro_pricing.expression.parser'
            - '@oro_pricing.expression.preprocessor'
            - '@oro_pricing.expression.node_to_query_designer_converter'
            - '@oro_pricing.query.price_list_expression_query_converter'
            - '@oro_pricing.expression.query_expression_builder'
            - '@oro_pricing.cache.rule_cache'

    oro_pricing.compiler.price_list_rule_compiler:
        class: 'Oro\Bundle\PricingBundle\Compiler\PriceListRuleCompiler'
        parent: oro_pricing.compiler.abstract_rule_compiler
        calls:
            - [setFieldsProvider, ['@oro_pricing.provider.price_rule_fields_provider']]

    oro_pricing.compiler.product_assignment_rule_compiler:
        class: 'Oro\Bundle\PricingBundle\Compiler\ProductAssignmentRuleCompiler'
        parent: oro_pricing.compiler.abstract_rule_compiler

    oro_pricing.builder.product_price_builder:
        class: 'Oro\Bundle\PricingBundle\Builder\ProductPriceBuilder'
        arguments:
            - '@doctrine'
            - '@oro_entity.orm.insert_from_select_query_executor'
            - '@oro_pricing.compiler.price_list_rule_compiler'
            - '@oro_pricing.price_list_trigger_handler'

    oro_pricing.builder.price_list_product_assignment_builder:
        class: 'Oro\Bundle\PricingBundle\Builder\PriceListProductAssignmentBuilder'
        arguments:
            - '@doctrine'
            - '@oro_entity.orm.insert_from_select_query_executor'
            - '@oro_pricing.compiler.product_assignment_rule_compiler'
            - '@event_dispatcher'

    oro_pricing.expression.expression_language_converter:
        class: 'Oro\Bundle\PricingBundle\Expression\ExpressionLanguageConverter'
        public: false
        arguments:
            - '@oro_pricing.provider.price_rule_fields_provider'

    oro_pricing.expression.parser:
        class: 'Oro\Bundle\PricingBundle\Expression\ExpressionParser'
        public: false
        arguments:
            - '@oro_pricing.expression.expression_language_converter'
        calls:
            - [addNameMapping, ['product', '%oro_product.entity.product.class%']]
            - [addNameMapping, ['pricelist', '%oro_pricing.entity.price_list.class%']]

    oro_pricing.expression.node_to_query_designer_converter:
        class: 'Oro\Bundle\PricingBundle\Expression\NodeToQueryDesignerConverter'
        public: false
        arguments:
            - '@oro_pricing.provider.price_rule_fields_provider'

    oro_pricing.expression.query_expression.converter.binary_node:
        class: 'Oro\Bundle\PricingBundle\Expression\QueryExpressionConverter\BinaryNodeConverter'
        public: false

    oro_pricing.expression.query_expression.converter.name_node:
        class: 'Oro\Bundle\PricingBundle\Expression\QueryExpressionConverter\NameNodeConverter'
        public: false

    oro_pricing.expression.query_expression.converter.relation_node:
        class: 'Oro\Bundle\PricingBundle\Expression\QueryExpressionConverter\RelationNodeConverter'
        public: false

    oro_pricing.expression.query_expression.converter.unary_node:
        class: 'Oro\Bundle\PricingBundle\Expression\QueryExpressionConverter\UnaryNodeConverter'
        public: false

    oro_pricing.expression.query_expression.converter.value_node:
        class: 'Oro\Bundle\PricingBundle\Expression\QueryExpressionConverter\ValueNodeConverter'
        public: false

    oro_pricing.expression.query_expression.converter.assigned_products:
        class: Oro\Bundle\PricingBundle\Expression\QueryExpressionConverter\AssignedProductsConverter
        arguments:
            - '@oro_pricing.provider.price_rule_fields_provider'
        public: false

    oro_pricing.expression.query_expression_builder:
        class: 'Oro\Bundle\PricingBundle\Expression\QueryExpressionBuilder'
        calls:
            - ['registerConverter', ['@oro_pricing.expression.query_expression.converter.assigned_products', 10]]
            - ['registerConverter', ['@oro_pricing.expression.query_expression.converter.binary_node']]
            - ['registerConverter', ['@oro_pricing.expression.query_expression.converter.name_node']]
            - ['registerConverter', ['@oro_pricing.expression.query_expression.converter.relation_node']]
            - ['registerConverter', ['@oro_pricing.expression.query_expression.converter.unary_node']]
            - ['registerConverter', ['@oro_pricing.expression.query_expression.converter.value_node']]

    oro_pricing.expression.preprocessor.product_assignment_rule:
        class: Oro\Bundle\PricingBundle\Expression\Preprocessor\ProductAssignmentRuleExpressionPreprocessor
        arguments:
            - '@doctrine'
        public: false

    oro_pricing.expression.preprocessor:
        class: Oro\Bundle\PricingBundle\Expression\Preprocessor\ExpressionPreprocessor
        calls:
            - ['registerPreprocessor', ['@oro_pricing.expression.preprocessor.product_assignment_rule']]

    oro_pricing.query.price_list_expression_query_converter:
        class: 'Oro\Bundle\PricingBundle\Query\PriceListExpressionQueryConverter'
        public: false
        arguments:
            - '@oro_query_designer.query_designer.manager'
            - '@oro_entity.virtual_field_provider.chain'
            - '@doctrine'
        calls:
            - [setVirtualRelationProvider, ['@oro_entity.virtual_relation_provider.chain']]

    oro_pricing.validator_constraints.logical_expression_validator:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\LogicalExpressionValidator'
        public: true
        arguments:
            - '@oro_pricing.expression.parser'
            - '@oro_pricing.expression.preprocessor'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing.validator_constraints.logical_expression_validator }

    oro_pricing.validator_constraints.price_rule_expression_validator:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\PriceRuleExpressionValidator'
        public: true
        arguments:
            - '@oro_pricing.expression.parser'
            - '@oro_pricing.expression.preprocessor'
            - '@oro_pricing.provider.price_rule_fields_provider'
            - '@translator'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing.validator_constraints.price_rule_expression_validator }

    oro_pricing.validator_constraints.lexeme_circular_reference_validator:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\LexemeCircularReferenceValidator'
        public: true
        arguments:
            - '@oro_pricing.expression.parser'
            - '@doctrine'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing.validator_constraints.lexeme_circular_reference_validator }

    oro_pricing.validator_constraints.price_rule_relation_expressions_validator:
        class: 'Oro\Bundle\PricingBundle\Validator\Constraints\PriceRuleRelationExpressionsValidator'
        arguments:
            - '@oro_pricing.expression.parser'
            - '@oro_pricing.provider.price_rule_fields_provider'
            - '@translator'
        tags:
            - { name: validator.constraint_validator, alias: oro_pricing.validator_constraints.price_rule_relation_expressions_validator }

    oro_pricing.hander.price_rule_lexeme_handler:
        class: 'Oro\Bundle\PricingBundle\Handler\PriceRuleLexemeHandler'
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_pricing.expression.parser'
            - '@oro_pricing.provider.price_rule_fields_provider'

    oro_pricing.cache.rule_cache.storage:
        public: false
        parent: oro.cache.abstract
        calls:
            - [ setNamespace, [ 'oro_pricing.cache.rule_cache' ] ]

    oro_pricing.cache.rule_cache:
        class: 'Oro\Bundle\PricingBundle\Cache\RuleCache'
        public: false
        arguments:
            - '@oro_pricing.cache.rule_cache.storage'
            - '@doctrine'

    oro_pricing.duplicator.price_list_to_product_duplicator:
        class: 'Oro\Bundle\PricingBundle\Duplicator\PriceListToProductDuplicator'
        arguments:
            - '@doctrine'
            - '@oro_entity.orm.insert_from_select_query_executor'
        calls:
            - [setEntityName, ['%oro_pricing.entity.price_list_to_product.class%']]

    oro_pricing.async.price_list_rule_processor:
        class: 'Oro\Bundle\PricingBundle\Async\PriceRuleProcessor'
        arguments:
            - '@oro_pricing.price_list_trigger_factory'
            - '@oro_pricing.builder.product_price_builder'
            - '@logger'
            - '@doctrine'
            - '@oro_pricing.notification_message.messenger'
            - '@translator'
        tags:
            - { name: 'oro_message_queue.client.message_processor' }

    oro_pricing.async.price_list_assigned_products_processor:
        class: Oro\Bundle\PricingBundle\Async\PriceListAssignedProductsProcessor
        arguments:
            - '@oro_pricing.price_list_trigger_factory'
            - '@oro_pricing.builder.price_list_product_assignment_builder'
            - '@logger'
            - '@oro_pricing.notification_message.messenger'
            - '@translator'
            - '@doctrine'
        tags:
            - { name: 'oro_message_queue.client.message_processor' }

    oro_pricing.async.combined_price_list_processor:
        class: 'Oro\Bundle\PricingBundle\Async\CombinedPriceListProcessor'
        arguments:
            - '@oro_pricing.builder.combined_price_list_builder'
            - '@oro_pricing.builder.website_combined_price_list_builder'
            - '@oro_pricing.builder.account_group_combined_price_list_builder'
            - '@oro_pricing.builder.account_combined_price_list_builder'
            - '@event_dispatcher'
            - '@logger'
            - '@oro_pricing.price_list_change_trigger_factory'
            - '@doctrine'
            - '@oro_entity.database_exception_helper'
        tags:
            - { name: 'oro_message_queue.client.message_processor' }

    oro_bundle_pricing.async.price_list_processor:
        class: 'Oro\Bundle\PricingBundle\Async\PriceListProcessor'
        arguments:
            - '@oro_pricing.price_list_trigger_factory'
            - '@doctrine'
            - '@oro_pricing.resolver.combined_product_price_resolver'
            - '@event_dispatcher'
            - '@logger'
            - '@oro_entity.database_exception_helper'
        tags:
            - { name: 'oro_message_queue.client.message_processor' }

    oro_pricing.price_list_reference_checker:
        class: 'Oro\Bundle\PricingBundle\Model\PriceListReferenceChecker'
        public: false
        arguments:
            - '@doctrine'
