|
| 1 | +using FikaAmazonAPI.ReportGeneration.ReportDataTable; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | + |
| 5 | +namespace FikaAmazonAPI.ReportGeneration |
| 6 | +{ |
| 7 | + public class FbaEstimateFeeReport |
| 8 | + { |
| 9 | + public List<FbaEstimateFeeReportRow> Data { get; set; } = new List<FbaEstimateFeeReportRow>(); |
| 10 | + public FbaEstimateFeeReport(string path, string refNumber) |
| 11 | + { |
| 12 | + if (string.IsNullOrEmpty(path)) |
| 13 | + return; |
| 14 | + |
| 15 | + var table = Table.ConvertFromCSV(path); |
| 16 | + |
| 17 | + List<FbaEstimateFeeReportRow> values = new List<FbaEstimateFeeReportRow>(); |
| 18 | + foreach (var row in table.Rows) |
| 19 | + { |
| 20 | + values.Add(FbaEstimateFeeReportRow.FromRow(row, refNumber)); |
| 21 | + } |
| 22 | + Data = values; |
| 23 | + } |
| 24 | + } |
| 25 | + public class FbaEstimateFeeReportRow |
| 26 | + { |
| 27 | + public string sku { get; set; } |
| 28 | + public string fnsku { get; set; } |
| 29 | + public string asin { get; set; } |
| 30 | + public string amazonStore { get; set; } |
| 31 | + public string productName { get; set; } |
| 32 | + public string productGroup { get; set; } |
| 33 | + public string brand { get; set; } |
| 34 | + public string fulfilledBy { get; set; } |
| 35 | + public decimal? yourPrice { get; set; } |
| 36 | + public decimal? salesPrice { get; set; } |
| 37 | + public decimal? longestSide { get; set; } |
| 38 | + public decimal? medianSide { get; set; } |
| 39 | + public decimal? shortestSide { get; set; } |
| 40 | + public decimal? lengthAndGirth { get; set; } |
| 41 | + public decimal? itemPackageWeight { get; set; } |
| 42 | + public decimal? estimatedFeeTotal { get; set; } |
| 43 | + public decimal? estimatedReferralFeePerUnit { get; set; } |
| 44 | + public decimal? estimatedPickPackFeePerUnit { get; set; } |
| 45 | + |
| 46 | + public decimal? ReferralFeePercentage |
| 47 | + { |
| 48 | + get |
| 49 | + { |
| 50 | + |
| 51 | + try |
| 52 | + { |
| 53 | + decimal? price = estimatedReferralFeePerUnit * 100 / yourPrice; |
| 54 | + return Math.Round(price.Value); |
| 55 | + } |
| 56 | + catch { return default(decimal?); } |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + |
| 61 | + public string unitOfDimension { get; set; } |
| 62 | + public string unitOfWeight { get; set; } |
| 63 | + public string currency { get; set; } |
| 64 | + public string refNumber { get; set; } |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + public static FbaEstimateFeeReportRow FromRow(TableRow rowData, string refNumber) |
| 70 | + { |
| 71 | + var row = new FbaEstimateFeeReportRow(); |
| 72 | + |
| 73 | + row.sku = rowData.GetString("sku"); |
| 74 | + row.fnsku = rowData.GetString("fnsku"); |
| 75 | + row.asin = rowData.GetString("asin"); |
| 76 | + row.amazonStore = rowData.GetString("amazon-store"); |
| 77 | + row.productName = rowData.GetString("product-name"); |
| 78 | + row.productGroup = rowData.GetString("product-group"); |
| 79 | + row.brand = rowData.GetString("brand"); |
| 80 | + row.fulfilledBy = rowData.GetString("fulfilled-by"); |
| 81 | + |
| 82 | + row.yourPrice = DataConverter.GetDecimal(rowData.GetString("your-price")); |
| 83 | + row.salesPrice = DataConverter.GetDecimal(rowData.GetString("sales-price")); |
| 84 | + row.longestSide = DataConverter.GetDecimal(rowData.GetString("longest-side")); |
| 85 | + row.medianSide = DataConverter.GetDecimal(rowData.GetString("median-side")); |
| 86 | + row.shortestSide = DataConverter.GetDecimal(rowData.GetString("shortest-side")); |
| 87 | + row.lengthAndGirth = DataConverter.GetDecimal(rowData.GetString("length-and-girth")); |
| 88 | + row.lengthAndGirth = DataConverter.GetDecimal(rowData.GetString("length-and-girth")); |
| 89 | + row.itemPackageWeight = DataConverter.GetDecimal(rowData.GetString("item-package-weight")); |
| 90 | + row.estimatedFeeTotal = DataConverter.GetDecimal(rowData.GetString("estimated-fee-total")); |
| 91 | + row.estimatedReferralFeePerUnit = DataConverter.GetDecimal(rowData.GetString("estimated-referral-fee-per-unit")); |
| 92 | + row.estimatedPickPackFeePerUnit = DataConverter.GetDecimal(rowData.GetString("estimated-pick-pack-fee-per-unit")); |
| 93 | + |
| 94 | + row.unitOfDimension = rowData.GetString("unit-of-dimension"); |
| 95 | + row.unitOfWeight = rowData.GetString("unit-of-weight"); |
| 96 | + row.currency = rowData.GetString("currency"); |
| 97 | + |
| 98 | + row.refNumber = refNumber; |
| 99 | + |
| 100 | + return row; |
| 101 | + } |
| 102 | + } |
| 103 | +} |
0 commit comments