Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns all primeAWB Billings
 /// </summary>
 /// <param name="primeFile"></param>
 /// <returns></returns>
 private List<Invoice> GetInvoices(FlatPrimeFile primeFile)
 {
     List<Invoice> primeBillings = new List<Invoice>();
     int batchSequenceNumber = 1;
     foreach (List<FlatPrimeRecord> flatCargoFileInvoice in primeFile.GetInvoices())
     {
         primeBillings.Add(GetInvoice(flatCargoFileInvoice, batchSequenceNumber));
         batchSequenceNumber += 1;
     }
     return primeBillings;
 }
        /// <summary>
        /// Loads the file into the FlatCargoFile private field
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTryLoad_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txtFileName.Text))
            {
                txtResults.Text = string.Empty;
                CsvParser<FlatPrimeRecord> csvParser = new CsvParser<FlatPrimeRecord>();
                csvParser.ValidationErrorOccurred += new CsvParser<FlatPrimeRecord>.ValidationErrorOccuredHandler(csvParser_ValidationErrorOccurred);

                try
                {
                    txtResults.Text += "Start reading file...\r\n";
                    _flatCargoFile = new FlatPrimeFile(csvParser.ReadFromFile(txtFileName.Text, ";", chkHasHeaders.Checked));
                    txtResults.Text += "\r\nEnd reading file.\r\n";
                    txtResults.Text += string.Format("Total {0} of {1} lines imported.", csvParser.ImportedLineCount, csvParser.TotalLineCount);

                }
                catch (IOException ex)
                {
                    txtResults.AppendText(ex.Message + "\r\n");
                }
                catch (Exception ex)
                {
                    txtResults.AppendText(ex.Message + "\r\n");
                }

            }
        }