[fix] resolved merge conflicts
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 405274a..edbd9a2 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -4,7 +4,7 @@
import frappe
from erpnext.hooks import regional_overrides
-__version__ = '9.0.6'
+__version__ = '9.0.7'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/subscription/subscription.json b/erpnext/accounts/doctype/subscription/subscription.json
index 902b062..dfdcbec 100644
--- a/erpnext/accounts/doctype/subscription/subscription.json
+++ b/erpnext/accounts/doctype/subscription/subscription.json
@@ -137,66 +137,6 @@
},
{
"allow_bulk_edit": 0,
- "allow_on_submit": 1,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "disabled",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Disabled",
- "length": 0,
- "no_copy": 1,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "submit_on_creation",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Submit on Creation",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -286,12 +226,12 @@
},
{
"allow_bulk_edit": 0,
- "allow_on_submit": 1,
+ "allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "next_schedule_date",
- "fieldtype": "Date",
+ "fieldname": "submit_on_creation",
+ "fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -299,14 +239,44 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Next Schedule Date",
+ "label": "Submit on Creation",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "disabled",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Disabled",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"precision": "",
- "print_hide": 1,
+ "print_hide": 0,
"print_hide_if_no_value": 0,
- "read_only": 1,
+ "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
@@ -320,7 +290,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "frequency_detail",
+ "fieldname": "section_break_10",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -329,7 +299,95 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "from_date",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "From Date",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "to_date",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "To Date",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_13",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -377,35 +435,6 @@
},
{
"allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_12",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_bulk_edit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -437,6 +466,36 @@
},
{
"allow_bulk_edit": 0,
+ "allow_on_submit": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "next_schedule_date",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Next Schedule Date",
+ "length": 0,
+ "no_copy": 1,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -785,7 +844,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2017-09-28 18:27:48.522098",
+ "modified": "2017-10-03 17:20:26.919630",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Subscription",
@@ -795,7 +854,7 @@
{
"amend": 0,
"apply_user_permissions": 0,
- "cancel": 0,
+ "cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
@@ -815,7 +874,7 @@
{
"amend": 0,
"apply_user_permissions": 0,
- "cancel": 0,
+ "cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
@@ -835,7 +894,7 @@
{
"amend": 0,
"apply_user_permissions": 0,
- "cancel": 0,
+ "cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
diff --git a/erpnext/accounts/doctype/subscription/subscription.py b/erpnext/accounts/doctype/subscription/subscription.py
index b7ea96f..69010dd 100644
--- a/erpnext/accounts/doctype/subscription/subscription.py
+++ b/erpnext/accounts/doctype/subscription/subscription.py
@@ -10,7 +10,7 @@
from frappe.utils.jinja import validate_template
from dateutil.relativedelta import relativedelta
from frappe.utils.user import get_system_managers
-from frappe.utils import cstr, getdate, split_emails, add_days, today
+from frappe.utils import cstr, getdate, split_emails, add_days, today, get_last_day, get_first_day
from frappe.model.document import Document
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
@@ -28,12 +28,23 @@
self.set_next_schedule_date()
def on_submit(self):
- self.update_subscription_id()
+ # self.update_subscription_id()
+ self.update_subscription_data()
def on_update_after_submit(self):
+ self.update_subscription_data()
self.validate_dates()
self.set_next_schedule_date()
+ def before_cancel(self):
+ self.unlink_subscription_id()
+
+ def unlink_subscription_id(self):
+ doc = frappe.get_doc(self.reference_doctype, self.reference_document)
+ if doc.meta.get_field('subscription'):
+ doc.subscription = None
+ doc.db_update()
+
def validate_dates(self):
if self.end_date and getdate(self.start_date) > getdate(self.end_date):
frappe.throw(_("End date must be greater than start date"))
@@ -68,6 +79,21 @@
self.next_schedule_date = get_next_schedule_date(self.start_date,
self.frequency, self.repeat_on_day)
+ def update_subscription_data(self):
+ update_doc = False
+ doc = frappe.get_doc(self.reference_doctype, self.reference_document)
+ if frappe.get_meta(self.reference_doctype).get_field("from_date"):
+ doc.from_date = self.from_date
+ doc.to_date = self.to_date
+ update_doc = True
+
+ if not doc.subscription:
+ doc.subscription = self.name
+ update_doc = True
+
+ if update_doc:
+ doc.db_update()
+
def update_subscription_id(self):
doc = frappe.get_doc(self.reference_doctype, self.reference_document)
if not doc.meta.get_field('subscription'):
@@ -116,6 +142,9 @@
def create_documents(data, schedule_date):
try:
doc = make_new_document(data, schedule_date)
+ if doc.from_date:
+ update_subscription_period(data, doc)
+
if data.notify_by_email and data.recipients:
print_format = data.print_format or "Standard"
send_notification(doc, data, print_format=print_format)
@@ -130,6 +159,13 @@
if data.reference_document and not frappe.flags.in_test:
notify_error_to_user(data)
+def update_subscription_period(data, doc):
+ from_date = doc.from_date
+ to_date = doc.to_date
+
+ frappe.db.set_value('Subscription', data.name, 'from_date', from_date)
+ frappe.db.set_value('Subscription', data.name, 'to_date', to_date)
+
def disabled_subscription(data):
subscription = frappe.get_doc('Subscription', data.name)
subscription.db_set('disabled', 1)
@@ -164,9 +200,24 @@
if new_document.meta.get_field('set_posting_time'):
new_document.set('set_posting_time', 1)
+ mcount = month_map.get(args.frequency)
+
if new_document.meta.get_field('subscription'):
new_document.set('subscription', args.name)
+ if args.from_date and args.to_date:
+ from_date = get_next_date(args.from_date, mcount)
+
+ if (cstr(get_first_day(args.from_date)) == cstr(args.from_date)) and \
+ (cstr(get_last_day(args.to_date)) == cstr(args.to_date)):
+ to_date = get_last_day(get_next_date(args.to_date, mcount))
+ else:
+ to_date = get_next_date(args.to_date, mcount)
+
+ if new_document.meta.get_field('from_date'):
+ new_document.set('from_date', from_date)
+ new_document.set('to_date', to_date)
+
new_document.run_method("on_recurring", reference_doc=reference_doc, subscription_doc=args)
for data in new_document.meta.fields:
if data.fieldtype == 'Date' and data.reqd:
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index e75c490..113c402 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -448,3 +448,4 @@
erpnext.patches.v8_9.delete_gst_doctypes_for_outside_india_accounts
erpnext.patches.v8_9.set_default_fields_in_variant_settings
erpnext.patches.v8_9.update_billing_gstin_for_indian_account
+erpnext.patches.v9_0.fix_subscription_next_date
diff --git a/erpnext/patches/v9_0/fix_subscription_next_date.py b/erpnext/patches/v9_0/fix_subscription_next_date.py
new file mode 100644
index 0000000..a36e60c
--- /dev/null
+++ b/erpnext/patches/v9_0/fix_subscription_next_date.py
@@ -0,0 +1,27 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ frappe.reload_doctype('Subscription')
+
+ doctypes = ('Purchase Order', 'Sales Order', 'Purchase Invoice', 'Sales Invoice')
+ for data in frappe.get_all('Subscription', fields = ["name", "reference_doctype", "reference_document"],
+ filters = {'reference_doctype': ('in', doctypes)}):
+ doc = frappe.get_doc('Subscription', data.name)
+ fields = ['transaction_date']
+ if doc.reference_doctype in ['Sales Invoice', 'Purchase Invoice']:
+ fields = ['posting_date']
+
+ fields.extend(['from_date', 'to_date'])
+ reference_data = frappe.db.get_value(data.reference_doctype,
+ data.reference_document, fields, as_dict=1)
+
+ if reference_data:
+ doc.start_date = reference_data.get('posting_date') or reference_data.get('transaction_date')
+ doc.from_date = reference_data.get('from_date')
+ doc.to_date = reference_data.get('to_date')
+ doc.set_next_schedule_date()
+ doc.db_update()
\ No newline at end of file
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js
index f9045b5..5eb8226 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.js
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.js
@@ -99,6 +99,17 @@
if (value == 'Pay') {
if (!this.payment) {
this.make_payment_modal();
+ } else {
+ const mop_field = this.payment.default_mop;
+ let amount = 0.0;
+ this.frm.doc.payments.map(p => {
+ if (p.mode_of_payment == mop_field) {
+ amount = p.amount;
+ return;
+ }
+ });
+
+ this.payment.dialog.set_value(mop_field, flt(amount));
}
this.payment.open_modal();
}
@@ -437,6 +448,12 @@
this.$taxes_and_totals.html(this.get_taxes_and_totals());
this.numpad && this.numpad.reset_value();
this.customer_field.set_value("");
+
+ this.wrapper.find('.grand-total-value').text(
+ format_currency(this.frm.doc.grand_total, this.frm.currency));
+
+ const customer = this.frm.doc.customer || this.pos_profile.customer;
+ this.customer_field.set_value(customer);
}
get_grand_total() {
@@ -1179,6 +1196,10 @@
const me = this;
let fields = this.frm.doc.payments.map(p => {
+ if (p.default) {
+ this.default_mop = p.mode_of_payment;
+ }
+
return {
fieldtype: 'Currency',
label: __(p.mode_of_payment),