Change vehicle taxation

see https://life-of-german.org/bugtracker/bug/60-neue-fahrzeugsteuern/

@hydrant update DB before merge with master.
This commit is contained in:
2021-04-21 21:32:19 +02:00
parent 8485102e49
commit 4fe9365902
5 changed files with 2331 additions and 12 deletions

View File

@@ -15,10 +15,13 @@ namespace ReallifeGamemode.Database.Entities
{ {
[ForeignKey("User")] [ForeignKey("User")]
public int UserId { get; set; } public int UserId { get; set; }
public User User { get; set; } public User User { get; set; }
public int? Price { get; set; } public int? Price { get; set; }
public int? BusinessId { get; set; }
public override string ToString() public override string ToString()
{ {
return "Spieler Fahrzeug | Besitzer: " + GetOwner().Name; return "Spieler Fahrzeug | Besitzer: " + GetOwner().Name;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,109 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace ReallifeGamemode.Database.Migrations
{
public partial class UserVehicleBusinessId : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Users_UserId",
table: "ChatLogs");
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Factions_FactionId",
table: "ChatLogs");
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Groups_GroupId",
table: "ChatLogs");
migrationBuilder.AddColumn<int>(
name: "UserVehicle_BusinessId",
table: "ServerVehicles",
nullable: true);
migrationBuilder.AlterColumn<int>(
name: "UserId",
table: "ChatLogs",
nullable: false,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Users_UserId",
table: "ChatLogs",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Factions_FactionId",
table: "ChatLogs",
column: "FactionId",
principalTable: "Factions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Groups_GroupId",
table: "ChatLogs",
column: "GroupId",
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Users_UserId",
table: "ChatLogs");
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Factions_FactionId",
table: "ChatLogs");
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Groups_GroupId",
table: "ChatLogs");
migrationBuilder.DropColumn(
name: "UserVehicle_BusinessId",
table: "ServerVehicles");
migrationBuilder.AlterColumn<int>(
name: "UserId",
table: "ChatLogs",
type: "int",
nullable: true,
oldClrType: typeof(int));
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Users_UserId",
table: "ChatLogs",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Factions_FactionId",
table: "ChatLogs",
column: "FactionId",
principalTable: "Factions",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Groups_GroupId",
table: "ChatLogs",
column: "GroupId",
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

View File

@@ -814,7 +814,7 @@ namespace ReallifeGamemode.Database.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("datetime(6)"); .HasColumnType("datetime(6)");
b.Property<int?>("UserId") b.Property<int>("UserId")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@@ -1749,7 +1749,7 @@ namespace ReallifeGamemode.Database.Migrations
{ {
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry"); b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
b.Property<int?>("FactionId") b.Property<int>("FactionId")
.HasColumnType("int"); .HasColumnType("int");
b.HasIndex("FactionId"); b.HasIndex("FactionId");
@@ -1768,7 +1768,7 @@ namespace ReallifeGamemode.Database.Migrations
{ {
b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry"); b.HasBaseType("ReallifeGamemode.Database.Entities.Logs.Chat.ChatLogEntry");
b.Property<int?>("GroupId") b.Property<int>("GroupId")
.HasColumnType("int"); .HasColumnType("int");
b.HasIndex("GroupId"); b.HasIndex("GroupId");
@@ -1891,6 +1891,10 @@ namespace ReallifeGamemode.Database.Migrations
{ {
b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle"); b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle");
b.Property<int?>("BusinessId")
.HasColumnName("UserVehicle_BusinessId")
.HasColumnType("int");
b.Property<int?>("Price") b.Property<int?>("Price")
.HasColumnName("UserVehicle_Price") .HasColumnName("UserVehicle_Price")
.HasColumnType("int"); .HasColumnType("int");
@@ -2011,7 +2015,9 @@ namespace ReallifeGamemode.Database.Migrations
{ {
b.HasOne("ReallifeGamemode.Database.Entities.User", "User") b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
.WithMany() .WithMany()
.HasForeignKey("UserId"); .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
}); });
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.CommandLogEntry", b => modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.CommandLogEntry", b =>
@@ -2134,14 +2140,18 @@ namespace ReallifeGamemode.Database.Migrations
{ {
b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction") b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction")
.WithMany() .WithMany()
.HasForeignKey("FactionId"); .HasForeignKey("FactionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
}); });
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.GroupChatLogEntry", b => modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Chat.GroupChatLogEntry", b =>
{ {
b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group") b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group")
.WithMany() .WithMany()
.HasForeignKey("GroupId"); .HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
}); });
modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupVehicle", b => modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupVehicle", b =>

View File

@@ -44,11 +44,31 @@ namespace ReallifeGamemode.Server.Finance
foreach (UserVehicle uVeh in dbContext.UserVehicles.Where(u => u.UserId == user.Id)) foreach (UserVehicle uVeh in dbContext.UserVehicles.Where(u => u.UserId == user.Id))
{ {
if (uVeh.Price == null) if (uVeh.Price == null)
{
vehicleTaxation += 400; vehicleTaxation += 400;
continue; else
} vehicleTaxation += (int)(uVeh.Price * 0.0015f);
vehicleTaxation += (int)(uVeh.Price * 0.005f);
int taxation = uVeh.BusinessId switch
{
3 => 75, ///<see cref="Business.VapidCarDealerBusiness"/>
4 => 200, ///<see cref="Business.PremiumDeluxeMotorsportCarDealerBusiness"/>
5 => 150, ///<see cref="Business.BoatDealerBusiness"/>
6 => 150, ///<see cref="Business.HelicopterDealerBusiness"/>
7 => 150, ///<see cref="Business.AirplaneDealerBusiness"/>
8 => 50, ///<see cref="Business.BikeDealerBusiness"/>
9 => 20, ///<see cref="Business.BeachDealerBusiness"/>
10 => 50, ///<see cref="Business.LastTrainDealerBusiness"/>
11 => 100, ///<see cref="Business.SUVDealerBusiness"/>
12 => 50, ///<see cref="Business.AdminDealerBusiness"/>
13 => 100, ///<see cref="Business.ClassicAndLuxuryCarshop"/>
14 => 200, ///<see cref="Business.OldschoolCarshop"/>
_ => 0,
};
if (taxation is 0)
Console.WriteLine($"[FINANCE] USER: {user.Name} ({user.Id}) has no BusinessId on UserVehicle ({uVeh.Id})");
vehicleTaxation += taxation;
} }
} }
return vehicleTaxation; return vehicleTaxation;
@@ -189,13 +209,13 @@ namespace ReallifeGamemode.Server.Finance
using var dbContext = new DatabaseContext(); using var dbContext = new DatabaseContext();
foreach (var player in NAPI.Pools.GetAllPlayers().Where(p => p.IsLoggedIn())) foreach (var player in NAPI.Pools.GetAllPlayers().Where(p => p.IsLoggedIn()))
{ {
if(player.IsAfk()) if (player.IsAfk())
{ {
continue; continue;
} }
User user = player.GetUser(dbContext); User user = player.GetUser(dbContext);
if(user == null) if (user == null)
{ {
continue; continue;
} }