[ADD] EMPLOYEE: Badge id setup in settings

This commit is contained in:
Horilla
2024-02-01 13:09:43 +05:30
parent f2764d4311
commit 633beb29ba
5 changed files with 146 additions and 30 deletions

View File

@@ -8,6 +8,7 @@ from django.http import HttpResponse
from attendance.models import AttendanceGeneralSetting
from base.models import Company
from base.urls import urlpatterns
from employee.models import EmployeeGeneralSetting
from offboarding.models import OffboardingGeneralSetting
from payroll.models.models import PayrollGeneralSetting
from recruitment.models import RecruitmentGeneralSetting
@@ -149,3 +150,17 @@ def check_candidate_self_tracking_rating(request):
if first:
rating_option = first.show_overall_rating
return {"check_candidate_self_tracking_rating": rating_option}
def get_intial_prefix(request):
"""
This method is used to get the initial prefexi
"""
settings = EmployeeGeneralSetting.objects.first()
instance_id = None
prefix = "PEP"
if settings:
instance_id = settings.id
prefix = settings.badge_id_prefix
return {"get_intial_prefix":prefix,"prefix_instance_id":instance_id}

View File

@@ -5,6 +5,7 @@
{% include "offboarding/settings/settings.html" %}
{% include "attendance/settings/settings.html" %}
{% include "payroll/settings/settings.html" %}
{% include "settings/settings.html" %}
{% include "announcement/expiry_day.html" %}
{% include "settings/encashment_settings.html" %}

View File

