mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
Fixes in recurring invoice
This commit is contained in:
@@ -645,20 +645,29 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Repair Outstanding
|
# Repair Outstanding
|
||||||
#######################################################################
|
|
||||||
def repair_rv_outstanding(self):
|
def repair_rv_outstanding(self):
|
||||||
get_obj(dt = 'GL Control').repair_voucher_outstanding(self)
|
get_obj(dt = 'GL Control').repair_voucher_outstanding(self)
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------------
|
||||||
def on_update_after_submit(self):
|
def on_update_after_submit(self):
|
||||||
self.convert_into_recurring()
|
self.convert_into_recurring()
|
||||||
|
|
||||||
|
|
||||||
def convert_into_recurring(self):
|
def convert_into_recurring(self):
|
||||||
if self.doc.convert_into_recurring_invoice:
|
if self.doc.convert_into_recurring_invoice:
|
||||||
event = 'accounts.doctype.gl_control.gl_control.manage_recurring_invoices'
|
|
||||||
self.set_next_date()
|
self.set_next_date()
|
||||||
if not self.doc.recurring_id:
|
if not self.doc.recurring_id:
|
||||||
set(self.doc, 'recurring_id', make_autoname('RECINV/.#####'))
|
set(self.doc, 'recurring_id', make_autoname('RECINV/.#####'))
|
||||||
|
elif self.doc.recurring_id:
|
||||||
|
sql("""update `tabReceivable Voucher` set convert_into_recurring_invoice = 0 where recurring_id = %s""", self.doc.recurring_id)
|
||||||
|
|
||||||
|
self.manage_scheduler()
|
||||||
|
|
||||||
|
def manage_scheduler(self):
|
||||||
|
""" set/cancel event in scheduler """
|
||||||
|
event = 'accounts.doctype.gl_control.gl_control.manage_recurring_invoices'
|
||||||
|
|
||||||
if sql("select name from `tabReceivable Voucher` where ifnull(convert_into_recurring_invoice, 0) = 1 and next_date <= end_date"):
|
if sql("select name from `tabReceivable Voucher` where ifnull(convert_into_recurring_invoice, 0) = 1 and next_date <= end_date"):
|
||||||
if not self.check_event_exists(event):
|
if not self.check_event_exists(event):
|
||||||
@@ -666,9 +675,6 @@ class DocType(TransactionBase):
|
|||||||
else:
|
else:
|
||||||
cancel_event(event)
|
cancel_event(event)
|
||||||
|
|
||||||
elif self.doc.recurring_id:
|
|
||||||
sql("""update `tabReceivable Voucher` set convert_into_recurring_invoice = 0 where recurring_id = %s""", self.doc.recurring_id)
|
|
||||||
|
|
||||||
|
|
||||||
def check_event_exists(self, event):
|
def check_event_exists(self, event):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user