From d6b198777f60ebc1d775d75491e821ae986a8dac Mon Sep 17 00:00:00 2001 From: Bobbie Hodgetts Date: Fri, 29 May 2020 16:28:16 +0100 Subject: [PATCH] wip --- .../Logic/Sku/Price/FbaPricing.cs | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/bnhtrade.Core/Logic/Sku/Price/FbaPricing.cs b/src/bnhtrade.Core/Logic/Sku/Price/FbaPricing.cs index 3dc41ce..f3de5e1 100644 --- a/src/bnhtrade.Core/Logic/Sku/Price/FbaPricing.cs +++ b/src/bnhtrade.Core/Logic/Sku/Price/FbaPricing.cs @@ -21,7 +21,7 @@ namespace bnhtrade.Core.Logic.Sku.Price private int newConditionId = Data.Database.Constants.GetProductConditionIdNew(); private List skuInfo; private Dictionary competitivePrices; - DateTime crTimeStamp = DateTime.UtcNow; + DateTime newTimeStamp = DateTime.UtcNow; private int repriceIncrementDivisor = 60; private Dictionary saleCountInPeriod = new Dictionary(); 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; } } + + /// + /// Before running reprice update, this method ensures that the relevant data needed is up to date. + /// + 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 + } } }