def set_missing_values(self): # simple or compound variable soc = simple if self.interest_type == "Compound": soc = compound self.total_capital_amount = self.loan_amount self.repayment_amount = soc.get_repayment_amount(self.total_capital_amount, dec(self.interest_rate), self.repayment_periods) self.total_interest_amount = soc.get_total_interest_amount(self.total_capital_amount, dec(self.interest_rate), self.repayment_periods) self.total_payable_amount = soc.get_total_payable_amount(self.total_capital_amount, dec(self.interest_rate), self.repayment_periods) # empty the table to avoid duplicated rows self.set("loan_schedule", []) for row in soc.get_as_array(self.total_capital_amount, dec(self.interest_rate), self.repayment_periods): # repayment_date = frappe.utils.add_months(self.posting_date, row.idx) repayment_date = frappe._dict({ "Daily": daily, "Weekly": weekly, "BiWeekly": biweekly, "Monthly": monthly, "Quartely": quartely, "Half-Yearly": half_yearly, "Yearly": yearly }).get(self.repayment_frequency)(self.disbursement_date, row.idx) self.append("loan_schedule", row.update({ "status": "Pending", # "repayment_date": frappe.format_value(repayment_date, df={"fieldtype": "Date"}), "repayment_date": repayment_date, "outstanding_amount": row.repayment_amount, "paid_amount": 0.000 })) self.set_accounts() self.set_company_currency() self.tryto_get_exchange_rate()
def set_missing_values(self): # simple or compound variable soc = simple if self.interest_type == "Compound": soc = compound self.total_capital_amount = self.loan_amount self.repayment_amount = soc.get_repayment_amount( self.total_capital_amount, dec(self.interest_rate), self.repayment_periods) self.total_interest_amount = soc.get_total_interest_amount( self.total_capital_amount, dec(self.interest_rate), self.repayment_periods) self.total_payable_amount = soc.get_total_payable_amount( self.total_capital_amount, dec(self.interest_rate), self.repayment_periods) # empty the table to avoid duplicated rows self.set("loan_schedule", []) for row in soc.get_as_array(self.total_capital_amount, dec(self.interest_rate), self.repayment_periods): repayment_date = frappe.utils.add_months(self.posting_date, row.idx) self.append( "loan_schedule", row.update({ "status": "Pending", "repayment_date": self.get_correct_date(repayment_date), "outstanding_amount": row.repayment_amount, "paid_amount": 0.000 })) self.set_accounts() self.set_company_currency() self.tryto_get_exchange_rate()
def set_repayment_amount(self): # simple or compound variable soc = simple self.validate_required_fields_for_repayment_amount() if self.interest_type == "Compound": soc = compound self.repayment_amount = soc.get_repayment_amount(self.approved_net_amount, dec(self.interest_rate), self.repayment_periods)
def set_repayment_amount(self): # simple or compound variable soc = simple self.validate_required_fields_for_repayment_amount() if self.interest_type == "Compound": soc = compound self.total_capital_amount = self.requested_net_amount self.total_interest_amount = soc.get_total_interest_amount( self.total_capital_amount, dec(self.interest_rate), self.repayment_periods) self.total_payable_amount = soc.get_total_payable_amount( self.total_capital_amount, dec(self.interest_rate), self.repayment_periods) self.make_repayment_schedule()
def make_repayment_schedule(self): if not self.approved_net_amount\ or not self.repayment_periods\ or not self.interest_rate: return soc = simple if self.interest_type == "Compound": soc = compound self.repayment_amount = soc.get_repayment_amount( self.approved_net_amount, dec(self.interest_rate), self.repayment_periods) self.total_capital_amount = self.requested_net_amount rows = soc.get_as_array(self.total_capital_amount, dec(self.interest_rate), self.repayment_periods) for row in rows: repayment_date = frappe._dict({ "Daily": daily, "Weekly": weekly, "BiWeekly": biweekly, "Monthly": monthly, "Quartely": quartely, "Half-Yearly": half_yearly, "Yearly": yearly }).get(self.repayment_frequency)(self.disbursement_date, row.idx) row.update({ "repayment_date": frappe.format_value(repayment_date, df={"fieldtype": "Date"}) }) self.amortization_schedule = frappe.render_template( "templates/repayment_schedule.html", {"rows": rows})