| 1 |
nino.borges |
515 |
"""
|
| 2 |
|
|
|
| 3 |
|
|
MCP_Reporting
|
| 4 |
|
|
|
| 5 |
|
|
Created by
|
| 6 |
|
|
Emanuel Borges
|
| 7 |
|
|
01.20.2014
|
| 8 |
|
|
|
| 9 |
|
|
This class will hold all of the reporting that you can do with the MCP.
|
| 10 |
|
|
|
| 11 |
|
|
"""
|
| 12 |
|
|
|
| 13 |
|
|
import os
|
| 14 |
|
|
|
| 15 |
|
|
class Reports():
|
| 16 |
|
|
"""Main Reporting Class"""
|
| 17 |
|
|
def __init__(self,dbObj):
|
| 18 |
|
|
self.dbObj = dbObj
|
| 19 |
|
|
self.tempDir = os.getenv('TEMP')
|
| 20 |
nino.borges |
531 |
print self.tempDir
|
| 21 |
nino.borges |
515 |
self.reportFileName = "MCP_Report.csv"
|
| 22 |
nino.borges |
531 |
self.tpmMatrix = self.dbObj.RetrieveAllTPMMatrix()
|
| 23 |
nino.borges |
515 |
def CreateTpmActiveCaseReport(self, TPM):
|
| 24 |
|
|
"""Returns a report that shows all active cases for a TPM"""
|
| 25 |
nino.borges |
531 |
empID = self.tpmMatrix[TPM][0]
|
| 26 |
nino.borges |
515 |
activeCases = self.dbObj.RetrieveMyActiveCaseList(empID)
|
| 27 |
nino.borges |
531 |
headderRow = '''"Client Matter","CaseName","Platform","Chargable Case?","Disclosure Letter On File","Upload Rate","Storage Rate","Disclosure Letter Link","Processing Vendor","Scanning Vendor","Hosting Vendor"\n'''
|
| 28 |
|
|
outputFile = open(os.path.join(self.tempDir,self.reportFileName),'w')
|
| 29 |
|
|
outputFile.write(headderRow)
|
| 30 |
|
|
matrix = {}
|
| 31 |
|
|
for clm in activeCases:
|
| 32 |
|
|
caseName = self.dbObj.GetCaseName(clm)
|
| 33 |
|
|
disclosureLetterOnFile,disclosureLetterLink = self.dbObj.GetDisclosureLetter(clm)
|
| 34 |
|
|
processingVendor,scanningVendor,hostingVendor = self.dbObj.GetResponsibleVendorTpl(clm)
|
| 35 |
|
|
if disclosureLetterOnFile:
|
| 36 |
|
|
disclosureLetterOnFile = "Yes"
|
| 37 |
|
|
else:
|
| 38 |
|
|
disclosureLetterOnFile = "No"
|
| 39 |
|
|
chargableCase = self.dbObj.GetChargable(clm)
|
| 40 |
|
|
if chargableCase:
|
| 41 |
|
|
chargableCase = "yes"
|
| 42 |
|
|
else:
|
| 43 |
|
|
chargableCase = "No"
|
| 44 |
|
|
reviewPlatform = self.dbObj.GetReviewPlatform(clm)
|
| 45 |
|
|
uploadRate = self.dbObj.GetUploadCostRate(clm)
|
| 46 |
|
|
if uploadRate:
|
| 47 |
|
|
uploadRate = "$"+ str(uploadRate)
|
| 48 |
|
|
storageRate = self.dbObj.GetStorageCostRate(clm)
|
| 49 |
|
|
if storageRate:
|
| 50 |
|
|
storageRate = "$"+str(storageRate)
|
| 51 |
|
|
|
| 52 |
|
|
outputFile.write('"=""%s""","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s"\n'%(clm,caseName,reviewPlatform,chargableCase,disclosureLetterOnFile,uploadRate,storageRate,disclosureLetterLink,processingVendor,scanningVendor,hostingVendor))
|
| 53 |
nino.borges |
515 |
outputFile.close()
|
| 54 |
nino.borges |
531 |
return activeCases, os.path.join(self.tempDir,self.reportFileName)
|
| 55 |
|
|
|
| 56 |
nino.borges |
515 |
def CreateTpmAllCaseReport(self,TPM):
|
| 57 |
|
|
"""Returns a report that shows all cases for a TPM"""
|
| 58 |
nino.borges |
531 |
empID = self.tpmMatrix[TPM][0]
|
| 59 |
nino.borges |
515 |
allTPMCases = self.dbObj.RetrieveMyCaseList(empID)
|
| 60 |
nino.borges |
531 |
headderRow = '''"Client Matter","CaseName","Status","Platform","Chargable Case?","Disclosure Letter On File","Upload Rate","Storage Rate","Disclosure Letter Link","Processing Vendor","Scanning Vendor","Hosting Vendor"\n'''
|
| 61 |
|
|
outputFile = open(os.path.join(self.tempDir,self.reportFileName),'w')
|
| 62 |
|
|
outputFile.write(headderRow)
|
| 63 |
|
|
matrix = {}
|
| 64 |
|
|
for clm in allTPMCases:
|
| 65 |
|
|
caseName = self.dbObj.GetCaseName(clm)
|
| 66 |
|
|
caseStatus = self.dbObj.GetCaseStatus(clm)
|
| 67 |
|
|
processingVendor,scanningVendor,hostingVendor = self.dbObj.GetResponsibleVendorTpl(clm)
|
| 68 |
|
|
disclosureLetterOnFile,disclosureLetterLink = self.dbObj.GetDisclosureLetter(clm)
|
| 69 |
|
|
if disclosureLetterOnFile:
|
| 70 |
|
|
disclosureLetterOnFile = "Yes"
|
| 71 |
|
|
else:
|
| 72 |
|
|
disclosureLetterOnFile = "No"
|
| 73 |
|
|
chargableCase = self.dbObj.GetChargable(clm)
|
| 74 |
|
|
if chargableCase:
|
| 75 |
|
|
chargableCase = "yes"
|
| 76 |
|
|
else:
|
| 77 |
|
|
chargableCase = "No"
|
| 78 |
|
|
reviewPlatform = self.dbObj.GetReviewPlatform(clm)
|
| 79 |
|
|
uploadRate = self.dbObj.GetUploadCostRate(clm)
|
| 80 |
|
|
if uploadRate:
|
| 81 |
|
|
uploadRate = "$"+ str(uploadRate)
|
| 82 |
|
|
storageRate = self.dbObj.GetStorageCostRate(clm)
|
| 83 |
|
|
if storageRate:
|
| 84 |
|
|
storageRate = "$"+str(storageRate)
|
| 85 |
|
|
## To keep excel from autoformating the clm, I used the trick below
|
| 86 |
|
|
outputFile.write('"=""%s""","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s"\n'%(clm,caseName,caseStatus,reviewPlatform,chargableCase,disclosureLetterOnFile,uploadRate,storageRate,disclosureLetterLink,processingVendor,scanningVendor,hostingVendor))
|
| 87 |
nino.borges |
515 |
|
| 88 |
|
|
outputFile.close()
|
| 89 |
nino.borges |
531 |
return allTPMCases,os.path.join(self.tempDir,self.reportFileName)
|
| 90 |
nino.borges |
515 |
|
| 91 |
nino.borges |
531 |
def CreateUnassignedCaseReport(self):
|
| 92 |
|
|
"""Returns a report that shows all unassigned cases"""
|
| 93 |
|
|
outputFile = open(os.path.join(self.tempDir,self.reportFileName),'w')
|
| 94 |
|
|
headderRow = '''"Client Matter","CaseName","TPM","Case Status","Platform"\n'''
|
| 95 |
|
|
caseList = self.dbObj.RetrieveUnassignedCaseList()
|
| 96 |
|
|
|
| 97 |
|
|
outputFile.write(headderRow)
|
| 98 |
|
|
matrix = {}
|
| 99 |
|
|
for clm in caseList:
|
| 100 |
|
|
caseName = self.dbObj.GetCaseName(clm)
|
| 101 |
|
|
respTpm = self.dbObj.GetResponsibleTPM(clm)
|
| 102 |
|
|
reviewPlatform = self.dbObj.GetReviewPlatform(clm)
|
| 103 |
|
|
caseStatus = self.dbObj.GetCaseStatus(clm)
|
| 104 |
|
|
|
| 105 |
|
|
outputFile.write('"=""%s""","%s","%s","%s","%s"\n'%(clm,caseName,respTpm,caseStatus,reviewPlatform))
|
| 106 |
|
|
outputFile.close()
|
| 107 |
|
|
return caseList, os.path.join(self.tempDir,self.reportFileName)
|
| 108 |
nino.borges |
515 |
|