|
1 |
| -using System; |
| 1 | +using FikaAmazonAPI.ReportGeneration.ReportDataTable; |
| 2 | +using System; |
2 | 3 | using System.Collections.Generic;
|
3 |
| -using System.IO; |
4 |
| -using System.Linq; |
5 | 4 |
|
6 | 5 | namespace FikaAmazonAPI.ReportGeneration
|
7 | 6 | {
|
8 | 7 | public class InventoryAgingReport
|
9 | 8 | {
|
10 |
| - public List<InventoryAgingRow> Data { get; set; }=new List<InventoryAgingRow>(); |
| 9 | + public List<InventoryAgingRow> Data { get; set; } = new List<InventoryAgingRow>(); |
11 | 10 | public InventoryAgingReport(string path, string refNumber)
|
12 | 11 | {
|
13 | 12 | if (string.IsNullOrEmpty(path))
|
14 | 13 | return;
|
15 |
| - var values = File.ReadAllLines(path) |
16 |
| - .Skip(1) |
17 |
| - .Select(v => InventoryAgingRow.FromCsv(v, refNumber)) |
18 |
| - .ToList(); |
19 |
| - Data = values; |
20 |
| - } |
21 | 14 |
|
| 15 | + var table = Table.ConvertFromCSV(path); |
22 | 16 |
|
| 17 | + List<InventoryAgingRow> values = new List<InventoryAgingRow>(); |
| 18 | + foreach (var row in table.Rows) |
| 19 | + { |
| 20 | + values.Add(InventoryAgingRow.FromRow(row, refNumber)); |
| 21 | + } |
| 22 | + Data = values; |
| 23 | + } |
23 | 24 | }
|
24 | 25 | public class InventoryAgingRow
|
25 | 26 | {
|
@@ -51,40 +52,37 @@ public class InventoryAgingRow
|
51 | 52 | public string RecommendedAction { get; set; }
|
52 | 53 | public string refNumber { get; set; }
|
53 | 54 |
|
54 |
| - public static InventoryAgingRow FromCsv(string csvLine, string refNumber) |
| 55 | + public static InventoryAgingRow FromRow(TableRow rowData, string refNumber) |
55 | 56 | {
|
56 |
| - string[] values = csvLine.Split('\t'); |
57 | 57 | var row = new InventoryAgingRow();
|
58 |
| - row.SnapshotDate = DataConverter.GetDate(values[0], DataConverter.DateTimeFormate.DATE_AGING_FORMAT); |
59 |
| - row.SKU = values[1]; |
60 |
| - row.FNSKU = values[2]; |
61 |
| - row.ASIN = values[3]; |
62 |
| - row.ProductName = values[4]; |
63 |
| - row.Condition = values[5]; |
64 |
| - row.AvaliableQuantitySellable = DataConverter.GetInt(values[6]); |
65 |
| - row.QtyWithRemovalsInProgress = DataConverter.GetInt(values[7]); |
66 |
| - row.InvAge0To90Days = DataConverter.GetInt(values[8]); |
67 |
| - row.InvAge91To180Days = DataConverter.GetInt(values[9]); |
68 |
| - row.InvAge181To270Days = DataConverter.GetInt(values[10]); |
69 |
| - row.InvAge271To365Days = DataConverter.GetInt(values[11]); |
70 |
| - row.InvAge365PlusDays = DataConverter.GetInt(values[12]); |
71 |
| - row.Currency = values[13]; |
72 |
| - row.QtyToBeChargedLtsf12Mo = DataConverter.GetInt(values[14]); |
73 |
| - row.ProjectedLtsf12Mo = DataConverter.GetInt(values[15]); |
74 |
| - row.UnitsShippedLast7Days = DataConverter.GetInt(values[16]); |
75 |
| - row.UnitsShippedLast30Days = DataConverter.GetInt(values[17]); |
76 |
| - row.UnitsShippedLast60Days = DataConverter.GetInt(values[18]); |
77 |
| - row.UnitsShippedLast90Days = DataConverter.GetInt(values[19]); |
78 |
| - row.Alert = values[20]; |
79 |
| - row.YourPrice = DataConverter.GetDecimal(values[21]); |
80 |
| - row.SalesPrice = DataConverter.GetDecimal(values[22]); |
81 |
| - row.LowestPriceNew = DataConverter.GetDecimal(values[23]); |
82 |
| - row.LowestPriceUsed = DataConverter.GetDecimal(values[24]); |
83 |
| - row.RecommendedAction = values[25]; |
84 |
| - |
| 58 | + row.SnapshotDate = DataConverter.GetDate(rowData.GetString("snapshot-date"), DataConverter.DateTimeFormate.DATE_AGING_FORMAT); |
| 59 | + row.SKU = rowData.GetString("sku"); |
| 60 | + row.FNSKU = rowData.GetString("fnsku"); |
| 61 | + row.ASIN = rowData.GetString("asin"); |
| 62 | + row.ProductName = rowData.GetString("product-name"); |
| 63 | + row.Condition = rowData.GetString("condition"); |
| 64 | + row.AvaliableQuantitySellable = DataConverter.GetInt(rowData.GetString("avaliable-quantity(sellable)")); |
| 65 | + row.QtyWithRemovalsInProgress = DataConverter.GetInt(rowData.GetString("qty-with-removals-in-progress")); |
| 66 | + row.InvAge0To90Days = DataConverter.GetInt(rowData.GetString("inv-age-0-to-90-days")); |
| 67 | + row.InvAge91To180Days = DataConverter.GetInt(rowData.GetString("inv-age-91-to-180-days")); |
| 68 | + row.InvAge181To270Days = DataConverter.GetInt(rowData.GetString("inv-age-181-to-270-days")); |
| 69 | + row.InvAge271To365Days = DataConverter.GetInt(rowData.GetString("inv-age-271-to-365-days")); |
| 70 | + row.InvAge365PlusDays = DataConverter.GetInt(rowData.GetString("inv-age-365-plus-days")); |
| 71 | + row.Currency = rowData.GetString("currency"); |
| 72 | + row.QtyToBeChargedLtsf12Mo = DataConverter.GetInt(rowData.GetString("qty-to-be-charged-ltsf-12-mo")); |
| 73 | + row.ProjectedLtsf12Mo = DataConverter.GetInt(rowData.GetString("projected-ltsf-12-mo")); |
| 74 | + row.UnitsShippedLast7Days = DataConverter.GetInt(rowData.GetString("units-shipped-last-7-days")); |
| 75 | + row.UnitsShippedLast30Days = DataConverter.GetInt(rowData.GetString("units-shipped-last-30-days")); |
| 76 | + row.UnitsShippedLast60Days = DataConverter.GetInt(rowData.GetString("units-shipped-last-60-days")); |
| 77 | + row.UnitsShippedLast90Days = DataConverter.GetInt(rowData.GetString("units-shipped-last-90-days")); |
| 78 | + row.Alert = rowData.GetString("alert"); |
| 79 | + row.YourPrice = DataConverter.GetDecimal(rowData.GetString("your-price")); |
| 80 | + row.SalesPrice = DataConverter.GetDecimal(rowData.GetString("sales_price")); |
| 81 | + row.LowestPriceNew = DataConverter.GetDecimal(rowData.GetString("lowest_price_new")); |
| 82 | + row.LowestPriceUsed = DataConverter.GetDecimal(rowData.GetString("lowest_price_used")); |
| 83 | + row.RecommendedAction = rowData.GetString("Recommended action"); |
85 | 84 | row.refNumber = refNumber;
|
86 | 85 |
|
87 |
| - |
88 | 86 | return row;
|
89 | 87 | }
|
90 | 88 | }
|
|
0 commit comments