[FIX] PAYROLL: Fixed payroll allowance and deductions operator_mapping range issue
This commit is contained in:
@@ -22,6 +22,11 @@ from payroll.models.models import (
|
||||
MultipleCondition,
|
||||
)
|
||||
|
||||
|
||||
def return_none(a, b):
|
||||
return None
|
||||
|
||||
|
||||
operator_mapping = {
|
||||
"equal": operator.eq,
|
||||
"notequal": operator.ne,
|
||||
@@ -30,6 +35,7 @@ operator_mapping = {
|
||||
"le": operator.le,
|
||||
"ge": operator.ge,
|
||||
"icontains": operator.contains,
|
||||
"range": return_none,
|
||||
}
|
||||
filter_mapping = {
|
||||
"work_type_id": {
|
||||
|
||||
@@ -18,6 +18,7 @@ from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from base.horilla_company_manager import HorillaCompanyManager
|
||||
from base.methods import get_next_month_same_date
|
||||
from base.models import (
|
||||
Company,
|
||||
Department,
|
||||
@@ -1508,19 +1509,10 @@ class LoanAccount(HorillaModel):
|
||||
installment_schedule = {}
|
||||
|
||||
installment_date = installment_start_date
|
||||
installment_date_copy = installment_start_date
|
||||
installment_schedule = {}
|
||||
for _ in range(total_installments):
|
||||
installment_schedule[str(installment_date)] = installment_amount
|
||||
month = installment_date.month + 1
|
||||
year = installment_date.year
|
||||
if month > 12:
|
||||
month = 1
|
||||
year = year + 1
|
||||
day = installment_date_copy.day
|
||||
total_days_in_month = calendar.monthrange(year, month)[1]
|
||||
day = min(day, total_days_in_month)
|
||||
installment_date = date(day=day, month=month, year=year)
|
||||
installment_date = get_next_month_same_date(installment_date)
|
||||
|
||||
return installment_schedule
|
||||
|
||||
@@ -1561,7 +1553,7 @@ class LoanAccount(HorillaModel):
|
||||
|
||||
def _create_deductions(instance, amount, date):
|
||||
installment = Deduction()
|
||||
installment.title = instance.title
|
||||
installment.title = f"{instance.title} - {date}"
|
||||
installment.include_active_employees = False
|
||||
installment.amount = amount
|
||||
installment.is_fixed = True
|
||||
|
||||
@@ -70,7 +70,19 @@
|
||||
</a>
|
||||
<div class="oh-modal__dialog-header" style="padding-top: 5px">
|
||||
<h3 class="oh-faq-card__title">{{loan.title}}</h3>
|
||||
<div class="oh-sticky-table__table mt-3">
|
||||
{% comment %} <h3 class="oh-faq-card__title">{{loan.loan_amount}}</h3> {% endcomment %}
|
||||
<div class="oh-sticky-table__table mt-3" id="deductionContainer">
|
||||
{% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table__thead">
|
||||
<div class="oh-sticky-table__tr">
|
||||
<div
|
||||
@@ -115,9 +127,19 @@
|
||||
>
|
||||
{{ deduction.one_time_date }}
|
||||
</div>
|
||||
<div class="oh-sticky-table__td" align="center">
|
||||
{{ deduction.amount|floatformat:2 }}
|
||||
</div>
|
||||
<input
|
||||
name="amount"
|
||||
class="oh-card__title oh-card__title--sm ms-3 w-100 editable-input border-0"
|
||||
hx-post="{% url 'edit-installment-amount' %}?loan_id={{loan.id}}&ded_id={{deduction.id}}"
|
||||
hx-select="#deductionContainer"
|
||||
hx-target="#deductionContainer"
|
||||
hx-trigger="change"
|
||||
hx-swap = "outerHTML"
|
||||
onclick="event.stopPropagation();"
|
||||
align="center"
|
||||
value="{{ deduction.amount|floatformat:2 }}"
|
||||
readonly
|
||||
/>
|
||||
<div class="oh-sticky-table__td" align="center">
|
||||
{% if deduction.installment_payslip %}
|
||||
<span title="Installment paid, Click to view">
|
||||
@@ -151,3 +173,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).on("htmx:afterSettle", function () {
|
||||
editableInput = $(".editable-input");
|
||||
|
||||
editableInput.on("focus", function () {
|
||||
$(this).prop("readonly", false);
|
||||
});
|
||||
|
||||
editableInput.on("blur", function () {
|
||||
$(this).prop("readonly", true);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -101,6 +101,11 @@ urlpatterns = [
|
||||
component_views.view_installments,
|
||||
name="view-installments",
|
||||
),
|
||||
path(
|
||||
"edit-installment-amount/",
|
||||
component_views.edit_installment_amount,
|
||||
name="edit-installment-amount",
|
||||
),
|
||||
path("delete-loan/", component_views.delete_loan, name="delete-loan"),
|
||||
path("search-loan/", component_views.search_loan, name="search-loan"),
|
||||
path(
|
||||
|
||||
Reference in New Issue
Block a user