def get(self): """ gets contracted transactions as per superclass, and attaches relevent invoice information """ data=TransactionCreator.get(self) for i in data: for j in i['Transactions']: self.cursor.execute("SELECT * from Invoices WHERE ContractedTransactionId = %(ContractedTransactionId)s",j) j['Invoices']=self.cursor.fetchall() return data
def __init__(self, databaseconnection, taskgroupid): """Initialise HarvesterTransactionCreator. Takes a DB-API Connection object and a task group id""" TransactionCreator.__init__(self,databaseconnection,taskgroupid) import TableConstructors TableConstructors.createInvoices(self.cursor)
if polist.addpurchaseorder({'PurchaseOrder':2342, 'ContractorId':23, 'StartDate':"3/4/89", 'EndDate':"3/4/99",'PropId':07, 'TaskGroupId':1}): for i in planlist.get(): polist.addpurchaseorderitem(join(con_d, {'PlanningItemId':i['PlanningItemId'], 'PurchaseOrder':2342, 'StartDate':"3/4/89", 'EndDate':"3/4/99"})); else: print "add failed for purchase order 2342" sys.exit(1) if polist.addpurchaseorder({'PurchaseOrder':1234, 'ContractorId':23, 'StartDate':"3/4/89", 'EndDate':"3/4/99",'PropId':07, 'TaskGroupId':1}): for i in planlist.get(): polist.addpurchaseorderitem(join(con_d, {'PlanningItemId':i['PlanningItemId'], 'PurchaseOrder':2342, 'StartDate':"3/4/89", 'EndDate':"3/4/99"})); else: print "add failed for purchase order 1234" sys.exit(1) from TransactionCreator import TransactionCreator tc=TransactionCreator(conn, other) polist.purchaseorder=2342 for i in polist.get()['PurchaseOrderItems']: tc.createtransaction({'ContractedItemId':i['ContractedItemId'], 'QtyCompleted':12, 'CompletionDate':30-12-2004}) from HarvesterTransactionCreator import HarvesterTransactionCreator htc=HarvesterTransactionCreator(conn,silv) for i in polist.get()['PurchaseOrderItems']: trans=htc.createtransaction({'ContractedItemId':i['ContractedItemId'], 'QtyCompleted':12, 'CompletionDate':30-12-2004}) htc.createinvoice(join(trans,{'InvoiceNo':732645})) from CertificateCreator import CertificateCreator certc=CertificateCreator(conn,2342) posscert= certc.get() print "Certifiable items for 2342:",posscert for i in posscert[:3]: