<commit_before>from zope.interface import Interface
from zope.interface import Attribute
from bda.plone.shipping.interfaces import IShippingExtensionLayer


class ICartExtensionLayer(IShippingExtensionLayer):
    """Browser layer for bda.plone.cart
    """


class ICartItem(Interface):
    """Marker for items which are addable to cart.
    """


class ICartDataProvider(Interface):

    data = Attribute(u"Cart data as dict.")

    total = Attribute(u"Total price of cart items currently in cart.")

    currency = Attribute(u"Currency")

    hide_cart_if_empty = Attribute(u"Flag whether to hide cart if empty.")

    max_artice_count = Attribute(u"Max article limit in cart.")

    disable_max_article = Attribute(u"Flag whether to disable max article "
                                    u"limit.")

    summary_total_only = Attribute(u"Flag whether to show total sum only in "
                                   u"summary.")

    include_shipping_costs = Attribute(u"Flag whether to include and display "
                                       u"shipping costs.")

    shipping_method = Attribute(u"Current shipping method identifyer.")

    checkout_url = Attribute(u"URL to checkout form.")

    cart_url = Attribute(u"URL to cart overview.")

    show_to_cart = Attribute(u"Flag whether to display link to cart "
                             u"overview in cart portlet")

    show_checkout = Attribute(u"Flag whether to display link to checkout "
                              u"form in cart portlet")

    show_currency = Attribute(u"Show the currency for items in portlet")

    def validate_set(uid):
        """Validate if setting item with UID is allowed.

        return {
            'success': [True|False],
            'error': 'Error message if no success',
        }
        """

    def validate_count(uid, count):
        """Validate if n items with UID are allowed in cart.

        return {
            'success': [True|False],
            'error': 'Error message if no success',
        }
        """

    def net(items):
        """Calculate net sum of cart items and return as Decimal.

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def vat(items):
        """Calculate vat sum of cart items and return as Decimal.

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def shipping(items):
        """Calculate shipping costs for cart items.

        return {
            'net': Decimal(0),
            'vat': Decimal(0),
            'label': 'Shipping label',
            'description': 'Shipping description'
        }

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def discount(items):
        """Calculate discount for cart items.

        return {
            'net': Decimal(0),
            'vat': Decimal(0),
        }

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def cart_items(items):
        """Return list of dicts with format returned by
        ``ICartDataProvider.item``.

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def item(uid, title, count, price, url, comment='', description='',
             comment_required=False, quantity_unit_float=False,
             quantity_unit='', preview_image_url='',
             no_longer_available=False, alert=''):
        """Create cart item entry for JSON response.

        :param uid: catalog uid
        :param title: string
        :param count: item count as int
        :param price: item price as float
        :param url: item URL
        :param comment: item comment
        :param description: item description
        :param comment_required: Flag whether comment is required
        :param quantity_unit_float: Flag whether item count can be float
        :param quantity_unit: Quantity unit
        :param preview_image_url: URL for item preview image
        :param no_longer_available: Item is no longer available
        :param alert: Optional alert message
        """


class ICartItemDataProvider(Interface):
    """Provide information relevant for being cart item.
    """
    title = Attribute(u"Title of the cart item")  # For custom/computed titles

    net = Attribute(u"Item base net price as float")

    vat = Attribute(u"Item VAT in % as float value")

    cart_count_limit = Attribute(u"Max count of this item in cart")

    display_gross = Attribute(u"Flag whether whether to display gross "
                              u"instead of net")

    comment_enabled = Attribute(u"Flag whether customer comment can be added "
                                u"when adding buyable to cart")

    comment_required = Attribute(u"Flag whether comment input is required in "
                                 u"order to add buyable to cart")

    quantity_unit_float = Attribute(u"Flag whether quantity unit value is "
                                    u"allowed as float")

    quantity_unit = Attribute(u"Quantity unit")

    discount_enabled = Attribute(u"Flag whether discount is enabled for this "
                                 u"cart item")

    def discount_net(count):
        """Item discount. Returns calculated discount for one item as Decimal.

        :param count: cart item count
        :param type: Decimal
        """


class ICartItemStock(Interface):
    """Access and modify stock information for buyable items.
    """

    display = Attribute(u"Flag whether whether to display availability")

    available = Attribute(u"Number of item available in stock. ``None`` "
                          u"means unlimited")

    overbook = Attribute(u"Allowed overbooking count. ``None`` "
                         u"means unlimited")

    minimum_stock = Attribute(u"Limit of minimum items in stock. ``None`` "
                         u"means unlimited")



class ICartItemPreviewImage(Interface):
    """Provides preview image url for cart item
    """

    url = Attribute(u"Item preview image url")


class ICartItemAvailability(Interface):
    """Interface for displaying availability information.
    """
<commit_msg>Improve naming Name of field in interface: stock_warning_threshold<commit_after>from zope.interface import Interface
from zope.interface import Attribute
from bda.plone.shipping.interfaces import IShippingExtensionLayer


class ICartExtensionLayer(IShippingExtensionLayer):
    """Browser layer for bda.plone.cart
    """


class ICartItem(Interface):
    """Marker for items which are addable to cart.
    """


class ICartDataProvider(Interface):

    data = Attribute(u"Cart data as dict.")

    total = Attribute(u"Total price of cart items currently in cart.")

    currency = Attribute(u"Currency")

    hide_cart_if_empty = Attribute(u"Flag whether to hide cart if empty.")

    max_artice_count = Attribute(u"Max article limit in cart.")

    disable_max_article = Attribute(u"Flag whether to disable max article "
                                    u"limit.")

    summary_total_only = Attribute(u"Flag whether to show total sum only in "
                                   u"summary.")

    include_shipping_costs = Attribute(u"Flag whether to include and display "
                                       u"shipping costs.")

    shipping_method = Attribute(u"Current shipping method identifyer.")

    checkout_url = Attribute(u"URL to checkout form.")

    cart_url = Attribute(u"URL to cart overview.")

    show_to_cart = Attribute(u"Flag whether to display link to cart "
                             u"overview in cart portlet")

    show_checkout = Attribute(u"Flag whether to display link to checkout "
                              u"form in cart portlet")

    show_currency = Attribute(u"Show the currency for items in portlet")

    def validate_set(uid):
        """Validate if setting item with UID is allowed.

        return {
            'success': [True|False],
            'error': 'Error message if no success',
        }
        """

    def validate_count(uid, count):
        """Validate if n items with UID are allowed in cart.

        return {
            'success': [True|False],
            'error': 'Error message if no success',
        }
        """

    def net(items):
        """Calculate net sum of cart items and return as Decimal.

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def vat(items):
        """Calculate vat sum of cart items and return as Decimal.

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def shipping(items):
        """Calculate shipping costs for cart items.

        return {
            'net': Decimal(0),
            'vat': Decimal(0),
            'label': 'Shipping label',
            'description': 'Shipping description'
        }

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def discount(items):
        """Calculate discount for cart items.

        return {
            'net': Decimal(0),
            'vat': Decimal(0),
        }

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def cart_items(items):
        """Return list of dicts with format returned by
        ``ICartDataProvider.item``.

        :param items: items in the cart
        :param type: list of 3-tuples containing ``(uid, count, comment)``
        """

    def item(uid, title, count, price, url, comment='', description='',
             comment_required=False, quantity_unit_float=False,
             quantity_unit='', preview_image_url='',
             no_longer_available=False, alert=''):
        """Create cart item entry for JSON response.

        :param uid: catalog uid
        :param title: string
        :param count: item count as int
        :param price: item price as float
        :param url: item URL
        :param comment: item comment
        :param description: item description
        :param comment_required: Flag whether comment is required
        :param quantity_unit_float: Flag whether item count can be float
        :param quantity_unit: Quantity unit
        :param preview_image_url: URL for item preview image
        :param no_longer_available: Item is no longer available
        :param alert: Optional alert message
        """


class ICartItemDataProvider(Interface):
    """Provide information relevant for being cart item.
    """
    title = Attribute(u"Title of the cart item")  # For custom/computed titles

    net = Attribute(u"Item base net price as float")

    vat = Attribute(u"Item VAT in % as float value")

    cart_count_limit = Attribute(u"Max count of this item in cart")

    display_gross = Attribute(u"Flag whether whether to display gross "
                              u"instead of net")

    comment_enabled = Attribute(u"Flag whether customer comment can be added "
                                u"when adding buyable to cart")

    comment_required = Attribute(u"Flag whether comment input is required in "
                                 u"order to add buyable to cart")

    quantity_unit_float = Attribute(u"Flag whether quantity unit value is "
                                    u"allowed as float")

    quantity_unit = Attribute(u"Quantity unit")

    discount_enabled = Attribute(u"Flag whether discount is enabled for this "
                                 u"cart item")

    def discount_net(count):
        """Item discount. Returns calculated discount for one item as Decimal.

        :param count: cart item count
        :param type: Decimal
        """


class ICartItemStock(Interface):
    """Access and modify stock information for buyable items.
    """

    display = Attribute(u"Flag whether whether to display availability")

    available = Attribute(u"Number of item available in stock. ``None`` "
                          u"means unlimited")

    overbook = Attribute(u"Allowed overbooking count. ``None`` "
                         u"means unlimited")

    stock_warning_threshold = Attribute(u"Item stock warning threshold. ``None`` "
                         u"means unlimited")



class ICartItemPreviewImage(Interface):
    """Provides preview image url for cart item
    """

    url = Attribute(u"Item preview image url")


class ICartItemAvailability(Interface):
    """Interface for displaying availability information.
    """

{'fraction_non_alphanumeric': 0.08776180056267584, 'fraction_numerical': 0.0014066895904970304, 'mean_word_length': 2.279600205023065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3496304', 'n_tokens_mistral': 3342, 'n_tokens_neox': 3175, 'n_words': 1189}