Include rental fees in payday

This commit is contained in:
hydrant
2019-07-30 13:30:53 +02:00
parent b2eef3f74b
commit 60718b24b5
3 changed files with 16 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using GTANetworkAPI;
using Microsoft.EntityFrameworkCore;
using ReallifeGamemode.Server.Entities;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Models;
@@ -158,15 +159,25 @@ namespace ReallifeGamemode.Server.Finance
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
float propertyTax = GetPropertyTaxation(client);
int vehicleTaxation = GetVehicleTaxation(client);
int rentalFees = GetRentalFees(client);
int amount = wage - (int)(wage * financialInterest) - vehicleTaxation - (int)propertyTax + (int)financialHelp;
Paycheck paycheck = new Paycheck(financialHelp, financialInterest, vehicleTaxation, propertyTax, wage, amount);
Paycheck paycheck = new Paycheck(financialHelp, financialInterest, vehicleTaxation, propertyTax, wage, amount, rentalFees);
User user = client.GetUser();
Paychecks[user.Id] = paycheck;
ReleasePayDay(client, paycheck);
}
private static int GetRentalFees(Client client)
{
using (var dbContext = new DatabaseContext())
{
User user = client.GetUser();
return dbContext.HouseRentals.Where(h => h.UserId == user.Id).Include(h => h.House).Sum(h => h.House.RentalFee);
}
}
public static void ReleasePayDay(Client client, Paycheck paycheck)
{
using (var dbContext = new DatabaseContext())