def setHolder(self, getClients=False, getRoles=False, *args, **kwargs):
requests = <NUM_LIT:0><EOL>if '<STR_LIT>' in kwargs:<EOL><INDENT>fullDetails = kwargs['<STR_LIT>']<EOL>kwargs.pop('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>fullDetails = True<EOL><DEDENT>if self['<STR_LIT>'] == "<STR_LIT>":<EOL><INDENT>self['<STR_LIT>'] = "<STR_LIT>"<EOL>try:<EOL><INDENT>holder = self.mambugroupclass(entid=self['<STR_LIT>'], fullDetails=True, *args, **kwargs)<EOL><DEDENT>except AttributeError as ae:<EOL><INDENT>from .mambugroup import MambuGroup<EOL>self.mambugroupclass = MambuGroup<EOL>holder = self.mambugroupclass(entid=self['<STR_LIT>'], fullDetails=True, *args, **kwargs)<EOL><DEDENT>self['<STR_LIT>'] = holder<EOL>requests += <NUM_LIT:1><EOL>if getRoles:<EOL><INDENT>roles = []<EOL>for c in holder['<STR_LIT>']:<EOL><INDENT>try:<EOL><INDENT>cli = self.mambuclientclass(entid=c['<STR_LIT>'], *args, **kwargs)<EOL><DEDENT>except AttributeError as ae:<EOL><INDENT>from .mambuclient import MambuClient<EOL>self.mambuclientclass = MambuClient<EOL>cli = self.mambuclientclass(entid=c['<STR_LIT>'], *args, **kwargs)<EOL><DEDENT>roles.append({'<STR_LIT>'   : c['<STR_LIT>'],<EOL>'<STR_LIT>' : cli<EOL>})<EOL>requests += <NUM_LIT:1><EOL><DEDENT>holder['<STR_LIT>'] = roles<EOL><DEDENT>if getClients:<EOL><INDENT>requests += holder.setClients(fullDetails=fullDetails, *args, **kwargs)<EOL>loanclients = {}<EOL>loanclientsdata = self.getClientDetails(holder=holder, *args, **kwargs)<EOL>for data in loanclientsdata:<EOL><INDENT>loanclients[data['<STR_LIT:id>']] = {'<STR_LIT>'     : data['<STR_LIT>'],<EOL>'<STR_LIT:name>'       : data['<STR_LIT:name>'],<EOL>'<STR_LIT>'       : self,<EOL>'<STR_LIT>'     : data['<STR_LIT>'],<EOL>'<STR_LIT>'  : data['<STR_LIT>'] / float(self['<STR_LIT>']),<EOL>'<STR_LIT>' : data['<STR_LIT>'] / float(self['<STR_LIT>']),<EOL>}<EOL>for k,v in [ (key,val) for (key,val) in data.items() if key not in['<STR_LIT>', '<STR_LIT:name>'] ]:<EOL><INDENT>loanclients[data['<STR_LIT:id>']][k] = v<EOL><DEDENT><DEDENT>self['<STR_LIT>'] = loanclients<EOL><DEDENT><DEDENT>else: <EOL><INDENT>self['<STR_LIT>'] = "<STR_LIT>"<EOL>try:<EOL><INDENT>holder = self.mambuclientclass(entid=self['<STR_LIT>'], fullDetails=fullDetails, *args, **kwargs)<EOL><DEDENT>except AttributeError as ae:<EOL><INDENT>from .mambuclient import MambuClient<EOL>self.mambuclientclass = MambuClient<EOL>holder = self.mambuclientclass(entid=self['<STR_LIT>'], fullDetails=fullDetails, *args, **kwargs)<EOL><DEDENT>self['<STR_LIT>'] = holder<EOL>requests += <NUM_LIT:1><EOL>if getClients:<EOL><INDENT>monto = float(self['<STR_LIT>'])<EOL>self['<STR_LIT>'] = {holder['<STR_LIT:name>']: {'<STR_LIT>'     : holder,<EOL>'<STR_LIT>'       : self,<EOL>'<STR_LIT>'     : monto,<EOL>'<STR_LIT>'  : monto / float(self['<STR_LIT>']),<EOL>'<STR_LIT>' : <NUM_LIT:1.0>,<EOL>}<EOL>}<EOL><DEDENT><DEDENT>return requests<EOL>
Adds the "holder" of the loan to a 'holder' field.

        Holder may be a MambuClient or a MambuGroup object, depending on
        the type of loan created at Mambu.

        getRoles argument tells this method to retrive the clients who
        have specific roles in the group, in case of a group holder.

        getClients argument tells this method to retrieve the client
        members of the group, in case of a group holder. See the
        definition of the 'clients' field added with this argument
        below.

        fullDetails argument works for Client Holder and for the client
        members of the group. But the Group is always retrieved with
        full details.

        When using getRoles argument also adds a 'roles' field to the
        holder, a dictionary with keys:

        * 'role' , the rolename

        * 'client', a MambuClient having that role on the group

.. todo:: since the roles field is added to the holder, and it only
          applies to Groups, perhaps the getRoles functionality should be
          on MambuGroup code

        When using getClients argument, also adds a 'clients' field to
        the loan. By the way it works, when holder is a Group, it calls
        the setClients method, which adds a 'clients' field to the
        MambuGroup.

        The 'clients' field on the loan is a dictionary with the full
        name of each client receiving from this loan account as a key
        (see the 'name' field on MambuClient and MambuGroup). Each key
        holds another dictionary with the following keys:

        * 'client' holds a MambuClient. So even if a group is the holder
          of the account, you can access each individual client object
          here.

        * 'loan' holds a reference to this loan account (self)

        * 'amount' defaults to the total loan amount ('loanAmount'
          field) (see the pydoc for getClientDetails method)

        * 'montoPago' defaults to the total loan amount divided by the
          number of repayment installments of the loan account (the
          'repaymentInstallments' field), that is, how much to pay for
          each repayment installment (see the pydoc for getClientDetails
          method)

.. todo:: change the name to an english name

        * 'porcentaje' defaults to a 100%, the total loan amount divided
          by itself, that is, hoy much in percentage of the debt belongs
          to this client (see the pydoc for getClientDetails method)

.. todo:: change the name to an english name

        This three fields are supposed to reflect individual numbers for
        each client, but Mambu does an awful job indicating this on
        group loan accounts. So you should indicate how much you
        assigned to each client in other ways. Using the notes of the
        loan account perhaps (with a predefined format you parse on the
        preprocessing of MambuLoan)? with custom fields? Your call that
        you may define making your own loan account class inheriting
        from MambuLoan class. See the pydoc for getClientDetails method
        below, it specifies the way to determine the amount for each
        client depending on your use of Mambu, and additionally any
        other fields you wish to add to the 'clients' field on the loan
        account.

        Returns the number of requests done to Mambu.

.. todo:: what to do on Hybrid loan accounts?