Merge branch 'staging-fixes' into staging
This commit is contained in:
commit
881bb4646b
@ -5,7 +5,7 @@ import frappe
|
|||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
__version__ = '10.1.61'
|
__version__ = '10.1.63'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
@ -41,24 +41,14 @@ def create_plan():
|
|||||||
plan.billing_interval_count = 14
|
plan.billing_interval_count = 14
|
||||||
plan.insert()
|
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):
|
class TestSubscription(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
create_plan()
|
create_plan()
|
||||||
create_subscriber()
|
|
||||||
|
|
||||||
def test_create_subscription_with_trial_with_correct_period(self):
|
def test_create_subscription_with_trial_with_correct_period(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.trial_period_start = nowdate()
|
subscription.trial_period_start = nowdate()
|
||||||
subscription.trial_period_end = add_days(nowdate(), 30)
|
subscription.trial_period_end = add_days(nowdate(), 30)
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
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):
|
def test_create_subscription_without_trial_with_correct_period(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
|
|
||||||
@ -91,7 +81,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
|
|
||||||
def test_create_subscription_trial_with_wrong_dates(self):
|
def test_create_subscription_trial_with_wrong_dates(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.trial_period_end = nowdate()
|
subscription.trial_period_end = nowdate()
|
||||||
subscription.trial_period_start = add_days(nowdate(), 30)
|
subscription.trial_period_start = add_days(nowdate(), 30)
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
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):
|
def test_create_subscription_multi_with_different_billing_fails(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.trial_period_end = nowdate()
|
subscription.trial_period_end = nowdate()
|
||||||
subscription.trial_period_start = add_days(nowdate(), 30)
|
subscription.trial_period_start = add_days(nowdate(), 30)
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
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):
|
def test_invoice_is_generated_at_end_of_billing_period(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.start = '2018-01-01'
|
subscription.start = '2018-01-01'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.insert()
|
subscription.insert()
|
||||||
@ -129,7 +119,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
|
|
||||||
def test_status_goes_back_to_active_after_invoice_is_paid(self):
|
def test_status_goes_back_to_active_after_invoice_is_paid(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.start = '2018-01-01'
|
subscription.start = '2018-01-01'
|
||||||
subscription.insert()
|
subscription.insert()
|
||||||
@ -159,7 +149,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.start = '2018-01-01'
|
subscription.start = '2018-01-01'
|
||||||
subscription.insert()
|
subscription.insert()
|
||||||
@ -182,7 +172,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.start = '2018-01-01'
|
subscription.start = '2018-01-01'
|
||||||
subscription.insert()
|
subscription.insert()
|
||||||
@ -200,7 +190,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
|
|
||||||
def test_subscription_invoice_days_until_due(self):
|
def test_subscription_invoice_days_until_due(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.days_until_due = 10
|
subscription.days_until_due = 10
|
||||||
subscription.start = add_months(nowdate(), -1)
|
subscription.start = add_months(nowdate(), -1)
|
||||||
@ -218,7 +208,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.start = '2018-01-01'
|
subscription.start = '2018-01-01'
|
||||||
subscription.insert()
|
subscription.insert()
|
||||||
@ -242,7 +232,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
|
|
||||||
def test_subscription_remains_active_during_invoice_period(self):
|
def test_subscription_remains_active_during_invoice_period(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
subscription.process() # no changes expected
|
subscription.process() # no changes expected
|
||||||
@ -268,7 +258,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
|
|
||||||
def test_subscription_cancelation(self):
|
def test_subscription_cancelation(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
subscription.cancel_subscription()
|
subscription.cancel_subscription()
|
||||||
@ -284,7 +274,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
|
|
||||||
@ -319,7 +309,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
subscription.cancel_subscription()
|
subscription.cancel_subscription()
|
||||||
@ -339,7 +329,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
subscription.cancel_subscription()
|
subscription.cancel_subscription()
|
||||||
@ -363,7 +353,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.start = '2018-01-01'
|
subscription.start = '2018-01-01'
|
||||||
subscription.insert()
|
subscription.insert()
|
||||||
@ -397,7 +387,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.start = '2018-01-01'
|
subscription.start = '2018-01-01'
|
||||||
subscription.insert()
|
subscription.insert()
|
||||||
@ -434,7 +424,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.start = '2018-01-01'
|
subscription.start = '2018-01-01'
|
||||||
subscription.insert()
|
subscription.insert()
|
||||||
@ -463,7 +453,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
|
|
||||||
def test_restart_active_subscription(self):
|
def test_restart_active_subscription(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
|
|
||||||
@ -473,7 +463,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
|
|
||||||
def test_subscription_invoice_discount_percentage(self):
|
def test_subscription_invoice_discount_percentage(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.additional_discount_percentage = 10
|
subscription.additional_discount_percentage = 10
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
@ -488,7 +478,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
|
|
||||||
def test_subscription_invoice_discount_amount(self):
|
def test_subscription_invoice_discount_amount(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.additional_discount_amount = 11
|
subscription.additional_discount_amount = 11
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
@ -505,7 +495,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
# Create a non pre-billed subscription, processing should not create
|
# Create a non pre-billed subscription, processing should not create
|
||||||
# invoices.
|
# invoices.
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
subscription.process()
|
subscription.process()
|
||||||
@ -527,7 +517,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
subscription.subscriber = '_Test Customer'
|
subscription.customer = '_Test Customer'
|
||||||
subscription.generate_invoice_at_period_start = True
|
subscription.generate_invoice_at_period_start = True
|
||||||
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
|
||||||
subscription.save()
|
subscription.save()
|
||||||
|
@ -339,19 +339,20 @@ def set_gl_entries_by_account(
|
|||||||
|
|
||||||
additional_conditions = get_additional_conditions(from_date, ignore_closing_entries, filters)
|
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`
|
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
|
where company=%(company)s
|
||||||
{additional_conditions}
|
{additional_conditions}
|
||||||
and posting_date <= %(to_date)s
|
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),
|
order by account, posting_date""".format(additional_conditions=additional_conditions),
|
||||||
{
|
{
|
||||||
"company": company,
|
"company": company,
|
||||||
"from_date": from_date,
|
"from_date": from_date,
|
||||||
"to_date": to_date,
|
"to_date": to_date,
|
||||||
"lft": root_lft,
|
|
||||||
"rgt": root_rgt,
|
|
||||||
"cost_center": filters.cost_center,
|
"cost_center": filters.cost_center,
|
||||||
"project": filters.project
|
"project": filters.project
|
||||||
},
|
},
|
||||||
|
@ -128,7 +128,7 @@ frappe.ui.form.on("Request for Quotation",{
|
|||||||
doctype: "Supplier",
|
doctype: "Supplier",
|
||||||
order_by: "name",
|
order_by: "name",
|
||||||
fields: ["name"],
|
fields: ["name"],
|
||||||
filters: [["Supplier", "supplier_group_name", "=", args.supplier_group]]
|
filters: [["Supplier", "supplier_group", "=", args.supplier_group]]
|
||||||
|
|
||||||
},
|
},
|
||||||
callback: load_suppliers
|
callback: load_suppliers
|
||||||
|
@ -12,7 +12,7 @@ app_license = "GNU General Public License (v3)"
|
|||||||
source_link = "https://github.com/frappe/erpnext"
|
source_link = "https://github.com/frappe/erpnext"
|
||||||
|
|
||||||
develop_version = '11.x.x-develop'
|
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"
|
error_report_email = "support@erpnext.com"
|
||||||
|
|
||||||
|
@ -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."))
|
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):
|
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)
|
consider_all_leaves_in_the_allocation_period=True)
|
||||||
|
|
||||||
if self.status != "Rejected" and self.leave_balance < self.total_leave_days:
|
if self.status != "Rejected" and self.leave_balance < self.total_leave_days:
|
||||||
if frappe.db.get_value("Leave Type", self.leave_type, "allow_negative"):
|
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}")
|
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
|
return ret
|
||||||
|
|
||||||
@frappe.whitelist()
|
@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):
|
consider_all_leaves_in_the_allocation_period=False, consider_encashed_leaves=True):
|
||||||
|
|
||||||
if allocation_records == None:
|
if allocation_records == None:
|
||||||
allocation_records = get_leave_allocation_records(date, employee).get(employee, frappe._dict())
|
allocation_records = get_leave_allocation_records(date, employee).get(employee, frappe._dict())
|
||||||
|
|
||||||
allocation = allocation_records.get(leave_type, frappe._dict())
|
allocation = allocation_records.get(leave_type, frappe._dict())
|
||||||
|
|
||||||
if consider_all_leaves_in_the_allocation_period:
|
if consider_all_leaves_in_the_allocation_period:
|
||||||
date = allocation.to_date
|
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
|
leaves_encashed = 0
|
||||||
if frappe.db.get_value("Leave Type", leave_type, 'allow_encashment') and consider_encashed_leaves:
|
if frappe.db.get_value("Leave Type", leave_type, 'allow_encashment') and consider_encashed_leaves:
|
||||||
leaves_encashed = flt(allocation.total_leaves_encashed)
|
leaves_encashed = flt(allocation.total_leaves_encashed)
|
||||||
|
|
||||||
return flt(allocation.total_leaves_allocated) - (flt(leaves_taken) + flt(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("""
|
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`
|
from `tabLeave Application`
|
||||||
where employee=%(employee)s and leave_type=%(leave_type)s
|
where employee=%(employee)s and leave_type=%(leave_type)s
|
||||||
and status = %(status)s and docstatus != 2
|
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,
|
"status": status,
|
||||||
"leave_type": leave_type
|
"leave_type": leave_type
|
||||||
}, as_dict=1)
|
}, as_dict=1)
|
||||||
|
|
||||||
leave_days = 0
|
leave_days = 0
|
||||||
for leave_app in leave_applications:
|
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):
|
if leave_app.from_date >= getdate(from_date) and leave_app.to_date <= getdate(to_date):
|
||||||
leave_days += leave_app.total_leave_days
|
leave_days += leave_app.total_leave_days
|
||||||
else:
|
else:
|
||||||
@ -450,7 +448,6 @@ def get_leave_allocation_records(date, employee=None):
|
|||||||
"total_leaves_allocated": d.total_leaves_allocated,
|
"total_leaves_allocated": d.total_leaves_allocated,
|
||||||
"total_leaves_encashed":d.total_leaves_encashed
|
"total_leaves_encashed":d.total_leaves_encashed
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return allocated_leaves
|
return allocated_leaves
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
@ -392,6 +392,34 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
i += 1
|
i += 1
|
||||||
self.assertEqual(get_leave_balance_on(employee.name, leave_type, nowdate()), 6)
|
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):
|
def make_allocation_record(employee=None, leave_type=None):
|
||||||
frappe.db.sql("delete from `tabLeave Allocation`")
|
frappe.db.sql("delete from `tabLeave Allocation`")
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe, requests, json, time
|
import frappe, requests, json, time
|
||||||
|
|
||||||
from frappe.model.document import Document
|
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 import _
|
||||||
from frappe.frappeclient import FrappeClient
|
from frappe.frappeclient import FrappeClient
|
||||||
from erpnext.utilities.product import get_price, get_qty_in_stock
|
from erpnext.utilities.product import get_price, get_qty_in_stock
|
||||||
@ -84,3 +84,11 @@ class MarketplaceSettings(Document):
|
|||||||
def unregister(self):
|
def unregister(self):
|
||||||
"""Disable the User on hubmarket.org"""
|
"""Disable the User on hubmarket.org"""
|
||||||
pass
|
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
|
||||||
|
@ -32,8 +32,9 @@ frappe.views.marketplaceFactory = class marketplaceFactory extends frappe.views.
|
|||||||
};
|
};
|
||||||
|
|
||||||
function is_marketplace_disabled() {
|
function is_marketplace_disabled() {
|
||||||
return frappe.model.with_doc('Marketplace Settings')
|
return frappe.call({
|
||||||
.then(doc => doc.disable_marketplace);
|
method: "erpnext.hub_node.doctype.marketplace_settings.marketplace_settings.is_marketplace_enabled"
|
||||||
|
}).then(r => r.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('toolbar_setup', () => {
|
$(document).on('toolbar_setup', () => {
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
{% for(var j=i*3; j
|
{% for(var j=i*3; j
|
||||||
<(i+1)*3; j++) { %} <button type="button" class="btn btn-default numeric-keypad" val="{{j+1}}">{{j+1}}</button>
|
<(i+1)*3; j++) { %} <button type="button" class="btn btn-default numeric-keypad" val="{{j+1}}">{{j+1}}</button>
|
||||||
{% } %}
|
{% } %}
|
||||||
<button type="button" {% if((!allow_user_to_edit_rate && chartData[i] == __("Price")) || (!allow_user_to_edit_discount && chartData[i] == __("Disc"))) { %} disabled {% } %} id="pos-item-{{ chartData[i].toLowerCase() }}" class="btn text-center btn-default numeric-keypad pos-operation">{{ __(chartData[i]) }}</button>
|
<button type="button" {% if((!allow_user_to_edit_rate && __(chartData[i]) == __("Price")) || (!allow_user_to_edit_discount && __(chartData[i]) == __("Disc"))) { %} disabled {% } %} id="pos-item-{{ chartData[i].toLowerCase() }}" class="btn text-center btn-default numeric-keypad pos-operation">{{ __(chartData[i]) }}</button>
|
||||||
</div>
|
</div>
|
||||||
{% } %}
|
{% } %}
|
||||||
<div class="row text-right">
|
<div class="row text-right">
|
||||||
|
@ -20,7 +20,7 @@ def execute(filters=None):
|
|||||||
for d in entries:
|
for d in entries:
|
||||||
if d.stock_qty > 0 or filters.get('show_return_entries', 0):
|
if d.stock_qty > 0 or filters.get('show_return_entries', 0):
|
||||||
data.append([
|
data.append([
|
||||||
d.name, d.customer, d.territory, item_details.get(d.item_code, {}).get("website_warehouse"), d.posting_date, d.item_code,
|
d.name, d.customer, d.territory, d.warehouse, d.posting_date, d.item_code,
|
||||||
item_details.get(d.item_code, {}).get("item_group"), item_details.get(d.item_code, {}).get("brand"),
|
item_details.get(d.item_code, {}).get("item_group"), item_details.get(d.item_code, {}).get("brand"),
|
||||||
d.stock_qty, d.base_net_amount, d.sales_person, d.allocated_percentage, d.contribution_amt, company_currency
|
d.stock_qty, d.base_net_amount, d.sales_person, d.allocated_percentage, d.contribution_amt, company_currency
|
||||||
])
|
])
|
||||||
@ -144,9 +144,9 @@ def get_entries(filters):
|
|||||||
conditions, values = get_conditions(filters, date_field)
|
conditions, values = get_conditions(filters, date_field)
|
||||||
|
|
||||||
entries = frappe.db.sql("""
|
entries = frappe.db.sql("""
|
||||||
select
|
SELECT
|
||||||
dt.name, dt.customer, dt.territory, dt.%s as posting_date, dt_item.item_code,
|
dt.name, dt.customer, dt.territory, dt.%s as posting_date, dt_item.item_code,
|
||||||
st.sales_person, st.allocated_percentage,
|
st.sales_person, st.allocated_percentage, dt_item.warehouse,
|
||||||
CASE
|
CASE
|
||||||
WHEN dt.status = "Closed" THEN dt_item.%s * dt_item.conversion_factor
|
WHEN dt.status = "Closed" THEN dt_item.%s * dt_item.conversion_factor
|
||||||
ELSE dt_item.stock_qty
|
ELSE dt_item.stock_qty
|
||||||
@ -159,9 +159,9 @@ def get_entries(filters):
|
|||||||
WHEN dt.status = "Closed" THEN ((dt_item.base_net_rate * dt_item.%s * dt_item.conversion_factor) * st.allocated_percentage/100)
|
WHEN dt.status = "Closed" THEN ((dt_item.base_net_rate * dt_item.%s * dt_item.conversion_factor) * st.allocated_percentage/100)
|
||||||
ELSE dt_item.base_net_amount * st.allocated_percentage/100
|
ELSE dt_item.base_net_amount * st.allocated_percentage/100
|
||||||
END as contribution_amt
|
END as contribution_amt
|
||||||
from
|
FROM
|
||||||
`tab%s` dt, `tab%s Item` dt_item, `tabSales Team` st
|
`tab%s` dt, `tab%s Item` dt_item, `tabSales Team` st
|
||||||
where
|
WHERE
|
||||||
st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = %s
|
st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = %s
|
||||||
and dt.docstatus = 1 %s order by st.sales_person, dt.name desc
|
and dt.docstatus = 1 %s order by st.sales_person, dt.name desc
|
||||||
""" %(date_field, qty_field, qty_field, qty_field, filters["doc_type"], filters["doc_type"], '%s', conditions),
|
""" %(date_field, qty_field, qty_field, qty_field, filters["doc_type"], filters["doc_type"], '%s', conditions),
|
||||||
@ -211,7 +211,7 @@ def get_items(filters):
|
|||||||
|
|
||||||
def get_item_details():
|
def get_item_details():
|
||||||
item_details = {}
|
item_details = {}
|
||||||
for d in frappe.db.sql("""select name, item_group, brand, website_warehouse from `tabItem`""", as_dict=1):
|
for d in frappe.db.sql("""SELECT `name`, `item_group`, `brand` FROM `tabItem`""", as_dict=1):
|
||||||
item_details.setdefault(d.name, d)
|
item_details.setdefault(d.name, d)
|
||||||
|
|
||||||
return item_details
|
return item_details
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"allow_copy": 0,
|
||||||
|
"allow_events_in_timeline": 0,
|
||||||
"allow_guest_to_view": 0,
|
"allow_guest_to_view": 0,
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
@ -397,7 +398,7 @@
|
|||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 1,
|
"read_only": 0,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -1613,7 +1614,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-08-29 06:29:51.682813",
|
"modified": "2018-10-19 12:38:34.448513",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Serial No",
|
"name": "Serial No",
|
||||||
@ -1684,7 +1685,7 @@
|
|||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"track_changes": 0,
|
"track_changes": 1,
|
||||||
"track_seen": 0,
|
"track_seen": 0,
|
||||||
"track_views": 0
|
"track_views": 0
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user