def load_upfront(self, filename):
        with open(filename, 'rU') as csvfile:
            csvreader = csv.reader(csvfile, delimiter=',', quotechar='"')

            # Delete all items in tables
            Upfront.objects.all().delete()

            # Remove the first line which is the header line
            csvreader.next()

            for row in csvreader:

                loan_type, va_status, va_first_use, min_ltv, max_ltv, premium = row

                u = Upfront()
                
                u.loan_type = loan_type.strip().upper()
                u.va_status = va_status.strip().upper()
                u.va_first_use = va_first_use.strip().upper()
                u.min_ltv = Decimal(min_ltv)
                u.max_ltv = Decimal(max_ltv)
                u.premium = Decimal(premium)

                u.save()

            self.stdout.write('\nSuccessfully loaded data from %s\n\n' % filename)
    def load_upfront(self, filename):
        with open(filename, 'rU') as csvfile:
            csvreader = csv.reader(csvfile, delimiter=',', quotechar='"')

            # Delete all items in tables
            Upfront.objects.all().delete()

            # Remove the first line which is the header line
            csvreader.next()

            for row in csvreader:

                loan_type, va_status, va_first_use, min_ltv, max_ltv, premium = row

                u = Upfront()

                u.loan_type = loan_type.strip().upper()
                u.va_status = va_status.strip().upper()
                u.va_first_use = va_first_use.strip().upper()
                u.min_ltv = Decimal(min_ltv)
                u.max_ltv = Decimal(max_ltv)
                u.premium = Decimal(premium)

                u.save()

            self.stdout.write('\nSuccessfully loaded data from %s\n\n' %
                              filename)
Example #3
0
    def populate_db(self):
        """ Prepopulate DB with dummy data. """

        m_ins1_1 = Monthly(insurer='INS1',min_ltv=Decimal("30.001"),max_ltv=Decimal("70"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("1.4"))
        m_ins1_1.save()
        m_ins2_1 = Monthly(insurer='INS2',min_ltv=Decimal("30.001"),max_ltv=Decimal("70"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("1.6"))
        m_ins2_1.save()
        m_ins1_2 = Monthly(insurer='INS1',min_ltv=Decimal("20.001"),max_ltv=Decimal("30"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("0.523"))
        m_ins1_2.save()
        m_ins2_2 = Monthly(insurer='INS2',min_ltv=Decimal("20.001"),max_ltv=Decimal("30"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("0.642"))
        m_ins2_2.save()
        m_fha = Monthly(insurer='FHA',min_ltv=Decimal("20.001"),max_ltv=Decimal("70"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("0.85"))
        m_fha.save()

        u_fha = Upfront(loan_type='FHA',min_ltv=Decimal("0"), max_ltv=Decimal("80"),premium=Decimal("3.75"))
        u_fha.save()
        u_va_disabled = Upfront(loan_type='VA',va_status='DISABLED',min_ltv=Decimal("0"), max_ltv=Decimal("80"),premium=Decimal("1.5"))
        u_va_disabled.save()
        u_va_regular_y = Upfront(loan_type='VA',va_status='REGULAR',va_first_use='Y',min_ltv=Decimal("0"),max_ltv=Decimal("80"),premium=Decimal("2.0"))
        u_va_regular_y.save()
Example #4
0
    def populate_db(self):
        """ Prepopulate DB with dummy data. """

        m_ins1_1 = Monthly(insurer='INS1',
                           min_ltv=Decimal("30.001"),
                           max_ltv=Decimal("70"),
                           min_fico=700,
                           max_fico=740,
                           loan_term=30,
                           pmt_type='FIXED',
                           min_loan_amt=Decimal("400000"),
                           max_loan_amt=Decimal("1000000"),
                           premium=Decimal("1.4"))
        m_ins1_1.save()
        m_ins2_1 = Monthly(insurer='INS2',
                           min_ltv=Decimal("30.001"),
                           max_ltv=Decimal("70"),
                           min_fico=700,
                           max_fico=740,
                           loan_term=30,
                           pmt_type='FIXED',
                           min_loan_amt=Decimal("400000"),
                           max_loan_amt=Decimal("1000000"),
                           premium=Decimal("1.6"))
        m_ins2_1.save()
        m_ins1_2 = Monthly(insurer='INS1',
                           min_ltv=Decimal("20.001"),
                           max_ltv=Decimal("30"),
                           min_fico=700,
                           max_fico=740,
                           loan_term=30,
                           pmt_type='FIXED',
                           min_loan_amt=Decimal("400000"),
                           max_loan_amt=Decimal("1000000"),
                           premium=Decimal("0.523"))
        m_ins1_2.save()
        m_ins2_2 = Monthly(insurer='INS2',
                           min_ltv=Decimal("20.001"),
                           max_ltv=Decimal("30"),
                           min_fico=700,
                           max_fico=740,
                           loan_term=30,
                           pmt_type='FIXED',
                           min_loan_amt=Decimal("400000"),
                           max_loan_amt=Decimal("1000000"),
                           premium=Decimal("0.642"))
        m_ins2_2.save()
        m_fha = Monthly(insurer='FHA',
                        min_ltv=Decimal("20.001"),
                        max_ltv=Decimal("70"),
                        min_fico=700,
                        max_fico=740,
                        loan_term=30,
                        pmt_type='FIXED',
                        min_loan_amt=Decimal("400000"),
                        max_loan_amt=Decimal("1000000"),
                        premium=Decimal("0.85"))
        m_fha.save()

        u_fha = Upfront(loan_type='FHA',
                        min_ltv=Decimal("0"),
                        max_ltv=Decimal("80"),
                        premium=Decimal("3.75"))
        u_fha.save()
        u_va_disabled = Upfront(loan_type='VA',
                                va_status='DISABLED',
                                min_ltv=Decimal("0"),
                                max_ltv=Decimal("80"),
                                premium=Decimal("1.5"))
        u_va_disabled.save()
        u_va_regular_y = Upfront(loan_type='VA',
                                 va_status='REGULAR',
                                 va_first_use='Y',
                                 min_ltv=Decimal("0"),
                                 max_ltv=Decimal("80"),
                                 premium=Decimal("2.0"))
        u_va_regular_y.save()