Skip to content

Commit 966167e

Browse files
committed
add new report to report manager GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA
1 parent fcfd875 commit 966167e

File tree

2 files changed

+127
-4
lines changed

2 files changed

+127
-4
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
}

Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using FikaAmazonAPI.Utils;
1+
using FikaAmazonAPI.AmazonSpApiSDK.Models.Reports;
2+
using FikaAmazonAPI.Utils;
23
using System;
34
using System.Collections.Generic;
5+
using System.Threading;
46
using System.Threading.Tasks;
5-
using FikaAmazonAPI.AmazonSpApiSDK.Models.Reports;
67
using static FikaAmazonAPI.Utils.Constants;
7-
using System.Threading;
88

99
namespace FikaAmazonAPI.ReportGeneration
1010
{
@@ -90,7 +90,7 @@ public async Task<List<ReturnFBAOrderRow>> GetReturnFBAOrderAsync(DateTime fromD
9090

9191
private async Task<string> GetReturnFBAOrderAsync(AmazonConnection amazonConnection, DateTime fromDate, DateTime toDate, List<MarketPlace> marketplaces = null, CancellationToken cancellationToken = default)
9292
{
93-
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA, fromDate, toDate, marketplaces: marketplaces, cancellationToken: cancellationToken);
93+
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA, fromDate, toDate, marketplaces: marketplaces, cancellationToken: cancellationToken);
9494
}
9595

9696

@@ -343,5 +343,25 @@ private async Task<string> GetInventoryPlanningDataAsync(AmazonConnection amazon
343343
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_FBA_INVENTORY_PLANNING_DATA);
344344
}
345345
#endregion
346+
347+
#region FbaEstimateFee
348+
public List<FbaEstimateFeeReportRow> GetFbaEstimateFeeData(DateTime fromDate, DateTime toDate) =>
349+
Task.Run(() => GetFbaEstimateFeeDataAsync(fromDate, toDate)).ConfigureAwait(false).GetAwaiter().GetResult();
350+
public async Task<List<FbaEstimateFeeReportRow>> GetFbaEstimateFeeDataAsync(DateTime fromDate, DateTime toDate)
351+
{
352+
List<FbaEstimateFeeReportRow> list = new List<FbaEstimateFeeReportRow>();
353+
354+
var path = await GetFbaEstimateFeeDataAsync(_amazonConnection, fromDate, toDate);
355+
FbaEstimateFeeReport report = new FbaEstimateFeeReport(path, _amazonConnection.RefNumber);
356+
list.AddRange(report.Data);
357+
358+
return list;
359+
}
360+
private async Task<string> GetFbaEstimateFeeDataAsync(AmazonConnection amazonConnection, DateTime fromDate, DateTime toDate)
361+
{
362+
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA, fromDate, toDate);
363+
}
364+
#endregion
365+
346366
}
347367
}

0 commit comments

Comments
 (0)