131 lines
3.9 KiB
C#
131 lines
3.9 KiB
C#
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
|
using System.Collections.Generic;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Aberwyn.Models
|
|
{
|
|
public class BudgetPeriod
|
|
{
|
|
public int Id { get; set; }
|
|
public int? Year { get; set; }
|
|
public int? Month { get; set; }
|
|
public int Order { get; set; }
|
|
public string? Name { get; set; }
|
|
|
|
public List<BudgetCategory> Categories { get; set; } = new();
|
|
}
|
|
|
|
public class BudgetCategory
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
public string Color { get; set; } // t.ex. "red", "green", "yellow"
|
|
public int BudgetPeriodId { get; set; }
|
|
public int Order { get; set; }
|
|
public int? BudgetCategoryDefinitionId { get; set; }
|
|
public BudgetCategoryDefinition? Definition { get; set; }
|
|
[JsonIgnore]
|
|
[ValidateNever]
|
|
public BudgetPeriod BudgetPeriod { get; set; }
|
|
|
|
public List<BudgetItem> Items { get; set; } = new();
|
|
}
|
|
|
|
public class BudgetItem
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
public decimal Amount { get; set; }
|
|
public bool IsExpense { get; set; } // true = utgift, false = inkomst/spar
|
|
public bool IncludeInSummary { get; set; } = true;
|
|
public int Order { get; set; } //
|
|
public int? BudgetItemDefinitionId { get; set; }
|
|
|
|
[JsonIgnore]
|
|
[ValidateNever]
|
|
public BudgetItemDefinition? BudgetItemDefinition { get; set; }
|
|
|
|
public int BudgetCategoryId { get; set; }
|
|
|
|
[JsonIgnore]
|
|
[ValidateNever]
|
|
|
|
|
|
public PaymentStatus PaymentStatus { get; set; } = PaymentStatus.None;
|
|
|
|
}
|
|
public enum PaymentStatus
|
|
{
|
|
None = 0,
|
|
Due = 1,
|
|
Paid = 2
|
|
}
|
|
// DTOs/BudgetDto.cs
|
|
public class BudgetDto
|
|
{
|
|
public int Id { get; set; }
|
|
public string? Name { get; set; }
|
|
public int? Year { get; set; }
|
|
public int? Month { get; set; }
|
|
public int Order { get; set; }
|
|
|
|
public List<BudgetCategoryDto> Categories { get; set; } = new();
|
|
}
|
|
|
|
public class BudgetCategoryDto
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
public string Color { get; set; }
|
|
public List<BudgetItemDto> Items { get; set; } = new();
|
|
public int Order { get; set; }
|
|
public int? BudgetCategoryDefinitionId { get; set; }
|
|
|
|
public int? BudgetPeriodId { get; set; }
|
|
public int Year { get; set; }
|
|
public int Month { get; set; }
|
|
}
|
|
|
|
public class BudgetItemDto
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
public decimal Amount { get; set; }
|
|
public int Order { get; set; }
|
|
public int? BudgetItemDefinitionId { get; set; }
|
|
|
|
public bool IsExpense { get; set; }
|
|
public bool IncludeInSummary { get; set; }
|
|
public PaymentStatus PaymentStatus { get; set; }
|
|
}
|
|
|
|
|
|
public class BudgetModel
|
|
{
|
|
public List<BudgetItem> BudgetItems { get; set; } = new List<BudgetItem>();
|
|
}
|
|
public class PaymentStatusUpdateDto
|
|
{
|
|
public int ItemId { get; set; }
|
|
public PaymentStatus Status { get; set; }
|
|
}
|
|
|
|
public class BudgetItemDefinition
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; } // t.ex. "Däck", "Elräkning", "Drivmedel"
|
|
public string? DefaultCategory { get; set; } // valfritt, kan föreslå "Bilar"
|
|
public bool IsExpense { get; set; }
|
|
public bool IncludeInSummary { get; set; }
|
|
public PaymentStatus? DefaultPaymentStatus { get; set; }
|
|
|
|
}
|
|
public class BudgetCategoryDefinition
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; } // t.ex. "Bilar", "Räkningar", "Semester"
|
|
public string Color { get; set; } // standardfärg, kan modifieras per period
|
|
}
|
|
|
|
}
|