/// <summary>
        /// Returns an InvoiceTransmission with values from the 
        /// FlatCargoFile parameter
        /// 
        /// </summary>
        /// <param name="primeFile"></param>
        /// <returns></returns>
        public InvoiceTransmission GetInvoiceTransmission(FlatPrimeFile primeFile, FlatRejectionFile rejectionFile, string iATAPeriod)
        {
            _iATAPeriod = iATAPeriod;
            List<Invoice> allInvoices = new List<Invoice>();

            //create transmission header
            _invoiceTransmission = new InvoiceTransmission();
            _invoiceTransmission.TransmissionHeader = GetTransmissionHeader();

            //add primeInvoices
            allInvoices.AddRange(GetInvoices(primeFile));
            //add rejection invoices
            allInvoices.AddRange(GetInvoices(rejectionFile));

            _invoiceTransmission.Invoice = allInvoices.ToArray();

            //Transmission Summary
            _invoiceTransmission.TransmissionSummary = new TransmissionSummary();
            _invoiceTransmission.TransmissionSummary.InvoiceCount = allInvoices.Count.ToString();
            _invoiceTransmission.TransmissionSummary.TotalAmount = GetAmountsPerCurrency().ToArray();
            return _invoiceTransmission;
        }
 /// <summary>
 /// Returns all rejection invoices in a list
 /// </summary>
 /// <param name="rejectionFile"></param>
 /// <returns></returns>
 private List<Invoice> GetInvoices(FlatRejectionFile rejectionFile)
 {
     List<Invoice> rejections = new List<Invoice>();
     int batchSequenceNumber = 1;
     foreach (List<FlatRejectionRecord> flatRejectionFileInvoice in rejectionFile.GetInvoices())
     {
         rejections.Add(GetInvoice(flatRejectionFileInvoice, batchSequenceNumber));
         batchSequenceNumber += 1;
     }
     return rejections;
 }
 /// <summary>
 /// Loads teh rejection file
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnTryLoadRejectionFile_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtRejectionFile.Text))
     {
         txtRejectionFileLoadResults.Text = "";
         CsvParser<FlatRejectionRecord> csvParser = new CsvParser<FlatRejectionRecord>();
         csvParser.ValidationErrorOccurred += new CsvParser<FlatRejectionRecord>.ValidationErrorOccuredHandler(csvParser_RejectionErrorOccurred);
         try
         {
             txtRejectionFileLoadResults.Text += "Start reading file...\r\n";
             _flatRejectionFile = new FlatRejectionFile(csvParser.ReadFromFile(txtRejectionFile.Text, ";", chkHasHeaders.Checked));
             txtRejectionFileLoadResults.Text += "\r\nEnd reading file.";
             txtRejectionFileLoadResults.Text += string.Format("Total {0} of {1} lines imported.", csvParser.ImportedLineCount, csvParser.TotalLineCount);
             if (_flatRejectionFile.GetInvoiceCount() > 0 || _flatCargoFile.GetInvoiceCount() > 0)
                 this.btnNext.Enabled = true;
             else
                 this.btnNext.Enabled = false;
         }
         catch (IOException ex)
         {
             txtRejectionFileLoadResults.AppendText(ex.Message + "\r\n");
         }
         catch (Exception ex)
         {
             txtRejectionFileLoadResults.AppendText(ex.Message + "\r\n");
         }
     }
 }