fix: Loan repayment schedule date
This commit is contained in:
		
							parent
							
								
									8116b9b62f
								
							
						
					
					
						commit
						1a5f0da6ca
					
				| @ -9,7 +9,7 @@ import math | ||||
| 
 | ||||
| import frappe | ||||
| from frappe import _ | ||||
| from frappe.utils import add_months, flt, getdate, now_datetime, nowdate | ||||
| from frappe.utils import add_months, flt, get_last_day, getdate, now_datetime, nowdate | ||||
| from six import string_types | ||||
| 
 | ||||
| import erpnext | ||||
| @ -102,7 +102,7 @@ class Loan(AccountsController): | ||||
| 				"total_payment": total_payment, | ||||
| 				"balance_loan_amount": balance_amount | ||||
| 			}) | ||||
| 			next_payment_date = add_months(payment_date, 1) | ||||
| 			next_payment_date = add_single_month(payment_date) | ||||
| 			payment_date = next_payment_date | ||||
| 
 | ||||
| 	def set_repayment_period(self): | ||||
| @ -391,3 +391,9 @@ def get_shortfall_applicants(): | ||||
| 		"value": len(applicants), | ||||
| 		"fieldtype": "Int" | ||||
| 	} | ||||
| 
 | ||||
| def add_single_month(date): | ||||
| 	if getdate(date) == get_last_day(date): | ||||
| 		return get_last_day(add_months(date, 1)) | ||||
| 	else: | ||||
| 		return add_months(date, 1) | ||||
| @ -414,7 +414,10 @@ def get_penalty_details(against_loan): | ||||
| 		return None, 0 | ||||
| 
 | ||||
| def regenerate_repayment_schedule(loan): | ||||
| 	from erpnext.loan_management.doctype.loan.loan import get_monthly_repayment_amount | ||||
| 	from erpnext.loan_management.doctype.loan.loan import ( | ||||
| 		add_single_month, | ||||
| 		get_monthly_repayment_amount, | ||||
| 	) | ||||
| 
 | ||||
| 	loan_doc = frappe.get_doc('Loan', loan) | ||||
| 	next_accrual_date = None | ||||
| @ -456,7 +459,7 @@ def regenerate_repayment_schedule(loan): | ||||
| 			"total_payment": total_payment, | ||||
| 			"balance_loan_amount": balance_amount | ||||
| 		}) | ||||
| 		next_payment_date = add_months(payment_date, 1) | ||||
| 		next_payment_date = add_single_month(payment_date) | ||||
| 		payment_date = next_payment_date | ||||
| 
 | ||||
| 	loan_doc.save() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user