-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HWPV-195: View & Edit individual claim page #650
base: main
Are you sure you want to change the base?
Changes from 33 commits
0bdbc8c
29dcdfb
4411511
e6ba557
dd6a852
4cbf08d
88c1623
66d7afc
95fa804
cc0586d
3cb9cbf
9e6e072
a3cc71c
1844329
f001589
3b2beba
e2a8ae1
9fdddff
10c4cc8
0e5e44a
7601f0c
0cbda76
5d866ac
c886749
0c880b5
d9d5aca
a23e94c
ddb41e0
e0c4374
b6724c2
422eb74
a34e1c3
b06ee86
4e5bdb2
c2d6a37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,151 @@ | ||
$(function () { | ||
totalApproved() | ||
function totalApproved () { | ||
let approvedCost = 0 | ||
const manuallyProcessed = 0 | ||
let deduction = 0 | ||
|
||
if (document.getElementById('additional-info-reject') !== null) { | ||
if (document.getElementById('additional-info-reject').value === 'Other') { | ||
document.getElementById('additional-info-reject-manual').style.display = 'block' | ||
document.getElementById('manual-label').style.display = 'block' | ||
} | ||
function isValidValue (value) { | ||
return !isNaN(value) && value.trim().length !== 0 && value.indexOf('e') === -1 && value.indexOf('E') === -1 | ||
} | ||
|
||
$('.claim-expense-status').change(function () { | ||
const id = $(this).attr('data-id') | ||
const value = $(this).val() | ||
if (value === 'APPROVED-DIFF-AMOUNT') { | ||
$(`#claim-expense-${id}-approvedcost`).removeClass('visibility-hidden').addClass('visibility-visible') | ||
$(this).next('input').on('input').addClass('approved-amount') | ||
$(this).parent().parent().find('td.cost').removeClass('approved-amount') | ||
$('input.approved-amount').on('input', function () { | ||
totalApproved() | ||
}) | ||
} else if (value === 'APPROVED') { | ||
$(`#claim-expense-${id}-approvedcost`).removeClass('visibility-visible').addClass('visibility-hidden') | ||
$(this).parent().parent().find('td.cost').addClass('approved-amount') | ||
$(this).next('input').on('input').removeClass('approved-amount') | ||
} else { | ||
$(`#claim-expense-${id}-approvedcost`).removeClass('visibility-visible').addClass('visibility-hidden') | ||
$(this).parent().parent().find('td.cost').removeClass('approved-amount') | ||
$(this).next('input').on('input').removeClass('approved-amount') | ||
} totalApproved() | ||
}) | ||
if ($('#unassign').length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how I missed this, the code inside the |
||
$('.approved-amount').each(function () { | ||
const value = $(this).val() | ||
if (isValidValue(value)) { | ||
approvedCost += parseFloat(value) | ||
} | ||
approvedCost += +$(this).text().replace('£', '').trim() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually this doesn't make sense, you're using |
||
}) | ||
} else { | ||
$('.approved-amount').each(function () { | ||
const value = $(this).val() | ||
if (isValidValue(value)) { | ||
approvedCost += parseFloat(value) | ||
} | ||
approvedCost += +$(this).text().replace('£', '').trim() | ||
}) | ||
} | ||
|
||
$('input[value="Remove"]').parent().parent().find('td.deduction').addClass('approved-amount') | ||
$('input.approved-amount').on('input', function () { | ||
totalApproved() | ||
$('.deduction').each(function () { | ||
deduction += +$(this).text().replace(' £', '') | ||
}) | ||
|
||
$('.claim-expense-status').each(function () { | ||
const value = this[this.selectedIndex].value | ||
if (value === 'APPROVED') { | ||
$(this).parent().parent().find('td.cost').addClass('approved-amount') | ||
$(this).next('input').removeClass('approved-amount') | ||
} else if (value === 'APPROVED-DIFF-AMOUNT') { | ||
$(this).next('input').addClass('approved-amount') | ||
$(this).parent().parent().find('td.cost').removeClass('approved-amount') | ||
} else { | ||
$(this).parent().parent().find('td.cost').removeClass('approved-amount') | ||
} | ||
}) | ||
const totalCost = approvedCost + manuallyProcessed + deduction | ||
|
||
$('.approved-amount').each(function () { | ||
totalApproved() | ||
}) | ||
const formattedCost = totalCost < 0 ? '- £' + Math.abs(totalCost).toFixed(2) : '£' + totalCost.toFixed(2) | ||
$('.claim-expense-approvedCostText').text(formattedCost) | ||
|
||
$('#overpayment-toggle').change(function () { | ||
showClosedClaimActionSection('#overpayment-input') | ||
}) | ||
if (totalCost < 0) { | ||
$('.claim-expense-approvedCostText').addClass('claim-table-negative') | ||
} else { | ||
$('.claim-expense-approvedCostText').removeClass('claim-table-negative') | ||
} | ||
} | ||
|
||
$('#close-toggle').change(function () { | ||
showClosedClaimActionSection('#close-advanced-claim-input') | ||
}) | ||
$(document).ready(function () { | ||
function initializeState () { | ||
if ($('#unassign').length) { | ||
// setting initial state for when assigned | ||
$('.claim-expense-status').each(function () { | ||
const id = $(this).attr('data-id') | ||
const value = $(this).val() | ||
if (value === 'APPROVED') { | ||
$(`#text-for-${id}-approved-cost`).text($(`#claimed-expense-for-${id}`).text().trim()) | ||
} else if (value === 'APPROVED-DIFF-AMOUNT') { | ||
$(`#text-for-${id}-approved-cost`).addClass('js-hidden').removeClass('approved-amount') | ||
$(`.input-container-for-${id}-approve-different-cost`).removeClass('js-hidden') | ||
$(`.input-value-for-${id}-approve-different-cost`).addClass('approved-amount') | ||
} | ||
}) | ||
} | ||
$('#additional-info-reject').each(function () { | ||
if (this[this.selectedIndex].value === 'Other') { | ||
$('.rejection-reason-other').removeClass('js-hidden') | ||
} | ||
}) | ||
$('#release-date-is-set').each(function () { | ||
if ($(this).is(':checked')) { | ||
$('#release').removeClass('js-hidden') | ||
} | ||
}) | ||
$('#is-trusted-checkbox').each(function () { | ||
if ($(this).is(':checked')) { | ||
$('.reject-auto-approval').addClass('js-hidden') | ||
} else { | ||
$('.reject-auto-approval').removeClass('js-hidden') | ||
} | ||
}) | ||
totalApproved() | ||
} | ||
initializeState() | ||
|
||
$('#request-new-payment-details-toggle').change(function () { | ||
showClosedClaimActionSection('#request-new-payment-details-input') | ||
}) | ||
$(function () { | ||
$('.claim-expense-status').change(function () { | ||
const id = $(this).attr('data-id') | ||
const value = $(this).val() | ||
if (value === 'APPROVED') { | ||
$(`#text-for-${id}-approved-cost`).removeClass('js-hidden').addClass('approved-amount').text($(`#claimed-expense-for-${id}`).text()) | ||
$(`.input-container-for-${id}-approve-different-cost`).addClass('js-hidden') | ||
$(`.input-value-for-${id}-approve-different-cost`).removeClass('approved-amount').val($(`#claimed-expense-for-${id}`).text().replace('£', '')) | ||
$(`.claim-expense-${id}-approvedcost`).val($(`#claimed-expense-for-${id}`).text()) | ||
} else if (value === 'APPROVED-DIFF-AMOUNT') { | ||
$(`#text-for-${id}-approved-cost`).addClass('js-hidden').removeClass('approved-amount') | ||
$(`.input-container-for-${id}-approve-different-cost`).removeClass('js-hidden') | ||
$(`.input-value-for-${id}-approve-different-cost`).addClass('approved-amount').val($(`#claimed-expense-for-${id}`).text().replace('£', '')) | ||
} else { | ||
$(`#text-for-${id}-approved-cost`).addClass('js-hidden').addClass('approved-amount').text('0.00') | ||
$(`.input-container-for-${id}-approve-different-cost`).addClass('js-hidden') | ||
$(`.input-value-for-${id}-approve-different-cost`).removeClass('approved-amount').val('0.00') | ||
} | ||
totalApproved() | ||
}) | ||
|
||
$('#additional-info-reject').change(function () { | ||
if (this[this.selectedIndex].value === 'Other') { | ||
document.getElementById('additional-info-reject-manual').style.display = 'block' | ||
document.getElementById('manual-label').style.display = 'block' | ||
} else { | ||
document.getElementById('additional-info-reject-manual').style.display = 'none' | ||
document.getElementById('manual-label').style.display = 'none' | ||
document.getElementById('additional-info-reject-manual').value = '' | ||
} | ||
}) | ||
}) | ||
$('.input-for-different-cost').on('input', function () { | ||
totalApproved() | ||
}) | ||
|
||
function totalApproved () { | ||
let approvedCost = 0 | ||
let manuallyProcessed = 0 | ||
$('input[value="Remove"]').parent().parent().find('td.deduction').addClass('approved-amount') | ||
|
||
if ($('#unassign').length) { | ||
$('input.approved-amount').each(function () { | ||
if (!isNaN(this.value) && this.value.length !== 0 && this.value.indexOf('e') === -1 && this.value.indexOf('E') === -1) { | ||
manuallyProcessed += parseFloat(this.value) | ||
} | ||
$('#overpayment-toggle').change(function () { | ||
showClosedClaimActionSection('#overpayment-input') | ||
}) | ||
|
||
$('td.approved-amount').each(function () { | ||
approvedCost += +$(this).text().replace('£', '') | ||
$('#close-toggle').change(function () { | ||
showClosedClaimActionSection('#close-advanced-claim-input') | ||
}) | ||
} else { // use hidden approved cost for unassigned claims | ||
$('input.approved-cost').each(function () { | ||
if (!isNaN(this.value) && this.value.length !== 0) { | ||
approvedCost += parseFloat(this.value) | ||
|
||
$('#request-new-payment-details-toggle').change(function () { | ||
showClosedClaimActionSection('#request-new-payment-details-input') | ||
}) | ||
|
||
$('#additional-info-reject').change(function () { | ||
if (this[this.selectedIndex].value === 'Other') { | ||
$('.rejection-reason-other').removeClass('js-hidden') | ||
} else { | ||
$('.rejection-reason-other').addClass('js-hidden') | ||
} | ||
}) | ||
$('td.deduction').each(function () { | ||
approvedCost += +$(this).text().replace('£', '') | ||
|
||
$('#is-trusted-checkbox').on('click', function () { | ||
if ($(this).is(':checked')) { | ||
$('.reject-auto-approval').addClass('js-hidden') | ||
} else { | ||
$('.reject-auto-approval').removeClass('js-hidden') | ||
} | ||
}) | ||
} | ||
|
||
$('.claim-expense-approvedCostText').text('£' + (approvedCost + manuallyProcessed).toFixed(2)) | ||
} | ||
$('#release-date-is-set').on('click', function () { | ||
if ($(this).is(':checked')) { | ||
$('#release').removeClass('js-hidden') | ||
} else { | ||
$('#release').addClass('js-hidden') | ||
} | ||
}) | ||
}) | ||
|
||
function showClosedClaimActionSection (id) { | ||
$('#overpayment-input').addClass('js-hidden') | ||
$('#close-advanced-claim-input').addClass('js-hidden') | ||
$('#request-new-payment-details-input').addClass('js-hidden') | ||
$(id).removeClass('js-hidden') | ||
} | ||
function showClosedClaimActionSection (id) { | ||
$('#overpayment-input').addClass('js-hidden') | ||
$('#close-advanced-claim-input').addClass('js-hidden') | ||
$('#request-new-payment-details-input').addClass('js-hidden') | ||
$(id).removeClass('js-hidden') | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I seem to spot things after re-reading. Is
value
a string or Number?isNan
doesn't make sense if you're also usingtrim
on a string?isNaN
will be OK with1e3
for example.