Esempio n. 1
0
    def test_avg_deal_close(self):
        """
        Tracks the days bewteen engagement date and deal closing
        """

        self.t1.engage_date = '2011-05-01'
        self.nl1.lease_execution_date = '2011-05-02'

        self.t2.engage_date = '2011-05-01'
        self.nl2.lease_execution_date = '2011-05-03'

        self.store.commit()
        
        r = Report(trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.avg_days_deal_close, Dec('1.5'))

       
        #missing data from one transaction, result should not be affectd.

        self.t3.engage_date = '2011-05-01'
        self.store.commit()

        r = Report(trans_obj='acquisition')
        r.buildReport()
        
        self.assertEqual(r.avg_days_deal_close, Dec('1.5'))
Esempio n. 2
0
    def test_meet_bov_timing(self):
        """
        Test percentage of bov timing that meet or exceeded expectations
        """
        
        self.build_disp()

        self.sl1.bov_expected_timing = 10
        self.sl1.bov_actual_timing = 9

        self.sl2.bov_expected_timing = 10
        self.sl2.bov_actual_timing = 10
        
        self.sl3.bov_expected_timing = 10
        self.sl3.bov_actual_timing = 11

        self.store.commit()

        r = Report(trans_obj='disposition')
        r.buildReport()

        self.assertEqual(r.meet_bov_timing, Dec('66.67'))

        self.sl3.bov_actual_timing = 10
        self.store.commit()
        
        r = Report(trans_obj='disposition')
        r.buildReport()
        
        self.assertEqual(r.meet_bov_timing, Dec('100.0'))
Esempio n. 3
0
    def test_build_report(self):
        """
        testing the report finds the correct amount of transactions
        """

        r = Report(trans_obj='acquisition')
        r.buildReport()
        self.assertEqual(r.trans.count(), 3)
Esempio n. 4
0
    def test_avg_value_add(self):
        """
        Testing the average value added of all transactions in the report
        """
        self.nl1.value_add = 25
        self.nl2.value_add = 50
        self.store.commit()

        r = Report(trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.avg_value_add, Dec('37.5'))
Esempio n. 5
0
    def test_avg_base_rent(self):
        """
        Determines the avg base rent across transactions
        """
        
        self.nl1.average_base_rent = 1523.34
        self.nl2.average_base_rent = 32152.56

        self.store.commit()

        r = Report(trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.avg_base_rent, Dec('16837.95'))
Esempio n. 6
0
    def test_num_of_surveys(self):
        """
        Total count of surveys from transactions
        """

        self.t1.survey_id = '1'
        self.t2.survey_id = '2'

        self.store.commit()

        r = Report(trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.num_survey_responses, 2)
Esempio n. 7
0
    def POST(self):
        
        i = web.input(comp_cbox=[], div_cbox=[], reg_cbox=[], area_cbox=[])
        
        reports = []

        report = Report(client_id=i.client_id, trans_obj=i.trans_obj)
        report.buildReport()
        reports.append(report)

        if i.trans_obj == 'acquisition':
            return jrender('/dashboard/acq_report.html', {'reports':reports})
        else:
            return jrender('/dashboard/disp_report.html', {'reports':reports})
Esempio n. 8
0
    def test_rfp_on_time(self):
        """
        checks the percentage of rfps on time
        """
        
        self.nl1.rfp_on_time = True
        self.nl2.rfp_on_time = True
        self.nl3.rfp_on_time = False

        self.store.commit()

        r = Report(trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.rfp_ontime, Dec('66.67'))
Esempio n. 9
0
    def test_survey_ratio(self):
        """
        ratio of transactions with surveys
        """

        self.t1.survey_sent = '2011-05-01'
        self.t1.survey_id = 1

        self.t2.survey_sent = '2011-05-01'

        self.store.commit()
       
        r = Report(trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.survey_resp_ratio, Dec('50.0'))
Esempio n. 10
0
    def test_total_recovery(self):
        """
        Tracks the total dollars recovered from dispositions
        """

        self.build_disp()

        self.sl1.actual_recovery = 1000.67
        self.sl2.actual_recovery = 4000.14

        self.s1.sale_price = 20000.00
        self.store.commit()

        r = Report(trans_obj='disposition')
        r.buildReport()

        self.assertEqual(r.total_recovery, Dec('25000.81'))
