This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function handle(Request $request): Stringable|string | |
| { | |
| $query = Expense::where('budget_id', $this->budgetId); | |
| if ($request['name'] ?? null) { | |
| $query->where('name', 'ilike', '%' . $request['name'] . '%'); | |
| } | |
| if ($request['category'] ?? null) { | |
| $query->where('category', 'ilike', '%' . $request['category'] . '%'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function instructions(): string | |
| { | |
| return <<<PROMPT | |
| Eres un asistente financiero personal para un presupuesto específico. | |
| Tu función es responder preguntas sobre los gastos y también agregar nuevos gastos. | |
| {$this->budgetContext} | |
| Reglas para consultar gastos: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ($budget->isGoal()) { | |
| $agent->budgetContext = "Este presupuesto es de tipo Meta/Objetivo llamado '{$budget->name}' con un monto total de \${$budget->amount}. Los gastos NO tienen categorías, solo nombre y monto."; | |
| } else { | |
| $agent->budgetContext = "Este presupuesto es de tipo General llamado '{$budget->name}' con un monto total de \${$budget->amount}. Los gastos tienen nombre, monto y categoría."; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState } from 'react'; | |
| type Props = { | |
| budgetId: number | |
| } | |
| export default function CashTrackrAgent({budgetId}: Props) { | |
| const [input, setInput] = useState(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('allows the expense owner to delete an expense', function () { | |
| $user = User::factory()->create([ | |
| 'email_verified_at' => now(), | |
| ]); | |
| $budget = Budget::factory()->for($user)->create([ | |
| 'type' => 'general', | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('allows the expense owner to update an expense', function () { | |
| $user = User::factory()->create([ | |
| 'email_verified_at' => now(), | |
| ]); | |
| $budget = Budget::factory()->for($user)->create([ | |
| 'type' => 'general', | |
| ]); | |
| $expense = Expense::factory()->for($budget)->create([ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| it('allows the budget owner to create an expense in a general budget', function () { | |
| $user = User::factory()->create([ | |
| 'email_verified_at' => now(), | |
| ]); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Dialog, DialogPanel, DialogTitle, DialogBackdrop } from '@headlessui/react' | |
| import { useDeleteExpenseStore } from '@/stores/expense-delete-store' | |
| export default function DeleteExpenseModal() { | |
| const open = useDeleteExpenseStore(state => state.open) | |
| const expense = useDeleteExpenseStore(state => state.expense) | |
| const closeModal = useDeleteExpenseStore(state => state.closeModal) | |
| return ( | |
| <Dialog open={open} onClose={closeModal} className="relative z-10"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react' | |
| export default function ExpenseDropdown() { | |
| return ( | |
| <Menu as="div" className="relative inline-block "> | |
| <MenuButton className="inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-xs inset-ring-1 inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20"> | |
| Opciones | |
| </MenuButton> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type CategoryValue = | |
| | 'food' | |
| | 'transportation' | |
| | 'health' | |
| | 'entertainment' | |
| | 'subscriptions' | |
| | 'beauty' | |
| | 'clothing' | |
| | 'home' | |
| | 'education' |