use yew::prelude::*; use wasm_bindgen::JsCast; use crate::components::accounting::models::*; use js_sys; #[derive(Properties, PartialEq)] pub struct ExpensesTabProps { pub state: UseStateHandle, } #[function_component(ExpensesTab)] pub fn expenses_tab(props: &ExpensesTabProps) -> Html { let state = &props.state; html! {
// Expense Form Modal {if state.show_expense_form { html! { } } else { html! {} }} // Expense Detail Modal {if state.show_expense_detail { if let Some(expense_id) = &state.selected_expense_id { if let Some(expense) = state.expense_entries.iter().find(|e| &e.id == expense_id) { let expense_transactions: Vec<&PaymentTransaction> = state.payment_transactions.iter() .filter(|t| t.expense_id.as_ref() == Some(expense_id)) .collect(); let total_paid: f64 = expense_transactions.iter().map(|t| t.amount).sum(); let remaining_balance = expense.total_amount - total_paid; html! { } } else { html! {} } } else { html! {} } } else { html! {} }} // Transaction Form Modal (for expense payments) {if state.show_transaction_form && state.transaction_form.expense_id.is_some() { html! { } } else { html! {} }} // Expense Actions and Table
{"Expense Entries"}
{"Click on any row to view details"}
{for state.expense_entries.iter().map(|entry| { html! { } })}
{"Receipt #"} {"Vendor"} {"Description"} {"Amount"} {"Payment Method"} {"Status"} {"Approval"} {"Actions"}
{&entry.receipt_number}
{&entry.date}
{&entry.vendor_name}
{&entry.vendor_email}
{&entry.description}
{entry.category.to_string()} {if entry.is_deductible { "• Tax Deductible" } else { "" }} {if let Some(project) = &entry.project_code { html! { {format!("• {}", project)} } } else { html! {} }}
{format!("${:.2}", entry.total_amount)}
{format!("${:.2} + ${:.2} tax", entry.amount, entry.tax_amount)}
{entry.payment_method.to_string()}
{entry.payment_status.to_string()} {entry.approval_status.to_string()} { if let Some(approver) = &entry.approved_by { html! { {format!("by {}", approver)} } } else { html! {} } }
} }