services:
    oro_sale.condition.quote_acceptable:
        class: Oro\Bundle\SaleBundle\Model\Condition\QuoteAcceptable
        tags:
            - { name: oro_action.condition, alias: quote_acceptable }

    oro_sale.provider.quote_product_price:
        class: 'Oro\Bundle\SaleBundle\Provider\QuoteProductPriceProvider'
        public: true
        arguments:
            - "@oro_pricing.provider.product_price"
            - "@oro_pricing.model.product_price_scope_criteria_factory"
            - "@oro_currency.config.currency"
            - "@oro_entity.doctrine_helper"
            - '@oro_security.acl_helper'
        calls:
            - ['setProductPriceCriteriaFactory', ['@oro_pricing.product_price_criteria_factory']]

    oro_sale.validator.quote_product:
        class: 'Oro\Bundle\SaleBundle\Validator\Constraints\QuoteProductValidator'
        tags:
            - { name: validator.constraint_validator, alias: oro_sale.validator.quote_product }

    oro_sale.twig.quote:
        class: 'Oro\Bundle\SaleBundle\Twig\QuoteExtension'
        public: false
        arguments:
            - "@oro_platform.twig.service_locator"
        tags:
            - { name: twig.extension }

    oro_sale.formatter.quote_product:
        class: 'Oro\Bundle\SaleBundle\Formatter\QuoteProductFormatter'
        arguments:
            - "@translator"
            - "@oro_locale.formatter.number"
            - "@oro_product.formatter.product_unit_value"
            - "@oro_product.formatter.product_unit_label"

    oro_sale.formatter.quote_product_offer:
        class: 'Oro\Bundle\SaleBundle\Formatter\QuoteProductOfferFormatter'
        public: false
        arguments:
            - "@translator"

    Oro\Bundle\SaleBundle\Model\QuoteProductOfferMatcher:
        alias: oro_sale.service.quote_product_offer_matcher

    oro_sale.service.quote_product_offer_matcher:
        class: 'Oro\Bundle\SaleBundle\Model\QuoteProductOfferMatcher'
        public: true

    oro_sale.line_item.converter.quote_demand:
        class: 'Oro\Bundle\SaleBundle\Converter\QuoteDemandLineItemConverter'
        public: false
        tags:
            - { name: oro.checkout.line_item.converter, alias: quote_demand }

    oro_sale.event_listener.product_db_query_restriction:
        class: 'Oro\Bundle\ProductBundle\EventListener\ScopedProductDBQueryRestrictionEventListener'
        parent: oro_product.event_listener.abstract_product_db_query_restriction
        calls:
            - [setScope, ['quote']]
            - [setBackendSystemConfigurationPath, ['oro_sale.backend_product_visibility']]
        tags:
            - { name: kernel.event_listener, event: oro_product.product_db_query.restriction, method: onDBQuery }

    oro_sale.helper.notification:
        class: 'Oro\Bundle\SaleBundle\Notification\NotificationHelper'
        public: true
        arguments:
            - '@doctrine'
            - '@oro_email.email.model.builder'
            - '@oro_email.sender.email_model_sender'
            - '@oro_featuretoggle.checker.feature_checker'
        calls:
            - [ setLogger, [ '@logger' ] ]
            - [ setQuoteClassName, [ 'Oro\Bundle\SaleBundle\Entity\Quote' ] ]
            - [ setEmailTemplateClassName, [ 'Oro\Bundle\EmailBundle\Entity\EmailTemplate' ] ]

    oro_sale.service.request_helper:
        class: 'Oro\Bundle\SaleBundle\Model\RequestHelper'
        public: true
        arguments:
            - "@doctrine"
            - 'Oro\Bundle\SaleBundle\Entity\Quote'
            - 'Oro\Bundle\RFPBundle\Entity\Request'

    oro_sale.manager.quote_address:
        class: 'Oro\Bundle\SaleBundle\Model\QuoteAddressManager'
        public: false
        arguments:
            - "@oro_sale.provider.quote_address"
            - "@doctrine"
            - 'Oro\Bundle\SaleBundle\Entity\QuoteAddress'
        calls:
            - [addEntity, ['a', 'Oro\Bundle\CustomerBundle\Entity\CustomerAddress']]
            - [addEntity, ['au', 'Oro\Bundle\CustomerBundle\Entity\CustomerUserAddress']]

    oro_sale.privider.form_template_data.quote:
        class: 'Oro\Bundle\SaleBundle\Form\QuoteFormTemplateDataProvider'
        public: false
        arguments:
            - '@event_dispatcher'
            - '@oro_sale.provider.quote_product_price'
            - '@oro_sale.provider.quote_address_security'
        tags:
            - { name: oro_form.form_template_data_provider, alias: quote_update }

    oro_sale.provider.quote_address:
        class: 'Oro\Bundle\SaleBundle\Provider\QuoteAddressProvider'
        public: false
        arguments:
            - "@security.authorization_checker"
            - "@oro_security.token_accessor"
            - "@doctrine"
            - "@oro_security.acl_helper"
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerAddress'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUserAddress'

    oro_sale.provider.quote_address_security:
        class: 'Oro\Bundle\SaleBundle\Provider\QuoteAddressSecurityProvider'
        arguments:
            - '@security.authorization_checker'
            - '@oro_frontend.request.frontend_helper'
            - '@oro_sale.provider.quote_address'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerAddress'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUserAddress'

    Oro\Bundle\SaleBundle\Model\QuoteRequestHandler:
        alias: oro_sale.service.quote_request_handler

    oro_sale.service.quote_request_handler:
        class: 'Oro\Bundle\SaleBundle\Model\QuoteRequestHandler'
        public: true
        arguments:
            - "@doctrine"
            - "@request_stack"
            - 'Oro\Bundle\CustomerBundle\Entity\Customer'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUser'

    oro_sale.manager.quote_demand_manager:
        class: 'Oro\Bundle\SaleBundle\Manager\QuoteDemandManager'
        public: true
        arguments:
            - "@oro_pricing.subtotal_processor.total_processor_provider"
            - "@oro_pricing.subtotal_processor.provider.subtotal_line_item"

    oro_sale.event_listener.quote_update:
        class: 'Oro\Bundle\SaleBundle\EventListener\QuoteUpdateHandlerEventListener'
        arguments:
            - '@oro_website.manager'
            - '@oro_sale.service.quote_request_handler'
            - '@request_stack'
        tags:
            - { name: kernel.event_listener, event: oro.form.update_handler.before_form_data_set.oro_sale_quote, method: ensureWebsite }
            - { name: kernel.event_listener, event: oro.form.update_handler.before_form_data_set.oro_sale_quote, method: ensureCustomer }

    oro_sale.event_listener.customer_view:
        class: 'Oro\Bundle\SaleBundle\EventListener\CustomerViewListener'
        public: true
        arguments:
            - '@translator'
            - '@oro_entity.doctrine_helper'
            - '@request_stack'
        tags:
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.customer-view, method: onCustomerView }
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.customer-user-view, method: onCustomerUserView }

    oro_sale.event_listener.datagrid.frontend_quote:
        class: 'Oro\Bundle\SaleBundle\EventListener\Datagrid\FrontendQuoteDatagridListener'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.frontend-quotes-grid, method: onBuildAfter }

    oro_sale.provider.quote_entity_name:
          class: Oro\Bundle\SaleBundle\Provider\QuoteEntityNameProvider
          arguments:
              - "@translator"
          tags:
              - { name: oro_entity.name_provider, priority: 100 }

    oro_sale.provider.quote_checkout:
        class: Oro\Bundle\SaleBundle\Provider\QuoteCheckoutProvider
        public: true
        arguments:
            - '@doctrine'

    oro_sale.provider.payment_term_decorator:
        class: Oro\Bundle\SaleBundle\Provider\PaymentTermProviderDecorator
        decorates: oro_payment_term.provider.payment_term
        arguments:
            - '@.inner'

    oro_sale.event_listener.quote_product:
        class: 'Oro\Bundle\SaleBundle\Entity\Listener\QuoteProductListener'
        arguments: ["@request_stack"]
        tags:
             - { name: doctrine.event_listener, event: preUpdate }

    oro_sale.provider.quote_currency_checker:
       class: Oro\Bundle\SaleBundle\Provider\CurrencyCheckerProvider
       public: false
       arguments:
           - '@doctrine'
       tags:
           - { name: oro_multi_currency.currency_checker_provider }

    oro_sale.quote_demand.subtotals_calculator_main:
        class: 'Oro\Bundle\SaleBundle\Quote\Demand\Subtotals\Calculator\Basic\BasicQuoteDemandSubtotalsCalculator'
        public: true
        arguments:
            - '@oro_pricing.subtotal_processor.total_processor_provider'

    Oro\Bundle\SaleBundle\Quote\Demand\Subtotals\Calculator\QuoteDemandSubtotalsCalculatorInterface:
        alias: 'oro_sale.quote_demand.subtotals_calculator_main'

    Oro\Bundle\SaleBundle\Storage\ReturnRouteDataStorage:
        alias: oro_sale.storage.return_route_storage

    oro_sale.storage.return_route_storage:
        class: 'Oro\Bundle\SaleBundle\Storage\ReturnRouteDataStorage'
        public: true
        parent: oro_product.storage.session_data_storage

    oro_sale.acl.voter.frontend_quote_permission_voter:
        class: Oro\Bundle\SaleBundle\Acl\Voter\FrontendQuotePermissionVoter
        arguments:
            - '@oro_frontend.request.frontend_helper'
        tags:
            - { name: security.voter }

    oro_sale.acl.voter.frontend_quote_demand_permission_voter:
        class: Oro\Bundle\SaleBundle\Acl\Voter\FrontendQuoteDemandPermissionVoter
        arguments:
            - '@oro_frontend.request.frontend_helper'
        tags:
            - { name: security.voter }

    oro_sale.access_rule.frontend_quote_demand:
        class: Oro\Bundle\SaleBundle\Acl\AccessRule\FrontendQuoteDemandAccessRule
        public: false
        arguments:
            - '@security.token_storage'
        tags:
            - { name: oro_security.access_rule, entityClass: Oro\Bundle\SaleBundle\Entity\QuoteDemand, frontend: true }

    oro_sale.provider.contact_info_source_options_provider:
        class: 'Oro\Bundle\SaleBundle\Provider\ContactInfoSourceOptionsProvider'
        public: false
        arguments:
           - '@oro_config.manager'

    oro_sale.provider.contact_info_available_user_options_provider:
        class: 'Oro\Bundle\SaleBundle\Provider\ContactInfoAvailableUserOptionsProvider'
        public: false
        arguments:
            - '@oro_config.manager'

    oro_sale.provider.contact_info_user_options_provider:
        class: 'Oro\Bundle\SaleBundle\Provider\ContactInfoUserOptionsProvider'
        public: false
        arguments:
            - '@oro_config.manager'
            - '@oro_sale.provider.contact_info_available_user_options_provider'
            - '@oro_sale.provider.contact_info_source_options_provider'
            - '@oro_locale.formatter.name'

    oro_sale.layout_data_provider.contact_info_widget_provider:
        class: 'Oro\Bundle\SaleBundle\Layout\DataProvider\ContactInfoWidgetProvider'
        arguments:
          - '@oro_security.token_accessor'
          - '@oro_sale.provider.contact_info_user_provider'
        tags:
            - { name: layout.data_provider, alias: oro_sale_contact_info_widget_provider }

    oro_sale.provider.contact_info_user_provider:
        class: 'Oro\Bundle\SaleBundle\Provider\ContactInfoProvider'
        arguments:
            - '@oro_config.manager'
            - '@oro_sale.provider.contact_info_source_options_provider'
            - '@oro_sale.provider.contact_info_user_options_provider'
            - '@oro_sale.model.contact_info_factory'

    oro_sale.model.contact_info_factory:
        class: 'Oro\Bundle\SaleBundle\Model\ContactInfoFactory'
        public: false
        arguments:
            - '@oro_locale.formatter.name'

    oro_sale.voter.guest_quote:
        parent: oro_customer.voter.anonymous_customer_user
        calls:
            - [ setFeatureName, ['guest_quote'] ]
        tags:
            - { name: oro_featuretogle.voter }

    oro_sale.provider.guest_quote_access:
        class: 'Oro\Bundle\SaleBundle\Provider\GuestQuoteAccessProvider'
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
            - '@oro_website.manager'

    Oro\Bundle\SaleBundle\Provider\GuestQuoteAccessProviderInterface:
        alias: 'oro_sale.provider.guest_quote_access'

    oro_sale.updater.customer_user_reassign.quote_updater:
        parent: oro_customer.updater.customer_user_reassign.abstract
        calls:
            - [ setEntityClass, [ 'Oro\Bundle\SaleBundle\Entity\Quote' ] ]
        tags:
            - { name: oro_customer.updater.customer_user_reassign }
        public: false

    oro_order.quote_create_for_customer.widget_provider.actions:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - quote_create_for_customer_button
            - quote_create_for_customer_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity }

    oro_order.quote_create_for_customer_user.widget_provider.actions:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - quote_create_for_customer_user_button
            - quote_create_for_customer_user_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity }

    oro_sale.event_listener.quote_status:
        class: Oro\Bundle\SaleBundle\EventListener\QuoteStatusListener
        arguments:
            - '@doctrine'
        tags:
            - { name: doctrine.orm.entity_listener, entity: Oro\Bundle\SaleBundle\Entity\Quote, event: prePersist}
