James Chapman 47d13ba922
All checks were successful
Docker Image CI / build (push) Successful in 3m45s
Add support for adding 'loose' items to transactions
2024-10-12 02:36:38 +01:00

31 lines
811 B
C#

namespace Groceries.Data;
using System.Text.Json.Serialization;
public class TransactionItem
{
[JsonConstructor]
public TransactionItem(Guid transactionId, Guid itemId, decimal price, decimal quantity, string? unit)
{
TransactionId = transactionId;
ItemId = itemId;
Price = price;
Quantity = quantity;
Unit = unit;
}
public TransactionItem(Guid itemId, decimal price, decimal quantity, string? unit) : this(default, itemId, price, quantity, unit)
{
}
public Guid TransactionId { get; init; }
public Guid ItemId { get; set; }
public decimal Price { get; set; }
public decimal Quantity { get; set; }
public string? Unit { get; set; }
public Item? Item { get; set; }
public decimal Amount => Price * Quantity;
}