from decimal import Decimal as D
from django.core import exceptions
from django.test import TestCase
from oscar.test import factories
from oscar.test.basket import add_product, add_products
from django_redis import get_redis_connection
from oscarbluelight.offer.models import (
    Range,
    Benefit,
    BluelightCountCondition,
    BluelightValueCondition,
    BluelightPercentageDiscountBenefit,
)
from unittest import mock


class TestAPercentageDiscountAppliedWithCountCondition(TestCase):
    def setUp(self):
        # Flush the cache
        conn = get_redis_connection("redis")
        conn.flushall()

        range = Range.objects.create(name="All products", includes_all_products=True)
        self.condition = BluelightCountCondition(
            range=range,
            proxy_class="oscarbluelight.offer.conditions.BluelightCountCondition",
            value=2,
        )
        self.benefit = BluelightPercentageDiscountBenefit(
            range=range,
            proxy_class="oscarbluelight.offer.benefits.BluelightPercentageDiscountBenefit",
            value=20,
        )
        self.offer = mock.Mock()
        self.basket = factories.create_basket(empty=True)

    def test_applies_correctly_to_empty_basket(self):
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(D("0.00"), result.discount)
        self.assertEqual(0, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_with_no_discountable_products(self):
        product = factories.create_product(is_discountable=False)
        add_product(self.basket, D("12.00"), 2, product=product)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(D("0.00"), result.discount)
        self.assertEqual(0, self.basket.num_items_with_discount)
        self.assertEqual(2, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_matches_condition(self):
        add_product(self.basket, D("12.00"), 2)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(2 * D("12.00") * D("0.2"), result.discount)
        self.assertEqual(2, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_exceeds_condition(self):
        add_product(self.basket, D("12.00"), 3)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(3 * D("12.00") * D("0.2"), result.discount)
        self.assertEqual(3, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_obeys_max_discount_setting(self):
        self.benefit.max_discount = D("5.00")
        self.benefit.save()
        add_product(self.basket, D("12.00"), 3)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(D("5.00"), result.discount)
        self.assertEqual(3, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_records_reason_for_discount_no_voucher(self):
        self.offer.name = "My Offer Name"
        self.offer.description = "My Offer Description"
        self.offer.get_voucher = mock.Mock()
        self.offer.get_voucher.return_value = None

        add_product(self.basket, D("5.00"))
        # Apply benefit twice to simulate how Applicator will actually do it
        self.benefit.apply(self.basket, self.condition, self.offer)
        self.benefit.apply(self.basket, self.condition, self.offer)

        line = self.basket.all_lines()[0]
        descrs = line.get_discount_descriptions()
        self.assertEqual(len(descrs), 1)
        self.assertEqual(descrs[0].amount, D("1.00"))
        self.assertEqual(descrs[0].offer_name, "My Offer Name")
        self.assertEqual(descrs[0].offer_description, "My Offer Description")
        self.assertIsNone(descrs[0].voucher_name)
        self.assertIsNone(descrs[0].voucher_code)

    def test_records_reason_for_discount_with_voucher(self):
        voucher = mock.Mock()
        voucher.name = "My Voucher"
        voucher.code = "SWEETDEAL"
        self.offer.name = "Offer for Voucher"
        self.offer.description = ""
        self.offer.get_voucher = mock.Mock()
        self.offer.get_voucher.return_value = voucher

        add_product(self.basket, D("5.00"))
        # Apply benefit twice to simulate how Applicator will actually do it
        self.benefit.apply(self.basket, self.condition, self.offer)
        self.benefit.apply(self.basket, self.condition, self.offer)

        line = self.basket.all_lines()[0]
        descrs = line.get_discount_descriptions()
        self.assertEqual(len(descrs), 1)
        self.assertEqual(descrs[0].amount, D("1.00"))
        self.assertEqual(descrs[0].offer_name, "Offer for Voucher")
        self.assertEqual(descrs[0].offer_description, "")
        self.assertEqual(descrs[0].voucher_name, "My Voucher")
        self.assertEqual(descrs[0].voucher_code, "SWEETDEAL")


class TestAPercentageDiscountWithMaxItemsSetAppliedWithCountCondition(TestCase):
    def setUp(self):
        # Flush the cache
        conn = get_redis_connection("redis")
        conn.flushall()

        range = Range.objects.create(name="All products", includes_all_products=True)
        self.condition = BluelightCountCondition(
            range=range,
            proxy_class="oscarbluelight.offer.conditions.BluelightCountCondition",
            value=2,
        )
        self.benefit = BluelightPercentageDiscountBenefit(
            range=range,
            proxy_class="oscarbluelight.offer.benefits.BluelightPercentageDiscountBenefit",
            value=20,
            max_affected_items=1,
        )
        self.offer = mock.Mock()
        self.basket = factories.create_basket(empty=True)

    def test_applies_correctly_to_empty_basket(self):
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(D("0.00"), result.discount)
        self.assertEqual(0, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_matches_condition(self):
        add_product(self.basket, D("12.00"), 2)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(1 * D("12.00") * D("0.2"), result.discount)
        self.assertEqual(2, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_exceeds_condition(self):
        add_products(self.basket, [(D("12.00"), 2), (D("20.00"), 2)])
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(1 * D("12.00") * D("0.2"), result.discount)
        # Should only consume the condition products
        self.assertEqual(2, self.basket.num_items_with_discount)
        self.assertEqual(2, self.basket.num_items_without_discount)


class TestAPercentageDiscountWithMultipleApplicationsWithCountCondition(TestCase):
    def setUp(self):
        # Flush the cache
        conn = get_redis_connection("redis")
        conn.flushall()

        self.range_mattresses = Range.objects.create(name="Mattresses")
        self.range_slippers = Range.objects.create(name="Slippers")

        self.mattress = factories.create_product(title="Mattress", price=D("2999.00"))
        self.slipper1 = factories.create_product(title="Slipper", price=D("78.00"))
        self.slipper2 = factories.create_product(title="Slipper", price=D("79.00"))

        self.range_mattresses.add_product(self.mattress)
        self.range_slippers.add_product(self.slipper1)
        self.range_slippers.add_product(self.slipper2)

        self.condition = BluelightCountCondition.objects.create(
            range=self.range_mattresses,
            proxy_class="oscarbluelight.offer.conditions.BluelightCountCondition",
            value=1,
        )

        self.benefit = BluelightPercentageDiscountBenefit.objects.create(
            range=self.range_slippers,
            proxy_class="oscarbluelight.offer.benefits.BluelightPercentageDiscountBenefit",
            value=D("100.00"),
            max_affected_items=1,
        )

        self.offer = mock.Mock()
        self.basket = factories.create_basket(empty=True)

    def test_applies_correctly_to_basket_which_matches_multiple_lines_multiple_times(
        self,
    ):
        # Add two different lines to the basket
        self.basket.add_product(self.mattress, 2)
        self.basket.add_product(self.slipper1, 1)
        self.basket.add_product(self.slipper2, 1)
        # Apply once
        self.assertTrue(self.condition.proxy().is_satisfied(self.offer, self.basket))
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertTrue(result.is_successful)
        self.assertEqual(result.discount, D("78.00"))
        self.assertEqual(self.basket.num_items_with_discount, 2)
        self.assertEqual(self.basket.num_items_without_discount, 2)
        # Apply second time
        self.assertTrue(self.condition.proxy().is_satisfied(self.offer, self.basket))
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertTrue(result.is_successful)
        self.assertEqual(result.discount, D("79.00"))
        self.assertEqual(self.basket.num_items_with_discount, 4)
        self.assertEqual(self.basket.num_items_without_discount, 0)
        # Can't apply a third time because the condition is no longer satisfied
        self.assertFalse(self.condition.proxy().is_satisfied(self.offer, self.basket))


class TestAPercentageDiscountAppliedWithValueCondition(TestCase):
    def setUp(self):
        # Flush the cache
        conn = get_redis_connection("redis")
        conn.flushall()

        range = Range.objects.create(name="All products", includes_all_products=True)
        self.condition = BluelightValueCondition.objects.create(
            range=range,
            proxy_class="oscarbluelight.offer.conditions.BluelightValueCondition",
            value=D("10.00"),
        )
        self.benefit = BluelightPercentageDiscountBenefit.objects.create(
            range=range,
            proxy_class="oscarbluelight.offer.benefits.BluelightPercentageDiscountBenefit",
            value=20,
        )
        self.offer = mock.Mock()
        self.basket = factories.create_basket(empty=True)

    def test_applies_correctly_to_empty_basket(self):
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(D("0.00"), result.discount)
        self.assertEqual(0, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_matches_condition(self):
        add_product(self.basket, D("5.00"), 2)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(2 * D("5.00") * D("0.2"), result.discount)
        self.assertEqual(2, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_exceeds_condition_but_matches_on_boundary(
        self,
    ):
        add_product(self.basket, D("5.00"), 3)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(3 * D("5.00") * D("0.2"), result.discount)
        self.assertEqual(3, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_exceeds_condition(self):
        add_product(self.basket, D("4.00"), 3)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(3 * D("4.00") * D("0.2"), result.discount)
        self.assertEqual(3, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)


class TestAPercentageDiscountWithMaxItemsSetAppliedWithValueCondition(TestCase):
    def setUp(self):
        # Flush the cache
        conn = get_redis_connection("redis")
        conn.flushall()

        range = Range.objects.create(name="All products", includes_all_products=True)
        self.condition = BluelightValueCondition.objects.create(
            range=range,
            proxy_class="oscarbluelight.offer.conditions.BluelightValueCondition",
            value=D("10.00"),
        )
        self.benefit = BluelightPercentageDiscountBenefit.objects.create(
            range=range,
            proxy_class="oscarbluelight.offer.benefits.BluelightPercentageDiscountBenefit",
            value=20,
            max_affected_items=1,
        )
        self.offer = mock.Mock()
        self.basket = factories.create_basket(empty=True)

    def test_applies_correctly_to_empty_basket(self):
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(D("0.00"), result.discount)
        self.assertEqual(0, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_matches_condition(self):
        add_product(self.basket, D("5.00"), 2)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(1 * D("5.00") * D("0.2"), result.discount)
        self.assertEqual(2, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_exceeds_condition_but_matches_on_boundary(
        self,
    ):
        add_product(self.basket, D("5.00"), 3)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(1 * D("5.00") * D("0.2"), result.discount)
        self.assertEqual(2, self.basket.num_items_with_discount)
        self.assertEqual(1, self.basket.num_items_without_discount)

    def test_applies_correctly_to_basket_which_exceeds_condition(self):
        add_product(self.basket, D("4.00"), 3)
        result = self.benefit.apply(self.basket, self.condition, self.offer)
        self.assertEqual(1 * D("4.00") * D("0.2"), result.discount)
        self.assertEqual(3, self.basket.num_items_with_discount)
        self.assertEqual(0, self.basket.num_items_without_discount)


class TestAPercentageDiscountBenefit(TestCase):
    def setUp(self):
        # Flush the cache
        conn = get_redis_connection("redis")
        conn.flushall()

    def test_requires_a_benefit_value(self):
        rng = Range.objects.create(name="", includes_all_products=True)
        benefit = Benefit.objects.create(
            range=rng,
            proxy_class="oscarbluelight.offer.benefits.BluelightPercentageDiscountBenefit",
        )
        with self.assertRaises(exceptions.ValidationError):
            benefit.clean()

[((20, 15, 20, 44), 'django_redis.get_redis_connection', 'get_redis_connection', ({(20, 36, 20, 43): '"""redis"""'}, {}), "('redis')", False, 'from django_redis import get_redis_connection\n'), ((23, 16, 23, 85), 'oscarbluelight.offer.models.Range.objects.create', 'Range.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((24, 25, 28, 9), 'oscarbluelight.offer.models.BluelightCountCondition', 'BluelightCountCondition', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((29, 23, 33, 9), 'oscarbluelight.offer.models.BluelightPercentageDiscountBenefit', 'BluelightPercentageDiscountBenefit', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((34, 21, 34, 32), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((35, 22, 35, 57), 'oscar.test.factories.create_basket', 'factories.create_basket', (), '', False, 'from oscar.test import factories\n'), ((44, 18, 44, 65), 'oscar.test.factories.create_product', 'factories.create_product', (), '', False, 'from oscar.test import factories\n'), ((66, 36, 66, 45), 'decimal.Decimal', 'D', ({(66, 38, 66, 44): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((77, 33, 77, 44), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((95, 18, 95, 29), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((100, 33, 100, 44), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((121, 15, 121, 44), 'django_redis.get_redis_connection', 'get_redis_connection', ({(121, 36, 121, 43): '"""redis"""'}, {}), "('redis')", False, 'from django_redis import get_redis_connection\n'), ((124, 16, 124, 85), 'oscarbluelight.offer.models.Range.objects.create', 'Range.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((125, 25, 129, 9), 'oscarbluelight.offer.models.BluelightCountCondition', 'BluelightCountCondition', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((130, 23, 135, 9), 'oscarbluelight.offer.models.BluelightPercentageDiscountBenefit', 'BluelightPercentageDiscountBenefit', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((136, 21, 136, 32), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((137, 22, 137, 57), 'oscar.test.factories.create_basket', 'factories.create_basket', (), '', False, 'from oscar.test import factories\n'), ((164, 15, 164, 44), 'django_redis.get_redis_connection', 'get_redis_connection', ({(164, 36, 164, 43): '"""redis"""'}, {}), "('redis')", False, 'from django_redis import get_redis_connection\n'), ((167, 32, 167, 71), 'oscarbluelight.offer.models.Range.objects.create', 'Range.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((168, 30, 168, 67), 'oscarbluelight.offer.models.Range.objects.create', 'Range.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((178, 25, 182, 9), 'oscarbluelight.offer.models.BluelightCountCondition.objects.create', 'BluelightCountCondition.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((191, 21, 191, 32), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((192, 22, 192, 57), 'oscar.test.factories.create_basket', 'factories.create_basket', (), '', False, 'from oscar.test import factories\n'), ((222, 15, 222, 44), 'django_redis.get_redis_connection', 'get_redis_connection', ({(222, 36, 222, 43): '"""redis"""'}, {}), "('redis')", False, 'from django_redis import get_redis_connection\n'), ((225, 16, 225, 85), 'oscarbluelight.offer.models.Range.objects.create', 'Range.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((231, 23, 235, 9), 'oscarbluelight.offer.models.BluelightPercentageDiscountBenefit.objects.create', 'BluelightPercentageDiscountBenefit.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((236, 21, 236, 32), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((237, 22, 237, 57), 'oscar.test.factories.create_basket', 'factories.create_basket', (), '', False, 'from oscar.test import factories\n'), ((272, 15, 272, 44), 'django_redis.get_redis_connection', 'get_redis_connection', ({(272, 36, 272, 43): '"""redis"""'}, {}), "('redis')", False, 'from django_redis import get_redis_connection\n'), ((275, 16, 275, 85), 'oscarbluelight.offer.models.Range.objects.create', 'Range.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((281, 23, 286, 9), 'oscarbluelight.offer.models.BluelightPercentageDiscountBenefit.objects.create', 'BluelightPercentageDiscountBenefit.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((287, 21, 287, 32), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((288, 22, 288, 57), 'oscar.test.factories.create_basket', 'factories.create_basket', (), '', False, 'from oscar.test import factories\n'), ((323, 15, 323, 44), 'django_redis.get_redis_connection', 'get_redis_connection', ({(323, 36, 323, 43): '"""redis"""'}, {}), "('redis')", False, 'from django_redis import get_redis_connection\n'), ((327, 14, 327, 71), 'oscarbluelight.offer.models.Range.objects.create', 'Range.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((328, 18, 331, 9), 'oscarbluelight.offer.models.Benefit.objects.create', 'Benefit.objects.create', (), '', False, 'from oscarbluelight.offer.models import Range, Benefit, BluelightCountCondition, BluelightValueCondition, BluelightPercentageDiscountBenefit\n'), ((39, 25, 39, 34), 'decimal.Decimal', 'D', ({(39, 27, 39, 33): '"""0.00"""'}, {}), "('0.00')", True, 'from decimal import Decimal as D\n'), ((45, 33, 45, 43), 'decimal.Decimal', 'D', ({(45, 35, 45, 42): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((47, 25, 47, 34), 'decimal.Decimal', 'D', ({(47, 27, 47, 33): '"""0.00"""'}, {}), "('0.00')", True, 'from decimal import Decimal as D\n'), ((52, 33, 52, 43), 'decimal.Decimal', 'D', ({(52, 35, 52, 42): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((59, 33, 59, 43), 'decimal.Decimal', 'D', ({(59, 35, 59, 42): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((68, 33, 68, 43), 'decimal.Decimal', 'D', ({(68, 35, 68, 42): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((70, 25, 70, 34), 'decimal.Decimal', 'D', ({(70, 27, 70, 33): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((80, 33, 80, 42), 'decimal.Decimal', 'D', ({(80, 35, 80, 41): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((88, 43, 88, 52), 'decimal.Decimal', 'D', ({(88, 45, 88, 51): '"""1.00"""'}, {}), "('1.00')", True, 'from decimal import Decimal as D\n'), ((103, 33, 103, 42), 'decimal.Decimal', 'D', ({(103, 35, 103, 41): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((111, 43, 111, 52), 'decimal.Decimal', 'D', ({(111, 45, 111, 51): '"""1.00"""'}, {}), "('1.00')", True, 'from decimal import Decimal as D\n'), ((141, 25, 141, 34), 'decimal.Decimal', 'D', ({(141, 27, 141, 33): '"""0.00"""'}, {}), "('0.00')", True, 'from decimal import Decimal as D\n'), ((146, 33, 146, 43), 'decimal.Decimal', 'D', ({(146, 35, 146, 42): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((205, 42, 205, 52), 'decimal.Decimal', 'D', ({(205, 44, 205, 51): '"""78.00"""'}, {}), "('78.00')", True, 'from decimal import Decimal as D\n'), ((212, 42, 212, 52), 'decimal.Decimal', 'D', ({(212, 44, 212, 51): '"""79.00"""'}, {}), "('79.00')", True, 'from decimal import Decimal as D\n'), ((241, 25, 241, 34), 'decimal.Decimal', 'D', ({(241, 27, 241, 33): '"""0.00"""'}, {}), "('0.00')", True, 'from decimal import Decimal as D\n'), ((246, 33, 246, 42), 'decimal.Decimal', 'D', ({(246, 35, 246, 41): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((255, 33, 255, 42), 'decimal.Decimal', 'D', ({(255, 35, 255, 41): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((262, 33, 262, 42), 'decimal.Decimal', 'D', ({(262, 35, 262, 41): '"""4.00"""'}, {}), "('4.00')", True, 'from decimal import Decimal as D\n'), ((292, 25, 292, 34), 'decimal.Decimal', 'D', ({(292, 27, 292, 33): '"""0.00"""'}, {}), "('0.00')", True, 'from decimal import Decimal as D\n'), ((297, 33, 297, 42), 'decimal.Decimal', 'D', ({(297, 35, 297, 41): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((306, 33, 306, 42), 'decimal.Decimal', 'D', ({(306, 35, 306, 41): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((313, 33, 313, 42), 'decimal.Decimal', 'D', ({(313, 35, 313, 41): '"""4.00"""'}, {}), "('4.00')", True, 'from decimal import Decimal as D\n'), ((54, 42, 54, 50), 'decimal.Decimal', 'D', ({(54, 44, 54, 49): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((61, 42, 61, 50), 'decimal.Decimal', 'D', ({(61, 44, 61, 49): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((148, 42, 148, 50), 'decimal.Decimal', 'D', ({(148, 44, 148, 49): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((155, 42, 155, 50), 'decimal.Decimal', 'D', ({(155, 44, 155, 49): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((170, 73, 170, 85), 'decimal.Decimal', 'D', ({(170, 75, 170, 84): '"""2999.00"""'}, {}), "('2999.00')", True, 'from decimal import Decimal as D\n'), ((171, 72, 171, 82), 'decimal.Decimal', 'D', ({(171, 74, 171, 81): '"""78.00"""'}, {}), "('78.00')", True, 'from decimal import Decimal as D\n'), ((172, 72, 172, 82), 'decimal.Decimal', 'D', ({(172, 74, 172, 81): '"""79.00"""'}, {}), "('79.00')", True, 'from decimal import Decimal as D\n'), ((187, 18, 187, 29), 'decimal.Decimal', 'D', ({(187, 20, 187, 28): '"""100.00"""'}, {}), "('100.00')", True, 'from decimal import Decimal as D\n'), ((229, 18, 229, 28), 'decimal.Decimal', 'D', ({(229, 20, 229, 27): '"""10.00"""'}, {}), "('10.00')", True, 'from decimal import Decimal as D\n'), ((248, 41, 248, 49), 'decimal.Decimal', 'D', ({(248, 43, 248, 48): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((257, 41, 257, 49), 'decimal.Decimal', 'D', ({(257, 43, 257, 48): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((264, 41, 264, 49), 'decimal.Decimal', 'D', ({(264, 43, 264, 48): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((279, 18, 279, 28), 'decimal.Decimal', 'D', ({(279, 20, 279, 27): '"""10.00"""'}, {}), "('10.00')", True, 'from decimal import Decimal as D\n'), ((299, 41, 299, 49), 'decimal.Decimal', 'D', ({(299, 43, 299, 48): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((308, 41, 308, 49), 'decimal.Decimal', 'D', ({(308, 43, 308, 48): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((315, 41, 315, 49), 'decimal.Decimal', 'D', ({(315, 43, 315, 48): '"""0.2"""'}, {}), "('0.2')", True, 'from decimal import Decimal as D\n'), ((54, 29, 54, 39), 'decimal.Decimal', 'D', ({(54, 31, 54, 38): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((61, 29, 61, 39), 'decimal.Decimal', 'D', ({(61, 31, 61, 38): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((148, 29, 148, 39), 'decimal.Decimal', 'D', ({(148, 31, 148, 38): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((153, 36, 153, 46), 'decimal.Decimal', 'D', ({(153, 38, 153, 45): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((153, 53, 153, 63), 'decimal.Decimal', 'D', ({(153, 55, 153, 62): '"""20.00"""'}, {}), "('20.00')", True, 'from decimal import Decimal as D\n'), ((155, 29, 155, 39), 'decimal.Decimal', 'D', ({(155, 31, 155, 38): '"""12.00"""'}, {}), "('12.00')", True, 'from decimal import Decimal as D\n'), ((248, 29, 248, 38), 'decimal.Decimal', 'D', ({(248, 31, 248, 37): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((257, 29, 257, 38), 'decimal.Decimal', 'D', ({(257, 31, 257, 37): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((264, 29, 264, 38), 'decimal.Decimal', 'D', ({(264, 31, 264, 37): '"""4.00"""'}, {}), "('4.00')", True, 'from decimal import Decimal as D\n'), ((299, 29, 299, 38), 'decimal.Decimal', 'D', ({(299, 31, 299, 37): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((308, 29, 308, 38), 'decimal.Decimal', 'D', ({(308, 31, 308, 37): '"""5.00"""'}, {}), "('5.00')", True, 'from decimal import Decimal as D\n'), ((315, 29, 315, 38), 'decimal.Decimal', 'D', ({(315, 31, 315, 37): '"""4.00"""'}, {}), "('4.00')", True, 'from decimal import Decimal as D\n')]