Esempio n. 1
0
        public async Task <AssignmentInvoiceDto> ExecuteQueryAsync(GetAssignmentInvoiceQuery query, CancellationToken cancellationToken)
        {
            var invoiceId = InvoiceId.With(query.InvoiceId).Value;
            var readModel = await _readStore.GetAsync(invoiceId, cancellationToken).ConfigureAwait(false);

            return(readModel.ReadModel.ToAssignmentInvoiceDto());
        }
Esempio n. 2
0
        public async Task SendReminder(Guid invoiceId)
        {
            var invoice = await _queryProcessor.ProcessAsync(new GetInvoiceQuery(invoiceId), CancellationToken.None);

            var invoiceEmployee = await _queryProcessor.ProcessAsync(new GetInvoiceEmployeeQuery(invoice.EmployeeId), CancellationToken.None);

            var invoiceCustomer = await _queryProcessor.ProcessAsync(new GetInvoiceCustomerQuery(invoice.CustomerId), CancellationToken.None);

            _invoicePrinter.PrintReminder(invoiceEmployee.Name, invoiceCustomer.Address);
            await _commandBus.PublishAsync(new InvoiceReminderCommand(InvoiceId.With(invoiceId)), CancellationToken.None);
        }
Esempio n. 3
0
        public async Task SendInvoice(SendInvoiceRequest request)
        {
            // Get data stored in this service
            var invoice = await _queryProcessor.ProcessAsync(new GetInvoiceQuery(request.InvoiceId), CancellationToken.None);

            var invoiceEmployee = await _queryProcessor.ProcessAsync(new GetInvoiceEmployeeQuery(invoice.EmployeeId), CancellationToken.None);

            var invoiceCustomer = await _queryProcessor.ProcessAsync(new GetInvoiceCustomerQuery(invoice.CustomerId), CancellationToken.None);

            var amount = invoice.InvoiceItems.Sum(item => item.Price * invoice.Vat);

            if (invoice.HasTaxReduction)
            {
                var reductionAmount = amount * 0.30m;
                amount = amount * 0.70m;
                await _skatteverketService.ApplyForReduction(invoiceCustomer.Name, reductionAmount);
            }

            _invoicePrinter.PrintInvoice(invoiceEmployee.Name, invoiceCustomer.Address, amount);

            await _commandBus.PublishAsync(new InvoiceSendCommand(InvoiceId.With(request.InvoiceId)), CancellationToken.None);
        }
Esempio n. 4
0
 public async Task SendInvoice(SendInvoiceRequest request)
 {
     await _commandBus.PublishAsync(new InvoiceSendCommand(InvoiceId.With(request.InvoiceId)),
                                    CancellationToken.None);
 }