-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCreatePaymentRequestsModal.js
More file actions
59 lines (51 loc) · 2 KB
/
CreatePaymentRequestsModal.js
File metadata and controls
59 lines (51 loc) · 2 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
function removeApplicationPaymentRequest(applicationId) {
let $container = $('#' + applicationId);
// Get the amount value inside this container before removing it
let amountValue = $container.find('.amount').val();
let amount = parseFloat((amountValue || "0").replace(/,/g, ''));
// Update the total amount
let $totalInput = $('.totalAmount');
let currentTotal = parseFloat(($totalInput.val() || "0").replace(/,/g, '')) || 0;
let newTotal = currentTotal - amount;
if (newTotal < 0) newTotal = 0;
$totalInput.val(newTotal.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
$('#' + 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");
}
}
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 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();
}
};