Esempio n. 11
0
    def test_avg_time_on_market(self):
        """
        This smells like a duplicate to me
        """

        self.t1.engage_date = '2011-05-01'
        self.nl1.lease_execution_date = '2011-05-02'

        self.t2.engage_date = '2011-05-01'
        self.nl2.lease_execution_date = '2011-05-03'

        self.store.commit()

        r = Report(trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.avg_time_on_market, Dec('1.5'))
Esempio n. 12
0
    def test_market_survey_ontime(self):
        """
        Test that the market survey on time percentage is correct
        """
        self.t1.engage_date = '2011-05-01'
        self.t2.engage_date = '2011-05-01'

        self.nl1.market_survey = True
        self.nl1.market_survey_date = '2011-05-03'

        self.nl2.market_survey = True
        self.nl2.market_survey_date = '2011-06-15'

        self.store.commit()

        r = Report(trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.market_survey_ontime, Dec('50.0'))
Esempio n. 13
0
    def test_meet_bov_recovery(self):
        """
        Test percentage of bov recovery that meet or exceeded expectations
        """

        self.build_disp()

        self.sl1.actual_recovery = 1000
        self.sl2.actual_recovery = 500

        self.sl1.expected_recovery = 700
        self.sl2.expected_recovery = 600
        
        self.store.commit()

        r = Report(trans_obj='disposition')
        r.buildReport()

        self.assertEqual(r.meet_bov_recovery, Dec('50.0'))
Esempio n. 14
0
    def test_bov_on_time(self):
        """
        Number of BOVs compared to BOVs ontime
        """

        self.build_disp()

        self.sl1.bov_ontime = True
        self.sl2.bov_ontime = False
        self.sl3.bov_ontime = True

        self.sl1.bov_date = '2011-05-11'
        self.sl2.bov_date = '2011-05-11'
        self.sl3.bov_date = '2011-05-11'

        self.store.commit()

        r = Report(trans_obj='disposition')
        r.buildReport()

        self.assertEqual(r.bov_on_time, Dec('66.67'))
Esempio n. 15
0
    def test_build_report_transactions(self):
        """
        I test that a report can be generated soley on company, division or region
        """
        
        t1 = self.fstore(Transaction())
        t1.company_id = self.comp1.id
        t1.division_id = self.div1.id
        t1.trans_type = u'New Lease'

        t2 = self.fstore(Transaction())
        t2.company_id = self.comp1.id
        t2.division_id = 23
        t2.trans_type = u'New Lease'

    
        t3 = self.fstore(Transaction())
        t3.company_id = self.comp1.id
        t3.division_id = self.div1.id
        t3.region_id = self.reg1.id
        t3.trans_type = u'New Lease'

        self.store.commit()

        r = Report(companies=[self.comp1.id], divisions=[self.div1.id])
        r.buildReport()
        self.assertEqual(r.trans.count(), 2)

        r = Report(companies=[self.comp1.id])
        r.buildReport()
        self.assertEqual(r.trans.count(), 3)

        r = Report(companies=[self.comp1.id], divisions=[self.div1.id], regions=[self.reg1.id])
        r.buildReport()
        self.assertEqual(r.trans.count(), 1)
Esempio n. 16
0
    def test_sqft_reduction(self):
        """
        testing the net difference btween old sqft and new sqft
        """

        self.nl1.old_sqft = 100
        self.nl1.new_sqft = 75
        
        self.nl2.old_sqft = 400
        self.nl2.new_sqft = 200
        
        self.store.commit()

        r = Report(trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.sqft_reduction, 225)

        #missing data from one transaction, result should not be affected.

        self.nl3.old_sqft = 400
        self.store.commit()

        self.assertEqual(r.sqft_reduction, 225)
