예제 #1
0
        internal static Dto.InvoiceData MapModificationInvoice(ModificationInvoice invoice)
        {
            var lines            = MapItems(invoice.Items, invoice.ItemIndexOffset);
            var invoiceReference = new Dto.InvoiceReferenceType
            {
                modificationIndex     = invoice.ModificationIndex,
                originalInvoiceNumber = invoice.OriginalDocumentNumber.Value,
                modifyWithoutMaster   = invoice.ModifyWithoutMaster
            };

            var invoiceDto = GetCommonInvoice(invoice, lines, invoiceReference);

            return(GetCommonInvoiceData(invoice, invoiceDto));
        }
예제 #2
0
        private static Dto.InvoiceType GetCommonInvoice(Invoice invoice, IEnumerable <Dto.LineType> lines, Dto.InvoiceReferenceType invoiceReference = null)
        {
            var invoiceAmount    = Amount.Sum(invoice.Items.Values.Select(i => i.Value.TotalAmounts.Amount));
            var invoiceAmountHUF = Amount.Sum(invoice.Items.Values.Select(i => i.Value.TotalAmounts.AmountHUF));
            var supplierInfo     = invoice.SupplierInfo;
            var receiver         = invoice.Receiver;

            return(new Dto.InvoiceType
            {
                invoiceReference = invoiceReference,
                invoiceLines = new Dto.LinesType
                {
                    line = lines.ToArray()
                },
                invoiceHead = new Dto.InvoiceHeadType
                {
                    invoiceDetail = new Dto.InvoiceDetailType
                    {
                        exchangeRate = invoice.ExchangeRate.Value,
                        currencyCode = invoice.CurrencyCode.Value,
                        invoiceAppearance = Dto.InvoiceAppearanceType.ELECTRONIC,
                        invoiceCategory = Dto.InvoiceCategoryType.AGGREGATE,
                        invoiceDeliveryDate = invoice.DeliveryDate,
                        paymentDate = invoice.PaymentDate,
                        paymentDateSpecified = true,
                        selfBillingIndicator = invoice.IsSelfBilling,
                        cashAccountingIndicator = invoice.IsCashAccounting,
                        paymentMethod = invoice.PaymentMethod.Map(m => MapPaymentMethod(m)).GetOrElse(Dto.PaymentMethodType.OTHER),
                        paymentMethodSpecified = invoice.PaymentMethod.NonEmpty
                    },
                    supplierInfo = new Dto.SupplierInfoType
                    {
                        supplierName = supplierInfo.Name.Value,
                        supplierAddress = MapAddress(supplierInfo.Address),
                        supplierTaxNumber = new Dto.TaxNumberType
                        {
                            taxpayerId = supplierInfo.TaxpayerId.TaxpayerNumber,
                            vatCode = supplierInfo.VatCode.Value
                        }
                    },
                    customerInfo = new Dto.CustomerInfoType
                    {
                        customerName = receiver.Match(
                            customer => null,
                            company => company.Name.Value
                            ),
                        customerAddress = receiver.Match(
                            customer => null,
                            company => MapAddress(company.Address)
                            ),
                        customerVatStatus = receiver.Match(
                            customer => Dto.CustomerVatStatusType.PRIVATE_PERSON,
                            company => company.Match(
                                local => Dto.CustomerVatStatusType.DOMESTIC,
                                foreign => Dto.CustomerVatStatusType.OTHER
                                )
                            ),
                        customerVatData = receiver.Match(
                            customer => Option.Empty <Dto.CustomerVatDataType>(),
                            company => company.Match(
                                local => GetCustomerVatDataType(local.TaxpayerId).ToOption(),
                                foreign => foreign.TaxpayerId.Map(i => GetCustomerVatDataType(i))
                                )
                            ).GetOrNull()
                    },
                },
                invoiceSummary = new Dto.SummaryType
                {
                    summaryGrossData = new Dto.SummaryGrossDataType
                    {
                        invoiceGrossAmount = invoiceAmount.Gross.Value,
                        invoiceGrossAmountHUF = invoiceAmountHUF.Gross.Value
                    },
                    Items = new object[]
                    {
                        MapTaxSummary(invoice, invoiceAmount, invoiceAmountHUF)
                    }
                }
            });
        }
        private static Dto.InvoiceType GetCommonInvoice(Invoice invoice, IEnumerable <Dto.LineType> lines, Dto.InvoiceReferenceType invoiceReference = null)
        {
            var invoiceAmount    = Amount.Sum(invoice.Items.Select(i => i.Item.TotalAmounts.Amount));
            var invoiceAmountHUF = Amount.Sum(invoice.Items.Select(i => i.Item.TotalAmounts.AmountHUF));
            var supplierInfo     = invoice.SupplierInfo;
            var customerInfo     = invoice.CustomerInfo;

            return(new Dto.InvoiceType
            {
                invoiceReference = invoiceReference,
                invoiceLines = lines.ToArray(),
                invoiceHead = new Dto.InvoiceHeadType
                {
                    invoiceDetail = new Dto.InvoiceDetailType
                    {
                        exchangeRate = invoice.ExchangeRate.Value,
                        currencyCode = invoice.CurrencyCode.Value,
                        invoiceAppearance = Dto.InvoiceAppearanceType.ELECTRONIC,
                        invoiceCategory = Dto.InvoiceCategoryType.AGGREGATE,
                        invoiceDeliveryDate = invoice.DeliveryDate,
                        paymentDate = invoice.PaymentDate,
                        selfBillingIndicator = invoice.IsSelfBilling,
                        cashAccountingIndicator = invoice.IsCashAccounting
                    },
                    supplierInfo = new Dto.SupplierInfoType
                    {
                        supplierName = supplierInfo.Name.Value,
                        supplierAddress = MapAddress(supplierInfo.Address),
                        supplierTaxNumber = new Dto.TaxNumberType
                        {
                            taxpayerId = supplierInfo.TaxpayerId.Value,
                            vatCode = supplierInfo.VatCode.Value
                        }
                    },
                    customerInfo = new Dto.CustomerInfoType
                    {
                        customerName = customerInfo.Name.Value,
                        customerAddress = MapAddress(customerInfo.Address),
                        customerTaxNumber = new Dto.TaxNumberType
                        {
                            taxpayerId = customerInfo.TaxpayerId.Value
                        }
                    },
                },
                invoiceSummary = new Dto.SummaryType
                {
                    summaryGrossData = new Dto.SummaryGrossDataType
                    {
                        invoiceGrossAmount = invoiceAmount.Gross.Value,
                        invoiceGrossAmountHUF = invoiceAmountHUF.Gross.Value
                    },
                    Items = new object[]
                    {
                        MapTaxSummary(invoice, invoiceAmount, invoiceAmountHUF)
                    }
                }
            });
        }