Giuliano Paschoalino 690ab131aa feat: Initialize ComplianceNFs project structure with core, infrastructure, service, and monitor components
- Created ComplianceNFs.Core project with domain entities and ports
- Implemented BuyingRecord, EnergyInvoice, ParsedInvoice entities
- Defined domain interfaces for mail listening, XML and PDF parsing, and repository access
- Established ComplianceNFs.Infrastructure project with file archiving, mail listening, and data access implementations
- Developed PDF and XML parsers for invoice data extraction
- Set up AccessDbRepository and AttachmentRepository for data retrieval and storage
- Created ComplianceNFs.Service project for background processing and service orchestration
- Implemented Worker service for periodic tasks
- Established ComplianceNFs.Monitor project with WPF UI for monitoring invoice statuses
- Added ViewModel for UI data binding and command handling
- Configured project files for .NET 9.0 and necessary package references
- Created initial appsettings.json for configuration management
- Added TODOs and roadmap for future development
2025-06-05 14:47:28 -03:00

34 lines
1.6 KiB
C#

using System.IO;
using ComplianceNFs.Core.Entities;
using ComplianceNFs.Core.Ports;
namespace ComplianceNFs.Infrastructure.Parsers
{
// Placeholder: fill in actual XML parsing logic
public class XmlParser : IXmlParser
{
public ParsedInvoice Parse(Stream xmlStream)
{
// Use System.Xml to parse known elements
var doc = new System.Xml.XmlDocument();
doc.Load(xmlStream);
var invoice = new ParsedInvoice
{
CnpjComp = doc.SelectSingleNode("//CNPJComp")?.InnerText,
CnpjVend = doc.SelectSingleNode("//CNPJVend")?.InnerText,
MontNF = decimal.TryParse(doc.SelectSingleNode("//MontNF")?.InnerText, out var mont) ? mont : 0,
PrecNF = decimal.TryParse(doc.SelectSingleNode("//PrecNF")?.InnerText, out var prec) ? prec : 0,
ValorSemImpostos = decimal.TryParse(doc.SelectSingleNode("//ValorSemImpostos")?.InnerText, out var vsi) ? vsi : 0,
ValorFinalComImpostos = decimal.TryParse(doc.SelectSingleNode("//ValorFinalComImpostos")?.InnerText, out var vfi) ? vfi : 0,
RsComp = doc.SelectSingleNode("//RsComp")?.InnerText,
RsVend = doc.SelectSingleNode("//RsVend")?.InnerText,
NumeroNF = doc.SelectSingleNode("//NumeroNF")?.InnerText,
IcmsNF = decimal.TryParse(doc.SelectSingleNode("//IcmsNF")?.InnerText, out var icms) ? icms : 0,
UfComp = doc.SelectSingleNode("//UfComp")?.InnerText,
UfVend = doc.SelectSingleNode("//UfVend")?.InnerText
};
return invoice;
}
}
}