# encoding: utf-8

from typing import Any, Dict

from _OrderBenefitInfo import OrderBenefitInfo


class OrderBenefit(object):
    def __init__(self, row_database, discount_items_values, list_benefit):
        # type: (Any, Dict, OrderBenefitInfo) -> OrderBenefit

        self.order_id = row_database.get_entry("OrderId")
        self.business_period = row_database.get_entry("BusinessPeriod")
        self.part_code = row_database.get_entry("PartCode")
        self.item_id = row_database.get_entry("ItemId")
        self.level = row_database.get_entry("Level")
        self.product_name = row_database.get_entry("ProductName")
        self.ordered_qty = float(row_database.get_entry("OrderedQty"))
        self.line_number = row_database.get_entry("LineNumber")
        self.default_unit_price = float(row_database.get_entry("DefaultUnitPrice"))
        self.discount_value = 0.0
        self.discount_type = row_database.get_entry("discountType")
        self.key_burn = "{}.{}.{}.{}".format(self.line_number, self.level, self.item_id, self.part_code)
        self.discount_items_values = discount_items_values
        self.applied_benefits = list_benefit
