Implemented validating eInvoices via API
This commit is contained in:
parent
d879ba74d8
commit
5395880429
|
@ -49,4 +49,12 @@ class InvoicingResource(
|
||||||
fun extractInvoiceData(invoice: java.nio.file.Path) =
|
fun extractInvoiceData(invoice: java.nio.file.Path) =
|
||||||
service.extractInvoiceData(invoice)
|
service.extractInvoiceData(invoice)
|
||||||
|
|
||||||
|
@Path("validate")
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
@Produces(MediaType.APPLICATION_XML)
|
||||||
|
@Operation(summary = "Validate a Factur-x / ZUGFeRD or XRechnung file")
|
||||||
|
fun validateInvoiceXml(invoice: java.nio.file.Path) =
|
||||||
|
service.validateInvoice(invoice).reportAsXml
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import jakarta.inject.Singleton
|
||||||
import net.codinux.invoicing.creation.EInvoiceCreator
|
import net.codinux.invoicing.creation.EInvoiceCreator
|
||||||
import net.codinux.invoicing.model.Invoice
|
import net.codinux.invoicing.model.Invoice
|
||||||
import net.codinux.invoicing.reader.EInvoiceReader
|
import net.codinux.invoicing.reader.EInvoiceReader
|
||||||
|
import net.codinux.invoicing.validation.EInvoiceValidator
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.extension
|
import kotlin.io.path.extension
|
||||||
|
@ -15,6 +16,8 @@ class InvoicingService {
|
||||||
|
|
||||||
private val reader = EInvoiceReader()
|
private val reader = EInvoiceReader()
|
||||||
|
|
||||||
|
private val validator = EInvoiceValidator()
|
||||||
|
|
||||||
|
|
||||||
fun createXRechnung(invoice: Invoice): String =
|
fun createXRechnung(invoice: Invoice): String =
|
||||||
creator.createXRechnungXml(invoice)
|
creator.createXRechnungXml(invoice)
|
||||||
|
@ -39,4 +42,8 @@ class InvoicingService {
|
||||||
else -> throw IllegalArgumentException("We can only extract eInvoice data from .xml and .pdf files")
|
else -> throw IllegalArgumentException("We can only extract eInvoice data from .xml and .pdf files")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun validateInvoice(invoice: Path) =
|
||||||
|
validator.validate(invoice.toFile())
|
||||||
|
|
||||||
}
|
}
|
|
@ -44,6 +44,12 @@ quarkus.log.loki.field.kubernetes.field.containername.include=false
|
||||||
|
|
||||||
# to turn off verbose FOP messages
|
# to turn off verbose FOP messages
|
||||||
quarkus.log.category."org.apache.fop.apps".level=ERROR
|
quarkus.log.category."org.apache.fop.apps".level=ERROR
|
||||||
|
# to turn off verbose invoice validation logging
|
||||||
|
quarkus.log.category."org.mustangproject.validator".level=ERROR
|
||||||
|
|
||||||
|
|
||||||
|
# to fix that javax.xml.namespace.QName gets loaded with Quarkus' class loader instead of default class loader which causes an error
|
||||||
|
quarkus.class-loading.parent-first-artifacts=xpp3:xpp3
|
||||||
|
|
||||||
|
|
||||||
# Live reload
|
# Live reload
|
||||||
|
|
Loading…
Reference in New Issue