Billing: fix calculation

This commit is contained in:
2023-11-02 11:57:38 +01:00
parent 193b4688d3
commit 9f67448b72
20 changed files with 327 additions and 117 deletions

View File

@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
using IndexAttribute = Microsoft.EntityFrameworkCore.IndexAttribute;
namespace Elwig.Models {
[Table("area_commitment_type"), PrimaryKey("VtrgId"), Index("SortId", "AttrId", "Discriminator")]
[Table("area_commitment_type"), PrimaryKey("VtrgId"), Index("SortId", "AttrId", "Discriminator", IsUnique = true)]
public class AreaComType {
[Column("vtrgid")]
public string VtrgId { get; set; }
@ -21,18 +21,30 @@ namespace Elwig.Models {
[Column("min_kg_per_ha")]
public int? MinKgPerHa { get; set; }
[Column("max_kg_per_ha")]
public int? MaxKgPerHa { get; set; }
[Column("penalty_per_kg")]
public long? PenaltyPerKgValue { get; set; }
[NotMapped]
public decimal? PenaltyPerKg {
get => PenaltyPerKgValue != null ? Utils.DecFromDb(PenaltyPerKgValue.Value, 4) : null;
set => PenaltyPerKgValue = value != null ? Utils.DecToDb(value.Value, 4) : null;
}
[Column("penalty_amount")]
public long? PenaltyAmoutValue { get; set; }
[NotMapped]
public decimal? PenaltyAmount {
get => PenaltyAmoutValue != null ? Utils.DecFromDb(PenaltyAmoutValue.Value, 4) : null;
set => PenaltyAmoutValue = value != null ? Utils.DecToDb(value.Value, 4) : null;
}
[Column("penalty_none")]
public long? PenaltyNoneValue { get; set; }
[NotMapped]
public decimal? PenaltyNone {
get => PenaltyNoneValue != null ? Utils.DecFromDb(PenaltyNoneValue.Value, 4) : null;
set => PenaltyNoneValue = value != null ? Utils.DecToDb(value.Value, 4) : null;
}
[ForeignKey("SortId")]
public virtual WineVar WineVar { get; private set; }