Exemple #1
0
        public InvoiceDto Convert2Dto(InvoiceType src)
        {
            var dest = new InvoiceDto();

            dest.ID        = src.ID.Value;
            dest.IssueDate = src.IssueDate.Value;
            if (src.Note.Length > 0)
            {
                dest.Reason = src.Note[0].Value;
            }

            dest.InvoiceType = src.InvoiceTypeCode.Value;

            dest.Supplier            = new Party();
            dest.Supplier.AccountID  = src.AccountingSupplierParty.CustomerAssignedAccountID.Value;
            dest.Supplier.Name       = src.AccountingSupplierParty.Party.PartyName[0].Name.Value;
            dest.Supplier.VAT        = src.AccountingSupplierParty.Party.PartyTaxScheme[0].TaxScheme.ID.Value;
            dest.Supplier.Address    = src.AccountingSupplierParty.Party.PostalAddress.StreetName.Value;
            dest.Supplier.Address   += " " + src.AccountingSupplierParty.Party.PostalAddress.BuildingNumber.Value;
            dest.Supplier.CityName   = src.AccountingSupplierParty.Party.PostalAddress.CityName.Value;
            dest.Supplier.PostalZone = src.AccountingSupplierParty.Party.PostalAddress.PostalZone.Value;
            if (src.AccountingSupplierParty.Party.IndustryClassificationCode != null)
            {
                dest.Supplier.IndustryClassificationCode = src.AccountingSupplierParty.Party.IndustryClassificationCode.Value;
                dest.Supplier.IndustryClassificationName = src.AccountingSupplierParty.Party.IndustryClassificationCode.name;
            }


            var lines = new List <InvoiceLineDto>();

            foreach (var item in src.InvoiceLine)
            {
                var lineDto = new InvoiceLineDto();
                lineDto.ID = item.ID.Value;
                if (item.UUID != null)
                {
                    lineDto.UUID = item.UUID.Value;
                }

                lineDto.ItemName         = item.Item.Name.Value;
                lineDto.UnitCode         = item.InvoicedQuantity.unitCode;
                lineDto.InvoicedQuantity = item.InvoicedQuantity.Value;
                lineDto.VatPercentage    = item.TaxTotal[0].TaxSubtotal[0].TaxCategory.Percent.Value;
                lineDto.TaxAmount        = item.TaxTotal[0].TaxSubtotal[0].TaxAmount.Value;
                lines.Add(lineDto);
            }

            dest.Lines = lines.ToArray();
            return(dest);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            string     filename = @"C:\eInvoicePdf\In\Invoice.pdf";
            FileInfo   fi       = new FileInfo(filename);
            var        service  = new InvoiceService();
            InvoiceDto dto      = service.LoadFromFile(fi);

            /*
             *
             * meta.SetProperty(ns, ublKey, content);
             * PdfStamper stamper = new PdfStamper(reader, new FileStream(@"C:\eInvoicePdf\out.pdf", FileMode.Create));
             * XmpCore.Options.SerializeOptions opts = new XmpCore.Options.SerializeOptions();
             * metadata = XmpCore.XmpMetaFactory.SerializeToBuffer(meta, opts);
             * stamper.XmpMetadata = metadata;
             * stamper.Close();
             *
             */
        }