Merge branch 'version-13-hotfix' into redisearch-app-install-v13

This commit is contained in:
Marica
2022-04-04 13:28:09 +05:30
committed by GitHub
10 changed files with 120 additions and 121 deletions

View File

@@ -2,6 +2,17 @@
// For license information, please see license.txt
frappe.ui.form.on("Contract", {
onload: function(frm) {
frappe.db.get_value(
"Selling Settings",
"Selling Settings",
"contract_naming_by",
(r) => {
frm.toggle_display("naming_series", r.contract_naming_by === "Naming Series");
}
);
},
contract_template: function (frm) {
if (frm.doc.contract_template) {
frappe.call({

View File

@@ -2,11 +2,13 @@
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "naming_series:",
"creation": "2018-04-12 06:32:04.582486",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"naming_series",
"party_type",
"is_signed",
"cb_party",
@@ -244,11 +246,20 @@
"fieldname": "authorised_by_section",
"fieldtype": "Section Break",
"label": "Authorised By"
},
{
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Naming Series",
"no_copy": 1,
"options": "CRM-CONTR-.YYYY.-",
"reqd": 1,
"set_only_once": 1
}
],
"is_submittable": 1,
"links": [],
"modified": "2020-12-07 11:15:58.385521",
"modified": "2022-03-28 10:22:11.156658",
"modified_by": "Administrator",
"module": "CRM",
"name": "Contract",

View File

@@ -5,22 +5,32 @@
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.model.naming import set_name_by_naming_series
from frappe.utils import getdate, nowdate
class Contract(Document):
def autoname(self):
name = self.party_name
if frappe.db.get_single_value("Selling Settings", "contract_naming_by") == "Naming Series":
set_name_by_naming_series(self)
if self.contract_template:
name += " - {} Agreement".format(self.contract_template)
else:
name = self.party_name
# If identical, append contract name with the next number in the iteration
if frappe.db.exists("Contract", name):
count = len(frappe.get_all("Contract", filters={"name": ["like", "%{}%".format(name)]}))
name = "{} - {}".format(name, count)
if self.contract_template:
name = f"{name} - {self.contract_template} Agreement"
self.name = _(name)
# If identical, append contract name with the next number in the iteration
if frappe.db.exists("Contract", name):
count = frappe.db.count(
"Contract",
filters={
"name": ("like", f"%{name}%"),
},
)
name = f"{name} - {count}"
self.name = _(name)
def validate(self):
self.validate_dates()

View File

@@ -1,6 +1,6 @@
<div class="web-list-item transaction-list-item">
{% set today = frappe.utils.getdate(frappe.utils.nowdate()) %}
<a href = "{{ doc.route }}/" class="no-underline">
<a href = "{{ doc.route }}" class="no-underline">
<div class="row">
<div class="col-sm-4 bold">
<span class="indicator

View File

@@ -735,9 +735,9 @@ def get_number_of_leave_days(
(Based on the include_holiday setting in Leave Type)"""
number_of_days = 0
if cint(half_day) == 1:
if from_date == to_date:
if getdate(from_date) == getdate(to_date):
number_of_days = 0.5
elif half_day_date and half_day_date <= to_date:
elif half_day_date and getdate(from_date) <= getdate(half_day_date) <= getdate(to_date):
number_of_days = date_diff(to_date, from_date) + 0.5
else:
number_of_days = date_diff(to_date, from_date) + 1

View File

@@ -205,7 +205,12 @@ class TestLeaveApplication(unittest.TestCase):
# creates separate leave ledger entries
frappe.delete_doc_if_exists("Leave Type", "Test Leave Validation", force=1)
leave_type = frappe.get_doc(
dict(leave_type_name="Test Leave Validation", doctype="Leave Type", allow_negative=True)
dict(
leave_type_name="Test Leave Validation",
doctype="Leave Type",
allow_negative=True,
include_holiday=True,
)
).insert()
employee = get_employee()
@@ -217,8 +222,14 @@ class TestLeaveApplication(unittest.TestCase):
# application across allocations
# CASE 1: from date has no allocation, to date has an allocation / both dates have allocation
start_date = add_days(year_start, -10)
application = make_leave_application(
employee.name, add_days(year_start, -10), add_days(year_start, 3), leave_type.name
employee.name,
start_date,
add_days(year_start, 3),
leave_type.name,
half_day=1,
half_day_date=start_date,
)
# 2 separate leave ledger entries
@@ -827,6 +838,7 @@ class TestLeaveApplication(unittest.TestCase):
leave_type_name="_Test_CF_leave_expiry",
is_carry_forward=1,
expire_carry_forwarded_leaves_after_days=90,
include_holiday=True,
)
leave_type.submit()
@@ -839,6 +851,8 @@ class TestLeaveApplication(unittest.TestCase):
leave_type=leave_type.name,
from_date=add_days(nowdate(), -3),
to_date=add_days(nowdate(), 7),
half_day=1,
half_day_date=add_days(nowdate(), -3),
description="_Test Reason",
company="_Test Company",
docstatus=1,
@@ -854,7 +868,7 @@ class TestLeaveApplication(unittest.TestCase):
self.assertEqual(len(leave_ledger_entry), 2)
self.assertEqual(leave_ledger_entry[0].employee, leave_application.employee)
self.assertEqual(leave_ledger_entry[0].leave_type, leave_application.leave_type)
self.assertEqual(leave_ledger_entry[0].leaves, -9)
self.assertEqual(leave_ledger_entry[0].leaves, -8.5)
self.assertEqual(leave_ledger_entry[1].leaves, -2)
def test_leave_application_creation_after_expiry(self):

View File

@@ -747,5 +747,8 @@ def calculate_amounts(against_loan, posting_date, payment_type=""):
amounts["payable_principal_amount"] = amounts["pending_principal_amount"]
amounts["interest_amount"] += amounts["unaccrued_interest"]
amounts["payable_amount"] = amounts["payable_principal_amount"] + amounts["interest_amount"]
amounts["payable_amount"] = (
amounts["payable_principal_amount"] + amounts["interest_amount"] + amounts["penalty_amount"]
)
return amounts

View File

@@ -1294,7 +1294,16 @@ def create_additional_salary(employee, payroll_period, amount):
return salary_date
def make_leave_application(employee, from_date, to_date, leave_type, company=None, submit=True):
def make_leave_application(
employee,
from_date,
to_date,
leave_type,
company=None,
half_day=False,
half_day_date=None,
submit=True,
):
leave_application = frappe.get_doc(
dict(
doctype="Leave Application",
@@ -1302,6 +1311,8 @@ def make_leave_application(employee, from_date, to_date, leave_type, company=Non
leave_type=leave_type,
from_date=from_date,
to_date=to_date,
half_day=half_day,
half_day_date=half_day_date,
company=company or erpnext.get_default_company() or "_Test Company",
status="Approved",
leave_approver="test@example.com",

View File

@@ -13,6 +13,7 @@
"territory",
"crm_settings_section",
"campaign_naming_by",
"contract_naming_by",
"default_valid_till",
"column_break_9",
"close_opportunity_after_days",
@@ -29,7 +30,6 @@
"so_required",
"dn_required",
"sales_update_frequency",
"column_break_5",
"allow_multiple_items",
"allow_against_multiple_purchase_orders",
"hide_tax_id"
@@ -193,6 +193,12 @@
"fieldname": "sales_transactions_settings_section",
"fieldtype": "Section Break",
"label": "Transaction Settings"
},
{
"fieldname": "contract_naming_by",
"fieldtype": "Select",
"label": "Contract Naming By",
"options": "Party Name\nNaming Series"
}
],
"icon": "fa fa-cog",
@@ -200,7 +206,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2021-09-14 22:05:06.139820",
"modified": "2022-03-28 12:18:06.768403",
"modified_by": "Administrator",
"module": "Selling",
"name": "Selling Settings",
@@ -219,4 +225,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
}

View File

@@ -1,109 +1,42 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"autoname": "field:barcode",
"beta": 0,
"creation": "2017-12-09 18:54:50.562438",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"actions": [],
"autoname": "hash",
"creation": "2022-02-11 11:26:22.155183",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"barcode",
"barcode_type"
],
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "barcode",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Barcode",
"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,
"translatable": 0,
"fieldname": "barcode",
"fieldtype": "Data",
"in_global_search": 1,
"in_list_view": 1,
"label": "Barcode",
"no_copy": 1,
"unique": 1
},
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "barcode_type",
"fieldtype": "Select",
"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": "Barcode Type",
"length": 0,
"no_copy": 0,
"options": "\nEAN\nUPC-A",
"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,
"translatable": 0,
"unique": 0
"fieldname": "barcode_type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Barcode Type",
"options": "\nEAN\nUPC-A"
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-11-13 06:03:09.814357",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item Barcode",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0,
"track_views": 0
],
"istable": 1,
"links": [],
"modified": "2022-04-01 05:54:27.314030",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item Barcode",
"naming_rule": "Random",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}