diff --git a/app/components/box1.js b/app/components/box1.js index 6e98490..0ffdb1a 100644 --- a/app/components/box1.js +++ b/app/components/box1.js @@ -11,14 +11,15 @@ export default function Box1({ salary }) { const [taxbase, setTaxbase] = useState(false) const [long, setLong] = useState(false) const [reduction, setReduction] = useState(0) + const [tax,setTax] = useState(0) useEffect(() => { let newreduction = 0 if (funds) { - newreduction += 5000 + newreduction += 2000 } if (insurance) { - newreduction += 5000 + newreduction += 2000 } if (government) { newreduction += 2000 @@ -38,8 +39,42 @@ export default function Box1({ salary }) { if (long) { newreduction += 2000 } + setReduction(newreduction) - }, [funds, insurance, government, charity]) + }, [funds, insurance, government, charity,health,home,taxbase,long]) + + useEffect(()=>{ + if (salary <= 150000) + { + setTax(0) + } + else if(salary <= 300000) + { + setTax(salary * 5/100) + } + else if(salary <= 500000) + { + setTax(7500 + ((salary-300000) * 10/100)) + } + else if(salary <= 750000) + { + setTax(27500 + ((salary-500000) * 15/100)) + } + else if(salary <= 1000000) + { + setTax(65000 + ((salary-750000) * 20/100)) + } + else if(salary <= 2000000) + { + setTax(115000 + ((salary-1000000) * 25/100)) + } + else if(salary <= 4000000) + { + setTax(365000 + ((salary-2000000) * 30/100)) + }else { + setTax(965000 + ((salary-2000000) * 30/100)) + } + },[]) return (
@@ -55,10 +90,10 @@ export default function Box1({ salary }) {
{ setHome(!home) }} /> ดอกเบี้ยบ้าน
{ setTaxbase(!taxbase) }} /> ฐานภาษี
{ setLong(!long) }} /> กองทุนรวมหุ้นระยะยาว
-
{ setGovernment(!government) }} /> ใช้สิทธิตามมาตรการกระตึ้นเศรษฐกิจของรัฐ
+
{ setGovernment(!government) }} /> ใช้สิทธิตามมาตรการกระตุ้นเศรษฐกิจของรัฐ
-

reduction : {reduction}

+

reduction : {tax - reduction <= 0 ? 0: tax - reduction }

); } diff --git a/app/page.js b/app/page.js index 1f21ebf..5b6c255 100644 --- a/app/page.js +++ b/app/page.js @@ -9,7 +9,7 @@ export default function Home() {
- +
);