示例#1
0
def parseTransactionsXML(transXML):
	root = ET.XML(transXML)
	transList = []

	for transElem in root.iter(bt + "transaction"):
                transaction = Transaction(transElem.find(bt + "auth-seq").text)
                amtString = transElem.find(bt + "amount").text
                transaction.amount = float(amtString)
                
                invoice = transElem.find(bt + "invoice")
                if invoice is not None:
                        transaction.invoice = invoice.text
                        
                job = transElem.find(bt + "job-code")
                if job is not None:
                        transaction.job = job.text

                oldInvoice = transElem.find(bt + "original-invoice")
                if oldInvoice is not None:
                        transaction.oldInvoice = oldInvoice.text

                custElem = transElem.find(bt + "customer")
                transaction.cust = parseCustomerElement(custElem)
		
                transList.append(transaction)
	return transList
示例#2
0
def convertToTransaction(date, amount, memo, payee):
    t = Transaction()
    t.date = date
    t.amount = amount
    t.memo = memo
    t.payee = getPayee(date, amount, memo, payee)
    t.category = getCategory(date, amount, memo, payee)
    return t
示例#3
0
    def archive(self, *args):
        d = wx.TextEntryDialog(
            self, "Archive transactions before what date (mm/dd/yy)?",
            "Archive Date")
        if d.ShowModal() == wx.ID_OK:
            date = Date(d.GetValue())
        else:
            date = None
        d.Destroy()
        if not date: return
        archive = Asset()
        newcb_starttransaction = Transaction()
        newcb_starttransaction.amount = 0
        newcb_starttransaction.payee = "Starting Balance"
        newcb_starttransaction.memo = "Archived by PyAsset"
        newcb_starttransaction.state = "cleared"
        newcb_starttransaction.date = date

        newcb = Asset()
        newcb.filename = self.cur_transaction.filename
        newcb.name = self.cur_transaction.name
        newcb.append(newcb_starttransaction)
        archtot = 0

        for transaction in self.cur_transaction:
            if transaction.date < date and transaction.state == "cleared":
                archive.append(transaction)
                archtot += transaction.amount
            else:
                newcb.append(transaction)
        newcb_starttransaction.amount = archtot
        self.cur_transaction = newcb
        while 1:
            d = wx.FileDialog(self, "Save Archive As", "", "", "*.qif",
                              wx.SAVE)
            if d.ShowModal() == wx.ID_OK:
                fname = d.GetFilename()
                dir = d.GetDirectory()
            d.Destroy()
            if fname: break
        archive.write_qif(os.path.join(dir, fname))
        self.redraw_all(-1)
        self.edited = True
        return
示例#4
0
 def adjust_balance(self, diff):
     self.edited = 1
     transaction = Transaction()
     transaction.payee = "Balance Adjustment"
     transaction.amount = diff
     transaction.cleared = 1
     transaction.memo = "Adjustment"
     self.cur_transaction.append(transaction)
     self.redraw_all(-1)  # only redraw [-1]?
     return
示例#5
0
    def archive(self, *args):
        d = wx.TextEntryDialog(self,
                               "Archive transactions before what date (mm/dd/yy)?",
                               "Archive Date")
        if d.ShowModal() == wx.ID_OK:
            date = Date(d.GetValue())
        else:
            date = None
        d.Destroy()
        if not date: return
        archive = Asset()
        newcb_starttransaction = Transaction()
        newcb_starttransaction.amount = 0
        newcb_starttransaction.payee = "Starting Balance"
        newcb_starttransaction.memo = "Archived by PyAsset"
        newcb_starttransaction.cleared = 1
        newcb_starttransaction.date = date

        newcb = Asset()
        newcb.filename = self.cur_transaction.filename
        newcb.name = self.cur_transaction.name
        newcb.append(newcb_starttransaction)
        archtot = 0

        for transaction in self.cur_transaction:
            if transaction.date < date and transaction.cleared:
                archive.append(transaction)
                archtot += transaction.amount
            else:
                newcb.append(transaction)
        newcb_starttransaction.amount = archtot
        self.cur_transaction = newcb
        while 1:
            d = wx.FileDialog(self, "Save Archive As", "", "", "*.qif", wx.SAVE)
            if d.ShowModal() == wx.ID_OK:
                fname = d.GetFilename()
                dir = d.GetDirectory()
            d.Destroy()
            if fname: break
        archive.write_qif(os.path.join(dir, fname))
        self.redraw_all(-1)
        self.edited = 1
        return