Files
bnhtrade/src/bnhtrade.Core/Model/Stock/SkuTransactionCreate.cs
Bobbie Hodgetts 30174290cf pull master into branch
* Migrated projects to dotnet8

migrated all projects over to .net8
incomplete feature for gui shipments

* Amazon inventory ledger testing and implementation

Tested what I can until more data for the Amazon Ledger Detail table comes in

* amazon settlement amounts now set to tax inclusive when exporting to invoice

* Some updates to the COM lib to attempt to get it to work on .net 8. Unfinished, porting all Access functions over to vs instead

* feature exchange rate update automation

Automated downloading exchange rates from HMRC and updating the database. Added function call to the console and form applications.

Also added a form to show the console output in form application.
2025-06-09 21:23:42 +01:00

73 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Stock
{
/// <summary>
/// Model/Data used to create an intial entry in the stock SKU transaction table
/// </summary>
public class SkuTransactionCreate : IValidatableObject
{
[Required()]
public DateTime TransactionDate { get; private set; }
[Required()]
public string SkuTransactionTypeCode { get; private set; }
public int? ForeignKey { get; private set; }
public string Reference { get; private set; }
public string Detail { get; private set; }
[Required()]
public string SkuNumber { get; private set; }
[Required(), Range(0, short.MaxValue)]
public int Quantity { get; private set; } // cannot be negative
public SkuTransactionCreate(DateTime transactionDate, string transactionTypeCode, int? foreignKey, string reference, string detail
, string skuNumber, int quantity)
{
this.TransactionDate = transactionDate;
this.SkuTransactionTypeCode = transactionTypeCode;
this.ForeignKey = foreignKey;
this.Reference = reference;
this.Detail = detail;
this.SkuNumber = skuNumber;
this.Quantity = quantity;
//var context = new ValidationContext(null);
var vaild = Validate(null);
if (new Logic.Validate.SkuTransaction().IsValidResult)
if (vaild.Any())
{
throw new Exception("Invalid parameters set");
}
}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var result = new List<ValidationResult>();
if (Logic.Validate.Format.DateTime(TransactionDate) == false)
{
result.Add(new ValidationResult("Invalid transaction date"));
}
if (string.IsNullOrEmpty(SkuTransactionTypeCode))
{
result.Add(new ValidationResult("Invalid transaction type code"));
}
if (Logic.Validate.Format.SkuNumber(SkuNumber) == false)
{
result.Add(new ValidationResult("Invalid SKU number"));
}
return result;
}
}
}