Exemplo n.º 1
0
        public async Task <IActionResult> ImportIncoming([FromBody] ImportIncomingInvoiceModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await WorkerServices.ImportIncomingInvoiceAsync(model);

            return(Ok());
        }
Exemplo n.º 2
0
        public async Task ImportIncomingInvoiceAsync(ImportIncomingInvoiceModel model)
        {
            var command = new ImportIncomingInvoiceCommand(
                model.UserId,
                model.InvoiceId,
                model.InvoiceNumber,
                model.InvoiceDate,
                model.DueDate,
                model.Currency,
                model.TaxableAmount,
                model.Taxes,
                model.TotalPrice,
                model.TotalToPay,
                model.Description,
                model.PaymentTerms,
                model.PurchaseOrderNumber,
                new ImportIncomingInvoiceCommand.PartyInfo(
                    model.Customer.Id,
                    model.Customer.Name,
                    model.Customer.StreetName,
                    model.Customer.City,
                    model.Customer.PostalCode,
                    model.Customer.Country,
                    model.Customer.VatIndex,
                    model.Customer.NationalIdentificationNumber
                    ),
                new ImportIncomingInvoiceCommand.PartyInfo(
                    model.Supplier.Id,
                    model.Supplier.Name,
                    model.Supplier.StreetName,
                    model.Supplier.City,
                    model.Supplier.PostalCode,
                    model.Supplier.Country,
                    model.Supplier.VatIndex,
                    model.Supplier.NationalIdentificationNumber
                    ),
                model.LineItems.Select(i => new ImportIncomingInvoiceCommand.InvoiceLineItem(i.Code, i.Description, i.Quantity, i.UnitPrice, i.TotalPrice, i.Vat, i.VatDescription)).ToList(),
                model.PricesAreVatIncluded,
                model.PricesByVat.Select(p => new ImportIncomingInvoiceCommand.InvoicePriceByVat(p.TaxableAmount, p.VatRate, p.VatAmount, p.TotalPrice, p.ProvidenceFundAmount)).ToList(),
                model.NonTaxableItems.Select(i => new ImportIncomingInvoiceCommand.NonTaxableItem(i.Description, i.Amount)).ToList(),
                model.ProvidenceFundDescription,
                model.ProvidenceFundRate,
                model.ProvidenceFundAmount,
                model.WithholdingTaxDescription,
                model.WithholdingTaxRate,
                model.WithholdingTaxTaxableAmountRate,
                model.WithholdingTaxAmount
                );

            await Bus.Send(command);
        }