File size: 56,320 Bytes
6cad3f0 | 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 | <!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> |