public async Task EditOutgoingInvoiceDraftAsync(Guid draftId, OutgoingInvoiceDraftModel 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 OutgoingInvoiceDraftCommands.EditDraft(
                draftId,
                customer,
                model.Date,
                model.Currency,
                model.Amount,
                model.Taxes,
                model.TotalPrice,
                model.Description,
                model.PaymentTerms,
                model.PurchaseOrderNumber,
                model.VatIncluded,
                lineItems,
                pricesByVat,
                nonTaxableItems);
        }
Esempio n. 2
0
 public async Task DeleteOutgoingInvoiceDraftAsync(Guid draftId)
 {
     await OutgoingInvoiceDraftCommands.DeleteDraft(draftId);
 }
Esempio n. 3
0
        public async Task CreateOutgoingDraftAsync(CreateOutgoingDraftModel 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
            {
                Code           = l.Code,
                Description    = l.Description,
                Quantity       = l.Quantity,
                TotalPrice     = l.TotalPrice,
                UnitPrice      = l.UnitPrice,
                Vat            = l.Vat,
                VatDescription = l.VatDescription
            });

            var pricesByVat = model.PricesByVat.Select(p => new PriceByVat
            {
                TaxableAmount        = p.TaxableAmount,
                TotalPrice           = p.TotalPrice,
                VatAmount            = p.VatAmount,
                VatRate              = p.VatRate,
                ProvidenceFundAmount = p.ProvidenceFundAmount
            });

            var nonTaxableItems = model.NonTaxableItems.Select(t => new NonTaxableItem
            {
                Amount      = t.Amount,
                Description = t.Description
            });

            switch (model.Type)
            {
            case Models.OutgoingDocumentTypes.OutgoingInvoice:
                await OutgoingInvoiceDraftCommands.CreateDraft(
                    customer,
                    model.Date,
                    model.Currency,
                    model.Amount,
                    model.Taxes,
                    model.TotalPrice,
                    model.Description,
                    model.PaymentTerms,
                    model.PurchaseOrderNumber,
                    model.VatIncluded,
                    lineItems,
                    pricesByVat,
                    nonTaxableItems,
                    model.ProvidenceFund?.Description,
                    model.ProvidenceFund?.Rate,
                    model.ProvidenceFund?.Amount,
                    model.WithholdingTax?.Description,
                    model.WithholdingTax?.Rate,
                    model.WithholdingTax?.TaxableAmountRate,
                    model.WithholdingTax?.Amount,
                    model.TotalToPay);

                break;

            case Models.OutgoingDocumentTypes.OutgoingCreditNote:
                await OutgoingCreditNoteDraftCommands.CreateDraft(
                    customer,
                    model.Date,
                    model.Currency,
                    model.Amount,
                    model.Taxes,
                    model.TotalPrice,
                    model.Description,
                    model.PaymentTerms,
                    model.PurchaseOrderNumber,
                    model.VatIncluded,
                    lineItems,
                    pricesByVat,
                    nonTaxableItems,
                    model.ProvidenceFund?.Description,
                    model.ProvidenceFund?.Rate,
                    model.ProvidenceFund?.Amount,
                    model.WithholdingTax?.Description,
                    model.WithholdingTax?.Rate,
                    model.WithholdingTax?.TaxableAmountRate,
                    model.WithholdingTax?.Amount,
                    model.TotalToPay);

                break;
            }
        }