From 91eae543831c7007d83584f1367ec1f1e96f64ca Mon Sep 17 00:00:00 2001 From: Zlash65 Date: Tue, 28 Aug 2018 15:41:03 +0530 Subject: [PATCH] manually provide start and end date --- .../accounts/doctype/sales_invoice/sales_invoice.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 443696c409..5ab9de3e0a 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1081,7 +1081,7 @@ class SalesInvoice(SellingController): if points_to_redeem < 1: # since points_to_redeem is integer break - def book_income_for_deferred_revenue(self): + def book_income_for_deferred_revenue(self, start_date=None, end_date=None): # book the income on the last day, but it will be trigger on the 1st of month at 12:00 AM # start_date: 1st of the last month or the start date # end_date: end_date or today-1 @@ -1115,6 +1115,11 @@ class SalesInvoice(SellingController): last_gl_entry = True booking_end_date = item.service_stop_date + if start_date and end_date: + # if start and end date are already provided + booking_start_date = start_date + booking_end_date = end_date + total_days = date_diff(item.service_end_date, item.service_start_date) total_booking_days = date_diff(booking_end_date, booking_start_date) + 1 @@ -1166,17 +1171,17 @@ class SalesInvoice(SellingController): make_gl_entries(gl_entries, cancel=(self.docstatus == 2), merge_entries=True) -def booked_deferred_revenue(): +def booked_deferred_revenue(start_date=None, end_date=None): # check for the sales invoice for which GL entries has to be done invoices = frappe.db.sql_list(''' select parent from `tabSales Invoice Item` where service_start_date<=%s and service_end_date>=%s and enable_deferred_revenue = 1 and docstatus = 1 - ''', (today(), add_months(today(), -1))) + ''', (start_date or today(), end_date or add_months(today(), -1))) # ToDo also find the list on the basic of the GL entry, and make another list for invoice in invoices: doc = frappe.get_doc("Sales Invoice", invoice) - doc.book_income_for_deferred_revenue() + doc.book_income_for_deferred_revenue(start_date, end_date) def validate_inter_company_party(doctype, party, company, inter_company_invoice_reference):