[UPDT] PAYROLL: Allowance and deduction card style and form submission updates

This commit is contained in:
Horilla
2024-03-15 16:37:29 +05:30
parent a903315adc
commit e2eab58850
3 changed files with 58 additions and 40 deletions

View File

@@ -963,6 +963,13 @@ class Allowance(models.Model):
self.field = None
self.condition = None
self.value = None
if not self.is_fixed:
if not self.based_on:
raise ValidationError(
_(
"If the 'Is fixed' field is disabled, the 'Based on' field is required."
)
)
if self.is_condition_based:
if not self.field or not self.value or not self.condition:
raise ValidationError(
@@ -1221,6 +1228,13 @@ class Deduction(models.Model):
if self.is_tax:
self.is_pretax = False
if not self.is_fixed:
if not self.based_on:
raise ValidationError(
_(
"If the 'Is fixed' field is disabled, the 'Based on' field is required."
)
)
if self.is_pretax and self.based_on in ["taxable_gross_pay"]:
raise ValidationError(
{

View File

@@ -28,13 +28,8 @@
<div class="oh-kanban-card__details">
<span class="oh-card__title oh-card__title--sm fw-bold" style="font-size:18px;">{{allowance}}</span>
<div class="oh-timeoff-modal__stats-container mb-1">
<div class="oh-timeoff-modal__stat mt-2">
<span class="oh-timeoff-modal__stat-title fw-bold text-dark">{% trans "Taxable" %}</span>
<span class="oh-timeoff-modal__stat-title">{{allowance.is_taxable|yesno|capfirst}}</span>
</div>
<div class="oh-timeoff-modal__stat mt-2" style="margin-left: 20px;">
<span class="oh-timeoff-modal__stat-title fw-bold text-dark">{% trans "Amount" %}</span>
<span class="oh-timeoff-modal__stat-title fw-bold text-dark mt-2 mb-1">{% trans "Amount" %}</span>
{% if allowance.is_fixed %}
<span class="oh-timeoff-modal__stat-title">{{allowance.amount}}</span>
{% else %}
@@ -54,16 +49,22 @@
<span class="oh-timeoff-modal__stat-title">{{allowance.amount_per_one_hr}} {{currency}} {% trans "Amount Per One Hour" %}</span>
{% endif %}
{% endif %}
<div class="oh-timeoff-modal__stats-container mb-1">
<div class="oh-timeoff-modal__stat mt-2">
<span class="oh-timeoff-modal__stat-title fw-bold text-dark" style="width:135px;">{% trans "One Time Allowance" %}</span>
{% if allowance.one_time_date %}
<span class="oh-timeoff-modal__stat-title">{% trans "On" %}</span> <span class="oh-timeoff-modal__stat-count dateformat_changer"> {{allowance.one_time_date}}</span>
{% else %}
<span class="oh-timeoff-modal__stat-title">{% trans "No" %}</span>
{% endif %}
</div>
<div class="oh-timeoff-modal__stat mt-2" style="margin-left: 20px;">
<span class="oh-timeoff-modal__stat-title fw-bold text-dark">{% trans "Taxable" %}</span>
<span class="oh-timeoff-modal__stat-title">{{allowance.is_taxable|yesno|capfirst}}</span>
</div>
</div>
<span class="oh-timeoff-modal__stat-title fw-bold text-dark">{% trans "One Time Allowance" %}</span>
{% if allowance.one_time_date %}
<span class="oh-timeoff-modal__stat-title">{% trans "On" %}</span> <span class="oh-timeoff-modal__stat-count dateformat_changer"> {{allowance.one_time_date}}</span>
{% else %}
<span class="oh-timeoff-modal__stat-title">{% trans "No" %}</span>
{% endif %}
</div>
<div class="oh-kanban-card__dots">
<div class="oh-dropdown" x-data="{show: false}" onclick="event.stopPropagation()">

View File

@@ -18,37 +18,40 @@
<div class="oh-kanban-card__details">
<span class="oh-card__title oh-card__title--sm fw-bold" style="font-size:18px;">{{deduction}}</span>
<span class="oh-timeoff-modal__stat-title fw-bold text-dark mt-2 mb-1">{% trans "Amount" %}</span>
{% if deduction.update_compensation %}
{% if deduction.is_fixed %}
<span class="oh-timeoff-modal__stat-title">{{deduction.amount}}{{currency}} Deduct From {{deduction.get_update_compensation_display}}</span>
{% else %}
<span class="oh-timeoff-modal__stat-title">{{deduction.rate}}% {% trans "of" %} {{deduction.get_update_compensation_display}}</span>
{% endif %}
{% else %}
{% if deduction.is_fixed %}
<span class="oh-timeoff-modal__stat-title ">{{deduction.amount}}{{currency}}</span>
{% else %}
<span class="oh-timeoff-modal__stat-title">{% trans "Employer Rate :" %} {{deduction.employer_rate}}% {% trans "of" %} {{deduction.get_based_on_display}}</span>
<span class="oh-timeoff-modal__stat-title">{% trans "Employee Rate :" %} {{deduction.rate}}% {% trans "of" %} {{deduction.get_based_on_display}}</span>
{% endif %}
{% endif %}
<div class="oh-timeoff-modal__stats-container mb-1">
<div class="oh-timeoff-modal__stat mt-2">
<span class="oh-timeoff-modal__stat-title fw-bold text-dark">{% trans "Taxable" %}</span>
<span class="oh-timeoff-modal__stat-title">{{deduction.is_tax|yesno|capfirst}}</span>
<div class="oh-timeoff-modal__stat">
<span class="oh-timeoff-modal__stat-title fw-bold text-dark mt-2" style="width:135px;">{% trans "One Time Deduction" %}</span>
{% if deduction.one_time_date %}
<span class="oh-timeoff-modal__stat-title">{% trans "On" %}</span> <span class="oh-timeoff-modal__stat-count dateformat_changer"> {{deduction.one_time_date}}</span>
{% else %}
<span class="oh-timeoff-modal__stat-title">{% trans "No" %}</span>
{% endif %}
</div>
<div class="oh-timeoff-modal__stat mt-2" style="margin-left: 20px;">
<span class="oh-timeoff-modal__stat-title fw-bold text-dark">{% trans "Amount" %}</span>
{% if deduction.update_compensation %}
{% if deduction.is_fixed %}
<span class="oh-timeoff-modal__stat-title">{{deduction.amount}}{{currency}} Deduct From {{deduction.get_update_compensation_display}}</span>
{% else %}
<span class="oh-timeoff-modal__stat-title">{{deduction.rate}}% {% trans "of" %} {{deduction.get_update_compensation_display}}</span>
{% endif %}
{% else %}
{% if deduction.is_fixed %}
<span class="oh-timeoff-modal__stat-title ">{{deduction.amount}}{{currency}}</span>
{% else %}
<span class="oh-timeoff-modal__stat-title">{% trans "Employer Rate :" %} {{deduction.employer_rate}}% {% trans "of" %} {{deduction.get_based_on_display}}</span>
<span class="oh-timeoff-modal__stat-title">{% trans "Employee Rate :" %} {{deduction.rate}}% {% trans "of" %} {{deduction.get_based_on_display}}</span>
{% endif %}
{% endif %}
<div class="oh-timeoff-modal__stat mt-2">
<span class="oh-timeoff-modal__stat-title fw-bold text-dark">{% trans "Pretax" %}</span>
<span class="oh-timeoff-modal__stat-title">{{deduction.is_pretax|yesno|capfirst}}</span>
</div>
</div>
<span class="oh-timeoff-modal__stat-title fw-bold text-dark">{% trans "One Time Allowance" %}</span>
{% if allowance.one_time_date %}
<span class="oh-timeoff-modal__stat-title">{% trans "On" %}</span> <span class="oh-timeoff-modal__stat-count dateformat_changer"> {{allowance.one_time_date}}</span>
{% else %}
<span class="oh-timeoff-modal__stat-title">{% trans "No" %}</span>
{% endif %}
</div>
<div class="oh-kanban-card__dots">
<div class="oh-dropdown" x-data="{show: false}" onclick="event.stopPropagation()">