Exemple #1
0
        public async Task NormalEmployee()
        {
            var request = new CreateEmployeeRequest()
            {
                PersonalIdentificationNumber = "1234567890",
                UserName = "******",
            };
            var employeeId = await _employeeController.CreateEmployee(request);

            var customerRequest = new CreateCustomerRequest()
            {
                EmployeeId = employeeId,
                PersonalIdentificationNumber = "customer ssn",
                UserName = "******",
                Address  = "address"
            };
            var customerId = await _customerController.CreateCustomer(customerRequest);

            var createInvoiceRequest = new CreateInvoiceRequest()
            {
                EmployeeId   = employeeId,
                CustomerId   = customerId,
                PayInAdvance = false,
                InvoiceItems = new List <InvoiceItemDto>()
                {
                    new InvoiceItemDto()
                    {
                        Price = 10000.0m, Description = "städning"
                    }
                }.ToArray(),
                EndDate            = DateTime.Now,
                StartDate          = DateTime.Now,
                Name               = "invoiceName",
                Vat                = 25m,
                InvoiceDescription = "invoice description"
            };
            var invoiceId = await _invoiceController.CreateInvoice(createInvoiceRequest);

            var assignment = await _assignmentController.GetAssignment(invoiceId);

            Assert.Equal(Status.Created, assignment.CurrentStatus);

            await _invoiceController.SendInvoice(invoiceId);

            var payment = await _paymentController.GetPayment(invoiceId);

            Assert.Equal(PaymentState.WaitingForPayment, payment.CurrentState);

            // simulate payment
            await _paymentController.SimulateReceivePayment(new ReceivePaymentRequest()
            {
                InvoiceId = invoiceId
            });

            payment = await _paymentController.GetPayment(invoiceId);

            Assert.Equal(PaymentState.PaymentReceived, payment.CurrentState);

            var payout = await _payoutController.GetPayout(invoiceId);

            Assert.Equal(5060m, Math.Floor(payout.Amount));

            assignment = await _assignmentController.GetAssignment(invoiceId);

            Assert.Equal(Status.Closed, assignment.CurrentStatus);
        }