Merge branch 'develop' of https://github.com/frappe/erpnext into cost_center_filter_p_r
This commit is contained in:
commit
c7edc29152
@ -114,10 +114,13 @@ class OpeningInvoiceCreationTool(Document):
|
|||||||
)
|
)
|
||||||
or {}
|
or {}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
default_currency = frappe.db.get_value(row.party_type, row.party, "default_currency")
|
||||||
|
|
||||||
if company_details:
|
if company_details:
|
||||||
invoice.update(
|
invoice.update(
|
||||||
{
|
{
|
||||||
"currency": company_details.get("default_currency"),
|
"currency": default_currency or company_details.get("default_currency"),
|
||||||
"letter_head": company_details.get("default_letter_head"),
|
"letter_head": company_details.get("default_letter_head"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -154,7 +157,6 @@ class OpeningInvoiceCreationTool(Document):
|
|||||||
"income_account" if row.party_type == "Customer" else "expense_account"
|
"income_account" if row.party_type == "Customer" else "expense_account"
|
||||||
)
|
)
|
||||||
default_uom = frappe.db.get_single_value("Stock Settings", "stock_uom") or _("Nos")
|
default_uom = frappe.db.get_single_value("Stock Settings", "stock_uom") or _("Nos")
|
||||||
default_currency = frappe.db.get_value(row.party_type, row.party, "default_currency")
|
|
||||||
rate = flt(row.outstanding_amount) / flt(row.qty)
|
rate = flt(row.outstanding_amount) / flt(row.qty)
|
||||||
|
|
||||||
item_dict = frappe._dict(
|
item_dict = frappe._dict(
|
||||||
@ -167,7 +169,6 @@ class OpeningInvoiceCreationTool(Document):
|
|||||||
"description": row.item_name or "Opening Invoice Item",
|
"description": row.item_name or "Opening Invoice Item",
|
||||||
income_expense_account_field: row.temporary_opening_account,
|
income_expense_account_field: row.temporary_opening_account,
|
||||||
"cost_center": cost_center,
|
"cost_center": cost_center,
|
||||||
"currency": default_currency,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import cint, get_datetime
|
from frappe.utils import cint, get_datetime, get_link_to_form
|
||||||
|
|
||||||
from erpnext.hr.doctype.attendance.attendance import (
|
from erpnext.hr.doctype.attendance.attendance import (
|
||||||
get_duplicate_attendance_record,
|
get_duplicate_attendance_record,
|
||||||
@ -130,14 +130,11 @@ def mark_attendance_and_link_log(
|
|||||||
"""
|
"""
|
||||||
log_names = [x.name for x in logs]
|
log_names = [x.name for x in logs]
|
||||||
employee = logs[0].employee
|
employee = logs[0].employee
|
||||||
|
|
||||||
if attendance_status == "Skip":
|
if attendance_status == "Skip":
|
||||||
frappe.db.sql(
|
skip_attendance_in_checkins(log_names)
|
||||||
"""update `tabEmployee Checkin`
|
|
||||||
set skip_auto_attendance = %s
|
|
||||||
where name in %s""",
|
|
||||||
("1", log_names),
|
|
||||||
)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
elif attendance_status in ("Present", "Absent", "Half Day"):
|
elif attendance_status in ("Present", "Absent", "Half Day"):
|
||||||
employee_doc = frappe.get_doc("Employee", employee)
|
employee_doc = frappe.get_doc("Employee", employee)
|
||||||
duplicate = get_duplicate_attendance_record(employee, attendance_date, shift)
|
duplicate = get_duplicate_attendance_record(employee, attendance_date, shift)
|
||||||
@ -159,6 +156,12 @@ def mark_attendance_and_link_log(
|
|||||||
}
|
}
|
||||||
attendance = frappe.get_doc(doc_dict).insert()
|
attendance = frappe.get_doc(doc_dict).insert()
|
||||||
attendance.submit()
|
attendance.submit()
|
||||||
|
|
||||||
|
if attendance_status == "Absent":
|
||||||
|
attendance.add_comment(
|
||||||
|
text=_("Employee was marked Absent for not meeting the working hours threshold.")
|
||||||
|
)
|
||||||
|
|
||||||
frappe.db.sql(
|
frappe.db.sql(
|
||||||
"""update `tabEmployee Checkin`
|
"""update `tabEmployee Checkin`
|
||||||
set attendance = %s
|
set attendance = %s
|
||||||
@ -167,13 +170,10 @@ def mark_attendance_and_link_log(
|
|||||||
)
|
)
|
||||||
return attendance
|
return attendance
|
||||||
else:
|
else:
|
||||||
frappe.db.sql(
|
skip_attendance_in_checkins(log_names)
|
||||||
"""update `tabEmployee Checkin`
|
add_comment_in_checkins(log_names, duplicate, overlapping)
|
||||||
set skip_auto_attendance = %s
|
|
||||||
where name in %s""",
|
|
||||||
("1", log_names),
|
|
||||||
)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
frappe.throw(_("{} is an invalid Attendance Status.").format(attendance_status))
|
frappe.throw(_("{} is an invalid Attendance Status.").format(attendance_status))
|
||||||
|
|
||||||
@ -241,3 +241,34 @@ def time_diff_in_hours(start, end):
|
|||||||
|
|
||||||
def find_index_in_dict(dict_list, key, value):
|
def find_index_in_dict(dict_list, key, value):
|
||||||
return next((index for (index, d) in enumerate(dict_list) if d[key] == value), None)
|
return next((index for (index, d) in enumerate(dict_list) if d[key] == value), None)
|
||||||
|
|
||||||
|
|
||||||
|
def add_comment_in_checkins(log_names, duplicate, overlapping):
|
||||||
|
if duplicate:
|
||||||
|
text = _("Auto Attendance skipped due to duplicate attendance record: {}").format(
|
||||||
|
get_link_to_form("Attendance", duplicate[0].name)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
text = _("Auto Attendance skipped due to overlapping attendance record: {}").format(
|
||||||
|
get_link_to_form("Attendance", overlapping.name)
|
||||||
|
)
|
||||||
|
|
||||||
|
for name in log_names:
|
||||||
|
frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Comment",
|
||||||
|
"comment_type": "Comment",
|
||||||
|
"reference_doctype": "Employee Checkin",
|
||||||
|
"reference_name": name,
|
||||||
|
"content": text,
|
||||||
|
}
|
||||||
|
).insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
|
||||||
|
def skip_attendance_in_checkins(log_names):
|
||||||
|
EmployeeCheckin = frappe.qb.DocType("Employee Checkin")
|
||||||
|
(
|
||||||
|
frappe.qb.update(EmployeeCheckin)
|
||||||
|
.set("skip_auto_attendance", 1)
|
||||||
|
.where(EmployeeCheckin.name.isin(log_names))
|
||||||
|
).run()
|
||||||
|
@ -134,7 +134,17 @@ class ShiftType(Document):
|
|||||||
shift_details = get_employee_shift(employee, timestamp, True)
|
shift_details = get_employee_shift(employee, timestamp, True)
|
||||||
|
|
||||||
if shift_details and shift_details.shift_type.name == self.name:
|
if shift_details and shift_details.shift_type.name == self.name:
|
||||||
mark_attendance(employee, date, "Absent", self.name)
|
attendance = mark_attendance(employee, date, "Absent", self.name)
|
||||||
|
if attendance:
|
||||||
|
frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Comment",
|
||||||
|
"comment_type": "Comment",
|
||||||
|
"reference_doctype": "Attendance",
|
||||||
|
"reference_name": attendance,
|
||||||
|
"content": frappe._("Employee was marked Absent due to missing Employee Checkins."),
|
||||||
|
}
|
||||||
|
).insert(ignore_permissions=True)
|
||||||
|
|
||||||
def get_start_and_end_dates(self, employee):
|
def get_start_and_end_dates(self, employee):
|
||||||
"""Returns start and end dates for checking attendance and marking absent
|
"""Returns start and end dates for checking attendance and marking absent
|
||||||
|
@ -244,7 +244,7 @@ def make_custom_fields():
|
|||||||
"Supplier Quotation Item": invoice_item_fields,
|
"Supplier Quotation Item": invoice_item_fields,
|
||||||
}
|
}
|
||||||
|
|
||||||
create_custom_fields(custom_fields)
|
create_custom_fields(custom_fields, ignore_validate=True)
|
||||||
|
|
||||||
|
|
||||||
def add_print_formats():
|
def add_print_formats():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user