Add project files.

This commit is contained in:
Elias Jansson
2023-01-29 12:04:01 +01:00
parent 1440dc03d5
commit 334c5b02d7
17 changed files with 557 additions and 0 deletions

61
Nevyn/Models/Money.cs Normal file
View File

@@ -0,0 +1,61 @@
using System;
namespace Nevyn.Models
{
public class Wallet
{
public int Id { get; set; }
public int TotalAmount
{
get
{
return this.Kort + this.Buffert + this.Spara + this.Fonder;
}
}
public int Kort { get; set; }
public int Buffert { get; set; }
public int Spara { get; set; }
public int Fonder { get; set; }
public int MoneyUntilSalary {
get
{
DateTime payDay = SalaryCalculator.CalculatePayDay(DateTime.Now);
this.DaysLeftUntilSalary = (payDay - DateTime.Now).Days;
return this.Kort / this.DaysLeftUntilSalary;
}
}
public int DaysLeftUntilSalary { get; set; }
public class SalaryCalculator
{
public static DateTime CalculatePayDay(DateTime date)
{
// Get the 25th of the current month
var payDay = new DateTime(date.Year, date.Month, 25);
// If the 25th is on a weekend, get the previous Friday
if (payDay.DayOfWeek == DayOfWeek.Saturday)
{
payDay = payDay.AddDays(-1);
}
else if (payDay.DayOfWeek == DayOfWeek.Sunday)
{
payDay = payDay.AddDays(-2);
}
return payDay;
}
}
}
public class WalletDTO
{
public int Id { get; set; }
public int TotalAmount { get; set; }
public int AmountLeftPerDay { get; set; }
public int Kort { get; set; }
public string Debug { get; set; }
}
}