Skip to content

Commit 411393c

Browse files
committed
fix #325
1 parent 21ba961 commit 411393c

File tree

1 file changed

+38
-40
lines changed

1 file changed

+38
-40
lines changed

Source/FikaAmazonAPI/ReportGeneration/InventoryAgingReport.cs

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
using System;
1+
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
2+
using System;
23
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
54

65
namespace FikaAmazonAPI.ReportGeneration
76
{
87
public class InventoryAgingReport
98
{
10-
public List<InventoryAgingRow> Data { get; set; }=new List<InventoryAgingRow>();
9+
public List<InventoryAgingRow> Data { get; set; } = new List<InventoryAgingRow>();
1110
public InventoryAgingReport(string path, string refNumber)
1211
{
1312
if (string.IsNullOrEmpty(path))
1413
return;
15-
var values = File.ReadAllLines(path)
16-
.Skip(1)
17-
.Select(v => InventoryAgingRow.FromCsv(v, refNumber))
18-
.ToList();
19-
Data = values;
20-
}
2114

15+
var table = Table.ConvertFromCSV(path);
2216

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+
}
2324
}
2425
public class InventoryAgingRow
2526
{
@@ -51,40 +52,37 @@ public class InventoryAgingRow
5152
public string RecommendedAction { get; set; }
5253
public string refNumber { get; set; }
5354

54-
public static InventoryAgingRow FromCsv(string csvLine, string refNumber)
55+
public static InventoryAgingRow FromRow(TableRow rowData, string refNumber)
5556
{
56-
string[] values = csvLine.Split('\t');
5757
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");
8584
row.refNumber = refNumber;
8685

87-
8886
return row;
8987
}
9088
}

0 commit comments

Comments
 (0)