<commit_before># This file is part of Shoop.
#
# Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.
#
# This source code is licensed under the AGPLv3 license found in the
# LICENSE file in the root directory of this source tree.

from __future__ import unicode_literals

import six

import shoop.core.models
import shoop.utils.money


class LineTax(object):
    """
    Tax of some line.

    This is an interface for specifying taxes of an `OrderLine` or
    `SourceLine`.

    .. attribute:: tax

       (`~shoop.core.models.Tax`)
       The tax that this line is about.

    .. attribute:: name

       (`str`)
       Name of the tax.

    .. attribute:: amount

       (`~shoop.utils.money.Money`)
       Tax amount.

    .. attribute:: base_amount

       (`~shoop.utils.money.Money`)
       Amount that this tax is calculated from.
    """

    @property
    def rate(self):
        return (self.amount / self.base_amount)

    @classmethod<commit_msg>LineTax.rate: Avoid dividing by zero<commit_after># This file is part of Shoop.
#
# Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.
#
# This source code is licensed under the AGPLv3 license found in the
# LICENSE file in the root directory of this source tree.

from __future__ import unicode_literals

import six

import shoop.core.models
import shoop.utils.money


class LineTax(object):
    """
    Tax of some line.

    This is an interface for specifying taxes of an `OrderLine` or
    `SourceLine`.

    .. attribute:: tax

       (`~shoop.core.models.Tax`)
       The tax that this line is about.

    .. attribute:: name

       (`str`)
       Name of the tax.

    .. attribute:: amount

       (`~shoop.utils.money.Money`)
       Tax amount.

    .. attribute:: base_amount

       (`~shoop.utils.money.Money`)
       Amount that this tax is calculated from.
    """

    @property
    def rate(self):
        if not self.base_amount:
            return self.tax.rate
        return (self.amount / self.base_amount)

    @classmethod
{'fraction_non_alphanumeric': 0.0961824491819534, 'fraction_numerical': 0.008924144769459593, 'mean_word_length': 2.4203389830508475, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7635031', 'n_tokens_mistral': 642, 'n_tokens_neox': 578, 'n_words': 216}