-
-
Save fbanke/c017d47bf59325531a3e3da9fc02762c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<List<string>> FetchPrices() | |
{ | |
var priceData = DB.LoadPriceData(); | |
var parsed = new List<List<string>>(); | |
var costPriceField = 5; | |
foreach (var row in priceData) | |
{ | |
var price = row.Value; | |
parsed.Add(new List<string> | |
{ | |
BuildProductSku(price), | |
CalculatePrice(price[costPriceField]).ToString(), | |
price[costPriceField].ToString(), | |
}); | |
} | |
return parsed; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public (List<List<string>>, List<string>) Parse(IDictionary<string, List<string>> dbData, | |
IDictionary<string, List<string>> csvData, IDictionary<string, List<decimal>> prices) | |
{ | |
var parsedData = new List<List<string>>(); | |
var skipped = new List<string>(); | |
var skuField = 3; | |
var costPriceField = 5; | |
foreach (var line in dbData) | |
{ | |
var product = line.Value; | |
if (!Validate(product, csvData)) | |
{ | |
skipped.Add(product[skuField]); | |
continue; | |
} | |
var parsed = product.Clone(); | |
var price = CalculatePrice(prices[product[skuField]][costPriceField]); | |
parsed[8] = AddEnvironmentalFee(price); | |
parsedData.Add((List<string>) parsed); | |
} | |
return ( | |
parsedData, | |
skipped | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public decimal CalculatePrice(decimal costprice) | |
{ | |
var price = costprice / (100 - Margin) * 100; | |
return AddEnvironmentalFee(ApplyTax(price)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public decimal CalculatePrice(decimal costprice) | |
{ | |
var price = costprice / (100 - Margin) * 100; | |
return ApplyTax(price); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment