diff --git a/Tiku.DbMigrator/Program.cs b/Tiku.DbMigrator/Program.cs index 9a76978..3c896ac 100644 --- a/Tiku.DbMigrator/Program.cs +++ b/Tiku.DbMigrator/Program.cs @@ -8,6 +8,7 @@ using Tiku.Infrastructure; using Tiku.Infrastructure.Persistence; using Tiku.Infrastructure.Bootstrap; using Tiku.Application; +using Tiku.Application.Security; var builder = Host.CreateApplicationBuilder(args); builder.Logging.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning); @@ -47,6 +48,8 @@ builder.Services.AddDataProtection().UseEphemeralDataProtectionProvider(); using var host = builder.Build(); await using var scope = host.Services.CreateAsyncScope(); +scope.ServiceProvider.GetRequiredService() + .InitializeSystem(null, "Database migration and bootstrap"); var dbContext = scope.ServiceProvider.GetRequiredService(); await dbContext.Database.MigrateAsync(); var catalogSeeder = ActivatorUtilities.CreateInstance(scope.ServiceProvider); diff --git a/Tiku.Infrastructure/Bootstrap/DevelopmentPlatformAdminSeeder.cs b/Tiku.Infrastructure/Bootstrap/DevelopmentPlatformAdminSeeder.cs index 8317abd..a55f8dc 100644 --- a/Tiku.Infrastructure/Bootstrap/DevelopmentPlatformAdminSeeder.cs +++ b/Tiku.Infrastructure/Bootstrap/DevelopmentPlatformAdminSeeder.cs @@ -411,6 +411,7 @@ public static class DevelopmentPlatformAdminSeeder IdempotencyKey = "demo-platform-payment-quote", Status = PlatformBillingQuoteStatus.Converted, Purpose = PlatformBillingOrderPurpose.NewSubscription, + OriginalAmountCents = 19900, TotalAmountCents = 19900, ExpiresAt = DateTimeOffset.UtcNow.AddDays(7) }; @@ -422,6 +423,7 @@ public static class DevelopmentPlatformAdminSeeder IdempotencyKey = "demo-platform-payment-order", Purpose = PlatformBillingOrderPurpose.NewSubscription, Status = PlatformBillingOrderStatus.PendingPayment, + OriginalAmountCents = 19900, TotalAmountCents = 19900, ExpiresAt = DateTimeOffset.UtcNow.AddDays(7) }; diff --git a/Tiku.UnitTests/Bootstrap/PlatformAdminBootstrapperTests.cs b/Tiku.UnitTests/Bootstrap/PlatformAdminBootstrapperTests.cs index 993954f..a9cf9df 100644 --- a/Tiku.UnitTests/Bootstrap/PlatformAdminBootstrapperTests.cs +++ b/Tiku.UnitTests/Bootstrap/PlatformAdminBootstrapperTests.cs @@ -100,6 +100,10 @@ public sealed class PlatformAdminBootstrapperTests Assert.Equal(BackendPermissions.Platform.Count, await context.PlatformBackendRolePermissions.CountAsync()); Assert.Single(context.PlatformBackendUserRoles); Assert.Single(context.AuditLogs); + var quote = await context.PlatformBillingQuotes.SingleAsync(); + Assert.Equal(quote.OriginalAmountCents - quote.DiscountAmountCents, quote.TotalAmountCents); + var order = await context.PlatformBillingOrders.SingleAsync(); + Assert.Equal(order.OriginalAmountCents - order.DiscountAmountCents, order.TotalAmountCents); } [Fact]