nodes: 0, module; 1, function_definition; 2, function_name:setTransactions; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, dictionary_splat_pattern; 8, expression_statement; 9, function_definition; 10, try_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier:args; 15, identifier:kwargs; 16, comment:"""Adds the transactions for this loan to a 'transactions' field.
  
          Transactions are MambuTransaction objects.
  
          Transactions get sorted by transaction id.
  
          Returns the number of requests done to Mambu.
  
  .. todo:: since pagination logic was added, is not always true that
            just 1 request was done. It may be more! But since request
            counter singleton holds true information about how many requests
            were done to Mambu, in fact this return value may be obsolete
          """; 17, function_name:transactionid; 18, parameters; 19, block; 20, block; 21, except_clause; 22, assignment; 23, assignment; 24, integer:1; 25, identifier:transaction; 26, expression_statement; 27, try_statement; 28, expression_statement; 29, as_pattern; 30, block; 31, attribute; 32, call; 33, subscript; 34, identifier:trans; 35, comment:"""Util function used for sorting transactions according to id"""; 36, block; 37, except_clause; 38, assignment; 39, identifier:AttributeError; 40, as_pattern_target; 41, import_from_statement; 42, expression_statement; 43, expression_statement; 44, identifier:trans; 45, identifier:attrs; 46, identifier:sorted; 47, argument_list; 48, identifier:self; 49, string; 50, return_statement; 51, as_pattern; 52, block; 53, identifier:trans; 54, call; 55, identifier:ae; 56, relative_import; 57, dotted_name; 58, assignment; 59, assignment; 60, attribute; 61, keyword_argument; 62, string_content:transactions; 63, subscript; 64, identifier:KeyError; 65, as_pattern_target; 66, return_statement; 67, attribute; 68, argument_list; 69, import_prefix; 70, dotted_name; 71, identifier:MambuTransactions; 72, attribute; 73, identifier:MambuTransactions; 74, identifier:trans; 75, call; 76, identifier:trans; 77, identifier:attrs; 78, identifier:key; 79, identifier:transactionid; 80, identifier:transaction; 81, string; 82, identifier:kerr; 83, None; 84, identifier:self; 85, identifier:mambutransactionsclass; 86, keyword_argument; 87, list_splat; 88, dictionary_splat; 89, identifier:mambutransaction; 90, identifier:self; 91, identifier:mambutransactionsclass; 92, attribute; 93, argument_list; 94, string_content:transactionId; 95, identifier:entid; 96, subscript; 97, identifier:args; 98, identifier:kwargs; 99, identifier:self; 100, identifier:mambutransactionsclass; 101, keyword_argument; 102, list_splat; 103, dictionary_splat; 104, identifier:self; 105, string; 106, identifier:entid; 107, subscript; 108, identifier:args; 109, identifier:kwargs; 110, string_content:id; 111, identifier:self; 112, string; 113, string_content:id
code: def setTransactions(self, *args, **kwargs):
          """Adds the transactions for this loan to a 'transactions' field.
  
          Transactions are MambuTransaction objects.
  
          Transactions get sorted by transaction id.
  
          Returns the number of requests done to Mambu.
  
  .. todo:: since pagination logic was added, is not always true that
            just 1 request was done. It may be more! But since request
            counter singleton holds true information about how many requests
            were done to Mambu, in fact this return value may be obsolete
          """
          def transactionid(transaction):
              """Util function used for sorting transactions according to id"""
              try:
                  return transaction['transactionId']
              except KeyError as kerr:
                  return None
  
          try:
              trans = self.mambutransactionsclass(entid=self['id'], *args, **kwargs)
          except AttributeError as ae:
              from .mambutransaction import MambuTransactions
              self.mambutransactionsclass = MambuTransactions
              trans = self.mambutransactionsclass(entid=self['id'], *args, **kwargs)
  
          trans.attrs = sorted(trans.attrs, key=transactionid)
          self['transactions'] = trans
  
          return 1