public async Task EditOutgoingCreditNoteDraftAsync(Guid draftId, OutgoingCreditNoteDraftModel model) { var customer = new PartyInfo { OriginalId = model.Customer.OriginalId, Name = model.Customer.Name, StreetName = Settings.Address, City = Settings.City, PostalCode = Settings.PostalCode, Country = Settings.Country, VatIndex = Settings.TaxId, NationalIdentificationNumber = Settings.TaxId }; var lineItems = model.LineItems.Select(l => new DraftLineItem { Id = l.Id, Code = l.Code, Description = l.Description, Quantity = l.Quantity, TotalPrice = l.TotalPrice, UnitPrice = l.UnitPrice, Vat = l.Vat }); var pricesByVat = model.PricesByVat.Select(p => new PriceByVat { TaxableAmount = p.TaxableAmount, TotalPrice = p.TotalPrice, VatAmount = p.VatAmount, VatRate = p.VatRate }); var nonTaxableItems = model.NonTaxableItems.Select(t => new NonTaxableItem { Id = t.Id, Amount = t.Amount, Description = t.Description }); await OutgoingCreditNoteDraftCommands.EditDraft( draftId, customer, model.Date, model.Currency, model.Amount, model.Taxes, model.TotalPrice, model.Description, model.PaymentTerms, model.PurchaseOrderNumber, model.VatIncluded, lineItems, pricesByVat, nonTaxableItems); }
public async Task <IActionResult> EditOutgoingCreditNoteDraft(Guid id, [FromBody] OutgoingCreditNoteDraftModel model) { if (id == Guid.Empty) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await WorkerServices.EditOutgoingCreditNoteDraftAsync(id, model); return(Ok()); }
public OutgoingCreditNoteDraftModel GetEditOutgoingCreditNoteDraft(Guid draftId) { var draft = Database.OutgoingCreditNoteDrafts .Include(d => d.LineItems) .Include(d => d.PricesByVat) .Include(d => d.NonTaxableItems) .Single(d => d.Id == draftId); var model = new OutgoingCreditNoteDraftModel { Amount = draft.TaxableAmount, Currency = draft.Currency, Customer = new Models.PartyInfo { OriginalId = draft.Customer.OriginalId, Name = draft.Customer.Name }, Date = draft.Date, Description = draft.Description, LineItems = draft.LineItems.Select(li => new DraftLineItemModel { Code = li.Code, Description = li.Description, Id = li.Id, Quantity = li.Quantity, TotalPrice = li.TotalPrice, UnitPrice = li.UnitPrice, Vat = li.Vat, VatDescription = li.VatDescription }), NonTaxableItems = draft.NonTaxableItems.Select(nt => new NonTaxableItemModel { Amount = nt.Amount, Description = nt.Description, Id = nt.Id }), PaymentTerms = draft.PaymentTerms, PricesByVat = draft.PricesByVat.Select(p => new DraftPriceByVatModel { Id = p.Id, TaxableAmount = p.TaxableAmount, TotalPrice = p.TotalPrice, VatAmount = p.VatAmount, VatRate = p.VatRate }), PurchaseOrderNumber = draft.PurchaseOrderNumber, Taxes = draft.Taxes, TotalPrice = draft.TotalPrice, TotalToPay = draft.TotalToPay, VatIncluded = draft.PricesAreVatIncluded }; if (!string.IsNullOrWhiteSpace(draft.ProvidenceFund.Description) && draft.ProvidenceFund.Rate.HasValue && draft.ProvidenceFund.Amount.HasValue) { model.ProvidenceFund = new Models.ProvidenceFundModel { Amount = draft.ProvidenceFund.Amount.Value, Description = draft.ProvidenceFund.Description, Rate = draft.ProvidenceFund.Rate.Value }; } if (!string.IsNullOrWhiteSpace(draft.WithholdingTax.Description)) { model.WithholdingTax = new Models.WithholdingTaxModel { Amount = draft.WithholdingTax.Amount, Description = draft.WithholdingTax.Description, Rate = draft.WithholdingTax.Rate, TaxableAmountRate = draft.WithholdingTax.TaxableAmountRate }; } return(model); }