Example #1
0
        private static void RandomTest()
        {
            // Setup a test dataset
            Invoices       inputInvoices;
            List <Payment> inputPayments;

            GenerateRandomData(out inputInvoices, out inputPayments);

            // Write out the input invoice set
            Console.WriteLine("Invoices to match");
            inputInvoices.Write();
            Console.WriteLine("Number of payments " + inputPayments.Count);
            Console.WriteLine();



            // Match all invoices against all payments;
            for (int i = 0; i < inputPayments.Count; i++)
            {
                // Write out the payment details.
                Console.WriteLine("Matches against Payment "
                                  + inputPayments[i].Date
                                  + " ID:" + inputPayments[i].Reference
                                  + " in the amount of " + inputPayments[i].Amount
                                  + " against an input set of " + inputInvoices.Count + " invoices"
                                  );

                // Perform the match
                Invoices invoicesToMatch = inputInvoices.GetUpToDate(inputPayments[i].Date);
                Hits     hits            = MatchPayment.Hits(inputPayments[i], invoicesToMatch);
                Console.WriteLine("Found " + hits.Count + " hits. Attempting best hit");
                Hit bestHit = hits.BestHit();


                if (bestHit != null)
                {
                    // Remove the hits from the match list.
                    inputInvoices.Remove(bestHit);

                    // Write out the match.
                    bestHit.Write();
                }
                else
                {
                    Console.WriteLine("*** There was no match against this payment");
                }

                Console.WriteLine();
            }

            // Write all unmatched Invoices.
            Console.WriteLine("Unmatched invoices");
            inputInvoices.Write();

            // Wait for keypress to exit
            Console.WriteLine();
            Console.WriteLine("Press Return to exit");
            Console.ReadLine();
        }
Example #2
0
        /// <summary>
        /// Simple test suitable for speed testing.
        /// </summary>
        private static void SimpleTest()
        {
            // Setup a test dataset
            Invoices       inputInvoices;
            List <Payment> inputPayments;

            GenerateSimpleData(out inputInvoices, out inputPayments);

            // Mark the current time
            long ticks = DateTime.Now.Ticks;

            // Perform the match
            Hits hits = MatchPayment.Hits(inputPayments[0], inputInvoices);

            // Mark the end of computation
            Console.WriteLine("Search complete for " + inputInvoices.Count + " levels");
            Console.WriteLine("Payment " + hits.Payment.Reference + " in the amount of " + hits.Payment.Amount);
            Console.WriteLine("Time taken: " + (DateTime.Now.Ticks - ticks) / 10000000.0 + " seconds");
            Console.WriteLine();

            // Write all hits.
            Console.WriteLine("Hits");
            hits.Write();

            Console.WriteLine();

            // Write out the best hit.
            Console.WriteLine("Best hit");
            Hit bestHit = hits.BestHit();

            bestHit.Write();

            Console.WriteLine();

            // Write all unmatched Invoices.
            Console.WriteLine("Unmatched invoices");
            inputInvoices.Remove(bestHit);
            inputInvoices.Write();

            // Wait for keypress to exit
            Console.ReadLine();
        }