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
This commit is contained in:
parent
1ff0e4519f
commit
edb528ce41
@ -38,7 +38,6 @@
|
||||
"project_details",
|
||||
"estimated_costing",
|
||||
"total_costing_amount",
|
||||
"total_expense_claim",
|
||||
"total_purchase_cost",
|
||||
"company",
|
||||
"column_break_28",
|
||||
@ -279,12 +278,6 @@
|
||||
"label": "Total Costing Amount (via Timesheets)",
|
||||
"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",
|
||||
@ -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",
|
||||
|
@ -211,26 +211,20 @@ class Project(Document):
|
||||
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 @@ class Project(Document):
|
||||
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()
|
||||
|
@ -42,7 +42,6 @@
|
||||
"act_end_date",
|
||||
"sb_costing",
|
||||
"total_costing_amount",
|
||||
"total_expense_claim",
|
||||
"column_break_20",
|
||||
"total_billing_amount",
|
||||
"sb_more_info",
|
||||
@ -279,13 +278,6 @@
|
||||
"options": "Company:company:default_currency",
|
||||
"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",
|
||||
|
@ -156,13 +156,6 @@ class Task(NestedSet):
|
||||
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,
|
||||
|
@ -129,7 +129,7 @@ frappe.tour['Employee'] = [
|
||||
{
|
||||
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",
|
||||
@ -141,19 +141,9 @@ frappe.tour['Employee'] = [
|
||||
title: "Date of Joining",
|
||||
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")
|
||||
},
|
||||
];
|
||||
|
@ -41,15 +41,6 @@ frappe.ui.form.on('Delivery Trip', {
|
||||
},
|
||||
|
||||
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');
|
||||
|
@ -8,7 +8,6 @@ import frappe
|
||||
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 @@ def get_driver_email(driver):
|
||||
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
|
||||
|
@ -10,7 +10,6 @@ from frappe.utils import add_days, flt, now_datetime, nowdate
|
||||
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 @@ class TestDeliveryTrip(FrappeTestCase):
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user