Esempio n. 1
0
        public async Task <IActionResult> ImportOutgoing([FromBody] ImportOutgoingInvoiceModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await WorkerServices.ImportOutgoingInvoiceAsync(model);

            return(Ok());
        }
Esempio n. 2
0
        public async Task ImportOutgoingInvoiceAsync(ImportOutgoingInvoiceModel model)
        {
            var command = new ImportOutgoingInvoiceCommand(
                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 ImportOutgoingInvoiceCommand.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 ImportOutgoingInvoiceCommand.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 ImportOutgoingInvoiceCommand.InvoiceLineItem(i.Code, i.Description, i.Quantity, i.UnitPrice, i.TotalPrice, i.Vat, i.VatDescription)).ToList(),
                model.PricesAreVatIncluded,
                model.PricesByVat.Select(p => new ImportOutgoingInvoiceCommand.InvoicePriceByVat(p.TaxableAmount, p.VatRate, p.VatAmount, p.TotalPrice, p.ProvidenceFundAmount)).ToList(),
                model.NonTaxableItems.Select(i => new ImportOutgoingInvoiceCommand.NonTaxableItem(i.Description, i.Amount)).ToList(),
                model.ProvidenceFundDescription,
                model.ProvidenceFundRate,
                model.ProvidenceFundAmount,
                model.WithholdingTaxDescription,
                model.WithholdingTaxRate,
                model.WithholdingTaxTaxableAmountRate,
                model.WithholdingTaxAmount
                );

            await Bus.Send(command);
        }