@@ -214,8 +214,12 @@ urlpatterns = [
kwargs={"model": Employee},
),
path("document-tab/<int:emp_id>", views.document_tab, name="document-tab"),
path("bonus-points-tab/<int:emp_id>", views.bonus_points_tab, name="bonus-points-tab"),
path("add-bonus-points/<int:emp_id>", views.add_bonus_points, name="add-bonus-points"),
path(
"bonus-points-tab/<int:emp_id>", views.bonus_points_tab, name="bonus-points-tab"
),
path(
"add-bonus-points/<int:emp_id>", views.add_bonus_points, name="add-bonus-points"
),
path("redeem-points/<int:emp_id>", views.redeem_points, name="redeem-points"),
path("employee-select/", views.employee_select, name="employee-select"),
path(
@@ -244,22 +248,58 @@ urlpatterns = [
path("search-policies", policies.search_policies, name="search-policies"),
path("create-policy", policies.create_policy, name="create-policy"),
path("view-policy", policies.view_policy, name="view-policy"),
path("add-attachment-policy", policies.add_attachment, name="add-attachment-policy"),
path("remove-attachment-policy", policies.remove_attachment, name="remove-attachment-policy"),
path("get-attachments-policy", policies.get_attachments, name="get-attachments-policy"),
path(
"add-attachment-policy", policies.add_attachment, name="add-attachment-policy"
),
path(
"remove-attachment-policy",
policies.remove_attachment,
name="remove-attachment-policy",
),
path(
"get-attachments-policy",
policies.get_attachments,
name="get-attachments-policy",
),
path("file-upload/<int:id>", views.file_upload, name="file-upload"),
path("view-file/<int:id>", views.view_file, name="view-file"),
path("document-create", views.document_create, name="document-create"),
path("document-create/<int:emp_id>", views.document_create, name="document-create"),
path("update-document-title/<int:id>", views.update_document_title, name="update-document-title"),
path(
"update-document-title/<int:id>",
views.update_document_title,
name="update-document-title",
),
path("document-approve/<int:id>", views.document_approve, name="document-approve"),
path("document-bulk-approve", views.document_bulk_approve, name="document-bulk-approve"),
path("document-bulk-reject", views.document_bulk_reject, name="document-bulk-reject"),
path(
"document-bulk-approve",
views.document_bulk_approve,
name="document-bulk-approve",
),
path(
"document-bulk-reject", views.document_bulk_reject, name="document-bulk-reject"
),
path("document-reject/<int:id>", views.document_reject, name="document-reject"),
path("document-request-view/", views.document_request_view, name="document-request-view"),
path("document-request-filter-view", views.document_filter_view, name="document-request-filter-view"),
path("document-request-create", views.document_request_create, name="document-request-create"),
path("document-request-update/<int:id>", views.document_request_update, name="document-request-update"),
path(
"document-request-view/",
views.document_request_view,
name="document-request-view",
),
path(
"document-request-filter-view",
views.document_filter_view,
name="document-request-filter-view",
),
path(
"document-request-create",
views.document_request_create,
name="document-request-create",
),
path(
"document-request-update/<int:id>",
views.document_request_update,
name="document-request-update",
),
path(
"document-request-kwargs={'model':Employee}delete/<int:id>/",
object_delete,
@@ -272,16 +312,40 @@ urlpatterns = [
name="document-delete",
),
path("organisation-chart/", views.organisation_chart, name="organisation-chart"),
path("delete-policies",policies.delete_policies,name="delete-policies"),
path("disciplinary-actions/", policies.disciplinary_actions, name="disciplinary-actions"),
path("delete-policies", policies.delete_policies, name="delete-policies"),
path(
"disciplinary-actions/",
policies.disciplinary_actions,
name="disciplinary-actions",
),
path("create-actions", policies.create_actions, name="create-actions"),
path("update-actions/<int:action_id>/", policies.update_actions, name="update-actions"),
path("delete-actions/<int:action_id>/",policies.delete_actions, name="delete-actions"),
path("action-type-details",policies.action_type_details,name="action-type-details",),
path("disciplinary-filter-view", policies.disciplinary_filter_view, name="disciplinary-filter-view"),
path("search-disciplinary", policies.search_disciplinary, name="search-disciplinary"),
path("encashment-condition-create", views.encashment_condition_create, name="encashment-condition-create"),
path(
"update-actions/<int:action_id>/",
policies.update_actions,
name="update-actions",
),
path(
"delete-actions/<int:action_id>/",
policies.delete_actions,
name="delete-actions",
),
path(
"action-type-details",
policies.action_type_details,
name="action-type-details",
),
path(
"disciplinary-filter-view",
policies.disciplinary_filter_view,
name="disciplinary-filter-view",
),
path(
"search-disciplinary", policies.search_disciplinary, name="search-disciplinary"
),
path(
"encashment-condition-create",
views.encashment_condition_create,
name="encashment-condition-create",
),
path("initial-prefix",views.initial_prefix,name="initial-prefix")
]

View File

@@ -91,13 +91,20 @@ from horilla_documents.forms import (
from employee.models import (
BonusPoint,
Employee,
EmployeeGeneralSetting,
EmployeeNote,
EmployeeWorkInformation,
EmployeeBankDetails,
)
from payroll.forms.forms import EncashmentGeneralSettingsForm
from payroll.methods.payslip_calc import dynamic_attr
from payroll.models.models import Allowance, Contract, Deduction, EncashmentGeneralSettings, Reimbursement
from payroll.models.models import (
Allowance,
Contract,
Deduction,
EncashmentGeneralSettings,
Reimbursement,
)
from pms.models import Feedback
from recruitment.models import Candidate
from horilla_documents.models import Document, DocumentRequest
@@ -2746,20 +2753,24 @@ def redeem_points(request, emp_id):
"""
user = Employee.objects.get(id=emp_id)
form = BonusPointRedeemForm()
amount_for_bonus_point = EncashmentGeneralSettings.objects.first().bonus_amount if EncashmentGeneralSettings.objects.first() else 1
amount_for_bonus_point = (
EncashmentGeneralSettings.objects.first().bonus_amount
if EncashmentGeneralSettings.objects.first()
else 1
)
if request.method == "POST":
form = BonusPointRedeemForm(request.POST)
if form.is_valid():
form.save(commit=False)
points = form.cleaned_data["points"]
amount = amount_for_bonus_point * points
reimbursement = Reimbursement.objects.create(
title=f"Bonus point Redeem for {user}",
type="bonus_encashment",
employee_id=user,
bonus_to_encash=points,
amount = amount,
amount=amount,
description=f"{user} want to redeem {points} points",
allowance_on=date.today(),
)
@@ -2866,10 +2877,30 @@ def encashment_condition_create(request):
instance = EncashmentGeneralSettings.objects.first()
encashment_form = EncashmentGeneralSettingsForm(instance=instance)
if request.method == "POST":
encashment_form = EncashmentGeneralSettingsForm(request.POST,instance=instance)
encashment_form = EncashmentGeneralSettingsForm(request.POST, instance=instance)
if encashment_form.is_valid():
encashment_form.save()
messages.success(request, _("Settings updated."))
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
return render(request, "settings/encashment_settings.html", {"encashment_form":encashment_form,})
return render(
request,
"settings/encashment_settings.html",
{
"encashment_form": encashment_form,
},
)
@login_required
@permission_required("employee.add_employeegeneralsetting")
def initial_prefix(request):
"""
This method is used to set initial prefix
"""
instance = EmployeeGeneralSetting.objects.first()
instance = instance if instance else EmployeeGeneralSetting()
instance.badge_id_prefix = request.POST["initial_prefix"]
instance.save()
messages.success(request,"Initial prefix update")
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))

View File

@@ -23,3 +23,8 @@ TEMPLATES[0]["OPTIONS"]["context_processors"].append(
TEMPLATES[0]["OPTIONS"]["context_processors"].append(
"base.context_processors.check_candidate_self_tracking_rating",
)
TEMPLATES[0]["OPTIONS"]["context_processors"].append(
"base.context_processors.get_intial_prefix",
)