public static Dictionary<string, InvoiceModel> CreateRecurlyInvoices(List<string> contentOfFiles) { RatesHistoryModel ratesHistory = new RatesHistoryModel(); Dictionary<String, InvoiceModel> invoices = new Dictionary<string, InvoiceModel>(); String invoicesRecurly = getBasicInvoicesFromFiles(contentOfFiles); String accountsRecurly = getAccountsFromFiles(contentOfFiles); String billingsRecurly = getBillingsFromFiles(contentOfFiles); if (invoicesRecurly == null) { CSVtoXMLExporter.WarningMessage += "Nepodarilo sa najst invoices subor! "; return null; }; if (accountsRecurly == null) { CSVtoXMLExporter.WarningMessage += "Nepodarilo sa najst accounts subor! "; return null; }; if (billingsRecurly == null) { CSVtoXMLExporter.WarningMessage += "Nepodarilo sa najst billings subor! "; return null; }; string[] lines = CSVSplitter.SplitCsvToLines(invoicesRecurly); for (int i = 1; i < lines.Length; ++i) { var cells = CSVSplitter.SplitCsvLineToCells(lines[i]); InvoiceModel invoice = new InvoiceModel(); invoice = recurlyBasicInvoiceFromCells(invoice, cells); if ((invoice != null) && (invoice.line_item_total >= 0)) { invoice.rate = ratesHistory.getRateForDate(invoice.date, invoice.currency); if (!invoices.ContainsKey(invoice.id) && (!invoice.status.Equals("open"))) { invoices.Add(invoice.id, invoice); } } } lines = CSVSplitter.SplitCsvToLines(accountsRecurly); for (int i = 1; i < lines.Length; ++i) { var cells = CSVSplitter.SplitCsvLineToCells(lines[i]); var acc_id = cells[0]; InvoiceModel invoiceWithSameAccID = getInvoiceFromInvoicesByAccountId(invoices, acc_id); if (invoiceWithSameAccID != null) { addAccountInfoToInvoiceFromCells(invoiceWithSameAccID, cells); } } lines = CSVSplitter.SplitCsvToLines(billingsRecurly); for (int i = 1; i < lines.Length; ++i) { var cells = CSVSplitter.SplitCsvLineToCells(lines[i]); var acc_id = cells[0]; InvoiceModel invoiceWithSameAccID = getInvoiceFromInvoicesByAccountId(invoices, acc_id); if (invoiceWithSameAccID != null) { addBillingInfoToInvoiceFromCells(invoiceWithSameAccID, cells); } } return invoices; }
public static Dictionary<string, InvoiceModel> CreatePayPalInvoices(List<string> contentOfFiles) { RatesHistoryModel ratesHistory = new RatesHistoryModel(); Dictionary<String, InvoiceModel> invoices = new Dictionary<string, InvoiceModel>(); String invoicesPayPal = getPayPalInvoices(contentOfFiles); String accountsPayPal = getPayPalWinfAccountInfo(contentOfFiles); if (invoicesPayPal == null) { CSVtoXMLExporter.WarningMessage += "Nepodarilo sa najst invoices Paypal subor! \n"; return null; }; if (accountsPayPal == null) { CSVtoXMLExporter.WarningMessage += "Nepodarilo sa najst accounts PayPal-winf subor! \n"; return null; }; string[] lines = CSVSplitter.SplitCsvToLines(invoicesPayPal); for (int i = 1; i < lines.Length; ++i) { var cells = CSVSplitter.SplitCsvLineToCells(lines[i]); InvoiceModel invoice = paypalInvoiceFromCells(cells); if ((invoice != null)) { invoice.rate = ratesHistory.getRateForDate(invoice.date, invoice.currency); if (!invoices.ContainsKey(invoice.transactionId)) { invoices.Add(invoice.transactionId, invoice); } else { CSVtoXMLExporter.WarningMessage += "Pozor, boli dve rovnake transaction id keys v dictionary, treba premysliet"; } } } lines = CSVSplitter.SplitCsvToLines(accountsPayPal); for (int i = 1; i < lines.Length; ++i) { var cells = CSVSplitter.SplitCsvLineToCells(lines[i]); var transactionId = cells[0]; // transaction id InvoiceModel invoiceWithSameTransactionId = getInvoiceFromInvoicesByTransactionId(invoices, transactionId); if (invoiceWithSameTransactionId != null) { addPayPalAccountInfoToInvoiceFromCells(invoiceWithSameTransactionId, cells); } } return invoices; }