diff --git a/package.json b/package.json index 80367ff..c1e4126 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "wealthfolio-app", "private": true, - "version": "1.0.6", + "version": "1.0.7", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 1eb72f0..741a7a3 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4352,7 +4352,7 @@ dependencies = [ [[package]] name = "wealthfolio-app" -version = "1.0.6" +version = "1.0.7" dependencies = [ "chrono", "csv", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index c2b802c..bc72b7d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "wealthfolio-app" -version = "1.0.6" +version = "1.0.7" description = "Portfolio tracker" authors = ["Aziz Fadil"] -license = "MIT" +license = "LGPL-3.0" repository = "" edition = "2021" diff --git a/src-tauri/src/asset/asset_service.rs b/src-tauri/src/asset/asset_service.rs index d1190f3..052be71 100644 --- a/src-tauri/src/asset/asset_service.rs +++ b/src-tauri/src/asset/asset_service.rs @@ -328,13 +328,15 @@ impl AssetService { for yahoo_quote in quotes_history { let timestamp = yahoo_quote.timestamp as i64; + let naive_datetime = chrono::DateTime::from_timestamp(timestamp, 0) + .ok_or_else(|| format!("Invalid timestamp: {}", timestamp))? + .naive_utc(); + let new_quote = Quote { id: uuid::Uuid::new_v4().to_string(), - created_at: chrono::NaiveDateTime::from_timestamp_opt(timestamp, 0) - .ok_or_else(|| format!("Invalid timestamp: {}", timestamp))?, + created_at: naive_datetime, data_source: "YAHOO".to_string(), - date: chrono::NaiveDateTime::from_timestamp_opt(timestamp, 0) - .ok_or_else(|| format!("Invalid date timestamp: {}", timestamp))?, + date: naive_datetime, symbol: symbol.to_string(), open: yahoo_quote.open, high: yahoo_quote.high, diff --git a/src-tauri/src/models.rs b/src-tauri/src/models.rs index 00676c9..b314326 100644 --- a/src-tauri/src/models.rs +++ b/src-tauri/src/models.rs @@ -1,6 +1,5 @@ use chrono::NaiveDateTime; use diesel::prelude::*; -use diesel::sql_types::{Double, Nullable, Text}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Queryable, Identifiable, AsChangeset, Serialize, Deserialize, Debug)] @@ -327,24 +326,6 @@ pub struct Holding { pub sectors: Option>, } -#[derive(QueryableByName, Debug)] -pub struct AggregatedHolding { - #[diesel(sql_type = Text)] - pub account_id: String, - #[diesel(sql_type = Text)] - pub account_name: String, - #[diesel(sql_type = Text)] - pub asset_id: String, - #[diesel(sql_type = Text)] - pub asset_name: String, // Assuming this is the field name for asset_symbol - #[diesel(sql_type = Nullable)] - pub quantity: Option, - #[diesel(sql_type = Double)] - pub book_value: f64, - #[diesel(sql_type = Nullable)] - pub average_cost: Option, -} - // FinancialSnapshot and FinancialHistory structs with serde for serialization/deserialization #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] diff --git a/src-tauri/src/portfolio/portfolio_service.rs b/src-tauri/src/portfolio/portfolio_service.rs index 0af0581..8a7a2a2 100644 --- a/src-tauri/src/portfolio/portfolio_service.rs +++ b/src-tauri/src/portfolio/portfolio_service.rs @@ -416,8 +416,8 @@ impl PortfolioService { cumulative_cash += activity_amount * activity.unit_price - activity_fee; } "WITHDRAWAL" | "TRANSFER_OUT" | "CONVERSION_OUT" => { - cumulative_cash -= activity_amount + activity_fee; - net_deposit -= activity_amount; + cumulative_cash -= activity_amount * activity.unit_price + activity_fee; + net_deposit -= activity_amount * activity.unit_price; } "FEE" | "TAX" => { cumulative_cash -= activity_fee; diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 44fcab5..6611476 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "Wealthfolio", - "version": "1.0.6" + "version": "1.0.7" }, "tauri": { "allowlist": { diff --git a/src/lib/schemas.ts b/src/lib/schemas.ts index ba604f9..660dafa 100644 --- a/src/lib/schemas.ts +++ b/src/lib/schemas.ts @@ -34,9 +34,9 @@ export const newGoalSchema = z.object({ export const newActivitySchema = z.object({ id: z.string().uuid().optional(), - accountId: z.string(), + accountId: z.string().min(1, { message: 'Account ID is required' }), activityDate: z.date(), - currency: z.string(), + currency: z.string().min(1, { message: 'Currency is required' }), fee: z.coerce .number({ required_error: 'Please enter a valid fee.', @@ -51,7 +51,7 @@ export const newActivitySchema = z.object({ invalid_type_error: 'Quantity must be a positive number.', }) .min(0, { message: 'Quantity must be a positive number.' }), - assetId: z.string(), + assetId: z.string().min(1, { message: 'Asset ID is required' }), activityType: z.enum([ 'BUY', 'SELL', diff --git a/src/pages/activity/activity-page.tsx b/src/pages/activity/activity-page.tsx index 8b324ab..310c177 100644 --- a/src/pages/activity/activity-page.tsx +++ b/src/pages/activity/activity-page.tsx @@ -9,7 +9,6 @@ import ActivityTable from './components/activity-table'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { Account, ActivityDetails } from '@/lib/types'; import { getAccounts } from '@/commands/account'; -// import { getActivities } from '@/commands/activity'; import { ActivityDeleteModal } from './components/activity-delete-modal'; import { deleteActivity } from '@/commands/activity'; import { toast } from '@/components/ui/use-toast'; @@ -65,15 +64,15 @@ const ActivityPage = () => {
- -
@@ -97,7 +96,10 @@ const ActivityPage = () => { } activity={selectedActivity} open={showEditModal} - onClose={() => setShowEditModal(false)} + onClose={() => { + setShowEditModal(false); + setSelectedActivity(null); + }} /> )} /> - +
+ + +
); diff --git a/src/pages/onboarding/onboarding-page.tsx b/src/pages/onboarding/onboarding-page.tsx index e764454..040a67b 100644 --- a/src/pages/onboarding/onboarding-page.tsx +++ b/src/pages/onboarding/onboarding-page.tsx @@ -10,11 +10,11 @@ export const OnboardingPage = () => { const renderStepIcon = (stepNumber: number) => { return currentStep >= stepNumber ? ( -
+
) : ( -
+
{stepNumber}
); @@ -22,7 +22,7 @@ export const OnboardingPage = () => { return (
-
+
Illustration { />
-

+

Welcome to Wealthfolio

@@ -45,22 +45,21 @@ export const OnboardingPage = () => { started:

- + {renderStepIcon(1)}

Set your main currency

+ - -
- 2 -
+ + {renderStepIcon(2)}

Add your accounts

+ -
-
- 3 -
+ + {renderStepIcon(3)}

Add or import activities

-
+ +