1
- using System ;
1
+ using FikaAmazonAPI . ReportGeneration . ReportDataTable ;
2
+ using System ;
2
3
using System . Collections . Generic ;
3
4
using System . IO ;
4
5
using System . Linq ;
@@ -12,10 +13,14 @@ public OrderInvoicingReport(string path, string refNumber)
12
13
{
13
14
if ( string . IsNullOrEmpty ( path ) )
14
15
return ;
15
- var values = File . ReadAllLines ( path )
16
- . Skip ( 1 )
17
- . Select ( v => OrderInvoicingReportRow . FromCsv ( v , refNumber ) )
18
- . ToList ( ) ;
16
+
17
+ var table = Table . ConvertFromCSV ( path ) ;
18
+
19
+ List < OrderInvoicingReportRow > values = new List < OrderInvoicingReportRow > ( ) ;
20
+ foreach ( var row in table . Rows )
21
+ {
22
+ values . Add ( OrderInvoicingReportRow . FromRow ( row , refNumber ) ) ;
23
+ }
19
24
Data = values ;
20
25
}
21
26
}
@@ -61,60 +66,57 @@ public class OrderInvoicingReportRow
61
66
public string BuyerCompany { get ; set ; }
62
67
public string BuyerTaxRegistationId { get ; set ; }
63
68
public string BuyerTaxRegistationCountry { get ; set ; }
69
+ public string refNumber { get ; set ; }
64
70
65
71
public OrderInvoicingReportRow ( )
66
72
{
67
73
68
74
}
69
75
70
- public static OrderInvoicingReportRow FromCsv ( string csvLine , string refNumber )
76
+ public static OrderInvoicingReportRow FromRow ( TableRow rowData , string refNumber )
71
77
{
72
- string [ ] values = csvLine . Split ( '\t ' ) ;
73
78
var row = new OrderInvoicingReportRow ( ) ;
74
- row . AmazonOrderId = values [ 0 ] ;
75
- row . OrderItemId = values [ 1 ] ;
76
- row . PurchaseDate = DataConverter . GetDate ( values [ 2 ] , DataConverter . DateTimeFormate . DATETIME_K_FORMAT ) ;
77
- row . PaymentDate = DataConverter . GetDate ( values [ 3 ] , DataConverter . DateTimeFormate . DATETIME_K_FORMAT ) ;
78
- row . BuyerEmail = values [ 4 ] ;
79
- row . BuyerName = values [ 5 ] ;
80
- row . PaymentMethodeDetails = values [ 6 ] ;
81
- row . BuyerPhoneNumber = values [ 7 ] ;
82
- row . SKU = values [ 8 ] ;
83
- row . ProductName = values [ 9 ] ;
84
- row . Quantity = DataConverter . GetInt ( values [ 10 ] ) ;
85
- row . Currency = values [ 11 ] ;
86
- row . ItemPrice = DataConverter . GetDecimal ( values [ 12 ] ) ;
87
- row . ItemTax = DataConverter . GetDecimal ( values [ 13 ] ) ;
88
- row . ShippingPrice = DataConverter . GetDecimal ( values [ 14 ] ) ;
89
- row . ShippingTax = DataConverter . GetDecimal ( values [ 15 ] ) ;
90
- row . ShipServiceLevel = values [ 16 ] ;
91
- row . RecipientName = values [ 17 ] ;
92
- row . ShipAddress1 = values [ 18 ] ;
93
- row . ShipAddress2 = values [ 19 ] ;
94
- row . ShipAddress3 = values [ 20 ] ;
95
- row . ShipCity = values [ 21 ] ;
96
- row . ShipState = values [ 22 ] ;
97
- row . ShipPostalCode = values [ 23 ] ;
98
- row . ShipCountry = values [ 24 ] ;
99
- row . ShipPhoneNumber = values [ 25 ] ;
100
- row . BillAddress1 = values [ 26 ] ;
101
- row . BillAddress2 = values [ 27 ] ;
102
- row . BillAddress3 = values [ 28 ] ;
103
- row . BillCity = values [ 29 ] ;
104
- row . BillState = values [ 30 ] ;
105
- row . BillPostalCode = values [ 31 ] ;
106
- row . BillCountry = values [ 32 ] ;
107
- row . DeliveryIndustructions = values [ 36 ] ;
108
- row . SalesChannel = values [ 37 ] ;
109
- row . BuyerCompany = values [ 50 ] ;
110
- row . BuyerTaxRegistationId = values [ 53 ] ;
111
- row . BuyerTaxRegistationCountry = values [ 54 ] ;
79
+ row . AmazonOrderId = rowData . GetString ( "order-id" ) ;
80
+ row . OrderItemId = rowData . GetString ( "order-item-id" ) ;
81
+ row . PurchaseDate = DataConverter . GetDate ( rowData . GetString ( "purchase-date" ) , DataConverter . DateTimeFormate . DATETIME_K_FORMAT ) ;
82
+ row . PaymentDate = DataConverter . GetDate ( rowData . GetString ( "payments-date" ) , DataConverter . DateTimeFormate . DATETIME_K_FORMAT ) ;
83
+ row . BuyerEmail = rowData . GetString ( "buyer-email" ) ;
84
+ row . BuyerName = rowData . GetString ( "buyer-name" ) ;
85
+ row . PaymentMethodeDetails = rowData . GetString ( "payment-method-details" ) ;
86
+ row . BuyerPhoneNumber = rowData . GetString ( "buyer-phone-number" ) ;
87
+ row . SKU = rowData . GetString ( "sku" ) ;
88
+ row . ProductName = rowData . GetString ( "product-name" ) ;
89
+ row . Quantity = rowData . GetDecimal ( "quantity-purchased" ) ;
90
+ row . Currency = rowData . GetString ( "currency" ) ;
91
+ row . ItemPrice = rowData . GetDecimal ( "item-price" ) ;
92
+ row . ItemTax = rowData . GetDecimal ( "item-tax" ) ;
93
+ row . ShippingPrice = rowData . GetDecimal ( "shipping-price" ) ;
94
+ row . ShippingTax = rowData . GetDecimal ( "shipping-tax" ) ;
95
+ row . ShipServiceLevel = rowData . GetString ( "ship-service-level" ) ;
96
+ row . RecipientName = rowData . GetString ( "recipient-name" ) ;
97
+ row . ShipAddress1 = rowData . GetString ( "ship-address-1" ) ;
98
+ row . ShipAddress2 = rowData . GetString ( "ship-address-2" ) ;
99
+ row . ShipAddress3 = rowData . GetString ( "ship-address-3" ) ;
100
+ row . ShipCity = rowData . GetString ( "ship-city" ) ;
101
+ row . ShipState = rowData . GetString ( "ship-state" ) ;
102
+ row . ShipPostalCode = rowData . GetString ( "ship-postal-code" ) ;
103
+ row . ShipCountry = rowData . GetString ( "ship-country" ) ;
104
+ row . ShipPhoneNumber = rowData . GetString ( "ship-phone-number" ) ;
105
+ row . BillAddress1 = rowData . GetString ( "bill-address-1" ) ;
106
+ row . BillAddress2 = rowData . GetString ( "bill-address-2" ) ;
107
+ row . BillAddress3 = rowData . GetString ( "bill-address-3" ) ;
108
+ row . BillCity = rowData . GetString ( "bill-city" ) ;
109
+ row . BillState = rowData . GetString ( "bill-state" ) ;
110
+ row . BillPostalCode = rowData . GetString ( "bill-postal-code" ) ;
111
+ row . BillCountry = rowData . GetString ( "bill-country" ) ;
112
+ row . DeliveryIndustructions = rowData . GetString ( "delivery-Instructions" ) ;
113
+ row . SalesChannel = rowData . GetString ( "sales-channel" ) ;
114
+ row . BuyerCompany = rowData . GetString ( "buyer-company-name" ) ;
115
+ row . BuyerTaxRegistationId = rowData . GetString ( "buyer-tax-registration-id" ) ;
116
+ row . BuyerTaxRegistationCountry = rowData . GetString ( "buyer-tax-registration-country" ) ;
117
+ row . refNumber = refNumber ;
118
+
112
119
return row ;
113
120
}
114
121
}
115
-
116
-
117
-
118
-
119
-
120
122
}
0 commit comments