mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 14:37:16 +00:00
wip
This commit is contained in:
@@ -21,7 +21,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
|||||||
private int newConditionId = Data.Database.Constants.GetProductConditionIdNew();
|
private int newConditionId = Data.Database.Constants.GetProductConditionIdNew();
|
||||||
private List<Model.Sku.Price.SkuPriceParameter> skuInfo;
|
private List<Model.Sku.Price.SkuPriceParameter> skuInfo;
|
||||||
private Dictionary<string, Model.Product.CompetitivePrice> competitivePrices;
|
private Dictionary<string, Model.Product.CompetitivePrice> competitivePrices;
|
||||||
DateTime crTimeStamp = DateTime.UtcNow;
|
DateTime newTimeStamp = DateTime.UtcNow;
|
||||||
private int repriceIncrementDivisor = 60;
|
private int repriceIncrementDivisor = 60;
|
||||||
private Dictionary<string, int> saleCountInPeriod = new Dictionary<string, int>();
|
private Dictionary<string, int> saleCountInPeriod = new Dictionary<string, int>();
|
||||||
private Logic.Account.TaxCalculation taxCalc;
|
private Logic.Account.TaxCalculation taxCalc;
|
||||||
@@ -31,28 +31,25 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
|||||||
{
|
{
|
||||||
this.sqlConnectionString = sqlConnectionString;
|
this.sqlConnectionString = sqlConnectionString;
|
||||||
taxCalc = new Account.TaxCalculation();
|
taxCalc = new Account.TaxCalculation();
|
||||||
crTimeStamp = DateTime.UtcNow;
|
newTimeStamp = DateTime.UtcNow;
|
||||||
marginSchemeMargin = taxCalc.GetMarginMultiplier(crTimeStamp);
|
marginSchemeMargin = taxCalc.GetMarginMultiplier(newTimeStamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(bool overrideDayCheck = false)
|
public void Update(bool overrideDayCheck = false)
|
||||||
{
|
{
|
||||||
|
UpdatePrecheck();
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
string orderChannel = "Amazon.co.uk"; // may in future enable other order channels
|
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.)
|
// get current sku base pricing details (stock quantity, competative price, VAT info, etc.)
|
||||||
skuInfo = new Data.Database.Sku.Price.ReadParameter(sqlConnectionString).Execute();
|
skuInfo = new Data.Database.Sku.Price.ReadParameter(sqlConnectionString).Execute();
|
||||||
if (skuInfo == null || !skuInfo.Any())
|
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
|
// create lists that we'll add to during lopp
|
||||||
@@ -85,7 +82,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
|||||||
cr.ReviewRequired = false;
|
cr.ReviewRequired = false;
|
||||||
cr.OrderChannel = orderChannel;
|
cr.OrderChannel = orderChannel;
|
||||||
cr.OrderChannelQuantity = skuInfo[i].TotalQuantity;
|
cr.OrderChannelQuantity = skuInfo[i].TotalQuantity;
|
||||||
cr.PriceInfoTimeStamp = crTimeStamp;
|
cr.PriceInfoTimeStamp = newTimeStamp;
|
||||||
cr.SkuNumber = skuInfo[i].SkuNumber;
|
cr.SkuNumber = skuInfo[i].SkuNumber;
|
||||||
|
|
||||||
// get inventory age range
|
// get inventory age range
|
||||||
@@ -258,7 +255,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
|||||||
|
|
||||||
bool update = false;
|
bool update = false;
|
||||||
lastPriceUpdate = new DateTime(lastPriceUpdate.Year, lastPriceUpdate.Month, lastPriceUpdate.Day);
|
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.
|
// will only update once on tue, wed or thurs each week.
|
||||||
if (today.DayOfWeek == DayOfWeek.Tuesday || today.DayOfWeek == DayOfWeek.Wednesday || today.DayOfWeek == DayOfWeek.Thursday)
|
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;
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user