This commit is contained in:
2020-05-29 16:28:16 +01:00
parent 3a53350f85
commit d6b198777f

View File

@@ -21,7 +21,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
private int newConditionId = Data.Database.Constants.GetProductConditionIdNew();
private List<Model.Sku.Price.SkuPriceParameter> skuInfo;
private Dictionary<string, Model.Product.CompetitivePrice> competitivePrices;
DateTime crTimeStamp = DateTime.UtcNow;
DateTime newTimeStamp = DateTime.UtcNow;
private int repriceIncrementDivisor = 60;
private Dictionary<string, int> saleCountInPeriod = new Dictionary<string, int>();
private Logic.Account.TaxCalculation taxCalc;
@@ -31,28 +31,25 @@ namespace bnhtrade.Core.Logic.Sku.Price
{
this.sqlConnectionString = sqlConnectionString;
taxCalc = new Account.TaxCalculation();
crTimeStamp = DateTime.UtcNow;
marginSchemeMargin = taxCalc.GetMarginMultiplier(crTimeStamp);
newTimeStamp = DateTime.UtcNow;
marginSchemeMargin = taxCalc.GetMarginMultiplier(newTimeStamp);
}
public void Update(bool overrideDayCheck = false)
{
UpdatePrecheck();
using (var scope = new TransactionScope())
{
string orderChannel = "Amazon.co.uk"; // may in future enable other order channels
// need to add some cheks up here for last stock reconcilliation
// get current sku base pricing details (stock quantity, competative price, VAT info, etc.)
skuInfo = new Data.Database.Sku.Price.ReadParameter(sqlConnectionString).Execute();
if (skuInfo == null || !skuInfo.Any())
{
throw new Exception("Querying the database returned no records.");
err += "Querying the database returned no records.";
log.LogError(err);
throw new Exception(err);
}
// create lists that we'll add to during lopp
@@ -85,7 +82,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
cr.ReviewRequired = false;
cr.OrderChannel = orderChannel;
cr.OrderChannelQuantity = skuInfo[i].TotalQuantity;
cr.PriceInfoTimeStamp = crTimeStamp;
cr.PriceInfoTimeStamp = newTimeStamp;
cr.SkuNumber = skuInfo[i].SkuNumber;
// get inventory age range
@@ -258,7 +255,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
bool update = false;
lastPriceUpdate = new DateTime(lastPriceUpdate.Year, lastPriceUpdate.Month, lastPriceUpdate.Day);
DateTime today = new DateTime(crTimeStamp.Year, crTimeStamp.Month, crTimeStamp.Day);
DateTime today = new DateTime(newTimeStamp.Year, newTimeStamp.Month, newTimeStamp.Day);
// will only update once on tue, wed or thurs each week.
if (today.DayOfWeek == DayOfWeek.Tuesday || today.DayOfWeek == DayOfWeek.Wednesday || today.DayOfWeek == DayOfWeek.Thursday)
@@ -382,5 +379,20 @@ namespace bnhtrade.Core.Logic.Sku.Price
return 0;
}
}
/// <summary>
/// Before running reprice update, this method ensures that the relevant data needed is up to date.
/// </summary>
private void UpdatePrecheck()
{
throw new NotImplementedException();
// check last FBA sale import
err += "Querying the database returned no records.";
log.LogError(err);
throw new Exception(err);
// check last amazon sku fees updates
}
}
}