Esempio n. 17
0
    def POST(self):
        i = web.input(comp_cbox=[], div_cbox=[], reg_cbox=[], area_cbox=[])
        
        reports = []
        
        # COMBINED REPORT
        if i.display == 'Combined':
            report = Report(client_id=i.client_id, companies=i.comp_cbox, divisions=i.div_cbox, regions=i.reg_cbox, areas=i.area_cbox, trans_obj=i.trans_obj, fiscal=i.fiscal)
            report.buildReport()
            reports.append(report)

        # SEPERATE REPORT
        else:
            for cid in i.comp_cbox:
                report = Report(client_id=i.client_id, companies=[cid], trans_obj=i.trans_obj, fiscal=i.fiscal)
                report.buildReport()
                reports.append(report)

            for did in i.div_cbox:
                report = Report(client_id=i.client_id, divisions=[did], trans_obj=i.trans_obj, fiscal=i.fiscal)
                report.buildReport()
                reports.append(report)
            
            for rid in i.reg_cbox:
                report = Report(client_id=i.client_id, regions=[rid], trans_obj=i.trans_obj, fiscal=i.fiscal)
                report.buildReport()
                reports.append(report)

            for aid in i.area_cbox:
                report = Report(client_id=i.client_id, areas=[aid], trans_obj=i.trans_obj, fiscal=i.fiscal)
                report.buildReport()
                reports.append(report)



        if i.trans_obj == 'acquisition':
            if i.export == 'PDF':
                html = jrender('/dashboard/acq_report_pdf.html', {'reports':reports})
                tmp = tempfile.TemporaryFile('w+b', prefix='tmp', suffix='.pdf')
                pdf = pisa.CreatePDF(str(html), tmp, '/var/www/webapps/static/')
                
                tmp.seek(0, 2)
                filesize = tmp.tell()
                tmp.seek(0)

                if pdf.err:
                    print 'PDF ERROR'
                if pdf.warn:
                    print 'WARNING'

                web.header('Content-Length', filesize)
                web.header('Content-Type', 'application/pdf')
                web.header('Content-Disposition', 'attachment; filename=%s' % 'Report.pdf')
                return tmp.read()

            if i.export == 'XLS':
                sheets = []
                for r in reports:
                    sheets.append(r.buildExcelData())

                xls = make_excel(sheets)

                xls.seek(0, 2)
                filesize = xls.tell()
                xls.seek(0)
                
                web.header('Content-Length', filesize)
                web.header('Content-Type', 'application/excel')
                web.header('Content-Disposition', 'attachment; filename=%s' % 'Report.xls')

                return xls.read()


                    


            return jrender('/dashboard/acq_report.html', {'reports':reports})
        else:
            return jrender('/dashboard/disp_report.html', {'reports':reports})
Esempio n. 18
0
    def test_build_report_transactions_expressions(self):
        """
        I test that we can build some basic expressions on the transaction obj
        """
        
        t1 = self.fstore(Transaction())
        t1.company_id = self.comp1.id
        t1.trans_type = 'New Lease'
        t1.trans_manager = 3

        t2 = self.fstore(Transaction())
        t2.company_id = self.comp1.id
        t2.trans_type = 'New Lease'
        t2.trans_manager = 1

    
        t3 = self.fstore(Transaction())
        t3.company_id = self.comp1.id

        self.store.commit()
        
        # ONE FILTER == CONSTRAINT
        filters = {
            'objects':['Transaction'],
            'fields':['ttpe'], 
            'constraints':['=='], 
            'args':['New Lease'],
            'operators':['none']}


        r = Report(companies=[self.comp1.id], filters=filters)
        r.buildReport()
        
        self.assertEqual(r.trans.count(), 2)
        # TWO FILTERS
        filters = {
            'objects':['Transaction', 'Transaction'],
            'fields':['ttpe', 'tman'], 
            'constraints':['==', '=='], 
            'args':['New Lease', '1'],
            'operators':['none','and']}

        r = Report(companies=[self.comp1.id], filters=filters)
        r.buildReport()

        self.assertEqual(r.trans.count(), 1)
        
        # THREE FILTERS NO RESULTS
        filters = {
            'objects':['Transaction', 'Transaction', 'Transaction'],
            'fields':['ttpe', 'tman', 'eda'], 
            'constraints':['==', '==', '=='], 
            'args':['New Lease', '1', '05-15-2011'],
            'operators':['none','and', 'and']}

        r = Report(companies=[self.comp1.id], filters=filters)
        r.buildReport()

        self.assertEqual(r.trans.count(), 0)
        
        
        # THREE FILTERS
        filters = {
            'objects':['Transaction', 'Transaction', 'Transaction'],
            'fields':['ttpe', 'tman', 'eda'], 
            'constraints':['==', '==', '=='], 
            'args':['New Lease', '1', '05-15-2011'],
            'operators':['none','and', 'and']}
        
        t2.engage_date = '05-15-2011'
        self.store.commit()

        r = Report(companies=[self.comp1.id], filters=filters)
        r.buildReport()
        self.assertEqual(r.trans.count(), 1)

        
        # SINGLE FILTER < CONSTRAINT
        filters = {
            'objects':['Transaction'],
            'fields':['eda'], 
            'constraints':['<'], 
            'args':['05-20-2011'],
            'operators':['none']}
        
        r = Report(companies=[self.comp1.id], filters=filters)
        r.buildReport()
        
        self.assertEqual(r.trans.count(), 1)
        self.assertEqual(r.trans.one().trans_manager, 1)
