diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index 9bfc5bed719..757ae1218a0 100755 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -2655,7 +2655,7 @@ "unique": 0 }, { - "allow_on_submit": 1, + "allow_on_submit": 0, "bold": 0, "collapsible": 0, "depends_on": "is_recurring", @@ -2673,7 +2673,7 @@ "permlevel": 0, "print_hide": 1, "print_hide_if_no_value": 0, - "read_only": 1, + "read_only": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -2692,7 +2692,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-03-16 15:02:51.511069", + "modified": "2016-03-18 02:03:39.309675", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index e640ad21be6..a9cf9cbf7df 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -3355,7 +3355,7 @@ "unique": 0 }, { - "allow_on_submit": 1, + "allow_on_submit": 0, "bold": 0, "collapsible": 0, "depends_on": "is_recurring", @@ -3373,7 +3373,7 @@ "permlevel": 0, "print_hide": 1, "print_hide_if_no_value": 0, - "read_only": 1, + "read_only": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -3418,7 +3418,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-03-15 19:02:25.882750", + "modified": "2016-03-18 02:03:34.511447", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json index 6c2fc79c0be..0b83e62eefe 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.json +++ b/erpnext/buying/doctype/purchase_order/purchase_order.json @@ -2657,7 +2657,7 @@ "unique": 0 }, { - "allow_on_submit": 1, + "allow_on_submit": 0, "bold": 0, "collapsible": 0, "depends_on": "is_recurring", @@ -2675,7 +2675,7 @@ "permlevel": 0, "print_hide": 1, "print_hide_if_no_value": 0, - "read_only": 1, + "read_only": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -2693,7 +2693,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-03-16 15:35:21.382861", + "modified": "2016-03-18 02:03:28.445402", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order", diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index ae225d2c44c..7b6f9436e9e 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe from frappe import _, throw -from frappe.utils import today, flt, cint, fmt_money +from frappe.utils import today, flt, cint, fmt_money, getdate from erpnext.setup.utils import get_company_currency, get_exchange_rate from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year, get_account_currency from erpnext.utilities.transaction_base import TransactionBase @@ -31,6 +31,9 @@ class AccountsController(TransactionBase): self.set_missing_values(for_validate=True) self.validate_date_with_fiscal_year() + if self.meta.get_field('next_date') and self.next_date: + self.validate_recurring_next_date() + if self.meta.get_field("currency"): self.calculate_taxes_and_totals() if not self.meta.get_field("is_return") or not self.is_return: @@ -88,6 +91,14 @@ class AccountsController(TransactionBase): validate_fiscal_year(self.get(date_field), self.fiscal_year, self.meta.get_label(date_field), self) + def validate_recurring_next_date(self): + posting_date = self.get("posting_date") or self.get("transaction_date") + if getdate(posting_date) > getdate(self.next_date): + frappe.throw(_("Next Date must be greater than Posting Date")) + + if getdate(self.next_date).day != self.repeat_on_day_of_month: + frappe.throw(_("Next Date's day and Repeat on Day of Month must be equal")) + def validate_due_date(self): from erpnext.accounts.party import validate_due_date if self.doctype == "Sales Invoice": diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py index f83df2bea81..c3e98e82606 100644 --- a/erpnext/controllers/recurring_document.py +++ b/erpnext/controllers/recurring_document.py @@ -72,7 +72,7 @@ def manage_recurring_documents(doctype, next_date=None, commit=True): frappe.throw(exception_message) def make_new_document(reference_doc, date_field, posting_date): - new_document = frappe.copy_doc(reference_doc, ignore_no_copy=True) + new_document = frappe.copy_doc(reference_doc, ignore_no_copy=False) mcount = month_map[reference_doc.recurring_type] from_date = get_next_date(reference_doc.from_date, mcount) @@ -89,7 +89,7 @@ def make_new_document(reference_doc, date_field, posting_date): date_field: posting_date, "from_date": from_date, "to_date": to_date, - "next_date": get_next_date(from_date, mcount,cint(reference_doc.repeat_on_day_of_month)) + "next_date": get_next_date(reference_doc.next_date, mcount,cint(reference_doc.repeat_on_day_of_month)) }) # copy document fields @@ -202,7 +202,7 @@ def set_next_date(doc, posting_date): if not doc.repeat_on_day_of_month: msgprint(_("Please enter 'Repeat on Day of Month' field value"), raise_exception=1) - next_date = doc.next_date or get_next_date(doc.from_date, month_map[doc.recurring_type], + next_date = get_next_date(posting_date, month_map[doc.recurring_type], cint(doc.repeat_on_day_of_month)) frappe.db.set(doc, 'next_date', next_date) diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index e6e0cd22d8f..072ade8b05f 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -2929,32 +2929,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_on_submit": 1, - "bold": 0, - "collapsible": 0, - "depends_on": "is_recurring", - "description": "", - "fieldname": "to_date", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "label": "To Date", - "length": 0, - "no_copy": 1, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, { "allow_on_submit": 1, "bold": 0, @@ -2987,6 +2961,32 @@ "collapsible": 0, "depends_on": "is_recurring", "description": "", + "fieldname": "to_date", + "fieldtype": "Date", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "To Date", + "length": 0, + "no_copy": 1, + "permlevel": 0, + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "depends_on": "is_recurring", + "description": "", "fieldname": "next_date", "fieldtype": "Date", "hidden": 0, @@ -3000,7 +3000,7 @@ "permlevel": 0, "print_hide": 1, "print_hide_if_no_value": 0, - "read_only": 1, + "read_only": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -3018,7 +3018,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-03-14 18:36:19.317513", + "modified": "2016-03-18 02:03:43.706326", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order",