mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-18 22:17:15 +00:00
the abandoned fba repricing feature
* Merge master into branch (#15) * Bug fix * Bug fix when retriving shipment stock status id * Various bug fixs and improvements to stock SKU reconciliation * Last MWS report import date time saved * master into branch (#16) * Bug fix * Bug fix when retriving shipment stock status id * Various bug fixs and improvements to stock SKU reconciliation * Last MWS report import date time saved * wip * wip * wip * wip * wip * some extra tidying up to get it to complie and the main merge is complete * wip
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -262,4 +262,5 @@ paket-files/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyc
|
||||
/src/bnhtrade.ScheduledTasks/app.local.config
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace bnhtrade.ComTypeLib
|
||||
public void ProductUpdateAmazonEstimateFee(ConnectionCredential sqlConnCred, object inputList)
|
||||
{
|
||||
// get com object in string array
|
||||
var inputTuple = new List<(string asin, decimal priceToEstimate)>();
|
||||
var inputTuple = new Dictionary<string, decimal>();
|
||||
var getArray = new Utility.LoadComObjextIntoStringArray();
|
||||
string[] stringArray = getArray.LoadComObjectIntoStringArray(inputList);
|
||||
|
||||
@@ -72,8 +72,7 @@ namespace bnhtrade.ComTypeLib
|
||||
{
|
||||
throw new Exception("Split function failed on line: " + item);
|
||||
}
|
||||
var tempTuple = (split[0], decimal.Parse(split[1]));
|
||||
inputTuple.Add(tempTuple);
|
||||
inputTuple.Add(split[0], decimal.Parse(split[1]));
|
||||
}
|
||||
|
||||
new Core.Logic.Product.AmazonEstimateFee().UpdateDatabase(inputTuple);
|
||||
|
||||
@@ -68,12 +68,6 @@
|
||||
<ItemGroup>
|
||||
<Content Include="ILMergeOrder.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\bnhtrade.Core\bnhtrade.Core.csproj">
|
||||
<Project>{339d7413-3da7-46ea-a55c-255a9a6b95eb}</Project>
|
||||
<Name>bnhtrade.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
|
||||
88
src/bnhtrade.Core/Data/AmazonMWS/Product/GetMyFeeEstimate.cs
Normal file
88
src/bnhtrade.Core/Data/AmazonMWS/Product/GetMyFeeEstimate.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using MarketplaceWebServiceProducts.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace bnhtrade.Core.Data.AmazonMWS.Product
|
||||
{
|
||||
public class GetMyFeeEstimate
|
||||
{
|
||||
public List<FeesEstimateResult> GetProductEstimateFee(FeesEstimateRequestList requestList)
|
||||
{
|
||||
var returnList = new List<FeesEstimateResult>();
|
||||
if (requestList == null || !requestList.IsSetFeesEstimateRequest())
|
||||
{
|
||||
return returnList;
|
||||
}
|
||||
else if (returnList.Count > 20)
|
||||
{
|
||||
throw new Exception("Max number of FeesEstimateRequest in one request is 20");
|
||||
}
|
||||
|
||||
CredentialMws cred = new CredentialMws();
|
||||
var mwsProduct = new Data.AmazonMWS.Service();// AmazonMwsProduct();
|
||||
MarketplaceWebServiceProducts.MarketplaceWebServiceProducts service = mwsProduct.MarketplaceProducts();
|
||||
|
||||
// Create a request.
|
||||
GetMyFeesEstimateRequest request = new GetMyFeesEstimateRequest();
|
||||
request.SellerId = cred.MerchantId;
|
||||
request.MWSAuthToken = "example";
|
||||
//FeesEstimateRequestList requestList = new FeesEstimateRequestList();
|
||||
|
||||
//foreach (var item in itemList)
|
||||
//{
|
||||
// string idType;
|
||||
// if (item.IdValueIsAsin) { idType = "ASIN"; }
|
||||
// else { idType = "SellerSku"; }
|
||||
|
||||
// requestList.FeesEstimateRequest.Add(new FeesEstimateRequest
|
||||
// {
|
||||
// MarketplaceId = item.marketPlaceId,
|
||||
// IdType = idType,
|
||||
// IdValue = item.IdValue,
|
||||
// PriceToEstimateFees = new PriceToEstimateFees
|
||||
// {
|
||||
// ListingPrice = new MoneyType { Amount = item.listingPrice, CurrencyCode = item.currencyCode },
|
||||
// //Shipping = new MoneyType { Amount = 3.5M, CurrencyCode = "GBP" },
|
||||
// //Points = new Points { PointsNumber = 0 }
|
||||
// },
|
||||
// Identifier = "request_" + Guid.NewGuid().ToString(),
|
||||
// IsAmazonFulfilled = true
|
||||
// });
|
||||
//}
|
||||
request.FeesEstimateRequestList = requestList;
|
||||
|
||||
// define the list
|
||||
GetMyFeesEstimateResult result = new GetMyFeesEstimateResult();
|
||||
//List<GetMyFeesEstimateResult> resultList = new List<GetMyFeesEstimateResult>();
|
||||
|
||||
try
|
||||
{
|
||||
int count = 0;
|
||||
do
|
||||
{
|
||||
GetMyFeesEstimateResponse response = service.GetMyFeesEstimate(request);
|
||||
if (response.IsSetGetMyFeesEstimateResult())
|
||||
{
|
||||
result = response.GetMyFeesEstimateResult;
|
||||
FeesEstimateResultList resultList = result.FeesEstimateResultList;
|
||||
|
||||
List<FeesEstimateResult> fees = resultList.FeesEstimateResult;
|
||||
|
||||
return fees;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
count++;
|
||||
}
|
||||
} while (count < 60); // 30 second timout
|
||||
throw new Exception("Response timeout");
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,8 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
return resultList;
|
||||
}
|
||||
|
||||
taxcodeList = taxcodeList.Distinct().ToList();
|
||||
|
||||
whereBuilder.Innit();
|
||||
whereBuilder.In("TaxCode", taxcodeList, "WHERE");
|
||||
|
||||
@@ -118,6 +120,8 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
return resultList;
|
||||
}
|
||||
|
||||
skuNumberList = skuNumberList.Distinct().ToList();
|
||||
|
||||
string sql = @"
|
||||
SELECT tblSku.skuSkuNumber
|
||||
,tblAccountTaxCode.TaxCode
|
||||
@@ -167,6 +171,8 @@ namespace bnhtrade.Core.Data.Database.Account
|
||||
return resultList;
|
||||
}
|
||||
|
||||
lineItemCode = lineItemCode.Distinct().ToList();
|
||||
|
||||
string sql = @"
|
||||
SELECT tblAccountInvoiceLineItem.ItemCode
|
||||
,tblAccountTaxCode.TaxCode
|
||||
|
||||
@@ -33,9 +33,28 @@ namespace bnhtrade.Core.Data.Database
|
||||
return "Amazon.co.uk";
|
||||
}
|
||||
|
||||
public static int GetProductConditionIdNew()
|
||||
/// <summary>
|
||||
/// Returns the sql table ID for a condition type
|
||||
/// </summary>
|
||||
public enum SkuCondition
|
||||
{
|
||||
return 10;
|
||||
New = 10,
|
||||
LikeNew = 11,
|
||||
VeryGood = 12,
|
||||
Good = 13,
|
||||
Acceptable = 14,
|
||||
// add the rest as needed
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the sql table ID for a stock status type
|
||||
/// </summary>
|
||||
public enum StockStatusType
|
||||
{
|
||||
FbaInventoryActive = 3,
|
||||
FbaShipment = 4,
|
||||
FbaShippingPlan = 5,
|
||||
// add the rest as needed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace bnhtrade.Core.Data.Database.Product
|
||||
{
|
||||
private List<string> filterByAsin;
|
||||
private List<int> filterByProductId;
|
||||
private Data.Database.SqlWhereBuilder sqlWhereBuilder = new SqlWhereBuilder();
|
||||
|
||||
public ReadProduct()
|
||||
{
|
||||
@@ -157,6 +158,7 @@ namespace bnhtrade.Core.Data.Database.Product
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
using MarketplaceWebServiceProducts.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Product
|
||||
{
|
||||
public class UpdateAmazonFeeEstimate : Connection
|
||||
{
|
||||
public UpdateAmazonFeeEstimate(string sqlConnectionString) : base(sqlConnectionString)
|
||||
{
|
||||
}
|
||||
|
||||
public void ByFeesEstimateResult(FeesEstimateResult updateItem)
|
||||
{
|
||||
ByFeesEstimateResult(new List<FeesEstimateResult> { updateItem });
|
||||
}
|
||||
|
||||
public void ByFeesEstimateResult(List<FeesEstimateResult> updateList)
|
||||
{
|
||||
foreach (var item in updateList)
|
||||
{
|
||||
bool isSellerSku = false;
|
||||
if (item.FeesEstimateIdentifier.IdType == "SellerSKU")
|
||||
{
|
||||
isSellerSku = true;
|
||||
}
|
||||
else if (item.FeesEstimateIdentifier.IdType != "ASIN")
|
||||
{
|
||||
// Amazon have updated API to include other identifiers?
|
||||
throw new Exception(
|
||||
"New FeesEstimateIdentifier encountered/unsupported of type '" + item.FeesEstimateIdentifier + "'.");
|
||||
}
|
||||
|
||||
string asin = item.FeesEstimateIdentifier.IdValue;
|
||||
bool isAmazonFulfilled = item.FeesEstimateIdentifier.IsAmazonFulfilled;
|
||||
DateTime timeOfFeeEstimation = item.FeesEstimate.TimeOfFeesEstimation;
|
||||
decimal totalFeeEstimate = item.FeesEstimate.TotalFeesEstimate.Amount;
|
||||
string currencyCode = item.FeesEstimate.TotalFeesEstimate.CurrencyCode;
|
||||
decimal priceToEstimateFeeListingPrice = item.FeesEstimateIdentifier.PriceToEstimateFees.ListingPrice.Amount;
|
||||
decimal priceToEstimateFeeShipping = 0;
|
||||
if (item.FeesEstimateIdentifier.PriceToEstimateFees.Shipping != null)
|
||||
{ priceToEstimateFeeShipping = item.FeesEstimateIdentifier.PriceToEstimateFees.Shipping.Amount; }
|
||||
decimal priceToEstimateFeePoints = 0;
|
||||
if (item.FeesEstimateIdentifier.PriceToEstimateFees.Points != null)
|
||||
{ priceToEstimateFeePoints = item.FeesEstimateIdentifier.PriceToEstimateFees.Points.PointsMonetaryValue.Amount; }
|
||||
|
||||
decimal referralFee = 0m;
|
||||
decimal variableClosingFee = 0m;
|
||||
decimal fulfillmentFees = 0m;
|
||||
decimal perItemFee = 0m;
|
||||
decimal otherFee_Exception = 0m;
|
||||
|
||||
FeeDetailList feeDetailList = item.FeesEstimate.FeeDetailList;
|
||||
List<FeeDetail> feeDetail = feeDetailList.FeeDetail;
|
||||
foreach (FeeDetail feeDetailItem in feeDetail)
|
||||
{
|
||||
if (feeDetailItem.FeeType == "AmazonReferralFee" || feeDetailItem.FeeType == "ReferralFee")
|
||||
{ referralFee = feeDetailItem.FinalFee.Amount; }
|
||||
else if (feeDetailItem.FeeType == "VariableClosingFee")
|
||||
{ variableClosingFee = feeDetailItem.FinalFee.Amount; }
|
||||
else if (feeDetailItem.FeeType == "PerItemFee")
|
||||
{ perItemFee = feeDetailItem.FinalFee.Amount; }
|
||||
else if (feeDetailItem.FeeType == "FBAFees" || feeDetailItem.FeeType == "FulfillmentFees")
|
||||
{ fulfillmentFees = feeDetailItem.FinalFee.Amount; }
|
||||
else
|
||||
{ otherFee_Exception = otherFee_Exception + feeDetailItem.FinalFee.Amount; }
|
||||
|
||||
}
|
||||
|
||||
// build sql statement
|
||||
string sqlProductId;
|
||||
if (isSellerSku)
|
||||
{
|
||||
sqlProductId = "(SELECT tblSku.skuProductID FROM tblSku INNER JOIN tblProduct ON tblSku.skuProductID = tblProduct.prdProductID WHERE tblProduct.prdAmazonASIN = @asin)";
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlProductId = "(SELECT prdProductID FROM tblProduct WHERE prdAmazonASIN = @asin)";
|
||||
}
|
||||
|
||||
string sql = @"
|
||||
UPDATE tblAmazonFeeEstimate SET
|
||||
IsAmazonFulfilled=@isAmazonFulfilled, TimeOfFeeEstimation=@timeOfFeeEstimation,
|
||||
TotalFeeEstimate=@totalFeeEstimate, PriceToEstimateFeeListingPrice=@priceToEstimateFeeListingPrice,
|
||||
PriceToEstimateFeeShipping=@priceToEstimateFeeShipping, PriceToEstimateFeePoints=@priceToEstimateFeePoints,
|
||||
ReferralFee=@referralFee, VariableClosingFee=@variableClosingFee, PerItemFee=@perItemFee, FBAFee=@fbaFee,
|
||||
OtherFee_Exception=@otherFee_Exception, currencyCode=CurrencyCode
|
||||
WHERE ProductID = " + sqlProductId + @"
|
||||
IF @@ROWCOUNT = 0
|
||||
INSERT INTO tblAmazonFeeEstimate (
|
||||
ProductID, IsAmazonFulfilled, TimeOfFeeEstimation, TotalFeeEstimate, PriceToEstimateFeeListingPrice,
|
||||
PriceToEstimateFeeShipping, PriceToEstimateFeePoints, ReferralFee, VariableClosingFee, PerItemFee, FBAFee,
|
||||
OtherFee_Exception, CurrencyCode
|
||||
) VALUES (
|
||||
" + sqlProductId + @", @isAmazonFulfilled, @timeOfFeeEstimation, @totalFeeEstimate, @priceToEstimateFeeListingPrice,
|
||||
@priceToEstimateFeeShipping, @priceToEstimateFeePoints, @referralFee, @variableClosingFee, @perItemFee, @fbaFee,
|
||||
@otherFee_Exception, @currencyCode
|
||||
)
|
||||
";
|
||||
|
||||
using (SqlConnection sqlConn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
sqlConn.Open();
|
||||
using (SqlCommand sqlCommand = new SqlCommand(sql, sqlConn))
|
||||
{
|
||||
sqlCommand.Parameters.AddWithValue("@asin", asin);
|
||||
sqlCommand.Parameters.AddWithValue("@isAmazonFulfilled", isAmazonFulfilled);
|
||||
sqlCommand.Parameters.AddWithValue("@timeOfFeeEstimation", timeOfFeeEstimation);
|
||||
sqlCommand.Parameters.AddWithValue("@totalFeeEstimate", totalFeeEstimate);
|
||||
sqlCommand.Parameters.AddWithValue("@priceToEstimateFeeListingPrice", priceToEstimateFeeListingPrice);
|
||||
sqlCommand.Parameters.AddWithValue("@priceToEstimateFeeShipping", priceToEstimateFeeShipping);
|
||||
sqlCommand.Parameters.AddWithValue("@priceToEstimateFeePoints", priceToEstimateFeePoints);
|
||||
sqlCommand.Parameters.AddWithValue("@referralFee", referralFee);
|
||||
sqlCommand.Parameters.AddWithValue("@variableClosingFee", variableClosingFee);
|
||||
sqlCommand.Parameters.AddWithValue("@perItemFee", perItemFee);
|
||||
sqlCommand.Parameters.AddWithValue("@fbaFee", fulfillmentFees);
|
||||
sqlCommand.Parameters.AddWithValue("@otherFee_Exception", otherFee_Exception);
|
||||
sqlCommand.Parameters.AddWithValue("@currencyCode", currencyCode);
|
||||
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,8 @@ namespace bnhtrade.Core.Data.Database
|
||||
return;
|
||||
}
|
||||
|
||||
var distinctList = orValueList.Distinct().ToList();
|
||||
|
||||
string sqlWhere = @"
|
||||
";
|
||||
|
||||
@@ -61,7 +63,7 @@ namespace bnhtrade.Core.Data.Database
|
||||
sqlWhere += " " + columnReference + " IN ( ";
|
||||
|
||||
var paramters = new Dictionary<string, object>();
|
||||
int listCount = orValueList.Count();
|
||||
int listCount = distinctList.Count();
|
||||
for (int i = 0; i < listCount; i++, parameterCount++)
|
||||
{
|
||||
if (i > 0)
|
||||
@@ -71,7 +73,7 @@ namespace bnhtrade.Core.Data.Database
|
||||
|
||||
string param = "@parameter" + parameterCount;
|
||||
sqlWhere += param;
|
||||
paramters.Add(param, orValueList[i]);
|
||||
paramters.Add(param, distinctList[i]);
|
||||
}
|
||||
sqlWhere += " )";
|
||||
|
||||
|
||||
@@ -12,13 +12,11 @@ namespace bnhtrade.Core.Logic.Export
|
||||
{
|
||||
public class AmazonSubmitFile
|
||||
{
|
||||
private string sqlConnectionString;
|
||||
private Logic.Utilities.StringCheck stringCheck = new Logic.Utilities.StringCheck();
|
||||
private Log.LogEvent log = new Log.LogEvent();
|
||||
|
||||
public AmazonSubmitFile(string sqlConnectionString)
|
||||
public AmazonSubmitFile()
|
||||
{
|
||||
this.sqlConnectionString = sqlConnectionString;
|
||||
}
|
||||
|
||||
public void SubmitInventoryLoader(MemoryStream stream)
|
||||
|
||||
@@ -9,17 +9,29 @@ namespace bnhtrade.Core.Logic.Product
|
||||
public class GetCompetitivePrice
|
||||
{
|
||||
private Dictionary<string, Model.Product.CompetitivePrice> competitivePrices;
|
||||
private int newConditionId = Data.Database.Constants.GetProductConditionIdNew();
|
||||
private string sqlConnectionString;
|
||||
private int newConditionId = (int)Data.Database.Constants.SkuCondition.New;
|
||||
private Data.Database.Product.ReadCompetitivePrice read;
|
||||
private List<string> productIdList;
|
||||
private List<string> conditionIdList;
|
||||
private Data.Database.Product.ReadCompetitivePrice dbRead;
|
||||
private Dictionary<int, decimal> newConditionMultipier;
|
||||
|
||||
public GetCompetitivePrice(string sqlConnectionString)
|
||||
public GetCompetitivePrice()
|
||||
{
|
||||
this.sqlConnectionString = sqlConnectionString;
|
||||
// was poart of a fba repricing feature, that, for now, is being abandoned
|
||||
throw new NotImplementedException();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dbRead = new Data.Database.Product.ReadCompetitivePrice();
|
||||
newConditionMultipier = new Dictionary<int, decimal>();
|
||||
}
|
||||
|
||||
@@ -8,15 +8,13 @@ namespace bnhtrade.Core.Logic.Sku
|
||||
{
|
||||
public class GetSkuInfo
|
||||
{
|
||||
private string sqlConnectionString;
|
||||
private Data.Database.Sku.ReadSku dbSkuInfo;
|
||||
private Logic.Product.GetProductInfo getProductInfo;
|
||||
private Logic.Sku.GetSkuConditionInfo getConditionInfo;
|
||||
private Logic.Account.GetTaxCodeInfo getTaxCodeInfo;
|
||||
|
||||
public GetSkuInfo(string sqlConnection)
|
||||
public GetSkuInfo()
|
||||
{
|
||||
this.sqlConnectionString = sqlConnection;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,10 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
||||
{
|
||||
public class FbaPricing
|
||||
{
|
||||
private string sqlConnectionString;
|
||||
private bnhtrade.Core.Logic.Log.LogEvent log = new Log.LogEvent();
|
||||
string err = "FbaPricing Error: ";
|
||||
private string marginSchemeTaxCode = Data.Database.Constants.GetMarginSchemeTaxCode();
|
||||
private int newConditionId = Data.Database.Constants.GetProductConditionIdNew();
|
||||
private int newConditionId = (int)Data.Database.Constants.SkuCondition.New;
|
||||
private List<Model.Sku.Price.SkuRepriceInfo> skuInfo;
|
||||
private Dictionary<string, Model.Product.CompetitivePrice> competitivePrices;
|
||||
DateTime newTimeStamp = DateTime.UtcNow;
|
||||
@@ -28,7 +27,25 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
||||
|
||||
public FbaPricing(string sqlConnectionString)
|
||||
{
|
||||
this.sqlConnectionString = sqlConnectionString;
|
||||
// was part of a fba repricing feature, that, for now, is being abandoned
|
||||
throw new NotImplementedException();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
taxCalc = new Account.TaxCalculation();
|
||||
newTimeStamp = DateTime.UtcNow;
|
||||
marginSchemeMargin = taxCalc.GetMarginMultiplier(newTimeStamp);
|
||||
@@ -45,11 +62,14 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
||||
string orderChannel = Data.Database.Constants.GetOrderChannelAmazonUk(); ; // may in future enable other order channels
|
||||
|
||||
// get SKU quantities in stock on FBA
|
||||
var statusTypeList = new List<int> { 3, 4 };
|
||||
var statusTypeList = new List<int>();
|
||||
statusTypeList.Add((int)Data.Database.Constants.StockStatusType.FbaInventoryActive);
|
||||
statusTypeList.Add((int)Data.Database.Constants.StockStatusType.FbaShipment);
|
||||
|
||||
var fbaSkuStock = new Logic.Stock.GetStatusTypeBalance().BySku(statusTypeList);
|
||||
|
||||
// retrive SKU info
|
||||
var getSku = new Logic.Sku.GetSkuInfo(sqlConnectionString);
|
||||
var getSku = new Logic.Sku.GetSkuInfo();
|
||||
var skuInfoDict = getSku.ConvertToDictionary(getSku.BySkuNumber(fbaSkuStock.Keys.ToList()));
|
||||
|
||||
|
||||
@@ -65,7 +85,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
||||
|
||||
|
||||
|
||||
// get current sku base pricing details (stock quantity, competative price, VAT info, etc.)
|
||||
// pull current sku base pricing details (stock quantity, competative price, VAT info, etc.) from the database
|
||||
skuInfo = new Data.Database.Sku.Price.ReadParameter().Execute();
|
||||
if (skuInfo == null || !skuInfo.Any())
|
||||
{
|
||||
@@ -78,18 +98,18 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
||||
var loader = new List<Model.Export.AmazonIventoryLoaderFile>();
|
||||
var crDictionary = new Dictionary<string, Model.Sku.Price.PriceInfo>();
|
||||
|
||||
// open needed classes
|
||||
// instanlise needed classes
|
||||
var readAge = new Data.Database.Import.AmazonFbaInventoryAgeRead();
|
||||
|
||||
// get current db pricing
|
||||
// get current pricing from database
|
||||
var dbDictionary = new Data.Database.Sku.Price.ReadPricingDetail().ReadDictionary(skuInfo.Select(o => o.SkuNumber).ToList(), orderChannel);
|
||||
|
||||
// get required competivie prices
|
||||
var readComp = new Logic.Product.GetCompetitivePrice(sqlConnectionString);
|
||||
var readComp = new Logic.Product.GetCompetitivePrice();
|
||||
readComp.EstimatePrice = true;
|
||||
var compPrices = readComp.Execute(skuInfo);
|
||||
|
||||
// loop through skus returnd from stock query
|
||||
// loop through sku pricing returned from database
|
||||
for (int i = 0; i < skuInfo.Count(); i++)
|
||||
{
|
||||
var existing = skuInfo[i];
|
||||
@@ -122,7 +142,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
||||
cr.InventoryAgeMax = invAge.Value.MaxAge;
|
||||
|
||||
// get minimum prices
|
||||
cr.UnitMinPriceCost = GetMinPriceCost(i);
|
||||
cr.UnitMinPriceCost = GetPriceBreakEven(i);
|
||||
cr.UnitMinPriceProfit = GetMinPriceProfit(i);
|
||||
cr.UnitPurchaseCost = skuInfo[i].UnitCostAverage;
|
||||
|
||||
@@ -224,12 +244,17 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, Model.Sku.Price.SkuRepriceInfo> GetSkuPricingInfo()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the minimum sale price to break even.
|
||||
/// </summary>
|
||||
/// <param name="i"></param>
|
||||
/// <returns></returns>
|
||||
private decimal GetMinPriceCost(int i)
|
||||
private decimal GetPriceBreakEven(int i)
|
||||
{
|
||||
decimal costPrice = skuInfo[i].UnitCostAverage;
|
||||
decimal agentFeeFixed = skuInfo[i].AgentFeeFixed;
|
||||
@@ -353,7 +378,7 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
||||
lastPriceUpdate = new DateTime(lastPriceUpdate.Year, lastPriceUpdate.Month, lastPriceUpdate.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. <------- Why??? don't know what my reasoning was for this
|
||||
if (today.DayOfWeek == DayOfWeek.Tuesday || today.DayOfWeek == DayOfWeek.Wednesday || today.DayOfWeek == DayOfWeek.Thursday)
|
||||
{
|
||||
if (today > lastPriceUpdate.AddDays(3))
|
||||
@@ -432,8 +457,8 @@ namespace bnhtrade.Core.Logic.Sku.Price
|
||||
csv.WriteRecords(exportList);
|
||||
}
|
||||
|
||||
// submit file to database and amazon mws
|
||||
var submit = new Logic.Export.AmazonSubmitFile(sqlConnectionString);
|
||||
// submit file to database and amazon
|
||||
var submit = new Logic.Export.AmazonSubmitFile();
|
||||
|
||||
return; // remove after testing
|
||||
|
||||
|
||||
@@ -50,4 +50,4 @@ namespace bnhtrade.Core.Model.Sku.Price
|
||||
|
||||
public decimal PriceMinProfit { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,4 +50,4 @@ namespace bnhtrade.Core.Model.Sku.Price
|
||||
|
||||
public decimal PriceMinProfit { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/bnhtrade.Core/Test/AmazonMWS/Report.cs
Normal file
28
src/bnhtrade.Core/Test/AmazonMWS/Report.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Test.AmazonMWS
|
||||
{
|
||||
public class Report
|
||||
{
|
||||
private string sqlConnectionString;
|
||||
public Report(string sqlConnectionString)
|
||||
{
|
||||
this.sqlConnectionString = sqlConnectionString;
|
||||
|
||||
// method you want to start here
|
||||
GetRport();
|
||||
|
||||
}
|
||||
public void GetRport()
|
||||
{
|
||||
string mwsReportEnum = "_GET_FBA_FULFILLMENT_INVENTORY_RECEIPTS_DATA_";
|
||||
DateTime start = new DateTime(2020, 10, 01);
|
||||
DateTime finish = new DateTime(2020, 11, 03);
|
||||
var result = new bnhtrade.Core.AmazonReport().GetMwsReportByPeriod(mwsReportEnum, start, finish, 12, 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace bnhtrade.Core.Test.Export
|
||||
var memStream = new MemoryStream();
|
||||
filestream.CopyTo(memStream);
|
||||
|
||||
var logicBit = new Core.Logic.Export.AmazonSubmitFile(sqlConnectionString);
|
||||
var logicBit = new Core.Logic.Export.AmazonSubmitFile();
|
||||
logicBit.SubmitInventoryLoader(memStream);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace bnhtrade.Core.Test.Sku
|
||||
this.sqlConnectionString = sqlConnectionString;
|
||||
|
||||
// method you want to start here
|
||||
UpdateFbaPricing();
|
||||
GetSkuInfo();
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,14 @@ namespace bnhtrade.Core.Test.Sku
|
||||
var instance = new bnhtrade.Core.Logic.Sku.Price.FbaPricing(sqlConnectionString);
|
||||
instance.Update();
|
||||
}
|
||||
|
||||
public void GetSkuInfo()
|
||||
{
|
||||
var inst = new bnhtrade.Core.Logic.Sku.GetSkuInfo();
|
||||
inst.IncludeConditionInfo = true;
|
||||
inst.IncludeProductInfo = true;
|
||||
inst.IncludeTaxCodeInfo = true;
|
||||
var ldskjflkdsa = inst.BySkuNumber("001234-10");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,6 @@
|
||||
<Compile Include="Logic\Product\AmazonEstimateFee.cs" />
|
||||
<Compile Include="Logic\Product\GetProductInfo.cs" />
|
||||
<Compile Include="Logic\Sku\GetSkuInfo.cs" />
|
||||
<Compile Include="Logic\Sku\Price\SkuRepriceInfo.cs" />
|
||||
<Compile Include="Logic\Stock\GetStatusTypeBalance.cs" />
|
||||
<Compile Include="Logic\Stock\StatusBalance.cs" />
|
||||
<Compile Include="Logic\Utilities\EasyMD5.cs" />
|
||||
@@ -280,6 +279,7 @@
|
||||
<Compile Include="Model\Sku\Price\DetailResponce.cs" />
|
||||
<Compile Include="Model\Sku\Price\PriceInfo.cs" />
|
||||
<Compile Include="Model\Sku\Price\SkuPriceParameter.cs" />
|
||||
<Compile Include="Model\Sku\Price\SkuRepriceInfo.cs" />
|
||||
<Compile Include="Model\Sku\Sku.cs" />
|
||||
<Compile Include="Model\Sku\SkuConditionInfo.cs" />
|
||||
<Compile Include="Model\Stock\JournalEntry.cs" />
|
||||
|
||||
Reference in New Issue
Block a user