Exemple #1
0
 def get_disbursements_due_on_date(self, datestr):
     result = []
     loans = self.get_loan()
     _date = datelib.coerce_date(datestr)
     for loan in loans:
         pending_tranches = [
             t for t in loan['tranches']
             if 'disbursementTransactionKey' not in t
             and datelib.coerce_date(t['expectedDisbursementDate']) == _date
         ]
         if len(pending_tranches) == 1:
             tranche = pending_tranches[0]
             amount = float(tranche['amount'])
             result.append(
                 dict(trancheEncodedKey=tranche['encodedKey'],
                      amount=amount,
                      loanEncodedKey=loan['encodedKey'],
                      accountHolderKey=loan['accountHolderKey'],
                      loanId=loan['id'],
                      expectedDisbursementDate=tranche[
                          'expectedDisbursementDate']))
         elif len(pending_tranches) > 1:
             logger.warning('%s has too many tranches pending on %s' %
                            (loan['id'], datestr))
     return result
Exemple #2
0
    def apply_fee(self, loan_id, amount, date=None):
        """Apply the fee to the loan associated with loan_id

        Parameters
        ----------
        loan_id: str
            id of the loan in mambu
        amount: float
            amount of the fee to apply to the loan in the local currency in
            whole units e.g. UK, 10 is equivalent to GBP10.00
        date: date, datetime, str
            date-like to coerce into datestr.  Passed to apply_fee to date
            transaction

        Returns
        -------
        dict
        """
        if date is None or datelib.coerce_date(date) == datelib.date_today():
            result = self._post_loan_transaction(
                loan_id, dict(type='FEE', amount=amount))
        else:
            date = datelib.mambu_date(date)
            result = self._post_loan_transaction(
                loan_id, dict(type='FEE', amount=amount, date=date))
        return result
Exemple #3
0
    def apply_fee(self, loan_id, amount, date=None):
        """Apply the fee to the loan associated with loan_id

        Parameters
        ----------
        loan_id: str
            id of the loan in mambu
        amount: float
            amount of the fee to apply to the loan in the local currency in
            whole units e.g. UK, 10 is equivalent to GBP10.00
        date: date, datetime, str
            date-like to coerce into datestr.  Passed to apply_fee to date
            transaction

        Returns
        -------
        dict
        """
        if date is None or datelib.coerce_date(date) == datelib.date_today():
            result = self._post_loan_transaction(
                loan_id, dict(type='FEE', amount=amount))
        else:
            date = datelib.mambu_date(date)
            result = self._post_loan_transaction(
                loan_id, dict(type='FEE', amount=amount, date=date))
        return result
Exemple #4
0
 def get_disbursements_due_on_date(self, datestr):
     result = []
     loans = self.get_loan()
     _date = datelib.coerce_date(datestr)
     for loan in loans:
         pending_tranches = [
             t for t in loan['tranches']
             if 'disbursementTransactionKey' not in t
             and datelib.coerce_date(t['expectedDisbursementDate']) == _date]
         if len(pending_tranches) == 1:
             tranche = pending_tranches[0]
             amount = float(tranche['amount'])
             result.append(dict(
                 trancheEncodedKey=tranche['encodedKey'], amount=amount,
                 loanEncodedKey=loan['encodedKey'],
                 accountHolderKey=loan['accountHolderKey'], loanId=loan['id'],
                 expectedDisbursementDate=tranche['expectedDisbursementDate']))
         elif len(pending_tranches) > 1:
             logger.warning('%s has too many tranches pending on %s' % (
                 loan['id'], datestr))
     return result