console.log( 'Code is Poetry' );
import React, { useState } from 'react';
import { Card, CardHeader, CardContent } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import { Label } from '@/components/ui/label';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
const RealEstateCalculator = () => {
const VAT_RATE = 0.17;
const [apartmentData, setApartmentData] = useState({
price: 0,
isFirstApartment: true,
brokerFee: 2,
lawyerFee: 0.5,
advisorFee: 0.5,
renovationCost: 0,
includeRenovation: false
});
// פונקציה לפורמוט מספרים לפורמט מטבע
const formatCurrency = (amount) => {
return new Intl.NumberFormat('he-IL', {
style: 'currency',
currency: 'ILS',
maximumFractionDigits: 0
}).format(amount);
};
// חישוב מס רכישה
const calculatePurchaseTax = (price, isFirstApartment) => {
if (isFirstApartment) {
if (price <= 1_748_470) return 0;
if (price <= 2_073_560) return (price - 1_748_470) * 0.035;
return (2_073_560 - 1_748_470) * 0.035 + (price - 2_073_560) * 0.05;
} else {
if (price <= 5_486_445) return price * 0.08;
return price * 0.10;
}
};
// חישוב עמלת תיווך כולל מע"מ
const calculateBrokerFee = (price, percentage) => {
const baseAmount = (price * percentage) / 100;
return {
base: baseAmount,
vat: baseAmount * VAT_RATE,
total: baseAmount * (1 + VAT_RATE)
};
};
// חישוב שכר טרחת עו"ד
const calculateLawyerFee = (price, percentage) => {
const baseAmount = Math.max((price * percentage) / 100, 5000);
return {
base: baseAmount,
vat: baseAmount * VAT_RATE,
total: baseAmount * (1 + VAT_RATE)
};
};
// חישוב עמלת יועץ השקעות
const calculateAdvisorFee = (price, percentage) => {
const baseAmount = (price * percentage) / 100;
return {
base: baseAmount,
vat: baseAmount * VAT_RATE,
total: baseAmount * (1 + VAT_RATE)
};
};
// חישוב עלות שיפוץ כולל מע"מ
const calculateRenovationCost = (amount) => {
return {
base: amount,
vat: amount * VAT_RATE,
total: amount * (1 + VAT_RATE)
};
};
// חישוב כל העלויות
const calculateTotalCosts = () => {
const propertyPrice = apartmentData.price;
const purchaseTax = calculatePurchaseTax(propertyPrice, apartmentData.isFirstApartment);
const brokerFee = calculateBrokerFee(propertyPrice, apartmentData.brokerFee);
const lawyerFee = calculateLawyerFee(propertyPrice, apartmentData.lawyerFee);
const investmentAdvisorFee = calculateAdvisorFee(propertyPrice, apartmentData.advisorFee);
const renovation = calculateRenovationCost(apartmentData.renovationCost);
const total = propertyPrice +
purchaseTax +
brokerFee.total +
lawyerFee.total +
investmentAdvisorFee.total +
(apartmentData.includeRenovation ? renovation.total : 0);
return {
propertyPrice,
purchaseTax,
brokerFee,
lawyerFee,
investmentAdvisorFee,
renovation,
total
};
};
const CostBreakdown = () => {
const costs = calculateTotalCosts();
return (
סעיף |
סכום לפני מע"מ |
מע"מ |
סה"כ כולל מע"מ |
מחיר דירה |
{formatCurrency(costs.propertyPrice)} |
- |
{formatCurrency(costs.propertyPrice)} |
מס רכישה |
{formatCurrency(costs.purchaseTax)} |
- |
{formatCurrency(costs.purchaseTax)} |
תיווך |
{formatCurrency(costs.brokerFee.base)} |
{formatCurrency(costs.brokerFee.vat)} |
{formatCurrency(costs.brokerFee.total)} |
עו"ד |
{formatCurrency(costs.lawyerFee.base)} |
{formatCurrency(costs.lawyerFee.vat)} |
{formatCurrency(costs.lawyerFee.total)} |
יועץ השקעות |
{formatCurrency(costs.investmentAdvisorFee.base)} |
{formatCurrency(costs.investmentAdvisorFee.vat)} |
{formatCurrency(costs.investmentAdvisorFee.total)} |
{apartmentData.includeRenovation && (
שיפוץ |
{formatCurrency(costs.renovation.base)} |
{formatCurrency(costs.renovation.vat)} |
{formatCurrency(costs.renovation.total)} |
)}
סה"כ |
- |
- |
{formatCurrency(costs.total)} |
);
};
return (
מחשבון עלויות רכישת דירה
חישוב עלויות
חישוב משכנתה
חלק זה בפיתוח - יתווסף בקרוב
);
};
export default RealEstateCalculator;