mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-21 15:27:15 +00:00
Feature repricing min max (#10)
amazon settlement import/export improvements
This commit is contained in:
@@ -1,58 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class AccountCode
|
||||
public class AccountCode : IValidatableObject
|
||||
{
|
||||
private int? accountCodeId;
|
||||
|
||||
[Required(), Range(1, int.MaxValue)]
|
||||
public int AccountCodeId
|
||||
{
|
||||
get { return (int)accountCodeId; }
|
||||
set { accountCodeId = value; }
|
||||
}
|
||||
|
||||
[Required(), MaxLength(150)]
|
||||
public string Title
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[MaxLength(500)]
|
||||
public string Description
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Required(), MaxLength(50)]
|
||||
public string Type
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Required(), MaxLength(50)]
|
||||
public string BasicType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool IsSetAccountCodeId
|
||||
{
|
||||
get { return accountCodeId != null; }
|
||||
}
|
||||
|
||||
public bool IsSetTitle
|
||||
{
|
||||
get { return Title != null; }
|
||||
}
|
||||
|
||||
public bool IsSetDescription
|
||||
{
|
||||
get { return Description != null; }
|
||||
}
|
||||
|
||||
public bool IsSetType
|
||||
{
|
||||
get { return Type != null; }
|
||||
}
|
||||
|
||||
public bool IsSetBasicType
|
||||
{
|
||||
get { return BasicType != null; }
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var resultList = new List<ValidationResult>();
|
||||
|
||||
if (!IsSetAccountCodeId)
|
||||
{
|
||||
resultList.Add(new ValidationResult("Account Code is not set"));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -8,6 +9,10 @@ namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public interface IInvoice : IInvoiceHeader
|
||||
{
|
||||
decimal InvoiceNetAmount { get; }
|
||||
|
||||
decimal InvoiceTaxAmount { get; }
|
||||
|
||||
List<Invoice.InvoiceLine> InvoiceLineList { get; set; }
|
||||
|
||||
bool InvoiceLineListIsSet { get; }
|
||||
@@ -17,163 +22,231 @@ namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
string ItemCode { get; set; }
|
||||
|
||||
bool ItemCodeIsSet { get; }
|
||||
|
||||
bool DescriptionIsSet { get; }
|
||||
|
||||
string Description { get; set; }
|
||||
|
||||
int Quantity { get; set; }
|
||||
decimal? Quantity { get; set; }
|
||||
|
||||
bool QuantityIsSet { get; }
|
||||
decimal? UnitAmount { get; set; }
|
||||
|
||||
decimal TotalNetAmount { get; set; }
|
||||
Model.Account.AccountCode AccountCode { get; set; }
|
||||
|
||||
bool TotalNetAmountIsSet { get; }
|
||||
Model.Account.TaxCodeInfo TaxCode { get; set; }
|
||||
|
||||
bool AccountCodeIsSet { get; }
|
||||
decimal? TaxAmountAdjust { get; set; }
|
||||
|
||||
int AccountCode { get; set; }
|
||||
decimal? TaxAmount { get; }
|
||||
|
||||
bool TaxCodeIsSet { get; }
|
||||
|
||||
string TaxCode { get; set; }
|
||||
|
||||
decimal TaxAmountAdjust { get; set; }
|
||||
|
||||
bool TaxAmountAdjustIsSet { get; }
|
||||
|
||||
decimal TaxAmount { get; }
|
||||
|
||||
bool TaxAmountIsSet { get; }
|
||||
|
||||
decimal GrossTotalAmount { get; }
|
||||
|
||||
bool GrossTotalAmountIsSet { get; }
|
||||
decimal LineTotalAmount { get; }
|
||||
}
|
||||
|
||||
|
||||
public abstract class Invoice : InvoiceHeader, IInvoice
|
||||
{
|
||||
private bool unitAmountIsTaxExclusive = true;
|
||||
|
||||
public decimal InvoiceNetAmount { get; }
|
||||
|
||||
public decimal InvoiceTaxAmount { get; }
|
||||
|
||||
public bool UnitAmountIsTaxExclusive
|
||||
{
|
||||
get { return unitAmountIsTaxExclusive; }
|
||||
set
|
||||
{
|
||||
unitAmountIsTaxExclusive = value;
|
||||
if (InvoiceLineList != null)
|
||||
{
|
||||
for (int i = 0; i < InvoiceLineList.Count; i++)
|
||||
{
|
||||
InvoiceLineList[i].UnitAmountIsTaxExclusive = unitAmountIsTaxExclusive;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<InvoiceLine> InvoiceLineList { get; set; } = new List<InvoiceLine>();
|
||||
|
||||
public bool InvoiceLineListIsSet
|
||||
{
|
||||
get
|
||||
{
|
||||
if (InvoiceLineList == null || !InvoiceLineList.Any())
|
||||
{ return false; }
|
||||
else
|
||||
{ return true; }
|
||||
if (InvoiceLineList == null || !InvoiceLineList.Any()) { return false; }
|
||||
else { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
public class InvoiceLine : IInvoiceLine
|
||||
public class InvoiceLine : IInvoiceLine, IValidatableObject
|
||||
{
|
||||
private int? accountCode;
|
||||
private decimal? netAmount;
|
||||
private decimal? taxAmount;
|
||||
private decimal? unitAmount;
|
||||
private Model.Account.TaxCodeInfo taxCode;
|
||||
private decimal? taxAmountAdjust;
|
||||
private int? quantity;
|
||||
private decimal? discount;
|
||||
private decimal? quantity;
|
||||
|
||||
public string ItemCode
|
||||
public InvoiceLine(bool unitAmountIsTaxExclusive)
|
||||
{
|
||||
get;
|
||||
set;
|
||||
UnitAmountIsTaxExclusive = unitAmountIsTaxExclusive;
|
||||
}
|
||||
|
||||
public bool ItemCodeIsSet
|
||||
public string ItemCode { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
[Required(), Range(0, 9999999.99)]
|
||||
public decimal? Quantity
|
||||
{
|
||||
get { return ItemCode != null; }
|
||||
get { return quantity; }
|
||||
set
|
||||
{
|
||||
if (value == null) { quantity = null; }
|
||||
else { quantity = decimal.Round((decimal)value, 4, MidpointRounding.AwayFromZero); }
|
||||
}
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get;
|
||||
set;
|
||||
[Required()]
|
||||
public decimal? UnitAmount
|
||||
{
|
||||
get { return unitAmount; }
|
||||
set
|
||||
{
|
||||
if (value == null) { unitAmount = null; }
|
||||
else { unitAmount = decimal.Round(value.GetValueOrDefault(), 4, MidpointRounding.AwayFromZero); }
|
||||
}
|
||||
}
|
||||
|
||||
public bool DescriptionIsSet
|
||||
{
|
||||
get { return Description != null; }
|
||||
public bool UnitAmountIsTaxExclusive { get; set; }
|
||||
|
||||
[Required()]
|
||||
public Model.Account.AccountCode AccountCode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public int Quantity
|
||||
{
|
||||
get { return (int)quantity.GetValueOrDefault(); }
|
||||
set { quantity = value; }
|
||||
[Required()]
|
||||
public Model.Account.TaxCodeInfo TaxCode
|
||||
{
|
||||
get { return taxCode; }
|
||||
set
|
||||
{
|
||||
if (value == null || TaxCode == null || value.TaxCode != taxCode.TaxCode)
|
||||
{
|
||||
TaxAmountAdjust = 0;
|
||||
}
|
||||
|
||||
taxCode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool QuantityIsSet
|
||||
[Required()]
|
||||
public decimal? TaxAmount
|
||||
{
|
||||
get { return quantity != null; }
|
||||
get
|
||||
{
|
||||
return TaxAmountAdjust + GetCalculatedTax();
|
||||
}
|
||||
}
|
||||
|
||||
public decimal TotalNetAmount
|
||||
public decimal? TaxAmountAdjust
|
||||
{
|
||||
get { return (decimal)netAmount.GetValueOrDefault(); }
|
||||
set { netAmount = value; }
|
||||
get { return taxAmountAdjust; }
|
||||
set
|
||||
{
|
||||
if (value == null) { taxAmountAdjust = null; }
|
||||
else { taxAmountAdjust = decimal.Round((decimal)value, 2, MidpointRounding.AwayFromZero); }
|
||||
}
|
||||
}
|
||||
|
||||
public bool TotalNetAmountIsSet
|
||||
public decimal LineTotalAmount
|
||||
{
|
||||
get { return netAmount != null; }
|
||||
get
|
||||
{
|
||||
if (CanCalculateLine())
|
||||
{
|
||||
return ((decimal)Quantity * (decimal)UnitAmount) + (decimal)TaxAmount;
|
||||
}
|
||||
else { return 0; }
|
||||
}
|
||||
}
|
||||
|
||||
public int AccountCode
|
||||
private bool CanCalculateLine()
|
||||
{
|
||||
get { return (int)accountCode.GetValueOrDefault(); }
|
||||
set { accountCode = value; }
|
||||
if (Quantity == null || UnitAmount == null || TaxCode == null) { return false; }
|
||||
else { return true; }
|
||||
}
|
||||
|
||||
public bool AccountCodeIsSet
|
||||
private decimal GetCalculatedTax()
|
||||
{
|
||||
get { return accountCode != null; }
|
||||
decimal calculatedTax = 0;
|
||||
if (CanCalculateLine())
|
||||
{
|
||||
if (UnitAmountIsTaxExclusive)
|
||||
{
|
||||
calculatedTax = ((decimal)Quantity * (decimal)UnitAmount) * (TaxCode.TaxRate / 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
calculatedTax = ((decimal)Quantity * (decimal)UnitAmount) * (TaxCode.TaxRate / (100 + TaxCode.TaxRate));
|
||||
}
|
||||
return decimal.Round(calculatedTax, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public string TaxCode
|
||||
public void SetTaxAmountAdjust(decimal lineTaxAmount)
|
||||
{
|
||||
get;
|
||||
set;
|
||||
decimal adjustedAmount = lineTaxAmount - GetCalculatedTax();
|
||||
if (adjustedAmount == 0) { TaxAmountAdjust = null; }
|
||||
else { TaxAmountAdjust = adjustedAmount; }
|
||||
}
|
||||
|
||||
public bool TaxCodeIsSet
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
get { return TaxCode != null; }
|
||||
throw new NotImplementedException();
|
||||
|
||||
var resultList = new List<ValidationResult>();
|
||||
|
||||
if (TaxAmount > LineTotalAmount / 2)
|
||||
{
|
||||
resultList.Add(new ValidationResult("Line tax amount is greater than net amount"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public new IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var subResult = base.Validate(validationContext);
|
||||
var resultList = new List<ValidationResult>();
|
||||
resultList.AddRange(subResult);
|
||||
|
||||
|
||||
// loop though lines and check sum totals
|
||||
if (!InvoiceLineListIsSet)
|
||||
{
|
||||
resultList.Add(new ValidationResult("No lines set on Invoice"));
|
||||
}
|
||||
else
|
||||
{
|
||||
decimal lineTotal = 0;
|
||||
foreach (var line in InvoiceLineList)
|
||||
{
|
||||
lineTotal += line.LineTotalAmount;
|
||||
|
||||
if (UnitAmountIsTaxExclusive != line.UnitAmountIsTaxExclusive)
|
||||
{
|
||||
resultList.Add(new ValidationResult("Invalid UnitAmountIsTaxExclusive"));
|
||||
}
|
||||
}
|
||||
|
||||
// check totals
|
||||
if (InvoiceTotalAmount != lineTotal)
|
||||
{ resultList.Add(new ValidationResult("Invoice line total does not equal invoice total")); }
|
||||
}
|
||||
|
||||
public decimal TaxAmount
|
||||
{
|
||||
get { return (decimal)taxAmount.GetValueOrDefault(); }
|
||||
set { taxAmount = decimal.Round(value, 2); }
|
||||
}
|
||||
|
||||
public bool TaxAmountIsSet
|
||||
{
|
||||
get { return taxAmount != null; }
|
||||
}
|
||||
|
||||
public decimal TaxAmountAdjust
|
||||
{
|
||||
get { return (decimal)taxAmountAdjust.GetValueOrDefault(); }
|
||||
set { taxAmountAdjust = decimal.Round(value, 2); }
|
||||
}
|
||||
|
||||
public bool TaxAmountAdjustIsSet
|
||||
{
|
||||
get { return taxAmountAdjust != null; }
|
||||
}
|
||||
|
||||
public decimal GrossTotalAmount
|
||||
{
|
||||
get { return (decimal)netAmount.GetValueOrDefault() + TaxAmount; }
|
||||
}
|
||||
|
||||
public bool GrossTotalAmountIsSet
|
||||
{
|
||||
get { return (TotalNetAmountIsSet && TaxAmountIsSet); }
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,31 +10,24 @@ namespace bnhtrade.Core.Model.Account
|
||||
public interface IInvoiceHeader
|
||||
{
|
||||
string ContactName { get; set; }
|
||||
bool ContactNameIsSet { get; }
|
||||
decimal InvoiceAmount { get; set; }
|
||||
bool InvoiceAmountIsSet { get; }
|
||||
|
||||
decimal? InvoiceTotalAmount { get; set; }
|
||||
|
||||
string InvoiceCurrencyCode { get; set; }
|
||||
bool InvoiceCurrencyCodeIsSet { get; }
|
||||
DateTime InvoiceDate { get; set; }
|
||||
bool InvoiceDateIsSet { get; }
|
||||
DateTime InvoiceDueDate { get; set; }
|
||||
bool InvoiceDueDateIsSet { get; }
|
||||
DateTimeKind InvoiceDateKind { get; set; }
|
||||
bool InvoiceDateKindIsSet { get; }
|
||||
|
||||
DateTime? InvoiceDate { get; set; }
|
||||
|
||||
DateTime? InvoiceDueDate { get; set; }
|
||||
|
||||
string InvoiceNumber { get; set; }
|
||||
bool InvoiceNumberIsSet { get; }
|
||||
|
||||
string InvoiceReference { get; set; }
|
||||
bool InvoiceReferenceIsSet { get; }
|
||||
|
||||
bool IsCreditNote { get; set; }
|
||||
bool IsCreditNoteIsSet { get; }
|
||||
}
|
||||
|
||||
public abstract class InvoiceHeader : IInvoiceHeader
|
||||
public abstract class InvoiceHeader :IInvoiceHeader, IValidatableObject
|
||||
{
|
||||
private string invoiceCurrencyCode;
|
||||
private DateTime? invoiceDate;
|
||||
private DateTime? invoiceDueDate;
|
||||
private DateTimeKind? invoiceDateKind = DateTimeKind.Utc;
|
||||
private decimal? invoiceAmount;
|
||||
|
||||
public InvoiceHeader()
|
||||
@@ -41,95 +35,51 @@ namespace bnhtrade.Core.Model.Account
|
||||
IsCreditNote = false;
|
||||
}
|
||||
|
||||
[Required()]
|
||||
public string ContactName { get; set; }
|
||||
|
||||
public bool ContactNameIsSet
|
||||
{
|
||||
get { return ContactName != null; }
|
||||
}
|
||||
[Required()]
|
||||
public DateTime? InvoiceDate { get; set; }
|
||||
|
||||
public DateTime InvoiceDate
|
||||
{
|
||||
get { return (DateTime)invoiceDate.GetValueOrDefault(); }
|
||||
set { invoiceDate = value; }
|
||||
}
|
||||
[Required()]
|
||||
public DateTime? InvoiceDueDate { get; set; }
|
||||
|
||||
public bool InvoiceDateIsSet
|
||||
{
|
||||
get { return invoiceDate != null; }
|
||||
}
|
||||
|
||||
public DateTime InvoiceDueDate
|
||||
{
|
||||
get { return (DateTime)invoiceDueDate.GetValueOrDefault(); }
|
||||
set { invoiceDueDate = value; }
|
||||
}
|
||||
|
||||
public bool InvoiceDueDateIsSet
|
||||
{
|
||||
get { return invoiceDueDate != null; }
|
||||
}
|
||||
|
||||
public DateTimeKind InvoiceDateKind
|
||||
{
|
||||
get { return (DateTimeKind)invoiceDateKind; }
|
||||
set { invoiceDateKind = value; }
|
||||
}
|
||||
|
||||
public bool InvoiceDateKindIsSet
|
||||
{
|
||||
get { return invoiceDateKind != null; }
|
||||
}
|
||||
|
||||
public string InvoiceCurrencyCode
|
||||
{
|
||||
get { return invoiceCurrencyCode; }
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
invoiceCurrencyCode = value.ToUpper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool InvoiceCurrencyCodeIsSet
|
||||
{
|
||||
get { return InvoiceCurrencyCode != null; }
|
||||
}
|
||||
[Required(), MinLength(3), MaxLength(3)]
|
||||
public string InvoiceCurrencyCode { get; set; }
|
||||
|
||||
[Required()]
|
||||
public string InvoiceNumber { get; set; }
|
||||
|
||||
public bool InvoiceNumberIsSet
|
||||
{
|
||||
get { return InvoiceNumber != null; }
|
||||
}
|
||||
|
||||
public string InvoiceReference { get; set; }
|
||||
|
||||
public bool InvoiceReferenceIsSet
|
||||
{
|
||||
get { return InvoiceReference != null; }
|
||||
}
|
||||
|
||||
public decimal InvoiceAmount
|
||||
[Required()]
|
||||
public decimal? InvoiceTotalAmount
|
||||
{
|
||||
get { return (decimal)invoiceAmount; }
|
||||
set { invoiceAmount = value; }
|
||||
set
|
||||
{
|
||||
if (value == null) { invoiceAmount = null; }
|
||||
else { invoiceAmount = decimal.Round((decimal)value, 2, MidpointRounding.AwayFromZero); }
|
||||
}
|
||||
}
|
||||
|
||||
public bool InvoiceAmountIsSet
|
||||
[Required()]
|
||||
public bool IsCreditNote { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
get { return invoiceAmount != null; }
|
||||
}
|
||||
public bool IsCreditNote
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public bool IsCreditNoteIsSet
|
||||
{
|
||||
get { return true; }
|
||||
var resultList = new List<ValidationResult>();
|
||||
|
||||
if (IsCreditNote && InvoiceTotalAmount > 0)
|
||||
{
|
||||
resultList.Add(new ValidationResult("Credit Note amount cannot be greater than zero"));
|
||||
}
|
||||
else if (!IsCreditNote && InvoiceTotalAmount < 0)
|
||||
{
|
||||
resultList.Add(new ValidationResult("Invoice amount cannot be less than zero"));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class InvoiceLineItem
|
||||
public class InvoiceLineItem : IValidatableObject
|
||||
{
|
||||
[Required()]
|
||||
public string ItemCode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string Title
|
||||
|
||||
[Required()]
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Required()]
|
||||
public bool IsNewReviewRequired
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Required()]
|
||||
public bool InvoiceLineEntryEnabled
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int DefaultAccountCode
|
||||
|
||||
[Required()]
|
||||
public Model.Account.AccountCode DefaultAccountCode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string DefaultTaxCode
|
||||
|
||||
[Required()]
|
||||
public Model.Account.TaxCodeInfo DefaultTaxCode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var resultList = new List<ValidationResult>();
|
||||
|
||||
resultList.AddRange(DefaultAccountCode.Validate(validationContext));
|
||||
resultList.AddRange(DefaultTaxCode.Validate(validationContext));
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class TaxCode
|
||||
{
|
||||
private decimal? netAmountMultiplier = null;
|
||||
private decimal? grossAmountMultiplier = null;
|
||||
private bool? isActive = null;
|
||||
private bool? isValidOnExpense = null;
|
||||
private bool? isValidOnIncome = null;
|
||||
|
||||
public string TaxCodeId { get; set; }
|
||||
public string TaxRateDescription { get; set; }
|
||||
public string TaxRateTitle { get; set; }
|
||||
public string TaxType { get; set; }
|
||||
public decimal NetAmountMultiplier
|
||||
{
|
||||
get { return (decimal)netAmountMultiplier; }
|
||||
set { netAmountMultiplier = value; }
|
||||
}
|
||||
public decimal GrossAmountMultiplier
|
||||
{
|
||||
get { return (decimal)grossAmountMultiplier; }
|
||||
set { grossAmountMultiplier = value; }
|
||||
}
|
||||
public bool IsActive
|
||||
{
|
||||
get { return (bool)isActive; }
|
||||
set { isActive = value; }
|
||||
}
|
||||
public bool IsSetAll
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsSetGrossAmountMultiplier
|
||||
&& IsSetIsActive
|
||||
&& IsSetIsValidOnExpense
|
||||
&& IsSetIsValidOnIncome
|
||||
&& IsSetNetAmountMultiplier
|
||||
&& IsSetTaxCodeId
|
||||
&& IsSetTaxRateTitle
|
||||
&& IsSetTaxRateDescription
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else { return false; }
|
||||
}
|
||||
}
|
||||
public bool IsSetGrossAmountMultiplier
|
||||
{
|
||||
get { return grossAmountMultiplier != null; }
|
||||
}
|
||||
public bool IsSetIsActive
|
||||
{
|
||||
get { return isActive != null; }
|
||||
}
|
||||
public bool IsSetIsValidOnExpense
|
||||
{
|
||||
get { return isValidOnExpense != null; }
|
||||
}
|
||||
public bool IsSetIsValidOnIncome
|
||||
{
|
||||
get { return isValidOnIncome != null; }
|
||||
}
|
||||
public bool IsSetNetAmountMultiplier
|
||||
{
|
||||
get { return netAmountMultiplier != null; }
|
||||
}
|
||||
public bool IsSetTaxCodeId
|
||||
{
|
||||
get { return TaxCodeId != null; }
|
||||
}
|
||||
public bool IsSetTaxRateTitle
|
||||
{
|
||||
get { return TaxRateTitle != null; }
|
||||
}
|
||||
public bool IsSetTaxRateDescription
|
||||
{
|
||||
get { return TaxRateDescription != null; }
|
||||
}
|
||||
public bool IsSetTaxType
|
||||
{
|
||||
get { return TaxType != null; }
|
||||
}
|
||||
public bool IsValidOnExpense
|
||||
{
|
||||
get { return (bool)isValidOnExpense; }
|
||||
set { isValidOnExpense = value; }
|
||||
}
|
||||
public bool IsValidOnIncome
|
||||
{
|
||||
get { return (bool)isValidOnIncome; }
|
||||
set { isValidOnIncome = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
72
src/bnhtrade.Core/Model/Account/TaxCodeInfo.cs
Normal file
72
src/bnhtrade.Core/Model/Account/TaxCodeInfo.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class TaxCodeInfo : IValidatableObject
|
||||
{
|
||||
public TaxCodeInfo(string taxCodeId, string title, string description, decimal taxRatePercent, bool isMarginSchemeRate,
|
||||
bool isValidOnExpense, bool isValidOnIncome, string taxType, bool isActive)
|
||||
{
|
||||
if (TaxRate < 0)
|
||||
{
|
||||
throw new Exception("Tax rate is less than zero");
|
||||
}
|
||||
|
||||
if (TaxRate >= 100)
|
||||
{
|
||||
// 100% rate has been used where the line total is all tax
|
||||
// you need to do somemore coding when this facility is required
|
||||
throw new Exception("Tax rate is >= 100%");
|
||||
}
|
||||
|
||||
TaxCode = taxCodeId;
|
||||
TaxCodeDescription = description;
|
||||
TaxRate = taxRatePercent;
|
||||
IsMarginScheme = isMarginSchemeRate;
|
||||
TaxCodeName = title;
|
||||
TaxType = taxType;
|
||||
IsActive = isActive;
|
||||
IsValidOnExpense = isValidOnExpense;
|
||||
IsValidOnIncome = isValidOnIncome;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unique identifier
|
||||
/// </summary>
|
||||
[Required()]
|
||||
public string TaxCode { get; private set; }
|
||||
|
||||
[Required()]
|
||||
public string TaxCodeName { get; private set; }
|
||||
|
||||
public string TaxCodeDescription { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Tax rate as a percentage
|
||||
/// </summary>
|
||||
[Required(), Range(0, 100)]
|
||||
public decimal TaxRate { get; private set; }
|
||||
|
||||
public bool IsMarginScheme { get; private set; }
|
||||
|
||||
[Required()]
|
||||
public string TaxType { get; private set; }
|
||||
|
||||
public bool IsValidOnExpense { get; private set; }
|
||||
|
||||
public bool IsValidOnIncome { get; private set; }
|
||||
|
||||
public bool IsActive { get; private set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var resultList = new List<ValidationResult>();
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
namespace bnhtrade.Core.Model.AmazonFba
|
||||
{
|
||||
public class ShipmentInfo
|
||||
{
|
||||
@@ -13,9 +13,12 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
private string shipmentStatus;
|
||||
private DateTime lastUpdatedUtc;
|
||||
private Dictionary<string, bool> shipmentStatusToIsClosed;
|
||||
private int? shipmentStockStatusId = null;
|
||||
|
||||
public string FbaShipmentId { get; set; }
|
||||
|
||||
public string AmazonShipmentId { get; set; }
|
||||
public string ShipmentName { get; set; }
|
||||
|
||||
public string DestinationFulfillmentCenterId
|
||||
{
|
||||
get { return destinationFulfillmentCenterId; }
|
||||
@@ -31,6 +34,7 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ShipmentStatus
|
||||
{
|
||||
get
|
||||
@@ -47,7 +51,16 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
shipmentStatus = status;
|
||||
}
|
||||
}
|
||||
public DateTime LastUpdatedUtc
|
||||
|
||||
public string ShipmentStockStatus { get; set; }
|
||||
|
||||
public int ShipmentStockStatusId
|
||||
{
|
||||
get { return shipmentStockStatusId.GetValueOrDefault(); }
|
||||
set { shipmentStockStatusId = value; }
|
||||
}
|
||||
|
||||
public DateTime LastUpdated
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -58,6 +71,7 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
lastUpdatedUtc = DateTime.SpecifyKind(value, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShipmentIsClosed
|
||||
{
|
||||
get
|
||||
@@ -72,6 +86,7 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ShipmentItemInfo> ShipmentItemInfoList
|
||||
{
|
||||
get { return shipmentItemInfoList; }
|
||||
@@ -84,7 +99,7 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
if (!item.IsSetAll())
|
||||
{ throw new Exception("Infomation missing from Shipment Item list"); }
|
||||
|
||||
if (item.AmazonShipmentId != AmazonShipmentId)
|
||||
if (item.AmazonShipmentId != FbaShipmentId)
|
||||
{ throw new Exception("Amazon shipment id in item list does not match header information."); }
|
||||
|
||||
if (skuCheck.ContainsKey(item.SKUNumber))
|
||||
@@ -104,6 +119,7 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
shipmentItemInfoList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSetAll()
|
||||
{
|
||||
if (IsSetAllHeaderInfo() && IsSetListShipmentItemInfo())
|
||||
@@ -115,6 +131,7 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSetAllHeaderInfo()
|
||||
{
|
||||
if (IsSetAmazonShipmentId()
|
||||
@@ -131,35 +148,52 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSetAmazonShipmentId()
|
||||
{
|
||||
return AmazonShipmentId != null;
|
||||
return FbaShipmentId != null;
|
||||
}
|
||||
|
||||
public bool IsSetShipmentName()
|
||||
{
|
||||
return ShipmentName != null;
|
||||
}
|
||||
|
||||
public bool IsSetDestinationFulfillmentCenterId()
|
||||
{
|
||||
return DestinationFulfillmentCenterId != null;
|
||||
}
|
||||
|
||||
public bool IsSetLastUpdated()
|
||||
{
|
||||
return LastUpdatedUtc != default(DateTime);
|
||||
return LastUpdated != default(DateTime);
|
||||
}
|
||||
|
||||
public bool IsSetListShipmentItemInfo()
|
||||
{
|
||||
return ShipmentItemInfoList != null;
|
||||
}
|
||||
|
||||
public bool IsSetShipmentIsClosed()
|
||||
{
|
||||
return ShipmentStatus != null;
|
||||
}
|
||||
|
||||
public bool IsSetShipmentStatus()
|
||||
{
|
||||
return ShipmentStatus != null;
|
||||
}
|
||||
|
||||
public bool IsSetShipmentStockStatus()
|
||||
{
|
||||
return ShipmentStockStatus != null;
|
||||
}
|
||||
|
||||
public bool IsSetShipmentStockStatusId()
|
||||
{
|
||||
return shipmentStockStatusId != null;
|
||||
}
|
||||
|
||||
public ShipmentInfo()
|
||||
{
|
||||
shipmentStatusToIsClosed = new Dictionary<string, bool>();
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
namespace bnhtrade.Core.Model.AmazonFba
|
||||
{
|
||||
public class ShipmentItemInfo
|
||||
{
|
||||
@@ -18,14 +18,17 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
/// Gets and sets the AmazonShipmentId property.
|
||||
/// </summary>
|
||||
public string AmazonShipmentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the SKUNumber property.
|
||||
/// </summary>
|
||||
public string SKUNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the FulfillmentNetworkSKU property.
|
||||
/// </summary>
|
||||
public string AmazonFNSKU { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the QuantityAllocated property.
|
||||
/// </summary>
|
||||
@@ -34,6 +37,7 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
get { return quantityAllocated; }
|
||||
set { quantityAllocated = value; isSetQuantityAllocated = true; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the QuantityReceived property.
|
||||
/// </summary>
|
||||
@@ -59,22 +63,27 @@ namespace bnhtrade.Core.Model.AmazonFBAInbound
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSetAmazonShipmentId()
|
||||
{
|
||||
return AmazonShipmentId != null;
|
||||
}
|
||||
|
||||
public bool IsSetSKUNumber()
|
||||
{
|
||||
return SKUNumber != null;
|
||||
}
|
||||
|
||||
public bool IsSetFulfillmentNetworkSKU()
|
||||
{
|
||||
return AmazonFNSKU != null;
|
||||
}
|
||||
|
||||
public bool IsSetQuantityAllocated()
|
||||
{
|
||||
return isSetQuantityAllocated;
|
||||
}
|
||||
|
||||
public bool IsSetQuantityReceived()
|
||||
{
|
||||
return isSetQuantityReceived;
|
||||
98
src/bnhtrade.Core/Model/Data/DatabaseFileStream.cs
Normal file
98
src/bnhtrade.Core/Model/Data/DatabaseFileStream.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Data
|
||||
{
|
||||
public class DatabaseFileStream : IDisposable, IValidatableObject
|
||||
{
|
||||
[Required()]
|
||||
public Guid FileGUID { get; set; }
|
||||
|
||||
[Required()]
|
||||
public MemoryStream FileData { get; set; }
|
||||
|
||||
public bool IsSetFileData
|
||||
{
|
||||
get { return FileData != null; }
|
||||
}
|
||||
|
||||
[Required(), StringLength(3, MinimumLength = 3)]
|
||||
public string FileExtention { get; set; }
|
||||
|
||||
[Required(), Range(1, 2147483647)]
|
||||
public int FileSize { get; set; }
|
||||
|
||||
[Required(), StringLength(24, MinimumLength = 24)]
|
||||
public string FileMD5base64 { get; set; }
|
||||
|
||||
public string CalculateContentMD5(MemoryStream stream)
|
||||
{
|
||||
MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
|
||||
byte[] hash = provider.ComputeHash(stream);
|
||||
return Convert.ToBase64String(hash);
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var resultList = new List<ValidationResult>();
|
||||
|
||||
if (IsSetFileData && FileData.Length == 0)
|
||||
{
|
||||
var validate = new ValidationResult("Stream is empty");
|
||||
resultList.Add(validate);
|
||||
}
|
||||
if (IsSetFileData && FileMD5base64 != new Logic.Utilities.CalculateMD5().Base64(FileData))
|
||||
{
|
||||
var validate = new ValidationResult("Calculated file MD5 hash does not match.");
|
||||
resultList.Add(validate);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
#region IDisposable Support
|
||||
private bool disposedValue = false; // To detect redundant calls
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// TODO: dispose managed state (managed objects).
|
||||
if (FileData != null)
|
||||
FileData.Dispose();
|
||||
}
|
||||
|
||||
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
|
||||
// TODO: set large fields to null.
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
|
||||
//~AmazonFeedSubmission()
|
||||
//{
|
||||
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
// Dispose(false);
|
||||
//}
|
||||
|
||||
// This code added to correctly implement the disposable pattern.
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
Dispose(true);
|
||||
// TODO: uncomment the following line if the finalizer is overridden above.
|
||||
// GC.SuppressFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
124
src/bnhtrade.Core/Model/Export/AmazonFeedSubmission.cs
Normal file
124
src/bnhtrade.Core/Model/Export/AmazonFeedSubmission.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Export
|
||||
{
|
||||
public class AmazonFeedSubmission : IValidatableObject
|
||||
{
|
||||
//private int? exportAmazonFeedSubmissionId;
|
||||
private DateTime? submittedDate;
|
||||
private DateTime? startedProcessingDate;
|
||||
private DateTime? completedProcessingDate;
|
||||
|
||||
//public int ExportAmazonFeedSubmissionID
|
||||
//{
|
||||
// get { return exportAmazonFeedSubmissionId.GetValueOrDefault(); }
|
||||
// set { exportAmazonFeedSubmissionId = value; }
|
||||
//}
|
||||
|
||||
//public bool IsSetExportAmazonFeedSubmissionID
|
||||
//{
|
||||
// get { return exportAmazonFeedSubmissionId != null; }
|
||||
//}
|
||||
|
||||
[Required()]
|
||||
public string FeedType { get; set; }
|
||||
|
||||
public bool IsSetFeedType
|
||||
{
|
||||
get { return !string.IsNullOrWhiteSpace(FeedType); }
|
||||
}
|
||||
|
||||
[Required()]
|
||||
public string FeedSubmissionId { get; set; }
|
||||
|
||||
public bool IsSetFeedSubmissionId
|
||||
{
|
||||
get { return !string.IsNullOrWhiteSpace(FeedSubmissionId); }
|
||||
}
|
||||
|
||||
public DateTime SubmittedDate
|
||||
{
|
||||
get { return submittedDate.GetValueOrDefault(); }
|
||||
set { submittedDate = value; }
|
||||
}
|
||||
|
||||
public bool IsSetSubmittedDate
|
||||
{
|
||||
get { return submittedDate != null; }
|
||||
}
|
||||
|
||||
public string FeedProcessingStatus { get; set; }
|
||||
|
||||
public bool IsSetFeedProcessingStatus
|
||||
{
|
||||
get { return !string.IsNullOrWhiteSpace(FeedProcessingStatus); }
|
||||
}
|
||||
|
||||
public DateTime StartedProcessingDate
|
||||
{
|
||||
get { return startedProcessingDate.GetValueOrDefault(); }
|
||||
set { startedProcessingDate = value; }
|
||||
}
|
||||
|
||||
public bool IsSetStartedProcessingDate
|
||||
{
|
||||
get { return startedProcessingDate != null; }
|
||||
}
|
||||
|
||||
public DateTime CompletedProcessingDate
|
||||
{
|
||||
get { return completedProcessingDate.GetValueOrDefault(); }
|
||||
set { completedProcessingDate = value; }
|
||||
}
|
||||
|
||||
public bool IsSetCompletedProcessingDate
|
||||
{
|
||||
get { return completedProcessingDate != null; }
|
||||
}
|
||||
|
||||
public Model.Data.DatabaseFileStream File { get; set; }
|
||||
|
||||
public bool FileIsSet
|
||||
{
|
||||
get { return File != null; }
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var results = new List<ValidationResult>();
|
||||
|
||||
if (IsSetSubmittedDate && SubmittedDate == default(DateTime))
|
||||
results.Add(new ValidationResult("Submitted Date is systen default"));
|
||||
if (IsSetStartedProcessingDate && StartedProcessingDate == default(DateTime))
|
||||
results.Add(new ValidationResult("Started Processing Date is systen default"));
|
||||
if (IsSetCompletedProcessingDate && CompletedProcessingDate == default(DateTime))
|
||||
results.Add(new ValidationResult("Completed Processing Date is systen default"));
|
||||
|
||||
if (IsSetFeedProcessingStatus)
|
||||
{
|
||||
if (FeedProcessingStatus != "_DONE_" || FeedProcessingStatus != "_SUBMITTED_" || FeedProcessingStatus != "_IN_PROGRESS_" ||
|
||||
FeedProcessingStatus != "_UNCONFIRMED_" || FeedProcessingStatus != "_CANCELLED_" || FeedProcessingStatus != "_IN_SAFETY_NET_" ||
|
||||
FeedProcessingStatus != "_AWAITING_ASYNCHRONOUS_REPLY_")
|
||||
{
|
||||
results.Add(new ValidationResult("Invalid Feed Processing Status '" + FeedProcessingStatus + "'"));
|
||||
}
|
||||
}
|
||||
|
||||
if (FileIsSet)
|
||||
{
|
||||
Validator.TryValidateObject(
|
||||
File,
|
||||
new ValidationContext(File, null, null),
|
||||
results);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
136
src/bnhtrade.Core/Model/Export/AmazonIventoryLoaderFile.cs
Normal file
136
src/bnhtrade.Core/Model/Export/AmazonIventoryLoaderFile.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using CsvHelper.Configuration.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Export
|
||||
{
|
||||
public class AmazonIventoryLoaderFile : IValidatableObject
|
||||
{
|
||||
private bool isSetSetFulfillmentCenterId = false;
|
||||
|
||||
[Required()]
|
||||
[Name("sku")]
|
||||
public string Sku { get; set; }
|
||||
|
||||
[Name("product-id")]
|
||||
public string ProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// One of the following: 1=ASIN, 2=ISBN, 3=UPC, 4=EAN
|
||||
/// </summary>
|
||||
[Name("product-id-type")]
|
||||
[Range(1,4)]
|
||||
public int? ProductIdType { get; set; }
|
||||
|
||||
[Name("price")]
|
||||
[Range(0, double.MaxValue)]
|
||||
public decimal? Price { get; set; }
|
||||
|
||||
[Name("minimum-seller-allowed-price")]
|
||||
[Range(0, double.MaxValue)]
|
||||
public decimal? MinimumAllowedPrice { get; set; }
|
||||
|
||||
[Name("maximum-seller-allowed-price")]
|
||||
[Range(0, double.MaxValue)]
|
||||
public decimal? MaximumAllowedPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 11=New, 1=Used Like New, 2=Used Very Good, 3=Used Good, 4=Used Acceptable,
|
||||
/// 5=Collectible Like New, 6=Collectible Very Good, 7=Collectible Good, 8=Collectible Acceptable, 9=Not used
|
||||
/// </summary>
|
||||
[Name("item-condition")]
|
||||
[Range(1,11)]
|
||||
public int? ItemCondition { get; set; }
|
||||
|
||||
[Name("quantity")]
|
||||
public int? Quantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// a = update/add, d = delete, x = delete completely from system
|
||||
/// </summary>
|
||||
[MaxLength(1)]
|
||||
[Name("add-delete")]
|
||||
public string AddDelete { get; set; }
|
||||
|
||||
[Name("will-ship-internationally")]
|
||||
[BooleanTrueValues("y")]
|
||||
[BooleanFalseValues("n")]
|
||||
public bool? WillShipInternationally { get; set; }
|
||||
|
||||
[Name("expedited-shipping")]
|
||||
public string ExpeditedShipping { get; set; }
|
||||
|
||||
[Name("standard-plus")]
|
||||
public string StandardPlus { get; set; }
|
||||
|
||||
[MaxLength(2000)]
|
||||
[Name("item-note")]
|
||||
public string ItemNote { get; set; }
|
||||
|
||||
[Name("fulfillment-center-id")]
|
||||
public string FulfillmentCenterId { get; private set; }
|
||||
|
||||
[Name("merchant-shipping-group-name")]
|
||||
public string MerchantShippingGroupName { get; set; }
|
||||
|
||||
public void SetFulfillmentCenterId(bool IsFba)
|
||||
{
|
||||
isSetSetFulfillmentCenterId = true;
|
||||
if (IsFba)
|
||||
{
|
||||
FulfillmentCenterId = "AMAZON_EU";
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var results = new List<ValidationResult>();
|
||||
|
||||
if (isSetSetFulfillmentCenterId == false)
|
||||
{
|
||||
results.Add(new ValidationResult("FulfillmentCenterId is not set."));
|
||||
}
|
||||
|
||||
if (ItemCondition.GetValueOrDefault() == 9 || ItemCondition.GetValueOrDefault() == 10)
|
||||
{
|
||||
results.Add(new ValidationResult("Invalid Item Condition id"));
|
||||
}
|
||||
|
||||
if (AddDelete != null && (AddDelete != "a" || AddDelete != "d" || AddDelete != "x"))
|
||||
{
|
||||
results.Add(new ValidationResult("Invalid AddDelete"));
|
||||
}
|
||||
|
||||
if (MaximumAllowedPrice != null || MinimumAllowedPrice != null)
|
||||
{
|
||||
if (MaximumAllowedPrice == null)
|
||||
{
|
||||
results.Add(new ValidationResult("If setting MinimumAllowedPrice, the MaximumAllowedPrice must also be set."));
|
||||
}
|
||||
|
||||
if (MinimumAllowedPrice == null)
|
||||
{
|
||||
results.Add(new ValidationResult("If setting MaximumAllowedPrice, the MinimumAllowedPrice must also be set."));
|
||||
}
|
||||
|
||||
if (Price == null)
|
||||
{
|
||||
results.Add(new ValidationResult("If setting MaximumAllowedPrice or MinimumAllowedPrice the Price must also be set."));
|
||||
}
|
||||
else if (MaximumAllowedPrice != null && MinimumAllowedPrice != null)
|
||||
{
|
||||
if (Price < MinimumAllowedPrice || Price > MaximumAllowedPrice)
|
||||
{
|
||||
results.Add(new ValidationResult("Price is ouside the bounds set by the MaximumAllowedPrice and MinimumAllowedPrice."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
src/bnhtrade.Core/Model/Product/CompetitivePrice.cs
Normal file
53
src/bnhtrade.Core/Model/Product/CompetitivePrice.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Product
|
||||
{
|
||||
public class CompetitivePrice
|
||||
{
|
||||
private bool? priceIsEstimated;
|
||||
private decimal? price = null;
|
||||
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public int ConditionId { get; set; }
|
||||
|
||||
public decimal Price
|
||||
{
|
||||
get { return price.GetValueOrDefault(); }
|
||||
set { price = value; }
|
||||
}
|
||||
|
||||
public bool PriceIsSet
|
||||
{
|
||||
get { return price != null; }
|
||||
}
|
||||
|
||||
public DateTime PriceDatetime { get; set; }
|
||||
|
||||
public bool PriceIsEstimated
|
||||
{
|
||||
get { return priceIsEstimated.GetValueOrDefault(); }
|
||||
set { priceIsEstimated = value; }
|
||||
}
|
||||
|
||||
public bool PriceIsEstimatedIsSet
|
||||
{
|
||||
get { return priceIsEstimated != null; }
|
||||
}
|
||||
|
||||
public CompetitivePrice Clone()
|
||||
{
|
||||
var clone = new CompetitivePrice();
|
||||
clone.ConditionId = ConditionId;
|
||||
if (PriceIsSet) { clone.Price = Price; }
|
||||
clone.PriceDatetime = PriceDatetime;
|
||||
if (PriceIsEstimatedIsSet) { clone.priceIsEstimated = PriceIsEstimated; }
|
||||
clone.ProductId = ProductId;
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,60 +9,95 @@ namespace bnhtrade.Core.Model.Sku
|
||||
public class Sku
|
||||
{
|
||||
private bool? isActive;
|
||||
public string ConditionModelPlaceholder
|
||||
private int? conditionId;
|
||||
private int? productId;
|
||||
|
||||
public int ConditionId
|
||||
{
|
||||
get { return conditionId.GetValueOrDefault(); }
|
||||
set { conditionId = value; }
|
||||
}
|
||||
|
||||
public bool ConditionIdIsSet
|
||||
{
|
||||
get { return conditionId != null; }
|
||||
}
|
||||
|
||||
public string ConditionTitle
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string ProductModelPlaceholder
|
||||
|
||||
public bool ConditionTitleIsSet
|
||||
{
|
||||
get { return ConditionTitle != null; }
|
||||
}
|
||||
|
||||
public int ProductId
|
||||
{
|
||||
get { return productId.GetValueOrDefault(); }
|
||||
set { productId = value; }
|
||||
}
|
||||
|
||||
public bool ProductIdIsSet
|
||||
{
|
||||
get { return productId != null; }
|
||||
}
|
||||
|
||||
public string ProductTitle
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool ProductTitleIsSet
|
||||
{
|
||||
get { return ProductTitle != null; }
|
||||
}
|
||||
|
||||
public string SkuNumber
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public Account.TaxCode TaxCode
|
||||
|
||||
public bool SkuNumberIsSet
|
||||
{
|
||||
get { return SkuNumber != null; }
|
||||
}
|
||||
|
||||
public string TaxCode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool TaxCodeIsSet
|
||||
{
|
||||
get { return TaxCode != null; }
|
||||
}
|
||||
|
||||
public string AmazonFNSKU
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool AmazonFNSKUIsSet
|
||||
{
|
||||
get { return AmazonFNSKU != null; }
|
||||
}
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get { return (bool)isActive; }
|
||||
set { isActive = value; }
|
||||
}
|
||||
public bool IsSetConditionModelPlaceholder
|
||||
{
|
||||
get { return ConditionModelPlaceholder != null; }
|
||||
}
|
||||
public bool IsSetProductModelPlaceholder
|
||||
{
|
||||
get { return ProductModelPlaceholder != null; }
|
||||
}
|
||||
public bool IsSetSkuNumber
|
||||
{
|
||||
get { return SkuNumber != null; }
|
||||
}
|
||||
public bool IsSetTaxCode
|
||||
{
|
||||
get { return TaxCode != null; }
|
||||
}
|
||||
public bool IsSetAmazonFNSKU
|
||||
{
|
||||
get { return AmazonFNSKU != null; }
|
||||
}
|
||||
public bool IsSetIsActive
|
||||
|
||||
public bool IsActiveIsSet
|
||||
{
|
||||
get { return isActive != null; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
35
src/bnhtrade.Core/Model/SKU/SkuConditionInfo.cs
Normal file
35
src/bnhtrade.Core/Model/SKU/SkuConditionInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Sku
|
||||
{
|
||||
public class SkuConditionInfo
|
||||
{
|
||||
public int SkuConditionId { get; set; }
|
||||
|
||||
public string SkuConditionNumber { get; set; }
|
||||
|
||||
public string TitleShort { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public bool IsFixedPrice { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Can be used to estimate a competitve price from 'New' condition competitive price
|
||||
/// </summary>
|
||||
public decimal CompetitivePriceMultiplier { get; set; }
|
||||
|
||||
public string AmazonBaseType { get; set; }
|
||||
|
||||
public int AmazonIdentifier { get; set; }
|
||||
|
||||
public string ConditionNoteDefault { get; set; }
|
||||
|
||||
public string RepricerStrategy { get; set; }
|
||||
}
|
||||
}
|
||||
41
src/bnhtrade.Core/Model/Sku/Price/DetailRequest.cs
Normal file
41
src/bnhtrade.Core/Model/Sku/Price/DetailRequest.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Sku.Price
|
||||
{
|
||||
public class DetailRequest
|
||||
{
|
||||
public int SkuId { get; set; }
|
||||
|
||||
public int OrderChannelId { get; set; }
|
||||
|
||||
public int OrderChannelQuantity { get; set; }
|
||||
|
||||
public decimal OrderChannelFeeFixed { get; set; }
|
||||
|
||||
public decimal OrderChannelFeeMargin { get; set; }
|
||||
|
||||
public decimal UnitAvgCost { get; set; }
|
||||
|
||||
public int InventoryAgeMin { get; set; }
|
||||
|
||||
public int InventoryAgeMax { get; set; }
|
||||
|
||||
public int PriceMin_SkuPriceType { get; set; }
|
||||
|
||||
public decimal? PriceMinAmountManual { get; set; }
|
||||
|
||||
public int? PriceMinStoredInt { get; set; }
|
||||
|
||||
public int PriceMax_SkuPriceType { get; set; }
|
||||
|
||||
public bool PriceMaxBaseMultipilerReset { get; set; } = false;
|
||||
|
||||
public decimal? PriceMaxAmountManual { get; set; }
|
||||
|
||||
public int? PriceMaxStoredInt { get; set; }
|
||||
}
|
||||
}
|
||||
71
src/bnhtrade.Core/Model/Sku/Price/DetailResponce.cs
Normal file
71
src/bnhtrade.Core/Model/Sku/Price/DetailResponce.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Sku.Price
|
||||
{
|
||||
public class DetailResponce
|
||||
{
|
||||
public int SkuId { get; set; }
|
||||
|
||||
public int OrderChannelId { get; set; }
|
||||
|
||||
public int OrderChannelQuantity { get; set; }
|
||||
|
||||
public decimal UnitAvgCost { get; set; }
|
||||
|
||||
public int InventoryAgeMin { get; set; }
|
||||
|
||||
public int InventoryAgeMax { get; set; }
|
||||
|
||||
public int PriceMin_SkuPriceType { get; set; }
|
||||
|
||||
public decimal PriceMinAmountAuto { get; set; }
|
||||
|
||||
public decimal? PriceMinAmountManual { get; set; }
|
||||
|
||||
public int? PriceMinStoredInt { get; set; }
|
||||
|
||||
public decimal PriceMinAmountFinalFee { get; set; }
|
||||
|
||||
public decimal PriceMinAmountFinalTax { get; set; }
|
||||
|
||||
public decimal PriceMinAmountFinal { get; set; }
|
||||
|
||||
public int PriceMax_SkuPriceType { get; set; }
|
||||
|
||||
public decimal PriceMaxAmountAutoBase { get; set; }
|
||||
|
||||
public decimal PriceMaxAmountAutoMultiplier { get; set; }
|
||||
|
||||
public DateTime PriceMaxAmountAutoModified { get; set; }
|
||||
|
||||
public decimal? PriceMaxAmountManual { get; set; }
|
||||
|
||||
public int? PriceMaxStoredInt { get; set; }
|
||||
|
||||
public decimal PriceMaxAmountFinal { get; set; }
|
||||
|
||||
public DateTime PriceCreated { get; set; }
|
||||
|
||||
public string TypeTitle { get; set; }
|
||||
|
||||
public bool ReviewRequired
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TypeTitle.Substring(0, 15) == "Review Required")
|
||||
{ return true; }
|
||||
else
|
||||
{ return false; }
|
||||
}
|
||||
}
|
||||
|
||||
public bool RequireAmountManual { get; set; }
|
||||
|
||||
public bool RequireStordedInt { get; set; }
|
||||
}
|
||||
}
|
||||
98
src/bnhtrade.Core/Model/Sku/Price/PriceInfo.cs
Normal file
98
src/bnhtrade.Core/Model/Sku/Price/PriceInfo.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Sku.Price
|
||||
{
|
||||
public class PriceInfo : IValidatableObject
|
||||
{
|
||||
private bool? reviewRequired;
|
||||
|
||||
[Required()]
|
||||
public string SkuNumber { get; set; }
|
||||
|
||||
[Required()]
|
||||
public string OrderChannel { get; set; }
|
||||
|
||||
[Required()]
|
||||
public DateTime PriceInfoTimeStamp { get; set; }
|
||||
|
||||
[Required(), Range(0, 32767)]
|
||||
public int OrderChannelQuantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The average purchase cost of each unit
|
||||
/// </summary>
|
||||
[Required(), Range(0, 9999999.99)]
|
||||
public decimal UnitPurchaseCost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The average minimun sale price to achieve set minumum profit
|
||||
/// </summary>
|
||||
[Required(), Range(0, 9999999.99)]
|
||||
public decimal UnitMinPriceProfit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The average minimun sale price to cover costs
|
||||
/// </summary>
|
||||
[Required(), Range(0, 9999999.99)]
|
||||
public decimal UnitMinPriceCost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The minimun price at which it is more ecomoical to destory item
|
||||
/// </summary>
|
||||
[Required(), Range(0, 9999999.99)]
|
||||
public decimal UnitMinPriceDestory { get; set; }
|
||||
|
||||
[Required(), Range(0, 32767)]
|
||||
public int InventoryAgeMin { get; set; }
|
||||
|
||||
[Required(), Range(0, 32767)]
|
||||
public int InventoryAgeMax { get; set; }
|
||||
|
||||
[Range(0, 255)]
|
||||
public int PriceTypeId { get; set; }
|
||||
|
||||
public string PriceTypeTitle { get; set; }
|
||||
|
||||
[Required(), Range(0, 9999999.99)]
|
||||
public decimal CompetitivePrice { get; set; }
|
||||
|
||||
public bool CompetitivePriceIsEstimated { get; set; }
|
||||
|
||||
[Required(), Range(0, 9999999.99)]
|
||||
public decimal MinPrice { get; set; }
|
||||
|
||||
[Required(), Range(0, 9999999.99)]
|
||||
public decimal MaxPrice { get; set; }
|
||||
|
||||
[Required(), Range(0, 9999999.99)]
|
||||
public decimal RepriceIncrement { get; set; }
|
||||
|
||||
[Required()]
|
||||
public bool ReviewRequired
|
||||
{
|
||||
get { return reviewRequired.GetValueOrDefault(); }
|
||||
set { reviewRequired = value; }
|
||||
}
|
||||
|
||||
public bool IsSetReviewRequired
|
||||
{
|
||||
get { return reviewRequired != null; }
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var resultList = new List<ValidationResult>();
|
||||
if (MaxPrice < MinPrice)
|
||||
{
|
||||
resultList.Add(new ValidationResult("Max price is less than min price"));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
src/bnhtrade.Core/Model/Sku/Price/SkuPriceParameter.cs
Normal file
53
src/bnhtrade.Core/Model/Sku/Price/SkuPriceParameter.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Sku.Price
|
||||
{
|
||||
public class SkuPriceParameter
|
||||
{
|
||||
public int SkuId { get; set; }
|
||||
|
||||
public string SkuNumber { get; set; }
|
||||
|
||||
public int TotalQuantity { get; set; }
|
||||
|
||||
public decimal UnitCostAverage { get; set; }
|
||||
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public int ConditionId { get; set; }
|
||||
|
||||
public string TaxCode { get; set; }
|
||||
|
||||
public decimal ProfitMargin { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Agent fee as ratio of selling price (i.e. 0.25)
|
||||
/// </summary>
|
||||
public decimal AgentFeeMargin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total of agent fixed fees
|
||||
/// </summary>
|
||||
public decimal AgentFeeFixed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Amazon margin as a ratio of 1 (i.e. 0.2)
|
||||
/// </summary>
|
||||
public decimal VatMargin { get; set; }
|
||||
|
||||
public string TaxRateName { get; set; }
|
||||
|
||||
public bool IsFixedPrice { get; set; }
|
||||
|
||||
public decimal CompetitivePriceMultiplierNew { get; set; }
|
||||
|
||||
public decimal TotalCost { get; set; }
|
||||
|
||||
public decimal PriceMinProfit { get; set; }
|
||||
}
|
||||
}
|
||||
189
src/bnhtrade.Core/Model/Stock/SkuTransaction.cs
Normal file
189
src/bnhtrade.Core/Model/Stock/SkuTransaction.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
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
|
||||
{
|
||||
public class SkuTransaction : IValidatableObject
|
||||
{
|
||||
private DateTime? transactionDate = null;
|
||||
private bool? isProcessed = null;
|
||||
private short? quantity = null;
|
||||
private int? stockjournalId = null;
|
||||
private int? skuTransactionId = null;
|
||||
private int? skuTransactionTypeId = null;
|
||||
private int? foreignKey = null;
|
||||
|
||||
public int SkuTransactionId
|
||||
{
|
||||
get { return skuTransactionId.GetValueOrDefault(); }
|
||||
set { skuTransactionId = value; }
|
||||
}
|
||||
|
||||
public bool IsSetSkuTransactionId
|
||||
{
|
||||
get { return skuTransactionId != null; }
|
||||
}
|
||||
|
||||
[Required()]
|
||||
public DateTime TransactionDate
|
||||
{
|
||||
get { return transactionDate.GetValueOrDefault(); }
|
||||
set { transactionDate = value; }
|
||||
}
|
||||
|
||||
public bool IsSetTransactionDate
|
||||
{
|
||||
get { return transactionDate != null; }
|
||||
}
|
||||
|
||||
[Required()]
|
||||
public int SkuTransactionTypeId
|
||||
{
|
||||
get { return skuTransactionTypeId.GetValueOrDefault(); }
|
||||
private set { skuTransactionTypeId = value; }
|
||||
}
|
||||
|
||||
public bool IsSetSkuTransactionTypeId
|
||||
{
|
||||
get { return skuTransactionTypeId != null; }
|
||||
}
|
||||
|
||||
public string SkuTransactionTypeName { get; private set; }
|
||||
|
||||
public bool IsSetReconcileSkuTypeName
|
||||
{
|
||||
get { return SkuTransactionTypeName != null; }
|
||||
}
|
||||
|
||||
public int ForeignKey
|
||||
{
|
||||
get { return foreignKey.GetValueOrDefault(); }
|
||||
set { foreignKey = value; }
|
||||
}
|
||||
|
||||
public bool IsSetForeignKey
|
||||
{
|
||||
get { return foreignKey != null; }
|
||||
}
|
||||
|
||||
public string Reference { get; set; }
|
||||
|
||||
public bool IsSetReference
|
||||
{
|
||||
get { return Reference != null; }
|
||||
}
|
||||
|
||||
public string Detail { get; set; }
|
||||
|
||||
public bool IsSetDetail
|
||||
{
|
||||
get { return Detail != null; }
|
||||
}
|
||||
|
||||
[Required()]
|
||||
public string SkuNumber { get; set; }
|
||||
|
||||
public bool IsSetSkuNumber
|
||||
{
|
||||
get { return SkuNumber != null; }
|
||||
}
|
||||
|
||||
[Required(), Range(0, short.MaxValue)]
|
||||
public short Quantity
|
||||
{
|
||||
get { return quantity.GetValueOrDefault(); }
|
||||
set { quantity = value; }
|
||||
}
|
||||
|
||||
public bool IsSetQuantity
|
||||
{
|
||||
get { return quantity != null; }
|
||||
}
|
||||
|
||||
public bool IsProcessed
|
||||
{
|
||||
get { return isProcessed.GetValueOrDefault(); }
|
||||
set { isProcessed = value; }
|
||||
}
|
||||
|
||||
public bool IsSetIsProcessed
|
||||
{
|
||||
get { return isProcessed != null; }
|
||||
}
|
||||
|
||||
public int StockJournalId
|
||||
{
|
||||
get { return stockjournalId.GetValueOrDefault(); }
|
||||
set { stockjournalId = value; }
|
||||
}
|
||||
|
||||
public bool IsSetStockJournalId
|
||||
{
|
||||
get { return stockjournalId != null; }
|
||||
}
|
||||
|
||||
public void SetReconcileSkuType(int reconcileSkuTypeId, string reconcileSkuTypeName)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(reconcileSkuTypeName) || reconcileSkuTypeId == 0)
|
||||
{
|
||||
SkuTransactionTypeId = reconcileSkuTypeId;
|
||||
SkuTransactionTypeName = reconcileSkuTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
public SkuTransaction Clone()
|
||||
{
|
||||
var clone = new SkuTransaction();
|
||||
|
||||
if (IsSetDetail) { clone.Detail = string.Copy(this.Detail); }
|
||||
if (IsSetForeignKey) { clone.ForeignKey = this.ForeignKey; }
|
||||
if (IsSetIsProcessed) { clone.IsProcessed = this.IsProcessed; }
|
||||
if (IsSetQuantity) { clone.Quantity = this.Quantity; }
|
||||
if (IsSetReference) { clone.Reference = string.Copy(this.Reference); }
|
||||
if (IsSetSkuNumber) { clone.SkuNumber = string.Copy(this.SkuNumber); }
|
||||
if (IsSetReconcileSkuTypeName) { clone.SkuTransactionTypeName = string.Copy(this.SkuTransactionTypeName); }
|
||||
if (IsSetStockJournalId) { clone.StockJournalId = this.StockJournalId; }
|
||||
if (IsSetSkuTransactionId) { clone.SkuTransactionId = this.SkuTransactionId; }
|
||||
if (IsSetSkuTransactionTypeId) { clone.SkuTransactionTypeId = this.SkuTransactionTypeId; }
|
||||
if (IsSetTransactionDate) { clone.TransactionDate = this.TransactionDate; }
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var result = new List<ValidationResult>();
|
||||
|
||||
if (!IsSetTransactionDate)
|
||||
{
|
||||
result.Add(new ValidationResult("Transaction date is not set"));
|
||||
}
|
||||
if (!IsSetIsProcessed)
|
||||
{
|
||||
result.Add(new ValidationResult("IsProcessed is not set"));
|
||||
}
|
||||
if (!IsSetQuantity)
|
||||
{
|
||||
result.Add(new ValidationResult("Quantity is not set"));
|
||||
}
|
||||
if (!IsSetSkuTransactionId)
|
||||
{
|
||||
result.Add(new ValidationResult("Stock Transaction Id is not set"));
|
||||
}
|
||||
if (!IsSetSkuTransactionTypeId)
|
||||
{
|
||||
result.Add(new ValidationResult("Stock Transaction TypeId is not set"));
|
||||
}
|
||||
if (IsSetStockJournalId && (!IsSetIsProcessed || IsProcessed == false))
|
||||
{
|
||||
result.Add(new ValidationResult("Stock Journal Id is set, IsProcessed must be set to true"));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
63
src/bnhtrade.Core/Model/Stock/SkuTransactionType.cs
Normal file
63
src/bnhtrade.Core/Model/Stock/SkuTransactionType.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
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
|
||||
{
|
||||
public class SkuTransactionType
|
||||
{
|
||||
private int? typeId = null;
|
||||
|
||||
[Required()]
|
||||
public int TypeId
|
||||
{
|
||||
get { return typeId.GetValueOrDefault(); }
|
||||
set { typeId = value; }
|
||||
}
|
||||
|
||||
public bool IsSetTypeId
|
||||
{
|
||||
get { return typeId != null; }
|
||||
}
|
||||
|
||||
public string TypeName { get; set; }
|
||||
|
||||
public bool IsSetTypeName
|
||||
{
|
||||
get { return TypeName != null; }
|
||||
}
|
||||
|
||||
public string TypeCode { get; set; }
|
||||
|
||||
public string TypeDescription { get; set; }
|
||||
|
||||
public int StockJournalTypeId { get; set; }
|
||||
|
||||
public string TransactionForeignKeyName { get; set; }
|
||||
|
||||
public string TransactionReferenceType { get; set; }
|
||||
|
||||
public bool IsNewReviewRequired { get; set; }
|
||||
|
||||
public bool TransactionImportEnabled { get; set; }
|
||||
|
||||
public bool StockJournalEntryEnabled { get; set; }
|
||||
|
||||
public int DebitStockStatusId { get; set; }
|
||||
|
||||
public string DebitStockStatus { get; set; }
|
||||
|
||||
public int CreditStockStatusId { get; set; }
|
||||
|
||||
public string CreditStockStatus { get; set; }
|
||||
|
||||
public bool StatusBalanceCheckRequired { get; set; }
|
||||
|
||||
public bool FilterStockOnDateTime { get; set; }
|
||||
|
||||
public bool FirstInFirstOut { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user