Example #1
0
    def result2transaction(self, result, parentObj, linkedTransaction=None, recurringCache=None):
        tid, pid, amount, description, date, linkId, recurringId = result
        t = Transaction(tid, parentObj, amount, description, date)

        # Handle a linked transaction being passed in, a special case called from a few lines down.
        if linkedTransaction:
            t.LinkedTransaction = linkedTransaction
        else:
            # Handle recurring parents.
            if recurringId:
                t.RecurringParent = recurringCache[recurringId]

            # Handle linked transactions.
            if linkId:
                try:
                    link, linkAccount = self.getTransactionAndParentById(linkId, parentObj, t)
                except MissingLinkException:
                    # The link is gone, it's Account was likely deleted before LP: #514183/605591 was fixed. Remove it.
                    t.LinkedTransaction = None
                else:
                    # If the link parent hasn't loaded its transactions yet, put this in its pre list so this
                    # object is used if and when they are loaded.
                    if linkAccount._Transactions is None:
                        linkAccount._preTransactions.append(link)
                    t.LinkedTransaction = link
                    # Synchronize the RecurringParent attribute.
                    t.LinkedTransaction.RecurringParent = t.RecurringParent
        return t
Example #2
0
    def result2transaction(self,
                           result,
                           parentObj,
                           linkedTransaction=None,
                           recurringCache=None):
        tid, pid, amount, description, date, linkId, recurringId = result
        t = Transaction(tid, parentObj, amount, description, date)

        # Handle a linked transaction being passed in, a special case called from a few lines down.
        if linkedTransaction:
            t.LinkedTransaction = linkedTransaction
        else:
            # Handle recurring parents.
            if recurringId:
                t.RecurringParent = recurringCache[recurringId]

            # Handle linked transactions.
            if linkId:
                try:
                    link, linkAccount = self.getTransactionAndParentById(
                        linkId, parentObj, t)
                except MissingLinkException:
                    # The link is gone, it's Account was likely deleted before LP: #514183/605591 was fixed. Remove it.
                    t.LinkedTransaction = None
                else:
                    # If the link parent hasn't loaded its transactions yet, put this in its pre list so this
                    # object is used if and when they are loaded.
                    if linkAccount._Transactions is None:
                        linkAccount._preTransactions.append(link)
                    t.LinkedTransaction = link
                    # Synchronize the RecurringParent attribute.
                    t.LinkedTransaction.RecurringParent = t.RecurringParent
        return t