Implement discount tiers for pricing settings and enhance related functionalities
CI / Backend (build + test) (push) Successful in 1m20s
CI / Frontend (lint + typecheck + build) (push) Successful in 32s

- Introduced a new `DiscountTierDto` to represent volume discount tiers, allowing roles with a config quota at or above specified thresholds to receive discounts on pricing.
- Updated the `PricingSettingsDto` to include a list of discount tiers, enhancing the pricing model to support more flexible pricing strategies.
- Modified the `GetPricingSettingsQueryHandler` and `UpdatePricingSettingsCommandHandler` to handle discount tiers, ensuring they are correctly retrieved and updated in the database.
- Enhanced validation in `UpdatePricingSettingsCommandValidator` to enforce uniqueness and progressive discount tiers, preventing invalid configurations.
- Updated frontend components to support the new discount tier functionality, including forms for adding and managing discount tiers in the admin interface.
- Revised API documentation to reflect the new discount tier features and their usage in pricing settings.
This commit is contained in:
Leonid Pershin
2026-07-19 15:51:01 +03:00
parent 6a2d2d2318
commit 0dcaf1203f
27 changed files with 1645 additions and 43 deletions
@@ -59,6 +59,8 @@ public class AppDbContext(DbContextOptions<AppDbContext> options)
public DbSet<PricingSettings> PricingSettings => Set<PricingSettings>();
public DbSet<PricingDiscountTier> PricingDiscountTiers => Set<PricingDiscountTier>();
public DbSet<BillingSettings> BillingSettings => Set<BillingSettings>();
public DbSet<PaymentRequest> PaymentRequests => Set<PaymentRequest>();
@@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PnvPanel.Domain.Pricing;
namespace PnvPanel.Infrastructure.Persistence.Configurations;
public class PricingDiscountTierConfiguration : IEntityTypeConfiguration<PricingDiscountTier>
{
public void Configure(EntityTypeBuilder<PricingDiscountTier> builder)
{
builder.ToTable("PricingDiscountTiers");
builder.HasKey(x => x.Id);
builder.HasIndex(x => new { x.PricingSettingsId, x.MinConfigs }).IsUnique();
}
}
@@ -0,0 +1,42 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PnvPanel.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddPricingDiscountTiers : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PricingDiscountTiers",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
PricingSettingsId = table.Column<Guid>(type: "uuid", nullable: false),
MinConfigs = table.Column<int>(type: "integer", nullable: false),
DiscountPercent = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PricingDiscountTiers", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_PricingDiscountTiers_PricingSettingsId_MinConfigs",
table: "PricingDiscountTiers",
columns: new[] { "PricingSettingsId", "MinConfigs" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PricingDiscountTiers");
}
}
}
@@ -583,6 +583,29 @@ namespace PnvPanel.Infrastructure.Persistence.Migrations
b.ToTable("Nodes", (string)null);
});
modelBuilder.Entity("PnvPanel.Domain.Pricing.PricingDiscountTier", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("DiscountPercent")
.HasColumnType("integer");
b.Property<int>("MinConfigs")
.HasColumnType("integer");
b.Property<Guid>("PricingSettingsId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PricingSettingsId", "MinConfigs")
.IsUnique();
b.ToTable("PricingDiscountTiers", (string)null);
});
modelBuilder.Entity("PnvPanel.Domain.Pricing.PricingSettings", b =>
{
b.Property<Guid>("Id")