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
def get_disbursements_due_today(self): """Return a list of loans with expectedDisbursementDate today. Specific use of the more general get_loans_by_filter_field Returns ------- list(Loan) """ datestr = datelib.mambu_date(datelib.date_today()) return self.get_disbursements_due_on_date(datestr)