def disburse(self, loan_id, first_repayment_date=None): if first_repayment_date is not None: first_repayment_date = datelib.mambu_date(first_repayment_date) # This spelling mistake is intentional and is present in mambu return self._post_loan_transaction( loan_id, dict(type='DISBURSMENT', firstRepaymentDate=first_repayment_date))
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 disburse_with_amount(self, loan_id, pay_amount, first_repayment_date=None): if first_repayment_date is not None: first_repayment_date = datelib.mambu_date(first_repayment_date) # This spelling mistake is intentional and is present in mambu return self._post_loan_transaction(loan_id, dict( type='DISBURSMENT', amount=pay_amount, firstRepaymentDate=first_repayment_date))
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)
def get_repayments_due_on_date(self, datestr): datestr = datelib.mambu_date(datestr) return self.get_loans_by_single_filter('FIRST_REPAYMENT_DATE', 'ON', datestr)
def get_principals_due_in_xbdays(self, days): due_date = datelib.mambu_date(datelib.next_n_bday(n=days)) return self.get_principals_due_on_date(due_date)
def get_principals_due_on_date(self, datestr): datestr = datelib.mambu_date(datestr) return self.get_loans_by_single_filter('EXPECTED_MATURITY_DATE', 'ON', datestr)
def get_disbursements_due_in_xbdays(self, days): due_date = datelib.mambu_date(datelib.next_n_bday(n=days)) return self.get_disbursements_due_on_date(due_date)
def get_repayments_due_on_date(self, datestr): datestr = datelib.mambu_date(datestr) return self.get_loans_by_single_filter( 'FIRST_REPAYMENT_DATE', 'ON', datestr)
def get_principals_due_on_date(self, datestr): datestr = datelib.mambu_date(datestr) return self.get_loans_by_single_filter( 'EXPECTED_MATURITY_DATE', 'ON', datestr)