Example #1
0
        public void TestVFJan13()
        {
            // Test scenario: Viktors Farmor booking 13 for sale VF Jan with Estrella Chimborazo
            ICustomer viktorsFarmor      = customerController.CreateCustomer(CustomerType.Bureau, "", "Viktors Farmor");
            ISupplier estrellaChimborazo = supplierController.CreateSupplier("Estrella Chimborazo", "",
                                                                             SupplierType.Restaurant);

            // PaymentRule to use for the booking
            supplierController.AddPaymentRule(estrellaChimborazo, viktorsFarmor, BookingType.Group, 100, -1,
                                              BaseDate.StartDate, PaymentType.Full);

            // Dummy PaymentRule (must not be applied)
            supplierController.AddPaymentRule(estrellaChimborazo, viktorsFarmor, BookingType.FIT, 100, 14,
                                              BaseDate.EndDate, PaymentType.Full);

            IBooking booking = bookingController.CreateBooking(estrellaChimborazo, viktorsFarmor, "VF Jan", 13,
                                                               new DateTime(2014, 01, 14), new DateTime(2014, 01, 14));

            booking.Type              = BookingType.Group;
            booking.IVAExempt         = 0m;
            booking.IVASubject        = 378m;
            booking.ProductRetention  = 2m;
            booking.SupplierRetention = 70m;

            bookingController.CalculatePaymentsForBooking(booking);

            // Check that TransferAmount and IVA match real world data
            string expectedTransferAmount = "384.05";
            string expectedIVA            = "45.36";

            Assert.AreEqual(expectedTransferAmount, booking.TransferAmount.ToString("N2", culture.NumberFormat));
            Assert.AreEqual(expectedIVA, booking.IVA.ToString("N2", culture.NumberFormat));

            // Check that correct number of payments was created
            int             expectedNumberOfPayments = 1;
            List <IPayment> createdPayments          = paymentController.ReadAllPayments();

            Assert.AreEqual(expectedNumberOfPayments, createdPayments.Count);

            // Check that Payment stats set by PaymentRules match real world data
            IPayment payment           = createdPayments[0];
            string   expectedDueAmount = "384.05";
            DateTime expectedDueDate   = new DateTime(2014, 01, 13);

            Assert.AreEqual(expectedDueAmount, payment.DueAmount.ToString("N2", culture.NumberFormat));
            Assert.AreEqual(expectedDueDate, payment.DueDate);
        }
 private void calculatePayments_Click(object sender, RoutedEventArgs e)
 {
     bookingController.CalculatePaymentsForBooking(selectedBooking);
     refreshDataGrid();
 }