Spaces:
Running

tracker / index.html
excz's picture
crea un pagina con vue, debe tener caracteristicas de PWA para registrar los gastos relacionados a multiples proyectos inversión relacionada con real estate. En particular, quiero poder crear un nuevo proyecto indicando el nombre, la ubicación, fecha de remate e institución que lo remata. Cuando cree eso podré ir agregando a cada uno de los proyectos los gastos asociados a esa propuesta, por ejemplo: copias=$1.50, abogado=$250. Al final puedo obtener un reporte visual de cuanto se ha invertido en el proyecto. Posterior a la venta también quiero registar los gastos asociados a la venta y finalmente visualizar el calculo de reantabilidad. La paleta de colores a usar deben ser parametrizables y priorizando el uso en móvil. Crea un menú de ayuda donde expliques cada una de las funcionalidades y sirva como tutorial para los usuarios. - Initial Deployment
6cad3f0 verified
Raw History Blame Contribute Delete
56.3 kB
<!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Real Estate Investment Tracker</title> <script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.jsdelivr.net/npm/vue@3.2.47/dist/vue.global.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <meta name="theme-color" content="#4f46e5"> <link rel="manifest" id="manifest"> <style> .slide-fade-enter-active { transition: all 0.3s ease-out; } .slide-fade-leave-active { transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1); } .slide-fade-enter-from, .slide-fade-leave-to { transform: translateX(20px); opacity: 0; } .chart-container { height: 300px; } @media (min-width: 768px) { .chart-container { height: 400px; } } [contenteditable]:focus { outline: none; border-bottom: 2px solid #4f46e5; } </style> </head> <body class="bg-gray-50 min-h-screen"> <div id="app" class="max-w-md mx-auto pb-20"> <!-- Header --> <header class="bg-indigo-600 text-white p-4 shadow-md sticky top-0 z-10"> <div class="flex justify-between items-center"> <h1 class="text-xl font-bold">REI Tracker</h1> <div class="flex space-x-4"> <button @click="showColorPicker = !showColorPicker" class="p-2 rounded-full hover:bg-indigo-500"> <i class="fas fa-palette"></i> </button> <button @click="currentView = 'help'" class="p-2 rounded-full hover:bg-indigo-500"> <i class="fas fa-question-circle"></i> </button> </div> </div> <!-- Color Picker --> <div v-if="showColorPicker" class="mt-4 bg-white p-3 rounded-lg shadow-lg"> <h3 class="text-gray-800 font-semibold mb-2">Color Theme</h3> <div class="grid grid-cols-5 gap-2"> <div v-for="color in colorThemes" :key="color.name" @click="changeTheme(color)" class="h-10 w-10 rounded-full cursor-pointer border-2" :class="[color.bg, currentTheme === color.name ? 'border-gray-800' : 'border-transparent']" :title="color.name"></div> </div> </div> <!-- Navigation --> <nav class="mt-4 flex overflow-x-auto pb-2 hide-scrollbar"> <button @click="currentView = 'projects'" class="px-4 py-2 rounded-t-lg mr-1 whitespace-nowrap" :class="currentView === 'projects' ? 'bg-white text-indigo-600 font-semibold' : 'text-white hover:bg-indigo-500'"> Projects </button> <button @click="currentView = 'reports'" class="px-4 py-2 rounded-t-lg mr-1 whitespace-nowrap" :class="currentView === 'reports' ? 'bg-white text-indigo-600 font-semibold' : 'text-white hover:bg-indigo-500'"> Reports </button> <button @click="currentView = 'profitability'" class="px-4 py-2 rounded-t-lg whitespace-nowrap" :class="currentView === 'profitability' ? 'bg-white text-indigo-600 font-semibold' : 'text-white hover:bg-indigo-500'"> Profitability </button> </nav> </header> <!-- Main Content --> <main class="p-4"> <!-- Projects View --> <transition name="slide-fade" mode="out-in"> <div v-if="currentView === 'projects'" key="projects"> <button @click="showNewProjectForm = true" class="w-full bg-indigo-600 text-white py-3 rounded-lg mb-6 font-semibold flex items-center justify-center"> <i class="fas fa-plus mr-2"></i> New Project </button> <!-- New Project Form --> <div v-if="showNewProjectForm" class="bg-white p-4 rounded-lg shadow-md mb-6"> <h2 class="text-lg font-semibold mb-4">New Project</h2> <div class="space-y-4"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Name</label> <input v-model="newProject.name" type="text" class="w-full p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Location</label> <input v-model="newProject.location" type="text" class="w-full p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Auction Date</label> <input v-model="newProject.auctionDate" type="date" class="w-full p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Auction Institution</label> <input v-model="newProject.auctionInstitution" type="text" class="w-full p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> </div> <div class="flex space-x-2"> <button @click="addProject" class="flex-1 bg-indigo-600 text-white py-2 rounded-lg font-semibold"> Save </button> <button @click="showNewProjectForm = false" class="flex-1 bg-gray-200 text-gray-800 py-2 rounded-lg font-semibold"> Cancel </button> </div> </div> </div> <!-- Projects List --> <div v-for="project in projects" :key="project.id" class="bg-white rounded-lg shadow-md mb-4 overflow-hidden"> <div class="p-4 border-b"> <div class="flex justify-between items-start"> <div> <h3 class="font-semibold text-lg">{{ project.name }}</h3> <p class="text-sm text-gray-600">{{ project.location }}</p> <p class="text-xs text-gray-500 mt-1"> Auction: {{ formatDate(project.auctionDate) }} @ {{ project.auctionInstitution }} </p> </div> <div class="flex space-x-2"> <button @click="toggleProjectDetails(project.id)" class="text-indigo-600 hover:text-indigo-800"> <i :class="expandedProject === project.id ? 'fas fa-chevron-up' : 'fas fa-chevron-down'"></i> </button> <button @click="editProject(project)" class="text-gray-600 hover:text-gray-800"> <i class="fas fa-edit"></i> </button> </div> </div> </div> <!-- Project Details --> <div v-if="expandedProject === project.id" class="p-4 bg-gray-50"> <!-- Add Expense Form --> <div class="mb-4"> <div class="flex items-center space-x-2 mb-2"> <input v-model="newExpenses[project.id].description" type="text" placeholder="Expense description" class="flex-1 p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <input v-model="newExpenses[project.id].amount" type="number" placeholder="Amount" class="w-24 p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <select v-model="newExpenses[project.id].phase" class="w-28 p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 text-sm"> <option value="acquisition">Acquisition</option> <option value="holding">Holding</option> <option value="sale">Sale</option> </select> <button @click="addExpense(project.id)" class="bg-indigo-600 text-white p-2 rounded-lg"> <i class="fas fa-plus"></i> </button> </div> </div> <!-- Expenses List --> <div class="mb-4"> <h4 class="font-medium mb-2">Expenses</h4> <div v-if="project.expenses.length === 0" class="text-sm text-gray-500 italic"> No expenses recorded yet </div> <div v-for="(expense, index) in project.expenses" :key="index" class="flex justify-between items-center py-2 border-b last:border-b-0"> <div> <span class="font-medium">{{ expense.description }}</span> <span class="text-xs text-gray-500 ml-2 capitalize">{{ expense.phase }}</span> </div> <div class="flex items-center"> <span class="font-semibold">${{ expense.amount.toFixed(2) }}</span> <button @click="removeExpense(project.id, index)" class="ml-2 text-red-500 hover:text-red-700"> <i class="fas fa-trash-alt text-xs"></i> </button> </div> </div> </div> <!-- Sale Information --> <div class="mb-4"> <h4 class="font-medium mb-2">Sale Information</h4> <div v-if="!project.salePrice" class="text-sm text-gray-500 italic mb-2"> Not sold yet </div> <div v-else class="text-sm mb-2"> Sold for ${{ project.salePrice.toFixed(2) }} on {{ formatDate(project.saleDate) }} </div> <div class="flex items-center space-x-2"> <input v-model="project.salePrice" type="number" placeholder="Sale price" class="flex-1 p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <input v-model="project.saleDate" type="date" class="w-32 p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <button @click="saveSaleInfo(project.id)" class="bg-indigo-600 text-white p-2 rounded-lg"> <i class="fas fa-save"></i> </button> </div> </div> <!-- Project Summary --> <div class="bg-white p-3 rounded-lg border"> <div class="flex justify-between mb-1"> <span>Acquisition Costs:</span> <span class="font-semibold">${{ getPhaseTotal(project, 'acquisition').toFixed(2) }}</span> </div> <div class="flex justify-between mb-1"> <span>Holding Costs:</span> <span class="font-semibold">${{ getPhaseTotal(project, 'holding').toFixed(2) }}</span> </div> <div class="flex justify-between mb-1"> <span>Sale Costs:</span> <span class="font-semibold">${{ getPhaseTotal(project, 'sale').toFixed(2) }}</span> </div> <div class="border-t mt-2 pt-2 font-bold flex justify-between"> <span>Total Investment:</span> <span>${{ getTotalInvestment(project).toFixed(2) }}</span> </div> </div> </div> </div> </div> </transition> <!-- Reports View --> <transition name="slide-fade" mode="out-in"> <div v-if="currentView === 'reports'" key="reports" class="space-y-6"> <h2 class="text-xl font-semibold mb-4">Investment Reports</h2> <!-- Project Selector --> <div class="bg-white p-4 rounded-lg shadow-md"> <label class="block text-sm font-medium text-gray-700 mb-1">Select Project</label> <select v-model="selectedReportProject" class="w-full p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <option value="">All Projects</option> <option v-for="project in projects" :key="project.id" :value="project.id"> {{ project.name }} - {{ project.location }} </option> </select> </div> <!-- Summary Cards --> <div class="grid grid-cols-2 gap-4"> <div class="bg-white p-4 rounded-lg shadow-md text-center"> <div class="text-sm text-gray-600">Total Projects</div> <div class="text-2xl font-bold">{{ filteredProjects.length }}</div> </div> <div class="bg-white p-4 rounded-lg shadow-md text-center"> <div class="text-sm text-gray-600">Total Investment</div> <div class="text-2xl font-bold">${{ getTotalInvestmentForReport().toFixed(2) }}</div> </div> </div> <!-- Charts --> <div class="bg-white p-4 rounded-lg shadow-md"> <h3 class="font-medium mb-3">Investment Distribution</h3> <div class="chart-container"> <canvas ref="investmentChart"></canvas> </div> </div> <div class="bg-white p-4 rounded-lg shadow-md"> <h3 class="font-medium mb-3">Expense Breakdown</h3> <div class="chart-container"> <canvas ref="expenseChart"></canvas> </div> </div> <!-- Detailed Report --> <div class="bg-white p-4 rounded-lg shadow-md"> <h3 class="font-medium mb-3">Detailed Expenses</h3> <div v-if="filteredProjects.length === 0" class="text-sm text-gray-500 italic"> No projects to display </div> <div v-for="project in filteredProjects" :key="project.id" class="mb-4 last:mb-0"> <div class="font-semibold mb-2">{{ project.name }} - {{ project.location }}</div> <div v-for="expense in project.expenses" :key="expense.id" class="flex justify-between text-sm py-1 border-b last:border-b-0"> <span>{{ expense.description }} ({{ expense.phase }})</span> <span>${{ expense.amount.toFixed(2) }}</span> </div> <div class="flex justify-between font-semibold mt-2 pt-2 border-t"> <span>Total</span> <span>${{ getTotalInvestment(project).toFixed(2) }}</span> </div> </div> </div> </div> </transition> <!-- Profitability View --> <transition name="slide-fade" mode="out-in"> <div v-if="currentView === 'profitability'" key="profitability" class="space-y-6"> <h2 class="text-xl font-semibold mb-4">Profitability Analysis</h2> <!-- Sold Projects Only --> <div class="bg-white p-4 rounded-lg shadow-md"> <label class="block text-sm font-medium text-gray-700 mb-1">Select Project</label> <select v-model="selectedProfitProject" class="w-full p-2 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <option value="">Select a sold project</option> <option v-for="project in soldProjects" :key="project.id" :value="project.id"> {{ project.name }} - Sold for ${{ project.salePrice.toFixed(2) }} </option> </select> </div> <div v-if="selectedProfitProject && selectedProfitProjectObj" class="space-y-4"> <!-- Profitability Summary --> <div class="bg-white p-4 rounded-lg shadow-md"> <h3 class="font-medium mb-3">Profitability Summary</h3> <div class="space-y-2"> <div class="flex justify-between"> <span>Sale Price:</span> <span class="font-semibold">${{ selectedProfitProjectObj.salePrice.toFixed(2) }}</span> </div> <div class="flex justify-between"> <span>Total Investment:</span> <span class="font-semibold">${{ getTotalInvestment(selectedProfitProjectObj).toFixed(2) }}</span> </div> <div class="border-t pt-2 mt-2 flex justify-between font-bold"> <span>Gross Profit:</span> <span :class="getGrossProfit(selectedProfitProjectObj) >= 0 ? 'text-green-600' : 'text-red-600'"> ${{ getGrossProfit(selectedProfitProjectObj).toFixed(2) }} </span> </div> <div class="flex justify-between"> <span>ROI:</span> <span :class="getROI(selectedProfitProjectObj) >= 0 ? 'text-green-600' : 'text-red-600'"> {{ getROI(selectedProfitProjectObj).toFixed(2) }}% </span> </div> <div class="flex justify-between"> <span>Holding Period:</span> <span>{{ getHoldingPeriod(selectedProfitProjectObj) }} days</span> </div> <div class="flex justify-between"> <span>Annualized ROI:</span> <span :class="getAnnualizedROI(selectedProfitProjectObj) >= 0 ? 'text-green-600' : 'text-red-600'"> {{ getAnnualizedROI(selectedProfitProjectObj).toFixed(2) }}% </span> </div> </div> </div> <!-- Profitability Chart --> <div class="bg-white p-4 rounded-lg shadow-md"> <h3 class="font-medium mb-3">Profitability Breakdown</h3> <div class="chart-container"> <canvas ref="profitabilityChart"></canvas> </div> </div> </div> <div v-else class="bg-white p-4 rounded-lg shadow-md text-center text-gray-500"> <i class="fas fa-chart-line text-4xl mb-2"></i> <p>Select a sold project to view profitability analysis</p> </div> </div> </transition> <!-- Help View --> <transition name="slide-fade" mode="out-in"> <div v-if="currentView === 'help'" key="help" class="bg-white p-4 rounded-lg shadow-md"> <h2 class="text-xl font-semibold mb-4">Help & Tutorial</h2> <div class="space-y-6"> <!-- Getting Started --> <div> <h3 class="font-medium text-lg mb-2 flex items-center"> <i class="fas fa-rocket mr-2 text-indigo-600"></i> Getting Started </h3> <div class="text-sm space-y-2"> <p>Welcome to REI Tracker! This app helps you track expenses for your real estate investment projects and analyze their profitability.</p> <p>To get started:</p> <ol class="list-decimal pl-5 space-y-1"> <li>Create a new project by clicking the "New Project" button</li> <li>Fill in the project details (name, location, auction info)</li> <li>Start adding expenses to your project</li> <li>When the property sells, record the sale price and date</li> <li>View reports and profitability analysis</li> </ol> </div> </div> <!-- Projects --> <div> <h3 class="font-medium text-lg mb-2 flex items-center"> <i class="fas fa-home mr-2 text-indigo-600"></i> Managing Projects </h3> <div class="text-sm space-y-2"> <p><strong>Creating Projects:</strong> Each project represents a property you're investing in. Include all relevant details to help you track it.</p> <p><strong>Expense Phases:</strong> Expenses are categorized into three phases:</p> <ul class="list-disc pl-5 space-y-1"> <li><strong>Acquisition:</strong> Costs before purchase (appraisals, inspections, etc.)</li> <li><strong>Holding:</strong> Ongoing costs (taxes, maintenance, utilities)</li> <li><strong>Sale:</strong> Costs to sell (agent commissions, staging, etc.)</li> </ul> <p><strong>Recording Sales:</strong> When you sell a property, enter the sale price and date to enable profitability calculations.</p> </div> </div> <!-- Reports --> <div> <h3 class="font-medium text-lg mb-2 flex items-center"> <i class="fas fa-chart-pie mr-2 text-indigo-600"></i> Reports </h3> <div class="text-sm space-y-2"> <p>The Reports section provides visualizations of your investment data:</p> <ul class="list-disc pl-5 space-y-1"> <li><strong>Investment Distribution:</strong> Pie chart showing how your total investment is distributed across projects</li> <li><strong>Expense Breakdown:</strong> Bar chart showing expenses by category (acquisition, holding, sale)</li> <li><strong>Detailed Expenses:</strong> List view of all expenses with filtering options</li> </ul> <p>Use the project selector to view data for specific projects or all projects combined.</p> </div> </div> <!-- Profitability --> <div> <h3 class="font-medium text-lg mb-2 flex items-center"> <i class="fas fa-dollar-sign mr-2 text-indigo-600"></i> Profitability Analysis </h3> <div class="text-sm space-y-2"> <p>For sold properties, the app calculates several profitability metrics:</p> <ul class="list-disc pl-5 space-y-1"> <li><strong>Gross Profit:</strong> Sale price minus total investment</li> <li><strong>ROI (Return on Investment):</strong> (Gross Profit / Total Investment) × 100</li> <li><strong>Holding Period:</strong> Days between acquisition and sale</li> <li><strong>Annualized ROI:</strong> ROI adjusted to a yearly rate</li> </ul> <p>These metrics help you evaluate the success of your investments and compare different projects.</p> </div> </div> <!-- Tips --> <div> <h3 class="font-medium text-lg mb-2 flex items-center"> <i class="fas fa-lightbulb mr-2 text-indigo-600"></i> Tips & Best Practices </h3> <div class="text-sm space-y-2"> <ul class="list-disc pl-5 space-y-1"> <li>Record expenses as soon as possible to maintain accurate records</li> <li>Be consistent with expense descriptions for easier reporting</li> <li>Review reports regularly to monitor your investment performance</li> <li>Use the profitability analysis to identify your most successful strategies</li> <li>Customize the color theme using the palette icon in the header</li> </ul> </div> </div> </div> <div class="mt-6 text-center"> <button @click="currentView = 'projects'" class="bg-indigo-600 text-white px-4 py-2 rounded-lg font-semibold"> <i class="fas fa-arrow-left mr-2"></i> Back to App </button> </div> </div> </transition> </main> <!-- Install Prompt --> <div v-if="showInstallPrompt" class="fixed bottom-0 left-0 right-0 bg-indigo-600 text-white p-4 shadow-lg"> <div class="flex justify-between items-center"> <div> <h3 class="font-semibold">Install REI Tracker</h3> <p class="text-sm">Add to your home screen for easy access</p> </div> <div class="flex space-x-2"> <button @click="installApp" class="bg-white text-indigo-600 px-4 py-1 rounded-lg font-semibold"> Install </button> <button @click="dismissInstallPrompt" class="text-white px-4 py-1 rounded-lg font-semibold"> Later </button> </div> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script> const { createApp, ref, computed, watch, nextTick, onMounted } = Vue; createApp({ setup() { // Theme management const colorThemes = [ { name: 'indigo', bg: 'bg-indigo-600', text: 'text-indigo-600', border: 'border-indigo-600' }, { name: 'emerald', bg: 'bg-emerald-600', text: 'text-emerald-600', border: 'border-emerald-600' }, { name: 'rose', bg: 'bg-rose-600', text: 'text-rose-600', border: 'border-rose-600' }, { name: 'amber', bg: 'bg-amber-600', text: 'text-amber-600', border: 'border-amber-600' }, { name: 'violet', bg: 'bg-violet-600', text: 'text-violet-600', border: 'border-violet-600' }, { name: 'cyan', bg: 'bg-cyan-600', text: 'text-cyan-600', border: 'border-cyan-600' }, { name: 'fuchsia', bg: 'bg-fuchsia-600', text: 'text-fuchsia-600', border: 'border-fuchsia-600' }, { name: 'lime', bg: 'bg-lime-600', text: 'text-lime-600', border: 'border-lime-600' }, { name: 'sky', bg: 'bg-sky-600', text: 'text-sky-600', border: 'border-sky-600' }, { name: 'stone', bg: 'bg-stone-600', text: 'text-stone-600', border: 'border-stone-600' } ]; const currentTheme = ref(localStorage.getItem('theme') || 'indigo'); const showColorPicker = ref(false); const changeTheme = (theme) => { currentTheme.value = theme.name; localStorage.setItem('theme', theme.name); updateThemeColors(theme); showColorPicker.value = false; }; const updateThemeColors = (theme) => { document.documentElement.style.setProperty('--primary-color', theme.bg); document.querySelector('meta[name="theme-color"]').setAttribute('content', theme.bg.split('-')[1]); // Update manifest theme color const manifest = document.getElementById('manifest'); manifest.setAttribute('href', `data:application/json,${JSON.stringify({ name: "REI Tracker", short_name: "REI Tracker", description: "Real Estate Investment Tracker", start_url: "/", display: "standalone", theme_color: theme.bg.split('-')[1], background_color: "#ffffff", icons: [ { src: "icon-192x192.png", sizes: "192x192", type: "image/png" }, { src: "icon-512x512.png", sizes: "512x512", type: "image/png" } ] })}`); }; // Initialize theme onMounted(() => { const theme = colorThemes.find(t => t.name === currentTheme.value) || colorThemes[0]; updateThemeColors(theme); }); // App state const currentView = ref('projects'); const expandedProject = ref(null); const showNewProjectForm = ref(false); const selectedReportProject = ref(''); const selectedProfitProject = ref(''); // Data models const projects = ref(JSON.parse(localStorage.getItem('projects')) || []); const newProject = ref({ name: '', location: '', auctionDate: '', auctionInstitution: '', expenses: [], salePrice: null, saleDate: null }); const newExpenses = ref({}); // Initialize newExpenses for each project watch(projects, (newProjects) => { newProjects.forEach(project => { if (!newExpenses.value[project.id]) { newExpenses.value[project.id] = { description: '', amount: '', phase: 'acquisition' }; } }); }, { immediate: true, deep: true }); // PWA installation const showInstallPrompt = ref(false); let deferredPrompt = null; window.addEventListener('beforeinstallprompt', (e) => { e.preventDefault(); deferredPrompt = e; showInstallPrompt.value = true; }); const installApp = async () => { if (deferredPrompt) { deferredPrompt.prompt(); const { outcome } = await deferredPrompt.userChoice; if (outcome === 'accepted') { console.log('User accepted the install prompt'); } else { console.log('User dismissed the install prompt'); } deferredPrompt = null; showInstallPrompt.value = false; } }; const dismissInstallPrompt = () => { showInstallPrompt.value = false; }; // Chart refs const investmentChart = ref(null); const expenseChart = ref(null); const profitabilityChart = ref(null); // Computed properties const filteredProjects = computed(() => { if (!selectedReportProject.value) return projects.value; return projects.value.filter(p => p.id === selectedReportProject.value); }); const soldProjects = computed(() => { return projects.value.filter(p => p.salePrice !== null); }); const selectedProfitProjectObj = computed(() => { if (!selectedProfitProject.value) return null; return projects.value.find(p => p.id === selectedProfitProject.value); }); // Methods const addProject = () => { if (!newProject.value.name || !newProject.value.location) return; const project = { id: Date.now().toString(), ...newProject.value, expenses: [] }; projects.value.push(project); newExpenses.value[project.id] = { description: '', amount: '', phase: 'acquisition' }; // Reset form newProject.value = { name: '', location: '', auctionDate: '', auctionInstitution: '', expenses: [], salePrice: null, saleDate: null }; showNewProjectForm.value = false; saveProjects(); }; const editProject = (project) => { newProject.value = { ...project }; showNewProjectForm.value = true; }; const toggleProjectDetails = (projectId) => { expandedProject.value = expandedProject.value === projectId ? null : projectId; }; const addExpense = (projectId) => { const expense = newExpenses.value[projectId]; if (!expense.description || !expense.amount) return; const project = projects.value.find(p => p.id === projectId); if (project) { project.expenses.push({ id: Date.now().toString(), description: expense.description, amount: parseFloat(expense.amount), phase: expense.phase }); // Reset form newExpenses.value[projectId] = { description: '', amount: '', phase: expense.phase }; saveProjects(); } }; const removeExpense = (projectId, expenseIndex) => { const project = projects.value.find(p => p.id === projectId); if (project) { project.expenses.splice(expenseIndex, 1); saveProjects(); } }; const saveSaleInfo = (projectId) => { const project = projects.value.find(p => p.id === projectId); if (project) { project.salePrice = parseFloat(project.salePrice); saveProjects(); } }; const saveProjects = () => { localStorage.setItem('projects', JSON.stringify(projects.value)); }; const formatDate = (dateString) => { if (!dateString) return 'Not set'; const options = { year: 'numeric', month: 'short', day: 'numeric' }; return new Date(dateString).toLocaleDateString(undefined, options); }; const getPhaseTotal = (project, phase) => { return project.expenses .filter(e => e.phase === phase) .reduce((sum, expense) => sum + expense.amount, 0); }; const getTotalInvestment = (project) => { return project.expenses.reduce((sum, expense) => sum + expense.amount, 0); }; const getTotalInvestmentForReport = () => { return filteredProjects.value.reduce((sum, project) => sum + getTotalInvestment(project), 0); }; const getGrossProfit = (project) => { if (!project.salePrice) return 0; return project.salePrice - getTotalInvestment(project); }; const getROI = (project) => { if (!project.salePrice) return 0; const investment = getTotalInvestment(project); if (investment === 0) return 0; return (getGrossProfit(project) / investment) * 100; }; const getHoldingPeriod = (project) => { if (!project.auctionDate || !project.saleDate) return 0; const start = new Date(project.auctionDate); const end = new Date(project.saleDate); return Math.ceil((end - start) / (1000 * 60 * 60 * 24)); }; const getAnnualizedROI = (project) => { const roi = getROI(project); const holdingDays = getHoldingPeriod(project); if (holdingDays === 0) return 0; return (Math.pow(1 + roi/100, 365/holdingDays) - 1) * 100; }; // Chart functions const renderInvestmentChart = () => { if (!investmentChart.value) return; const ctx = investmentChart.value.getContext('2d'); // Group projects by name with their total investment const projectData = filteredProjects.value.map(project => ({ name: project.name, total: getTotalInvestment(project) })); // Sort by total investment (descending) projectData.sort((a, b) => b.total - a.total); new Chart(ctx, { type: 'pie', data: { labels: projectData.map(p => p.name), datasets: [{ data: projectData.map(p => p.total), backgroundColor: [ '#6366f1', '#8b5cf6', '#ec4899', '#f43f5e', '#ef4444', '#f97316', '#f59e0b', '#10b981', '#14b8a6', '#06b6d4', '#0ea5e9', '#3b82f6' ], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { position: 'bottom', }, tooltip: { callbacks: { label: function(context) { const label = context.label || ''; const value = context.raw || 0; const total = context.dataset.data.reduce((a, b) => a + b, 0); const percentage = Math.round((value / total) * 100); return `${label}: $${value.toFixed(2)} (${percentage}%)`; } } } } } }); }; const renderExpenseChart = () => { if (!expenseChart.value) return; const ctx = expenseChart.value.getContext('2d'); // Group expenses by phase const phases = ['acquisition', 'holding', 'sale']; const phaseTotals = phases.map(phase => { return filteredProjects.value.reduce((sum, project) => { return sum + getPhaseTotal(project, phase); }, 0); }); new Chart(ctx, { type: 'bar', data: { labels: ['Acquisition', 'Holding', 'Sale'], datasets: [{ label: 'Expenses by Phase', data: phaseTotals, backgroundColor: [ 'rgba(99, 102, 241, 0.7)', 'rgba(16, 185, 129, 0.7)', 'rgba(244, 63, 94, 0.7)' ], borderColor: [ 'rgba(99, 102, 241, 1)', 'rgba(16, 185, 129, 1)', 'rgba(244, 63, 94, 1)' ], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, ticks: { callback: function(value) { return '$' + value; } } } }, plugins: { tooltip: { callbacks: { label: function(context) { return '$' + context.raw.toFixed(2); } } } } } }); }; const renderProfitabilityChart = () => { if (!profitabilityChart.value || !selectedProfitProjectObj.value) return; const ctx = profitabilityChart.value.getContext('2d'); const project = selectedProfitProjectObj.value; const acquisitionCosts = getPhaseTotal(project, 'acquisition'); const holdingCosts = getPhaseTotal(project, 'holding'); const saleCosts = getPhaseTotal(project, 'sale'); const totalInvestment = getTotalInvestment(project); const grossProfit = getGrossProfit(project); new Chart(ctx, { type: 'bar', data: { labels: ['Investment', 'Profit'], datasets: [ { label: 'Acquisition Costs', data: [acquisitionCosts, 0], backgroundColor: 'rgba(99, 102, 241, 0.7)', stack: 'Stack 0' }, { label: 'Holding Costs', data: [holdingCosts, 0], backgroundColor: 'rgba(16, 185, 129, 0.7)', stack: 'Stack 0' }, { label: 'Sale Costs', data: [saleCosts, 0], backgroundColor: 'rgba(244, 63, 94, 0.7)', stack: 'Stack 0' }, { label: 'Gross Profit', data: [0, grossProfit], backgroundColor: grossProfit >= 0 ? 'rgba(52, 211, 153, 0.7)' : 'rgba(239, 68, 68, 0.7)', stack: 'Stack 1' } ] }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { stacked: true, }, y: { stacked: true, beginAtZero: true, ticks: { callback: function(value) { return '$' + value; } } } }, plugins: { tooltip: { callbacks: { label: function(context) { return context.dataset.label + ': $' + context.raw.toFixed(2); } } }, legend: { position: 'bottom', } } } }); }; // Watch for changes that require chart updates watch([selectedReportProject, projects], () => { nextTick(() => { renderInvestmentChart(); renderExpenseChart(); }); }, { deep: true }); watch([selectedProfitProject, projects], () => { nextTick(() => { renderProfitabilityChart(); }); }, { deep: true }); // Initialize charts on mount onMounted(() => { nextTick(() => { renderInvestmentChart(); renderExpenseChart(); }); }); return { // State currentView, expandedProject, showNewProjectForm, selectedReportProject, selectedProfitProject, showColorPicker, showInstallPrompt, // Data projects, newProject, newExpenses, colorThemes, currentTheme, // Refs investmentChart, expenseChart, profitabilityChart, // Computed filteredProjects, soldProjects, selectedProfitProjectObj, // Methods addProject, editProject, toggleProjectDetails, addExpense, removeExpense, saveSaleInfo, formatDate, getPhaseTotal, getTotalInvestment, getTotalInvestmentForReport, getGrossProfit, getROI, getHoldingPeriod, getAnnualizedROI, changeTheme, installApp, dismissInstallPrompt }; } }).mount('#app'); </script> <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=excz/tracker" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> </html>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Real Estate Investment Tracker</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@3.2.47/dist/vue.global.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<meta name="theme-color" content="#4f46e5">
<link rel="manifest" id="manifest">
<style>
.slide-fade-enter-active {
transition: all 0.3s ease-out;
}
.slide-fade-leave-active {
transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter-from,
.slide-fade-leave-to {
transform: translateX(20px);
opacity: 0;
}
.chart-container {
height: 300px;
}
@media (min-width: 768px) {
.chart-container {
height: 400px;
}
}
[contenteditable]:focus {
outline: none;
border-bottom: 2px solid #4f46e5;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div id="app" class="max-w-md mx-auto pb-20">
<!-- Header -->
<header class="bg-indigo-600 text-white p-4 shadow-md sticky top-0 z-10">
<div class="flex justify-between items-center">
<h1 class="text-xl font-bold">REI Tracker</h1>
<div class="flex space-x-4">
<button @click="showColorPicker = !showColorPicker" class="p-2 rounded-full hover:bg-indigo-500">
<i class="fas fa-palette"></i>
</button>
<button @click="currentView = 'help'" class="p-2 rounded-full hover:bg-indigo-500">
<i class="fas fa-question-circle"></i>
</button>
</div>
</div>
<!-- Color Picker -->
<div v-if="showColorPicker" class="mt-4 bg-white p-3 rounded-lg shadow-lg">
<h3 class="text-gray-800 font-semibold mb-2">Color Theme</h3>
<div class="grid grid-cols-5 gap-2">
<div v-for="color in colorThemes" :key="color.name"
@click="changeTheme(color)"
class="h-10 w-10 rounded-full cursor-pointer border-2"
:class="[color.bg, currentTheme === color.name ? 'border-gray-800' : 'border-transparent']"
:title="color.name"></div>
</div>
</div>
<!-- Navigation -->
<nav class="mt-4 flex overflow-x-auto pb-2 hide-scrollbar">
<button @click="currentView = 'projects'"
class="px-4 py-2 rounded-t-lg mr-1 whitespace-nowrap"
:class="currentView === 'projects' ? 'bg-white text-indigo-600 font-semibold' : 'text-white hover:bg-indigo-500'">
Projects
</button>
<button @click="currentView = 'reports'"
class="px-4 py-2 rounded-t-lg mr-1 whitespace-nowrap"
:class="currentView === 'reports' ? 'bg-white text-indigo-600 font-semibold' : 'text-white hover:bg-indigo-500'">
Reports
</button>
<button @click="currentView = 'profitability'"
class="px-4 py-2 rounded-t-lg whitespace-nowrap"
:class="currentView === 'profitability' ? 'bg-white text-indigo-600 font-semibold' : 'text-white hover:bg-indigo-500'">
Profitability
</button>
</nav>
</header>
<!-- Main Content -->
<main class="p-4">
<!-- Projects View -->
<transition name="slide-fade" mode="out-in">
<div v-if="currentView === 'projects'" key="projects">
<button @click="showNewProjectForm = true"
class="w-full bg-indigo-600 text-white py-3 rounded-lg mb-6 font-semibold flex items-center justify-center">
<i class="fas fa-plus mr-2"></i> New Project
</button>
<!-- New Project Form -->
<div v-if="showNewProjectForm" class="bg-white p-4 rounded-lg shadow-md mb-6">
<h2 class="text-lg font-semibold mb-4">New Project</h2>
<div class="space-y-4">
<div>