[fix] before_recurring, set due_date, ageing_date as None, fixed account due date validation
This commit is contained in:
parent
65bef02607
commit
01d171756b
@ -169,15 +169,13 @@ class Account(Document):
|
||||
|
||||
def validate_due_date(self, posting_date, due_date):
|
||||
credit_days = (self.credit_days or frappe.db.get_value("Company", self.company, "credit_days"))
|
||||
if credit_days is None:
|
||||
return
|
||||
|
||||
posting_date, due_date = getdate(posting_date), getdate(due_date)
|
||||
diff = (due_date - posting_date).days
|
||||
|
||||
if diff < 0:
|
||||
frappe.throw(_("Due Date cannot be before Posting Date"))
|
||||
elif diff > credit_days:
|
||||
|
||||
elif credit_days is not None and diff > credit_days:
|
||||
is_credit_controller = frappe.db.get_value("Accounts Settings", None,
|
||||
"credit_controller") in frappe.user.get_roles()
|
||||
|
||||
|
@ -71,7 +71,9 @@ class SalesInvoice(SellingController):
|
||||
self.is_opening = 'No'
|
||||
|
||||
self.set_aging_date()
|
||||
|
||||
frappe.get_doc("Account", self.debit_to).validate_due_date(self.posting_date, self.due_date)
|
||||
|
||||
self.set_against_income_account()
|
||||
self.validate_c_form()
|
||||
self.validate_time_logs_are_submitted()
|
||||
@ -147,6 +149,10 @@ class SalesInvoice(SellingController):
|
||||
validate_recurring_document(self)
|
||||
convert_to_recurring(self, "RECINV.#####", self.posting_date)
|
||||
|
||||
def before_recurring(self):
|
||||
self.aging_date = None
|
||||
self.due_date = None
|
||||
|
||||
def get_portal_page(self):
|
||||
return "invoice" if self.docstatus==1 else None
|
||||
|
||||
|
@ -36,6 +36,9 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
|
||||
% (doctype, date_field, '%s', '%s'), (next_date, recurring_id)):
|
||||
try:
|
||||
ref_wrapper = frappe.get_doc(doctype, ref_document)
|
||||
if hasattr(ref_wrapper, "before_recurring"):
|
||||
ref_wrapper.before_recurring()
|
||||
|
||||
new_document_wrapper = make_new_document(ref_wrapper, date_field, next_date)
|
||||
send_notification(new_document_wrapper)
|
||||
if commit:
|
||||
|
Loading…
x
Reference in New Issue
Block a user