chore: Remove code for Expense Claim from Project, Task, Delivery Trip
- Remove `total_expense_claim` field from Project and Task, will be installed with hrms setup
- Remove Expense Claim calculation from `update_costing` in project
- Remove `update_total_expense_claim` from task
- Remove Expense Claim references from employee form tour
- Remove 'Make Expense Claim' button from Delivery Trip, will only be available if hrms is installed
- Update delivery trip tests
diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json
index 1790da4..37d98ad 100644
--- a/erpnext/projects/doctype/project/project.json
+++ b/erpnext/projects/doctype/project/project.json
@@ -38,7 +38,6 @@
"project_details",
"estimated_costing",
"total_costing_amount",
- "total_expense_claim",
"total_purchase_cost",
"company",
"column_break_28",
@@ -280,12 +279,6 @@
"read_only": 1
},
{
- "fieldname": "total_expense_claim",
- "fieldtype": "Currency",
- "label": "Total Expense Claim (via Expense Claims)",
- "read_only": 1
- },
- {
"fieldname": "total_purchase_cost",
"fieldtype": "Currency",
"label": "Total Purchase Cost (via Purchase Invoice)",
@@ -458,7 +451,7 @@
"index_web_pages_for_search": 1,
"links": [],
"max_attachments": 4,
- "modified": "2022-05-25 22:45:06.108499",
+ "modified": "2022-06-23 16:45:06.108499",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project",
diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py
index b1fd1d9..7646078 100644
--- a/erpnext/projects/doctype/project/project.py
+++ b/erpnext/projects/doctype/project/project.py
@@ -211,26 +211,20 @@
self.status = "Completed"
def update_costing(self):
- from_time_sheet = frappe.db.sql(
- """select
- sum(costing_amount) as costing_amount,
- sum(billing_amount) as billing_amount,
- min(from_time) as start_date,
- max(to_time) as end_date,
- sum(hours) as time
- from `tabTimesheet Detail` where project = %s and docstatus = 1""",
- self.name,
- as_dict=1,
- )[0]
+ from frappe.query_builder.functions import Max, Min, Sum
- from_expense_claim = frappe.db.sql(
- """select
- sum(total_sanctioned_amount) as total_sanctioned_amount
- from `tabExpense Claim` where project = %s
- and docstatus = 1""",
- self.name,
- as_dict=1,
- )[0]
+ TimesheetDetail = frappe.qb.DocType("Timesheet Detail")
+ from_time_sheet = (
+ frappe.qb.from_(TimesheetDetail)
+ .select(
+ Sum(TimesheetDetail.costing_amount).as_("costing_amount"),
+ Sum(TimesheetDetail.billing_amount).as_("billing_amount"),
+ Min(TimesheetDetail.from_time).as_("start_date"),
+ Max(TimesheetDetail.to_time).as_("end_date"),
+ Sum(TimesheetDetail.hours).as_("time"),
+ )
+ .where((TimesheetDetail.project == self.name) & (TimesheetDetail.docstatus == 1))
+ ).run(as_dict=True)[0]
self.actual_start_date = from_time_sheet.start_date
self.actual_end_date = from_time_sheet.end_date
@@ -239,7 +233,6 @@
self.total_billable_amount = from_time_sheet.billing_amount
self.actual_time = from_time_sheet.time
- self.total_expense_claim = from_expense_claim.total_sanctioned_amount
self.update_purchase_costing()
self.update_sales_amount()
self.update_billed_amount()
diff --git a/erpnext/projects/doctype/task/task.json b/erpnext/projects/doctype/task/task.json
index 8182208..141a99e 100644
--- a/erpnext/projects/doctype/task/task.json
+++ b/erpnext/projects/doctype/task/task.json
@@ -42,7 +42,6 @@
"act_end_date",
"sb_costing",
"total_costing_amount",
- "total_expense_claim",
"column_break_20",
"total_billing_amount",
"sb_more_info",
@@ -280,13 +279,6 @@
"read_only": 1
},
{
- "fieldname": "total_expense_claim",
- "fieldtype": "Currency",
- "label": "Total Expense Claim (via Expense Claim)",
- "options": "Company:company:default_currency",
- "read_only": 1
- },
- {
"fieldname": "column_break_20",
"fieldtype": "Column Break"
},
@@ -397,7 +389,7 @@
"is_tree": 1,
"links": [],
"max_attachments": 5,
- "modified": "2022-01-29 13:58:47.005241",
+ "modified": "2022-06-23 16:58:47.005241",
"modified_by": "Administrator",
"module": "Projects",
"name": "Task",
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index 4575fb5..f2600d3 100755
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -156,13 +156,6 @@
if self.status == "Cancelled":
clear(self.doctype, self.name)
- def update_total_expense_claim(self):
- self.total_expense_claim = frappe.db.sql(
- """select sum(total_sanctioned_amount) from `tabExpense Claim`
- where project = %s and task = %s and docstatus=1""",
- (self.project, self.name),
- )[0][0]
-
def update_time_and_costing(self):
tl = frappe.db.sql(
"""select min(from_time) as start_date, max(to_time) as end_date,
diff --git a/erpnext/setup/doctype/employee/employee.js b/erpnext/setup/doctype/employee/employee.js
index 7c62def..637993e 100755
--- a/erpnext/setup/doctype/employee/employee.js
+++ b/erpnext/setup/doctype/employee/employee.js
@@ -129,7 +129,7 @@
{
fieldname: "company",
title: "Company",
- description: __("Select a Company this Employee belongs to. Other HR features like Payroll. Expense Claims and Leaves for this Employee will be created for a given company only.")
+ description: __("Select a Company this Employee belongs to.")
},
{
fieldname: "date_of_birth",
@@ -142,18 +142,8 @@
description: __("Select Date of joining. It will have impact on the first salary calculation, Leave allocation on pro-rata bases.")
},
{
- fieldname: "holiday_list",
- title: "Holiday List",
- description: __("Select a default Holiday List for this Employee. The days listed in Holiday List will not be counted in Leave Application.")
- },
- {
fieldname: "reports_to",
title: "Reports To",
description: __("Here, you can select a senior of this Employee. Based on this, Organization Chart will be populated.")
},
- {
- fieldname: "leave_approver",
- title: "Leave Approver",
- description: __("Select Leave Approver for an employee. The user one who will look after his/her Leave application")
- },
];
diff --git a/erpnext/stock/doctype/delivery_trip/delivery_trip.js b/erpnext/stock/doctype/delivery_trip/delivery_trip.js
index 68cba29..a6fbb66 100755
--- a/erpnext/stock/doctype/delivery_trip/delivery_trip.js
+++ b/erpnext/stock/doctype/delivery_trip/delivery_trip.js
@@ -41,15 +41,6 @@
},
refresh: function (frm) {
- if (frm.doc.docstatus == 1 && frm.doc.employee) {
- frm.add_custom_button(__('Expense Claim'), function() {
- frappe.model.open_mapped_doc({
- method: 'erpnext.stock.doctype.delivery_trip.delivery_trip.make_expense_claim',
- frm: cur_frm,
- });
- }, __("Create"));
- }
-
if (frm.doc.docstatus == 1 && frm.doc.delivery_stops.length > 0) {
frm.add_custom_button(__("Notify Customers via Email"), function () {
frm.trigger('notify_customers');
diff --git a/erpnext/stock/doctype/delivery_trip/delivery_trip.py b/erpnext/stock/doctype/delivery_trip/delivery_trip.py
index 73b250d..88204ef 100644
--- a/erpnext/stock/doctype/delivery_trip/delivery_trip.py
+++ b/erpnext/stock/doctype/delivery_trip/delivery_trip.py
@@ -8,7 +8,6 @@
from frappe import _
from frappe.contacts.doctype.address.address import get_address_display
from frappe.model.document import Document
-from frappe.model.mapper import get_mapped_doc
from frappe.utils import cint, get_datetime, get_link_to_form
@@ -416,15 +415,3 @@
employee = frappe.db.get_value("Driver", driver, "employee")
email = frappe.db.get_value("Employee", employee, "prefered_email")
return {"email": email}
-
-
-@frappe.whitelist()
-def make_expense_claim(source_name, target_doc=None):
- doc = get_mapped_doc(
- "Delivery Trip",
- source_name,
- {"Delivery Trip": {"doctype": "Expense Claim", "field_map": {"name": "delivery_trip"}}},
- target_doc,
- )
-
- return doc
diff --git a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py
index 555361a..ed699e3 100644
--- a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py
+++ b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py
@@ -10,7 +10,6 @@
import erpnext
from erpnext.stock.doctype.delivery_trip.delivery_trip import (
get_contact_and_address,
- make_expense_claim,
notify_customers,
)
from erpnext.tests.utils import create_test_contact_and_address
@@ -34,10 +33,6 @@
frappe.db.sql("delete from `tabDelivery Trip`")
return super().tearDown()
- def test_expense_claim_fields_are_fetched_properly(self):
- expense_claim = make_expense_claim(self.delivery_trip.name)
- self.assertEqual(self.delivery_trip.name, expense_claim.delivery_trip)
-
def test_delivery_trip_notify_customers(self):
notify_customers(delivery_trip=self.delivery_trip.name)
self.delivery_trip.load_from_db()