diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 699dcf3996d..4def02cce5a 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '10.1.61' +__version__ = '10.1.63' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/accounts/doctype/subscription/test_subscription.py b/erpnext/accounts/doctype/subscription/test_subscription.py index a5285ea16a3..3d96f233b40 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -41,24 +41,14 @@ def create_plan(): plan.billing_interval_count = 14 plan.insert() - -def create_subscriber(): - if not frappe.db.exists('Subscriber', '_Test Customer'): - subscriber = frappe.new_doc('Subscriber') - subscriber.subscriber_name = '_Test Customer' - subscriber.customer = '_Test Customer' - subscriber.insert() - - class TestSubscription(unittest.TestCase): def setUp(self): create_plan() - create_subscriber() def test_create_subscription_with_trial_with_correct_period(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.trial_period_start = nowdate() subscription.trial_period_end = add_days(nowdate(), 30) subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -75,7 +65,7 @@ class TestSubscription(unittest.TestCase): def test_create_subscription_without_trial_with_correct_period(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() @@ -91,7 +81,7 @@ class TestSubscription(unittest.TestCase): def test_create_subscription_trial_with_wrong_dates(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.trial_period_end = nowdate() subscription.trial_period_start = add_days(nowdate(), 30) subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -101,7 +91,7 @@ class TestSubscription(unittest.TestCase): def test_create_subscription_multi_with_different_billing_fails(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.trial_period_end = nowdate() subscription.trial_period_start = add_days(nowdate(), 30) subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -112,7 +102,7 @@ class TestSubscription(unittest.TestCase): def test_invoice_is_generated_at_end_of_billing_period(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.start = '2018-01-01' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.insert() @@ -129,7 +119,7 @@ class TestSubscription(unittest.TestCase): def test_status_goes_back_to_active_after_invoice_is_paid(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.start = '2018-01-01' subscription.insert() @@ -159,7 +149,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.start = '2018-01-01' subscription.insert() @@ -182,7 +172,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.start = '2018-01-01' subscription.insert() @@ -200,7 +190,7 @@ class TestSubscription(unittest.TestCase): def test_subscription_invoice_days_until_due(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.days_until_due = 10 subscription.start = add_months(nowdate(), -1) @@ -218,7 +208,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.start = '2018-01-01' subscription.insert() @@ -242,7 +232,7 @@ class TestSubscription(unittest.TestCase): def test_subscription_remains_active_during_invoice_period(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() subscription.process() # no changes expected @@ -268,7 +258,7 @@ class TestSubscription(unittest.TestCase): def test_subscription_cancelation(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() subscription.cancel_subscription() @@ -284,7 +274,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() @@ -319,7 +309,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() subscription.cancel_subscription() @@ -339,7 +329,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() subscription.cancel_subscription() @@ -363,7 +353,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.start = '2018-01-01' subscription.insert() @@ -397,7 +387,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.start = '2018-01-01' subscription.insert() @@ -434,7 +424,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.start = '2018-01-01' subscription.insert() @@ -463,7 +453,7 @@ class TestSubscription(unittest.TestCase): def test_restart_active_subscription(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() @@ -473,7 +463,7 @@ class TestSubscription(unittest.TestCase): def test_subscription_invoice_discount_percentage(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.additional_discount_percentage = 10 subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() @@ -488,7 +478,7 @@ class TestSubscription(unittest.TestCase): def test_subscription_invoice_discount_amount(self): subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.additional_discount_amount = 11 subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() @@ -505,7 +495,7 @@ class TestSubscription(unittest.TestCase): # Create a non pre-billed subscription, processing should not create # invoices. subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() subscription.process() @@ -527,7 +517,7 @@ class TestSubscription(unittest.TestCase): settings.save() subscription = frappe.new_doc('Subscription') - subscription.subscriber = '_Test Customer' + subscription.customer = '_Test Customer' subscription.generate_invoice_at_period_start = True subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) subscription.save() diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 74ca2585fe1..937911f4836 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -339,19 +339,20 @@ def set_gl_entries_by_account( additional_conditions = get_additional_conditions(from_date, ignore_closing_entries, filters) + accounts = frappe.db.sql_list("""select name from `tabAccount` + where lft >= %s and rgt <= %s""", (root_lft, root_rgt)) + additional_conditions += " and account in ('{}')"\ + .format("', '".join([frappe.db.escape(d) for d in accounts])) + gl_entries = frappe.db.sql("""select posting_date, account, debit, credit, is_opening, fiscal_year, debit_in_account_currency, credit_in_account_currency, account_currency from `tabGL Entry` where company=%(company)s {additional_conditions} and posting_date <= %(to_date)s - and account in (select name from `tabAccount` - where lft >= %(lft)s and rgt <= %(rgt)s) order by account, posting_date""".format(additional_conditions=additional_conditions), { "company": company, "from_date": from_date, "to_date": to_date, - "lft": root_lft, - "rgt": root_rgt, "cost_center": filters.cost_center, "project": filters.project }, diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js index 2ff80755df6..873d2107495 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js @@ -128,7 +128,7 @@ frappe.ui.form.on("Request for Quotation",{ doctype: "Supplier", order_by: "name", fields: ["name"], - filters: [["Supplier", "supplier_group_name", "=", args.supplier_group]] + filters: [["Supplier", "supplier_group", "=", args.supplier_group]] }, callback: load_suppliers diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 1d6b5e02bec..58b2c446847 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -12,7 +12,7 @@ app_license = "GNU General Public License (v3)" source_link = "https://github.com/frappe/erpnext" develop_version = '11.x.x-develop' -staging_version = '11.0.3-beta.13' +staging_version = '11.0.3-beta.14' error_report_email = "support@erpnext.com" diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 2278036ba39..aca277effdf 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -191,9 +191,8 @@ class LeaveApplication(Document): frappe.throw(_("The day(s) on which you are applying for leave are holidays. You need not apply for leave.")) if not is_lwp(self.leave_type): - self.leave_balance = get_leave_balance_on(self.employee, self.leave_type, self.from_date, + self.leave_balance = get_leave_balance_on(self.employee, self.leave_type, self.from_date, docname=self.name, consider_all_leaves_in_the_allocation_period=True) - if self.status != "Rejected" and self.leave_balance < self.total_leave_days: if frappe.db.get_value("Leave Type", self.leave_type, "allow_negative"): frappe.msgprint(_("Note: There is not enough leave balance for Leave Type {0}") @@ -385,26 +384,24 @@ def get_leave_details(employee, date): return ret @frappe.whitelist() -def get_leave_balance_on(employee, leave_type, date, allocation_records=None, +def get_leave_balance_on(employee, leave_type, date, allocation_records=None, docname=None, consider_all_leaves_in_the_allocation_period=False, consider_encashed_leaves=True): + if allocation_records == None: allocation_records = get_leave_allocation_records(date, employee).get(employee, frappe._dict()) - allocation = allocation_records.get(leave_type, frappe._dict()) - if consider_all_leaves_in_the_allocation_period: date = allocation.to_date - leaves_taken = get_leaves_for_period(employee, leave_type, allocation.from_date, date, status="Approved") - + leaves_taken = get_leaves_for_period(employee, leave_type, allocation.from_date, date, status="Approved", docname=docname) leaves_encashed = 0 if frappe.db.get_value("Leave Type", leave_type, 'allow_encashment') and consider_encashed_leaves: leaves_encashed = flt(allocation.total_leaves_encashed) return flt(allocation.total_leaves_allocated) - (flt(leaves_taken) + flt(leaves_encashed)) -def get_leaves_for_period(employee, leave_type, from_date, to_date, status): +def get_leaves_for_period(employee, leave_type, from_date, to_date, status, docname=None): leave_applications = frappe.db.sql(""" - select employee, leave_type, from_date, to_date, total_leave_days + select name, employee, leave_type, from_date, to_date, total_leave_days from `tabLeave Application` where employee=%(employee)s and leave_type=%(leave_type)s and status = %(status)s and docstatus != 2 @@ -418,9 +415,10 @@ def get_leaves_for_period(employee, leave_type, from_date, to_date, status): "status": status, "leave_type": leave_type }, as_dict=1) - leave_days = 0 for leave_app in leave_applications: + if docname and leave_app.name == docname: + continue if leave_app.from_date >= getdate(from_date) and leave_app.to_date <= getdate(to_date): leave_days += leave_app.total_leave_days else: @@ -450,7 +448,6 @@ def get_leave_allocation_records(date, employee=None): "total_leaves_allocated": d.total_leaves_allocated, "total_leaves_encashed":d.total_leaves_encashed })) - return allocated_leaves @frappe.whitelist() diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 71c602b5007..4748011b626 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -392,6 +392,34 @@ class TestLeaveApplication(unittest.TestCase): i += 1 self.assertEqual(get_leave_balance_on(employee.name, leave_type, nowdate()), 6) + # test to not consider current leave in leave balance while submitting + def test_current_leave_on_submit(self): + employee = get_employee() + leave_type = 'Sick leave' + allocation = frappe.get_doc(dict( + doctype = 'Leave Allocation', + employee = employee.name, + leave_type = leave_type, + from_date = '2018-10-01', + to_date = '2018-10-10', + new_leaves_allocated = 1 + )) + allocation.insert(ignore_permissions=True) + allocation.submit() + leave_application = frappe.get_doc(dict( + doctype = 'Leave Application', + employee = employee.name, + leave_type = leave_type, + from_date = '2018-10-02', + to_date = '2018-10-02', + company = '_Test Company', + status = 'Approved', + leave_approver = 'test@example.com' + )) + self.assertTrue(leave_application.insert()) + leave_application.submit() + self.assertEqual(leave_application.docstatus, 1) + def make_allocation_record(employee=None, leave_type=None): frappe.db.sql("delete from `tabLeave Allocation`") diff --git a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py index 9bfa39f73ff..91c7bf5850a 100644 --- a/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py +++ b/erpnext/hub_node/doctype/marketplace_settings/marketplace_settings.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe, requests, json, time from frappe.model.document import Document -from frappe.utils import add_years, now, get_datetime, get_datetime_str +from frappe.utils import add_years, now, get_datetime, get_datetime_str, cint from frappe import _ from frappe.frappeclient import FrappeClient from erpnext.utilities.product import get_price, get_qty_in_stock @@ -84,3 +84,11 @@ class MarketplaceSettings(Document): def unregister(self): """Disable the User on hubmarket.org""" pass + +@frappe.whitelist() +def is_marketplace_enabled(): + if not hasattr(frappe.local, 'is_marketplace_enabled'): + frappe.local.is_marketplace_enabled = cint(frappe.db.get_single_value('Marketplace Settings', + 'disable_marketplace')) + + return frappe.local.is_marketplace_enabled diff --git a/erpnext/public/js/hub/hub_factory.js b/erpnext/public/js/hub/hub_factory.js index 506d374f5e6..7d9fefc8b9d 100644 --- a/erpnext/public/js/hub/hub_factory.js +++ b/erpnext/public/js/hub/hub_factory.js @@ -32,8 +32,9 @@ frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views. }; function is_marketplace_disabled() { - return frappe.model.with_doc('Marketplace Settings') - .then(doc => doc.disable_marketplace); + return frappe.call({ + method: "erpnext.hub_node.doctype.marketplace_settings.marketplace_settings.is_marketplace_enabled" + }).then(r => r.message) } $(document).on('toolbar_setup', () => { diff --git a/erpnext/public/js/pos/pos.html b/erpnext/public/js/pos/pos.html index 7287d798f23..89e2940c896 100644 --- a/erpnext/public/js/pos/pos.html +++ b/erpnext/public/js/pos/pos.html @@ -82,7 +82,7 @@ {% for(var j=i*3; j <(i+1)*3; j++) { %} {% } %} - + {% } %}