|
| 1 | +using FikaAmazonAPI.ReportGeneration.ReportDataTable; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.IO; |
| 5 | +using System.Linq; |
| 6 | + |
| 7 | +namespace FikaAmazonAPI.ReportGeneration |
| 8 | +{ |
| 9 | + public class OrderInvoicingReport |
| 10 | + { |
| 11 | + public List<OrderInvoicingReportRow> Data { get; set; } = new List<OrderInvoicingReportRow>(); |
| 12 | + public OrderInvoicingReport(string path, string refNumber) |
| 13 | + { |
| 14 | + if (string.IsNullOrEmpty(path)) |
| 15 | + return; |
| 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 | + } |
| 24 | + Data = values; |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + |
| 29 | + public class OrderInvoicingReportRow |
| 30 | + { |
| 31 | + public string AmazonOrderId { get; set; } |
| 32 | + public string OrderItemId { get; set; } |
| 33 | + public DateTime? PurchaseDate{ get; set; } |
| 34 | + public DateTime? PaymentDate { get; set; } |
| 35 | + public string BuyerEmail { get; set; } |
| 36 | + public string BuyerName { get; set; } |
| 37 | + public string PaymentMethodeDetails { get; set; } |
| 38 | + public string BuyerPhoneNumber { get; set; } |
| 39 | + public string SKU { get; set; } |
| 40 | + public string ProductName { get; set; } |
| 41 | + public decimal? Quantity { get; set; } |
| 42 | + public string Currency { get; set; } |
| 43 | + public decimal? ItemPrice { get; set; } |
| 44 | + public decimal? ItemTax { get; set; } |
| 45 | + public decimal? ShippingPrice { get; set; } |
| 46 | + public decimal? ShippingTax { get; set; } |
| 47 | + public string ShipServiceLevel { get; set; } |
| 48 | + public string RecipientName { get; set; } |
| 49 | + public string ShipAddress1 { get; set; } |
| 50 | + public string ShipAddress2 { get; set; } |
| 51 | + public string ShipAddress3 { get; set; } |
| 52 | + public string ShipCity { get; set; } |
| 53 | + public string ShipState { get; set; } |
| 54 | + public string ShipPostalCode { get; set; } |
| 55 | + public string ShipCountry { get; set; } |
| 56 | + public string ShipPhoneNumber { get; set; } |
| 57 | + public string BillAddress1 { get; set; } |
| 58 | + public string BillAddress2 { get; set; } |
| 59 | + public string BillAddress3 { get; set; } |
| 60 | + public string BillCity { get; set; } |
| 61 | + public string BillState { get; set; } |
| 62 | + public string BillPostalCode { get; set; } |
| 63 | + public string BillCountry { get; set; } |
| 64 | + public string DeliveryIndustructions { get; set; } |
| 65 | + public string SalesChannel { get; set; } |
| 66 | + public string BuyerCompany { get; set; } |
| 67 | + public string BuyerTaxRegistationId { get; set; } |
| 68 | + public string BuyerTaxRegistationCountry { get; set; } |
| 69 | + public string refNumber { get; set; } |
| 70 | + |
| 71 | + public OrderInvoicingReportRow() |
| 72 | + { |
| 73 | + |
| 74 | + } |
| 75 | + |
| 76 | + public static OrderInvoicingReportRow FromRow(TableRow rowData, string refNumber) |
| 77 | + { |
| 78 | + var row = new OrderInvoicingReportRow(); |
| 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 | + |
| 119 | + return row; |
| 120 | + } |
| 121 | + } |
| 122 | +} |
0 commit comments