-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUpdatePaymentRequestStatusModal.js
More file actions
121 lines (94 loc) · 3.48 KB
/
UpdatePaymentRequestStatusModal.js
File metadata and controls
121 lines (94 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const upatePaymentNumberFormatter = createNumberFormatter();
function removeApplicationPaymentApproval(applicationId, groupId) {
let $container = $('#' + applicationId);
$container.remove();
$('#' + applicationId).remove();
let applicationCount = $('#ApplicationCount').val();
let groupCount = $(`#${groupId}_count`).val();
$(`#${groupId}_count`).val(groupCount - 1);
$('#ApplicationCount').val(applicationCount - 1);
let paymentCount = $('div.single-payment').length;
let invalidCount = $('input[name$=".IsValid"]').filter(function () {
return $(this).val() === "False";
}).length;
let groupContainer = $(`#${groupId}_container`);
let invalidGroupCount = groupContainer.find('input[name$=".IsValid"]').filter(function () {
return $(this).val() === "False";
}).length;
if ((applicationCount - 1) == 1) {
$('.max-error').css("display", "none");
$('.payment-divider').css("display", "none");
}
if (paymentCount == 0) {
$('#no-payment-msg').css("display", "block");
$("#payment-modal").find('#btnSubmitPayment').prop("disabled", true);
}
else {
$('#no-payment-msg').css("display", "none");
$("#payment-modal").find('#btnSubmitPayment').prop("disabled", invalidCount > 0);
$('.payment-error-column').css("display", invalidCount > 0 ? "block" : "none");
groupContainer.find(".payment-status-transition-ban").css("display", invalidGroupCount > 0 ? "inline-block" : "none");
}
if (groupCount - 1 == 0) {
$(`#${groupId}_container .payment-status-transition`).css("display", "none");
}
calculateUpdateTotalAmount();
}
function closePaymentModal() {
$('#payment-modal').modal('hide');
}
function checkMaxValue(applicationId, input, amountRemaining) {
let enteredValue = parseFloat(input.value.replace(/,/g, ""));
let remainingErrorId = "#column_" + applicationId + "_remaining_error";
if (amountRemaining < enteredValue) {
$(remainingErrorId).css("display", "block");
} else {
$(remainingErrorId).css("display", "none");
}
}
function submitPaymentApprovals() {
// check for error class divs
$('#paymentRequestStatus').submit();
};
function getStatusText(data) {
switch (data) {
case "L1Pending":
return "L1 Pending";
case "L1Approved":
return "L1 Approved";
case "L1Declined":
return "L1 Declined";
case "L2Pending":
return "L2 Pending";
case "L2Approved":
return "L2 Approved";
case "L2Declined":
return "L2 Declined";
case "L3Pending":
return "L3 Pending";
case "L3Approved":
return "L3 Approved";
case "L3Declined":
return "L3 Declined";
case "Submitted":
return "Submitted";
case "Paid":
return "Paid";
case "PaymentFailed":
return "Payment Failed"
default:
return "Created";
}
}
function calculateUpdateTotalAmount() {
let total = 0;
$('.amount').each(function () {
// Remove commas and $ symbols before parsing
let rawValue = $(this).val().replace(/[$,]/g, '');
let value = parseFloat(rawValue) || 0;
total += value;
this.value = upatePaymentNumberFormatter.format(value);
});
let totalFormatted = upatePaymentNumberFormatter.format(total);
$('#UpdateTotalAmount').val(totalFormatted);
}