[UPDT] PAYROLL: Updated tax bracket model by adding abstract class
This commit is contained in:
@@ -317,3 +317,10 @@ _("employee-tag-view"),
|
||||
_("grace-settings-view"),
|
||||
_("helpdesk-tag-view"),
|
||||
_("feedback-answer-view"),
|
||||
_("requested"),
|
||||
_("approved"),
|
||||
_("cancelled"),
|
||||
_("rejected"),
|
||||
_("true"),
|
||||
_("false"),
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ class FilingStatusForm(ModelForm):
|
||||
|
||||
model = FilingStatus
|
||||
fields = "__all__"
|
||||
exclude = ["is_active"]
|
||||
|
||||
|
||||
class TaxBracketForm(ModelForm):
|
||||
@@ -102,6 +103,7 @@ class TaxBracketForm(ModelForm):
|
||||
|
||||
model = TaxBracket
|
||||
fields = "__all__"
|
||||
exclude = ["is_active"]
|
||||
widgets = {
|
||||
"filing_status_id": forms.Select(
|
||||
attrs={"class": "oh-select oh-select-2 select2-hidden-accessible"}
|
||||
|
||||
@@ -11,10 +11,11 @@ from django.utils.text import format_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from base.models import Company
|
||||
|
||||
from horilla.models import HorillaModel
|
||||
from payroll.models.models import FilingStatus
|
||||
|
||||
|
||||
class PayrollSettings(models.Model):
|
||||
class PayrollSettings(HorillaModel):
|
||||
"""
|
||||
Payroll settings model"""
|
||||
|
||||
@@ -34,7 +35,7 @@ class PayrollSettings(models.Model):
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
|
||||
class TaxBracket(models.Model):
|
||||
class TaxBracket(HorillaModel):
|
||||
"""
|
||||
TaxBracket model
|
||||
"""
|
||||
@@ -85,14 +86,14 @@ class TaxBracket(models.Model):
|
||||
tax_rate=self.tax_rate,
|
||||
).exclude(pk=self.pk)
|
||||
if existing_bracket.exists():
|
||||
raise ValidationError("This tax bracket already exists")
|
||||
raise ValidationError(_("This tax bracket already exists"))
|
||||
|
||||
if self.max_income is None:
|
||||
self.max_income = math.inf
|
||||
|
||||
if self.min_income >= self.max_income:
|
||||
raise ValidationError(
|
||||
{"max_income": "Maximum income must be greater than minimum income."}
|
||||
{"max_income": _("Maximum income must be greater than minimum income.")}
|
||||
)
|
||||
|
||||
existing_brackets = TaxBracket.objects.filter(
|
||||
@@ -112,14 +113,3 @@ class TaxBracket(models.Model):
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# class FederalTax(models.Model):
|
||||
# """
|
||||
# FederalTax models
|
||||
# """
|
||||
|
||||
# filing_status_id = models.ForeignKey(
|
||||
# FilingStatus, models.CASCADE, verbose_name=_("Filing Status")
|
||||
# )
|
||||
# taxable_gross = models.IntegerField(null=False, blank=False)
|
||||
|
||||
@@ -24,14 +24,16 @@
|
||||
data-dismiss="oh-modal"
|
||||
aria-label="Close"
|
||||
data-toggle="oh-modal-toggle"
|
||||
hx-get="{% url 'filing-status-search' %}"
|
||||
hx-target="#FilingStatusList"
|
||||
{% if messages %}
|
||||
hx-get="{% url 'filing-status-search' %}"
|
||||
hx-target="#FilingStatusList"
|
||||
{% endif %}
|
||||
>
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
<form
|
||||
hx-post="{%url 'create-filing-status' %}"
|
||||
hx-target="#FilingStatusFormTarget"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
>
|
||||
{% csrf_token %} {{ form.as_p }}
|
||||
<div class="oh-modal__dialog-footer">
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</button>
|
||||
<form
|
||||
hx-post="{%url 'filing-status-update' form.instance.id %}"
|
||||
hx-target="#FilingStatusFormTarget"
|
||||
hx-target="#objectUpdateModalTarget"
|
||||
>
|
||||
{% csrf_token %} {{ form.as_p }}
|
||||
<div class="oh-modal__dialog-footer">
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
<div>
|
||||
<a class="oh-btn oh-btn--secondary oh-btn--shadow"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#FilingStatusModal"
|
||||
data-target="#objectCreateModal"
|
||||
hx-get = "{% url 'create-filing-status' %}"
|
||||
hx-target="#FilingStatusFormTarget"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
>
|
||||
<ion-icon class="me-2" name="add-outline"></ion-icon>{% trans "Create" %}</a>
|
||||
</div>
|
||||
@@ -23,12 +23,6 @@
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<div class="oh-modal" id="FilingStatusModal" role="dialog" aria-labelledby="FilingStatusModal" aria-hidden="true">
|
||||
<div class="oh-modal__dialog " style="max-width: 550px;" id="FilingStatusFormTarget"></div>
|
||||
</div>
|
||||
<div class="oh-modal" id="TaxBracketModal" role="dialog" aria-labelledby="TaxBracketModal" aria-hidden="true">
|
||||
<div class="oh-modal__dialog" style="max-width: 550px" id="TaxBracketFormTarget"></div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="oh-wrapper-main"
|
||||
|
||||
@@ -49,10 +49,10 @@
|
||||
<a
|
||||
class="oh-dropdown__link oh-dropdown__link"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#TaxBracketModal"
|
||||
data-target="#objectCreateModal"
|
||||
hx-get="{% url 'tax-bracket-create' filing_status_id=filing_status.id %}"
|
||||
onclick="event.stopPropagation()"
|
||||
hx-target="#TaxBracketFormTarget"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
>{% trans "Create" %}
|
||||
</a>
|
||||
</li>
|
||||
@@ -62,10 +62,10 @@
|
||||
<a
|
||||
class="oh-dropdown__link oh-dropdown__link"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#FilingStatusModal"
|
||||
data-target="#objectUpdateModal"
|
||||
hx-get="{% url 'filing-status-update' filing_status_id=filing_status.id %}"
|
||||
onclick="event.stopPropagation()"
|
||||
hx-target="#FilingStatusFormTarget"
|
||||
hx-target="#objectUpdateModalTarget"
|
||||
>
|
||||
{% trans "Update" %}</a
|
||||
>
|
||||
|
||||
@@ -45,9 +45,9 @@
|
||||
<a
|
||||
class="oh-btn oh-btn--secondary oh-btn--shadow"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#FilingStatusModal"
|
||||
data-target="#objectCreateModal"
|
||||
hx-get="{% url 'create-filing-status' %}"
|
||||
hx-target="#FilingStatusFormTarget"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
>
|
||||
<ion-icon name="add-outline"></ion-icon>
|
||||
{% trans "Create" %}
|
||||
@@ -78,32 +78,6 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</main>
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="FilingStatusModal"
|
||||
role="dialog"
|
||||
aria-labelledby="FilingStatusModal"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div
|
||||
class="oh-modal__dialog"
|
||||
style="max-width: 550px"
|
||||
id="FilingStatusFormTarget"
|
||||
></div>
|
||||
</div>
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="TaxBracketModal"
|
||||
role="dialog"
|
||||
aria-labelledby="TaxBracketModal"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div
|
||||
class="oh-modal__dialog"
|
||||
style="max-width: 550px"
|
||||
id="TaxBracketFormTarget"
|
||||
></div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$(".oh-accordion-meta__header").click(function () {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</button>
|
||||
<form
|
||||
hx-post="{%url 'tax-bracket-create' filing_status_id=form.initial.filing_status_id %}"
|
||||
hx-target="#TaxBracketFormTarget"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
>
|
||||
{% csrf_token %} {{ form.as_p }}
|
||||
<div class="oh-modal__dialog-footer">
|
||||
@@ -34,23 +34,3 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% comment %}
|
||||
<script>
|
||||
// Function to display the pop-up message
|
||||
function showPopupMessage(message) {
|
||||
alert(message);
|
||||
}
|
||||
|
||||
// Event listener for form submission
|
||||
document
|
||||
.getElementById("TaxBracketFormTarget")
|
||||
.addEventListener("submit", function (event) {
|
||||
var maxIncomeInput = document.getElementById("id_max_income");
|
||||
if (maxIncomeInput.value === "") {
|
||||
showPopupMessage(
|
||||
"The value for maximum income will be set to infinity."
|
||||
);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endcomment %}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</button>
|
||||
<form
|
||||
hx-post="{%url 'tax-bracket-update' form.instance.id %}"
|
||||
hx-target="#TaxBracketFormTarget"
|
||||
hx-target="#objectUpdateModalTarget"
|
||||
>
|
||||
{% csrf_token %} {{ form.as_p }}
|
||||
<div class="oh-modal__dialog-footer">
|
||||
|
||||
@@ -37,10 +37,9 @@
|
||||
<a
|
||||
class="oh-btn oh-btn--light-bkg w-100"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#TaxBracketModal"
|
||||
data-target="#objectUpdateModal"
|
||||
hx-get="{% url 'tax-bracket-update' tax_bracket_id=tax_bracket.id %}"
|
||||
onclick="event.stopPropagation(); document.querySelector('#TaxBracketModal').classList.add('oh-modal--show')"
|
||||
hx-target="#TaxBracketFormTarget"
|
||||
hx-target="#objectUpdateModalTarget"
|
||||
title="{% trans 'Update' %}"
|
||||
>
|
||||
<ion-icon
|
||||
|
||||
Reference in New Issue
Block a user