-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
42 lines (38 loc) · 1.74 KB
/
util.js
File metadata and controls
42 lines (38 loc) · 1.74 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
function calculate() {
let gstRate;
let invoiceNumberInput = document.getElementById("invoiceNumberInput").value;
let dateInput = document.getElementById("dateInput").value;
let partyNameInput = document.getElementById("partyNameInput").value;
let gstnInput = document.getElementById("gstnInput").value;
let amountInput = document.getElementById("amountInput").value;
let totalAmountInput = document.getElementById("totalAmountInput").value;
// Access Radio Button
if (document.getElementById("rate_5").checked) {
gstRate = document.getElementById("rate_5").value;
} else if (document.getElementById("rate_12").checked) {
gstRate = document.getElementById("rate_12").value
} else if (document.getElementById("rate_18").checked) {
gstRate = document.getElementById("rate_18").value
} else if (document.getElementById("rate_28").checked) {
gstRate = document.getElementById("rate_28").value
}
// calculateTotalAmount(gstRate, amountInput);
calculateAmount(gstRate,totalAmountInput);
}
function calculateTotalAmount(gstRate, amount) {
// let a= "Hello World"
let f_amount = parseFloat(amount);
let i_gstRate = parseInt(gstRate);
let totalAmount = f_amount + i_gstRate * f_amount / 100;
let roundedTotalAmount = totalAmount.toFixed(2)
alert(`Total Amount Is: ${roundedTotalAmount}`)
return roundedTotalAmount;
}
function calculateAmount(gstRate, totalAmount) {
let i_gstRate = parseInt(gstRate);
let f_totalAmount = parseFloat(totalAmount);
let amount = f_totalAmount * 100 / (100 + i_gstRate);
let roundedAmount = amount.toFixed(2);
alert(`Amount Is: ${roundedAmount}`);
return roundedAmount
}