# Path: ratechecker/loader.py
# class AdjustmentLoader(Loader):
#     model_cls = Adjustment
# 
#     def make_instance(self, row):
#         adj_value = self.nullable_decimal(row["adjvalue"])
# 
#         return self.model_cls(
#             product_id=int(row["planid"]),
#             rule_id=int(row["ruleid"]),
#             affect_rate_type=row["affectratetype"],
#             adj_value=adj_value if adj_value is not None else 0,
#             min_loan_amt=self.nullable_decimal(row["minloanamt"]),
#             max_loan_amt=self.nullable_decimal(row["maxloanamt"].strip()),
#             prop_type=self.nullable_string(row["proptype"]),
#             min_fico=self.nullable_int(row["minfico"]),
#             max_fico=self.nullable_int(row["maxfico"]),
#             min_ltv=self.nullable_decimal(row["minltv"]),
#             max_ltv=self.nullable_decimal(row["maxltv"]),
#             state=row["state"],
#             data_timestamp=self.data_timestamp,
#         )
# 
# class ProductLoader(Loader):
#     model_cls = Product
# 
#     def make_instance(self, row):
#         return self.model_cls(
#             plan_id=int(row["planid"]),
#             institution=row["institution"],
#             loan_purpose=row["loanpurpose"],
#             pmt_type=row["pmttype"],
#             loan_type=row["loantype"],
#             loan_term=int(row["loanterm"]),
#             int_adj_term=self.nullable_int(row["intadjterm"]),
#             adj_period=self.nullable_int(row["adjperiod"]),
#             io=self.string_to_boolean(row["i/o"]),
#             arm_index=self.nullable_string(row["armindex"]),
#             int_adj_cap=self.nullable_int(row["initialadjcap"]),
#             annual_cap=self.nullable_int(row["annualcap"]),
#             loan_cap=self.nullable_int(row["loancap"]),
#             arm_margin=self.nullable_decimal(row["armmargin"]),
#             ai_value=self.nullable_decimal(row["aivalue"]),
#             min_ltv=Decimal(row["minltv"]).quantize(Decimal(".001")),
#             max_ltv=Decimal(row["maxltv"]).quantize(Decimal(".001")),
#             min_fico=int(row["minfico"]),
#             max_fico=int(row["maxfico"]),
#             min_loan_amt=Decimal(row["minloanamt"]),
#             max_loan_amt=Decimal(row["maxloanamt"]),
#             data_timestamp=self.data_timestamp,
#         )
# 
# class RateLoader(Loader):
#     model_cls = Rate
# 
#     def make_instance(self, row):
#         return self.model_cls(
#             rate_id=int(row["ratesid"]),
#             product_id=int(row["planid"]),
#             region_id=int(row["regionid"]),
#             lock=int(row["lock"]),
#             base_rate=Decimal(row["baserate"]),
#             total_points=Decimal(row["totalpoints"]),
#             data_timestamp=self.data_timestamp,
#         )
# 
# class RegionLoader(Loader):
#     model_cls = Region
# 
#     def make_instance(self, row):
#         return self.model_cls(
#             region_id=int(row["RegionID"]),
#             state_id=row["StateID"],
#             data_timestamp=self.data_timestamp,
#         )


import io
from collections import OrderedDict
from datetime import datetime, time
from xml.etree import cElementTree as ET
from zipfile import ZipFile
from django.utils import timezone
from django.utils.functional import cached_property
from ratechecker.loader import (
    AdjustmentLoader,
    ProductLoader,
    RateLoader,
    RegionLoader,
)




class Dataset(object):
    loaders = {
        "adjustment": AdjustmentLoader,

# Path: ratechecker/loader.py
# class AdjustmentLoader(Loader):
#     model_cls = Adjustment
# 
#     def make_instance(self, row):
#         adj_value = self.nullable_decimal(row["adjvalue"])
# 
#         return self.model_cls(
#             product_id=int(row["planid"]),
#             rule_id=int(row["ruleid"]),
#             affect_rate_type=row["affectratetype"],
#             adj_value=adj_value if adj_value is not None else 0,
#             min_loan_amt=self.nullable_decimal(row["minloanamt"]),
#             max_loan_amt=self.nullable_decimal(row["maxloanamt"].strip()),
#             prop_type=self.nullable_string(row["proptype"]),
#             min_fico=self.nullable_int(row["minfico"]),
#             max_fico=self.nullable_int(row["maxfico"]),
#             min_ltv=self.nullable_decimal(row["minltv"]),
#             max_ltv=self.nullable_decimal(row["maxltv"]),
#             state=row["state"],
#             data_timestamp=self.data_timestamp,
#         )
# 
# class ProductLoader(Loader):
#     model_cls = Product
# 
#     def make_instance(self, row):
#         return self.model_cls(
#             plan_id=int(row["planid"]),
#             institution=row["institution"],
#             loan_purpose=row["loanpurpose"],
#             pmt_type=row["pmttype"],
#             loan_type=row["loantype"],
#             loan_term=int(row["loanterm"]),
#             int_adj_term=self.nullable_int(row["intadjterm"]),
#             adj_period=self.nullable_int(row["adjperiod"]),
#             io=self.string_to_boolean(row["i/o"]),
#             arm_index=self.nullable_string(row["armindex"]),
#             int_adj_cap=self.nullable_int(row["initialadjcap"]),
#             annual_cap=self.nullable_int(row["annualcap"]),
#             loan_cap=self.nullable_int(row["loancap"]),
#             arm_margin=self.nullable_decimal(row["armmargin"]),
#             ai_value=self.nullable_decimal(row["aivalue"]),
#             min_ltv=Decimal(row["minltv"]).quantize(Decimal(".001")),
#             max_ltv=Decimal(row["maxltv"]).quantize(Decimal(".001")),
#             min_fico=int(row["minfico"]),
#             max_fico=int(row["maxfico"]),
#             min_loan_amt=Decimal(row["minloanamt"]),
#             max_loan_amt=Decimal(row["maxloanamt"]),
#             data_timestamp=self.data_timestamp,
#         )
# 
# class RateLoader(Loader):
#     model_cls = Rate
# 
#     def make_instance(self, row):
#         return self.model_cls(
#             rate_id=int(row["ratesid"]),
#             product_id=int(row["planid"]),
#             region_id=int(row["regionid"]),
#             lock=int(row["lock"]),
#             base_rate=Decimal(row["baserate"]),
#             total_points=Decimal(row["totalpoints"]),
#             data_timestamp=self.data_timestamp,
#         )
# 
# class RegionLoader(Loader):
#     model_cls = Region
# 
#     def make_instance(self, row):
#         return self.model_cls(
#             region_id=int(row["RegionID"]),
#             state_id=row["StateID"],
#             data_timestamp=self.data_timestamp,
#         )


# Path: ratechecker/dataset.py
import io
from collections import OrderedDict
from datetime import datetime, time
from xml.etree import cElementTree as ET
from zipfile import ZipFile
from django.utils import timezone
from django.utils.functional import cached_property
from ratechecker.loader import (
    AdjustmentLoader,
    ProductLoader,
    RateLoader,
    RegionLoader,
)





class Dataset(object):
    loaders = {
        "adjustment": AdjustmentLoader,

        "product": ProductLoader,