def setRepayments(self, *args, **kwargs):
        """Adds the repayments for this loan to a 'repayments' field.

        Repayments are MambuRepayment objects.

        Repayments get sorted by due date.

        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 duedate(repayment):
            """Util function used for sorting repayments according to due Date"""
            try:
                return repayment['dueDate']
            except KeyError as kerr:
                return datetime.now()

        try:
            reps = self.mamburepaymentsclass(entid=self['id'], *args, **kwargs)
        except AttributeError as ae:
            from .mamburepayment import MambuRepayments
            self.mamburepaymentsclass = MambuRepayments
            reps = self.mamburepaymentsclass(entid=self['id'], *args, **kwargs)

        reps.attrs = sorted(reps.attrs, key=duedate)
        self['repayments'] = reps

        return 1
def setRepayments ( self , * args , ** kwargs ) : def duedate ( repayment ) : try : return repayment [ 'dueDate' ] except KeyError as kerr : return datetime . now ( ) try : reps = self . mamburepaymentsclass ( entid = self [ 'id' ] , * args , ** kwargs ) except AttributeError as ae : from . mamburepayment import MambuRepayments self . mamburepaymentsclass = MambuRepayments reps = self . mamburepaymentsclass ( entid = self [ 'id' ] , * args , ** kwargs ) reps . attrs = sorted ( reps . attrs , key = duedate ) self [ 'repayments' ] = reps return 1
Adds the repayments for this loan to a 'repayments' field.

        Repayments are MambuRepayment objects.

        Repayments get sorted by due date.

        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