Esempio n. 19
0
    def test_build_report_acq_expressions(self):
        """
        I test that we can build some basic expressions on the acq obj
        """
        t1 = self.fstore(Transaction())  
        nl1 = self.fstore(NewLease())
        self.store.commit()
        t1.company_id = self.comp1.id
        t1.trans_type = 'New Lease'
        t1.trans_manager = 3
        nl1.old_sqft = 100
        nl1.trans_id = t1.id
        
        t2 = self.fstore(Transaction())
        nl2 = self.fstore(NewLease())
        self.store.commit()
        t2.company_id = self.comp1.id
        t2.trans_type = 'New Lease'
        t2.trans_manager = 1
        nl2.old_sqft = 200
        nl2.trans_id = t2.id

        t3 = self.fstore(Transaction())
        le1 = self.fstore(LeaseExtension())
        self.store.commit()
        t3.company_id = self.comp1.id
        t3.trans_type = 'Lease Extension'
        t3.trans_manager = 1

        le1.market_survey_date = '05-15-2011'
        le1.old_sqft = 100
        le1.trans_id = t3.id
        

        self.store.commit()
        
        # ONE FILTER == CONSTRAINT
        filters = {
            'objects':['New Lease'],
            'fields':['nl2'], 
            'constraints':['=='], 
            'args':['100'],
            'operators':['none']}


        r = Report(companies=[self.comp1.id], filters=filters, trans_obj='acquisition')
        r.buildReport()
        self.assertEqual(r.trans.count(), 1)

        # TWO FILTERS
        filters = {
            'objects':['New Lease', 'New Lease'],
            'fields':['nl2', 'nl2'], 
            'constraints':['>', '>'], 
            'args':['500', '101'],
            'operators':['none','or']}


        r = Report(companies=[self.comp1.id], filters=filters, trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.trans.count(), 1)
        
        
        # FOUR FILTERS TWO OBJECTS
        filters = {
            'objects':['Transaction', 'Transaction', 'New Lease', 'New Lease'],
            'fields':['ttpe', 'tman', 'nl6', 'nl2'], 
            'constraints':['==', '==', '==', '<'], 
            'args':['New Lease', '1', '05-15-2011', '300'],
            'operators':['none','and', 'and', 'and']}

        nl2.market_survey_date = '05-15-2011'
        self.store.commit()

        r = Report(companies=[self.comp1.id], filters=filters, trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.trans.count(), 1)
        
        # FOUR FILTERS TWO OBJECTS
        filters = {
            'objects':[
                'Transaction', 'Transaction', 'Transaction', 
                'New Lease', 'Lease Extension', 'New Lease',
                'Lease Extension'],
            'fields':['ttpe', 'ttpe', 'tman', 'nl6', 'le6', 'nl2', 'le2'], 
            'constraints':['==', '==', '==', '==', '==', '<', '<'], 
            'args':['New Lease', 'Lease Extension', '1', '05-15-2011', '05-15-2011', '300', '300'],
            'operators':['none','or', 'and', 'and', 'or', 'and', 'or']}

        r = Report(companies=[self.comp1.id], filters=filters, trans_obj='acquisition')
        r.buildReport()

        self.assertEqual(r.trans.count(), 2)