From f1462e554998e145aa76a9190de7027db0c0c38e Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 16 Sep 2025 14:32:23 +0000 Subject: [PATCH] 1 --- assets/css/custom.css | 4 +++- assets/js/main.js | 53 ++++++++++++++++++++----------------------- index.php | 32 +++++++++----------------- 3 files changed, 39 insertions(+), 50 deletions(-) diff --git a/assets/css/custom.css b/assets/css/custom.css index 3aa1d23..49bf6e0 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -93,5 +93,7 @@ body { .footer { padding: 2rem 0; background-color: #FFFFFF; - margin-top: 4rem; + position: fixed; + bottom: 0; + width: 100%; } diff --git a/assets/js/main.js b/assets/js/main.js index 9d9c334..dfa3e27 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,14 +1,15 @@ document.addEventListener('DOMContentLoaded', function () { const amountInput = document.getElementById('amount'); const rateInput = document.getElementById('rate'); + const agreementInput = document.getElementById('agreement'); const vatAmountOutput = document.getElementById('vatAmount'); const totalAmountOutput = document.getElementById('totalAmount'); - const grossSalaryInput = document.getElementById('gross-salary'); - const netSalaryOutput = document.getElementById('netSalary'); + const netAmountOutput = document.getElementById('netAmount'); - function calculateVAT() { + function updateCalculator() { const amount = parseFloat(amountInput.value) || 0; const rate = parseFloat(rateInput.value) || 0; + let tax = 0; if (amount > 0 && rate > 0) { const vatAmount = (amount * rate) / 100; @@ -16,41 +17,37 @@ document.addEventListener('DOMContentLoaded', function () { vatAmountOutput.textContent = vatAmount.toFixed(2); totalAmountOutput.textContent = totalAmount.toFixed(2); + + if (totalAmount > 0) { + if (totalAmount <= 1000) { + tax = totalAmount * 0.10; + } else if (totalAmount <= 3000) { + tax = (1000 * 0.10) + ((totalAmount - 1000) * 0.20); + } else { + tax = (1000 * 0.10) + (2000 * 0.20) + ((totalAmount - 3000) * 0.30); + } + const netAmount = totalAmount - tax; + netAmountOutput.textContent = netAmount.toFixed(2); + } else { + netAmountOutput.textContent = '0.00'; + } + } else { vatAmountOutput.textContent = '0.00'; totalAmountOutput.textContent = '0.00'; - } - } - - function calculateNetSalary() { - const grossSalary = parseFloat(grossSalaryInput.value) || 0; - let tax = 0; - - if (grossSalary > 0) { - if (grossSalary <= 1000) { - tax = grossSalary * 0.10; - } else if (grossSalary <= 3000) { - tax = (1000 * 0.10) + ((grossSalary - 1000) * 0.20); - } else { - tax = (1000 * 0.10) + (2000 * 0.20) + ((grossSalary - 3000) * 0.30); - } - const netSalary = grossSalary - tax; - netSalaryOutput.textContent = netSalary.toFixed(2); - } else { - netSalaryOutput.textContent = '0.00'; + netAmountOutput.textContent = '0.00'; } } window.setRate = function(rate) { rateInput.value = rate; - calculateVAT(); + updateCalculator(); } - amountInput.addEventListener('input', calculateVAT); - rateInput.addEventListener('input', calculateVAT); - grossSalaryInput.addEventListener('input', calculateNetSalary); + amountInput.addEventListener('input', updateCalculator); + rateInput.addEventListener('input', updateCalculator); + agreementInput.addEventListener('change', updateCalculator); // Initial calculation - calculateVAT(); - calculateNetSalary(); + updateCalculator(); }); \ No newline at end of file diff --git a/index.php b/index.php index b8d07a7..8445908 100644 --- a/index.php +++ b/index.php @@ -27,9 +27,17 @@

Instant VAT Calculator

- +
+
+ + +
@@ -46,25 +54,7 @@

VAT Amount: 0.00


Total (incl. VAT): 0.00

-
- - - - -
-
-
-
-

Net Salary Calculator

- -
- - -
- - -
-

Net Salary: 0.00

+

Net Amount: 0.00

@@ -80,7 +70,7 @@ - +