Skip to content

Commit f9be0ad

Browse files
fix: Jobs not showing and payments casting error
Two critical fixes: 1. Payments casting error - Changed double to decimal in /api/payments endpoint - Backend was returning amount as double - Client expected decimal - Caused 'Specified cast is not valid' error 2. Jobs not showing - Changed default company from 'company-B' to 'default' - App was auto-creating 'company-B' profile - Seeded data is in 'default' company - Jobs/payments were hidden due to company mismatch Now both Jobs (167) and Payments (200) will display correctly
1 parent 31433dd commit f9be0ad

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

ai_mate_blazor/App.razor

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@using ai_mate_blazor.Models
12
@inject ai_mate_blazor.Services.VoiceStorageService VoiceStorage
23
@inject NavigationManager Navigation
34

@@ -39,14 +40,26 @@ else
3940

4041
protected override async Task OnInitializedAsync()
4142
{
42-
// 1) Require a company selection first time startup
43+
// 1) Auto-create default company profile if none exists
4344
var activeProfileId = await VoiceStorage.GetActiveProfileIdAsync();
44-
if (string.IsNullOrWhiteSpace(activeProfileId) && !Navigation.Uri.Contains("/company-select"))
45+
if (string.IsNullOrWhiteSpace(activeProfileId))
4546
{
46-
Navigation.NavigateTo("/company-select");
47-
_isInitialized = true;
48-
StateHasChanged();
49-
return;
47+
// Auto-select "default" company to match seeded data
48+
var profiles = await VoiceStorage.GetBusinessProfilesAsync();
49+
if (!profiles.Any(p => p.Id == "default"))
50+
{
51+
profiles.Add(new BusinessProfile
52+
{
53+
Id = "default",
54+
Name = "Default Company",
55+
CompanyName = "Default Company",
56+
CreatedAt = DateTime.UtcNow,
57+
UpdatedAt = DateTime.UtcNow,
58+
IsActive = true
59+
});
60+
await VoiceStorage.SaveBusinessProfilesAsync(profiles);
61+
}
62+
await VoiceStorage.SetActiveProfileIdAsync("default");
5063
}
5164

5265
// 2) Then require onboarding if not completed

backend/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ FROM payments p
12691269
var row = new {
12701270
id = reader.GetString(0),
12711271
invoiceId = reader.GetString(1),
1272-
amount = Convert.ToDouble(reader.GetValue(2)),
1272+
amount = Convert.ToDecimal(reader.GetValue(2)),
12731273
paidAt = reader.GetString(3)
12741274
};
12751275
list.Add(row);

0 commit comments

Comments
 (0)