[UPDT] PAYROLL: Reimbursement approve and reject form updates

This commit is contained in:
Horilla
2024-04-04 17:12:34 +05:30
parent 751c66caf8
commit 8b4cab34bd
4 changed files with 104 additions and 94 deletions

View File

@@ -1747,7 +1747,8 @@ class Reimbursement(HorillaModel):
if self.allowance_id:
self.allowance_id.delete()
return super().delete(*args, **kwargs)
def __str__(self):
return f"{self.title}"
# changing status canceled to reject for existing reimbursement
try:

View File

@@ -117,7 +117,7 @@
</div>
<div class="oh-sticky-table__tbody">
{% for req in reimbursements %}
<div class="oh-sticky-table__tr"
<div class="oh-sticky-table__tr" id="requestCard{{ req.id }}"
hx-get="{% url 'reimbursement-individual-view' req.id %}?instances_ids={{reimbursements_ids}}"
hx-target="#objectDetailsModalTarget"
data-target="#objectDetailsModal" data-toggle="oh-modal-toggle"
@@ -188,9 +188,10 @@
</a>
{% endif %}
{% if perms.payroll.delete_reimbursement %}
<a href="{% url "delete-reimbursement" %}?ids={{req.id}}" onclick="return confirm('Do you want to delete this record?')"
<a href="{% url "delete-reimbursement" %}?ids={{req.id}}" onclick="event.stopPropagation();return confirm('Do you want to delete this record?')"
class='w-100 oh-btn oh-btn--danger-outline oh-btn--light-bkg' title='{% trans "Delete" %}'>
<input type="hidden" name="ids" value="{{ req.id }}" />
<input type="hidden" name="status" />
<ion-icon name="trash-outline"></ion-icon>
</a>
{% endif %}
@@ -198,39 +199,52 @@
</div>
<div class="oh-sticky-table__td oh-sticky-table__right">
<input type="hidden" name="ids" value="{{ req.id }}" />
<input type="hidden" name="status" />
<div class="oh-btn-group" onclick="event.stopPropagation();">
<form
action="{% url 'approve-reimbursements' %}"
{% comment %} id="requestCard{{ req.id }}" {% endcomment %}
>
<div class="oh-btn-group" onclick="event.stopPropagation();">
{% if req.status != "approved" and req.status != 'rejected'%}
{% if req.status != "approved" and req.status != 'rejected'%}
<input type="hidden" name="ids" value="{{ req.id }}" />
<input type="hidden" name="status" />
<button
type="button"
onclick="reimbursementConfirm('Do You really want to approve the request?','#requestCard{{ req.id }}',true);$('#requestCard{{ req.id }} [name=status]').val('approved')"
class='oh-btn oh-btn--success w-100'
title="{% trans 'Approve' %}"
>
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
</button>
<input
{% comment %} onclick="event.stopPropagation()" {% endcomment %}
type="submit"
hidden
id="requestCard{{ req.id }}Button"
/>
{% else %}
<button class='oh-btn oh-btn--success w-100' disabled onclick="event.preventDefault();">
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
</button>
{% endif %}
<button
type="button"
onclick="reimbursementConfirm('Do You really want to approve the request?','#requestCard{{ req.id }}',true);$('#requestCard{{ req.id }} [name=status]').val('approved')"
class='oh-btn oh-btn--success w-100'
title="{% trans 'Approve' %}"
onclick="event.preventDefault();$('#requestCard{{ req.id }} [name=amount]').attr('required',false);reimbursementConfirm('Do You really want to reject the request?','#requestCard{{ req.id }}');$('#requestCard{{ req.id }} [name=status]').val('canceled')"
class="oh-btn oh-btn--danger w-100"
title="{% trans 'Reject' %}"
>
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
</button>
{% else %}
<button class='oh-btn oh-btn--success w-100' disabled onclick="event.preventDefault();">
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
</button>
{% endif %}
<button
type="button"
onclick="event.preventDefault();$('#requestCard{{ req.id }} [name=amount]').attr('required',false);reimbursementConfirm('Do You really want to reject the request?','#requestCard{{ req.id }}');$('#requestCard{{ req.id }} [name=status]').val('canceled')"
class="oh-btn oh-btn--danger w-100"
title="{% trans 'Reject' %}"
>
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
</button>
</div>
</div>
</form>
<input
{% comment %} <input
onclick="event.stopPropagation()"
type="submit"
hidden
id="requestCard{{ req.id }}Button"
/>
/> {% endcomment %}
</div>
@@ -414,16 +428,12 @@
</div>
<div class="oh-sticky-table__tbody">
{% for req in leave_encashments %}
<div class="oh-sticky-table__tr"
<div class="oh-sticky-table__tr" id="requestCard{{ req.id }}"
hx-get="{% url 'reimbursement-individual-view' req.id %}?instances_ids={{leave_encashments_ids}}"
hx-target="#objectDetailsModalTarget"
data-target="#objectDetailsModal" data-toggle="oh-modal-toggle"
>
{% comment %} <form
action="{% url 'approve-reimbursements' %}"
class="oh-sticky-table__tr"
id="requestCard{{ req.id }}"
> {% endcomment %}
{% comment %} <div class="oh-sticky-table__sd" onclick="event.stopPropagation();">
<input
type="checkbox"
@@ -454,7 +464,7 @@
<div data-cell-index="12" class="oh-sticky-table__td">
{{req.title|truncatechars:20 }}
</div>
<div data-cell-index="13" class="oh-sticky-table__td">
<div data-cell-index="13" class="oh-sticky-table__td" onclick="event.stopPropagation()">
<input type="number" required
default="0" min="0" placeholder="Amount"
name="amount" class="w-75"{% if req.status == "approved" %}disabled{% endif %} {% if req.amount %}
@@ -483,7 +493,7 @@
</div>
<div class="oh-sticky-table__td">
<div class="oh-btn-group">
<div class="oh-btn-group" onclick="event.stopPropagation()">
{% if perms.payroll.change_reimbursement or request.user %}
<a
onclick="event.stopPropagation()"
@@ -507,43 +517,48 @@
</div>
</div>
<div class="oh-sticky-table__td oh-sticky-table__right">
<input type="hidden" name="ids" value="{{ req.id }}" />
<input type="hidden" name="status" />
<div class="oh-btn-group">
{% if req.status != "approved" and req.status != "rejected" %}
<button
type="button"
title="{% trans 'Approve' %}"
onclick="reimbursementConfirm('Do You really want to approve the request?','#requestCard{{ req.id }}',true);$('#requestCard{{ req.id }} [name=status]').val('approved')"
class="oh-btn oh-btn--success w-100"
>
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
</button>
{% else %}
<button
type="button"
title="{% trans 'Approve' %}"
class="oh-btn oh-btn--success oh-btn--disabled w-100"
>
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
</button>
{% endif %}
<button
type="button"
title="{% trans 'Reject' %}"
onclick="$('#requestCard{{ req.id }} [name=amount]').attr('required',false);reimbursementConfirm('Do You really want to reject the request?','#requestCard{{ req.id }}');$('#requestCard{{ req.id }} [name=status]').val('canceled')"
class="oh-btn oh-btn--danger w-100"
>
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
</button>
</div>
<input
type="submit"
hidden
id="requestCard{{ req.id }}Button"
/>
<form
action="{% url 'approve-reimbursements' %}"
>
<input type="hidden" name="ids" value="{{ req.id }}" />
<input type="hidden" name="status" />
<div class="oh-btn-group" onclick="event.stopPropagation()">
{% if req.status != "approved" and req.status != "rejected" %}
<button
type="button"
title="{% trans 'Approve' %}"
onclick="reimbursementConfirm('Do You really want to approve the request?','#requestCard{{ req.id }}',true);$('#requestCard{{ req.id }} [name=status]').val('approved')"
class="oh-btn oh-btn--success w-100"
>
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
</button>
{% else %}
<button
type="button"
title="{% trans 'Approve' %}"
class="oh-btn oh-btn--success oh-btn--disabled w-100"
>
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
</button>
{% endif %}
<button
type="button"
title="{% trans 'Reject' %}"
onclick="$('#requestCard{{ req.id }} [name=amount]').attr('required',false);reimbursementConfirm('Do You really want to reject the request?','#requestCard{{ req.id }}');$('#requestCard{{ req.id }} [name=status]').val('canceled')"
class="oh-btn oh-btn--danger w-100"
>
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
</button>
<input
type="submit"
hidden
id="requestCard{{ req.id }}Button"
/>
</div>
</form>
</div>
{% comment %} </form> {% endcomment %}
</div>
{% endfor %}
</div>
@@ -718,7 +733,7 @@
</div>
<div class="oh-sticky-table__tbody">
{% for req in bonus_encashments %}
<div class="oh-sticky-table__tr"
<div class="oh-sticky-table__tr" id="requestCard{{ req.id }}"
hx-get="{% url 'reimbursement-individual-view' req.id %}?instances_ids={{bonus_encashment_ids}}"
hx-target="#objectDetailsModalTarget"
data-target="#objectDetailsModal" data-toggle="oh-modal-toggle"
@@ -758,7 +773,7 @@
<div data-cell-index="22" class="oh-sticky-table__td">
{{req.title|truncatechars:20 }}
</div>
<div data-cell-index="23" class="oh-sticky-table__td">
<div onclick="event.stopPropagation()" data-cell-index="23" class="oh-sticky-table__td">
<input type="number" required
default="0" min="0" placeholder="Amount"
name="amount" class="w-75"{% if req.status == "approved" %}disabled{% endif %} {% if req.amount %}
@@ -779,7 +794,7 @@
<ion-icon name="newspaper-outline" role="img" class="md hydrated" aria-label="newspaper outline"></ion-icon>
</button>
</div>
<div class="oh-sticky-table__td">
<div onclick="event.stopPropagation()" class="oh-sticky-table__td">
<div class="oh-btn-group">
{% if perms.payroll.change_reimbursement or request.user %}
<a
@@ -803,10 +818,13 @@
{% endif %}
</div>
</div>
<div class="oh-sticky-table__td oh-sticky-table__right">
<div class="oh-sticky-table__td oh-sticky-table__right" onclick="event.stopPropagation">
<form
action="{% url 'approve-reimbursements' %}"
>
<input type="hidden" name="ids" value="{{ req.id }}" />
<input type="hidden" name="status" />
<div class="oh-btn-group">
<div class="oh-btn-group" onclick="event.stopPropagation()">
{% if req.status != "approved" and req.status != "rejected" %}
<button
type="button"
@@ -833,15 +851,16 @@
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
</button>
<input
type="submit"
hidden
id="requestCard{{ req.id }}Button"
/>
</div>
<input
type="submit"
hidden
id="requestCard{{ req.id }}Button"
/>
</form>
</div>
{% comment %} </form> {% endcomment %}
</div>
{% endfor %}
</div>

View File

@@ -64,6 +64,7 @@
<script>
function reimbursementConfirm(params, target, approve = false) {
event.preventDefault();event.stopPropagation()
Swal.fire({
text: params,
icon: "question",

View File

@@ -1203,11 +1203,6 @@ def search_loan(request):
adv_salary_ids=json.dumps(
list(adv_salary.values_list("id", flat=True))
)
print('ooooooooooooooooooooooo')
print(fine_ids)
print(loan_ids)
print(adv_salary_ids)
print('ooooooooooooooooooooooo')
loan = sortby(request, loan, "sortby")
adv_salary = sortby(request, adv_salary, "sortby")
fine = sortby(request, fine, "sortby")
@@ -1353,12 +1348,6 @@ def search_reimbursement(request):
if view == "list":
template = "payroll/reimbursement/reimbursement_list.html"
get_key_instances(Reimbursement, data_dict)
print('================')
print(reimbursements_ids)
print(leave_encashments_ids)
print(bonus_encashment_ids)
print('================')
return render(
request,