コード例 #1
0
ファイル: liquids_illiquids.py プロジェクト: robertbetts/Kew
 def run(self):
     self.tmpl = resource_filename("kew.pe.utils","liquids_illiquids.html")
     args = {
         'cols' : ['Group', 'Holding Description', 'Quantity', 'Curr', 'Mkt Price Local',
                   'Current Value (USD)', 'Valuation Method', 'ADT Volume', 'VAR'],
         'headers' : { 
             'Group' : {'name' : 'Group', 
                                      'class':'text', 
                                      '_fmt' : fmtdata1},
             'Holding Description' : {'name' : 'Holding', 
                                      'class':'text', 
                                      '_fmt' : fmtdata1},
             'Quantity' : {'name' : 'Quantity', 
                           'class':'number', 
                           '_fmt' : lambda a: fmtdata1(a, 0)},                
             'Curr' : {'name' : 'Currency', 
                       'class':'text', 
                       '_fmt' : fmtdata1},
             'Mkt Price Local' : {'name' : 'Price (Local Currency)', 
                          'class':'number', 
                          '_fmt' : lambda a: fmtdata1(a, 2)},                
             'Current Value (USD)' : {'name' : 'Current Value (USD)', 
                                      'class':'number', 
                                      '_fmt' : fmtdata1},
             'Valuation Method' : {'name' : 'Valuation Method', 
                                   'class':'text', 
                                   '_fmt' : fmtdata1},
             'ADT Volume' : {'name' : 'ADT Volume', 
                             'class':'number', 
                             '_fmt' : lambda a: fmtdata1(a, 0)},                
             'VAR' : {'name' : 'Value At Risk', 
                          'class':'number',
                          '_fmt' : lambda a: fmtdata1(a, 0)},                
         },
         'asof' : self._asof.strftime('%A, %d %B %Y') ,
         'rows'  : [],
         '_fmt' : fmtdata1,
     }
        
     file_data = self.parse_file(self.src_file)
     
     args["sheader"] = file_data.get("sheader", [])
     args["sdata"] = file_data.get("sdata", [])
     
     args['rows'] = file_data['rows']
     
     self._gen_report_(args)    
     
     # Now convert it to a pdf file
     pdf_output = self.outputfile.replace('.html', '.pdf')
     pdfargs = ['--username','corp\\reportingdb', '--password','&AdRekAd'] 
     htmltopdf([os.path.abspath(self.outputfile)], os.path.abspath(pdf_output), orientation='landscape', pdfargs=pdfargs)              
コード例 #2
0
ファイル: exceptions.py プロジェクト: robertbetts/Kew
    def run(self):
        self.tmpl = resource_filename("kew.pe.utils","exceptions.html")
        args = {
            'cols' : ['deal', 'entity', 'bank', 'account_type', 'account', 'iban', 'currency', 'balance', 'collateral', 'fx', 'bal_usd', 'subtotal', 'total', 'balance_date', 'age'],
            'headers' : { 
                'deal' : {'name' : 'Deal', 
                          'class':'text', 
                          '_fmt' : fmtdata1},
                'entity' : {'name' : 'Entity', 
                            'class':'text', 
                            '_fmt' : fmtdata1},
                'bank' : {'name' : 'Bank', 
                          'class':'text', 
                          '_fmt' : fmtdata1},
                'account' : {'name' : 'Account#',
                             'class':'text', 
                             '_fmt' : fmtdata1},
                'account_type' : {'name' : 'Account Type', 
                             'class':'text', 
                             '_fmt' : fmtdata1},
                'iban' : {'name' : 'IBAN',
                             'class':'text', 
                             '_fmt' : fmtdata1},
                'currency' : {'name' : 'CCY', 
                              'class':'text', 
                              '_fmt' : fmtdata1},
                'balance' : {'name' : 'Balance', 
                             'class':'number',
                             '_fmt' : lambda a: fmtdata1(a, 0)},
                'collateral' : {'name' : 'Collateral', 
                             'class':'number',
                             '_fmt' : lambda a: fmtdata1(a, 0)},                   
                'fx' : {'name' : 'FX Rate', 
                        'class':'number', 
                        '_fmt' : lambda a: fmtdata1(a, 4)},
                'bal_usd' : {'name' : 'USD Equiv.', 
                             'class':'number', 
                             '_fmt' : lambda a: fmtdata1(a, 0, '$')},
                'subtotal' : {'name' : 'Sub Total', 
                             'class':'number',
                             '_fmt' : lambda a : fmtdata1(a, 0, '$')},
                'total' : {'name' : 'Total', 
                             'class':'number',
                             '_fmt' : lambda a : fmtdata1(a, 0, '$')},
                'balance_date' : {'name' : 'Balance Date', 
                         'class':'text', 
                         '_fmt' : fmtdata1},
                'age' : {'name' : 'Aged', 
                         'class':'number', 
                         '_fmt' : lambda a: fmtdata1(a, 0)},
            },
            'asof' : self._asof.strftime('%A, %d %B %Y') ,
            'acc_info': []

        }
        # Note - CRM url is hard coded!
        control = Control(file_archive=None, db_url=self._dburl)
        aged, no_data, dropped, age_limit = control.fetch_cash_exception_data()
        args['acc_info'] = ((aged, "Aged Accounts (Balances older than %s days)" % age_limit, "No old balances to report"),
                            (no_data, "Accounts that have never had a balance", "All accounts have a balance."),
                            (dropped, "Automatic accounts not loading automatically (Balance >1 day old)", "No old balances to report")
                            )
        self._gen_report_(args)
        
        # Now convert it to a pdf file
        pdf_output = self.outputfile.replace('.html', '.pdf')
        pdfargs = ['--username','corp\\reportingdb', '--password','&AdRekAd'] 
        htmltopdf([os.path.abspath(self.outputfile)], os.path.abspath(pdf_output), orientation='landscape', pdfargs=pdfargs)