-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCreatePaymentRequestsModal.js
More file actions
65 lines (55 loc) · 1.96 KB
/
CreatePaymentRequestsModal.js
File metadata and controls
65 lines (55 loc) · 1.96 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
function removeApplicationPaymentRequest(applicationId) {
let $container = $('#' + applicationId);
$container.remove();
$('#' + applicationId).remove();
let applicationCount = $('#ApplicationCount').val();
$('#ApplicationCount').val(applicationCount - 1);
if ((applicationCount - 1) == 1) {
$('.max-error').css("display", "none");
$('.payment-divider').css("display", "none");
}
if (!$('div.single-payment').length) {
$('#no-payment-msg').css("display", "block");
$("#payment-modal").find('#btnSubmitPayment').prop("disabled", true);
}
else {
$('#no-payment-msg').css("display", "none");
}
// Always recalculate the total after removal
calculateTotalAmount();
}
function closePaymentModal() {
$('#payment-modal').modal('hide');
}
function checkMaxValueRequest(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");
}
// Update the total amount after checking the value
calculateTotalAmount();
}
function submitPayments() {
// check for error class divs
let validationFailed = $(".payment-error-column:visible").length > 0;
if (validationFailed) {
abp.notify.error(
'',
'There are payment requests that are in error please remove or fix them before submitting.'
);
return false;
} else {
$('#paymentform').submit();
}
};
function calculateTotalAmount() {
let total = 0;
$('.amount').each(function () {
let value = parseFloat($(this).val().replace(/,/g, '')) || 0;
total += value;
});
$('.totalAmount').val(total.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
}