Files
everything2/EveryThing/Models/Invoice/InvoiceItem.cs
David Štaleker a45fe73754 Odstranjenn projekt
dodan vnos pozicije fakture
2023-05-13 16:42:01 +02:00

84 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using static EveryThing.Models.Invoice.Invoice;
namespace EveryThing.Models.Invoice
{
public class InvoiceItem
{
public enum InvoiceItemState
{
[Display(Name = "Novo")]
New = 0,
[Display(Name = "Potrjeno")]
Confirmed = 10,
[Display(Name = "Zaprto")]
Closed = 50
}
[Key]
public int IdInvoiceItem { get; set; }
[Required]
[ForeignKey("Invoice")]
public int IdInvoiceFk { get; set; }
[ForeignKey("ProjectPartItem")]
public int? IdProjectPartItem { get; set; }
[ForeignKey("Item")]
[Display(Name = "Artikel")]
public int? IdItemFk { get; set; }
[ForeignKey("InvoiceItemJoin")]
[Display(Name = "Pozicija")]
public int? IdInvoiceItemJoinFk { get; set; }
[Display(Name = "Opis pozicije")]
public string ItemDescription { get; set; }
[Display(Name = "Artikel")]
public string UnlistedItem { get; set; }
[NotMapped] public string ItemDisplay => Item?.Title ?? UnlistedItem;
[Display(Name = "Opomba")]
public string Note { get; set; }
[Display(Name = "Količina")]
[DisplayFormat(DataFormatString = "{0:#,###,##0.00}", ApplyFormatInEditMode = true)]
public double Quantity { get; set; }
[Display(Name = "Cena")]
[DisplayFormat(DataFormatString = "{0:#,###,##0.00}", ApplyFormatInEditMode = true)]
public double Price { get; set; }
[Display(Name = "Rabat")]
[DisplayFormat(DataFormatString = "{0:#,###,##0.00}", ApplyFormatInEditMode = true)]
public double Discount { get; set; }
[Display(Name = "DDV")]
public double Tax { get; set; }
[Required]
[Display(Name = "Status")]
public InvoiceItemState State { get; set; } = InvoiceItemState.New;
[NotMapped]
[Display(Name = "Skupaj")]
[DisplayFormat(DataFormatString = "{0:#,###,##0.00}", ApplyFormatInEditMode = true)]
public double TotalValue => Math.Round((Price * (100 - Discount) / 100) * Quantity, 2);
// ForeignKey
public Invoice Invoice { get; set; }
public CodeTable.CodeTableItem Item { get; set; }
/// <summary>
/// Povezana pozicija fakture, npr ko se iz dob naredi racun
/// </summary>
public InvoiceItem InvoiceItemJoin { get; set; }
}
}