Implemented creating Zugferd XML
This commit is contained in:
parent
3273625f7a
commit
3bd3024f11
|
@ -1,8 +1,10 @@
|
||||||
package net.codinux.invoicing.creation
|
package net.codinux.invoicing.creation
|
||||||
|
|
||||||
import net.codinux.invoicing.model.Invoice
|
import net.codinux.invoicing.model.Invoice
|
||||||
|
import org.mustangproject.ZUGFeRD.IXMLProvider
|
||||||
import org.mustangproject.ZUGFeRD.Profiles
|
import org.mustangproject.ZUGFeRD.Profiles
|
||||||
import org.mustangproject.ZUGFeRD.ZUGFeRD2PullProvider
|
import org.mustangproject.ZUGFeRD.ZUGFeRD2PullProvider
|
||||||
|
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA3
|
||||||
|
|
||||||
class EInvoiceCreator(
|
class EInvoiceCreator(
|
||||||
private val mapper: MustangMapper = MustangMapper()
|
private val mapper: MustangMapper = MustangMapper()
|
||||||
|
@ -11,7 +13,25 @@ class EInvoiceCreator(
|
||||||
fun createXRechnungXml(invoice: Invoice): String {
|
fun createXRechnungXml(invoice: Invoice): String {
|
||||||
val provider = ZUGFeRD2PullProvider()
|
val provider = ZUGFeRD2PullProvider()
|
||||||
provider.profile = Profiles.getByName("XRechnung")
|
provider.profile = Profiles.getByName("XRechnung")
|
||||||
provider.generateXML(mapper.mapToTransaction(invoice))
|
|
||||||
|
return createXml(provider, invoice)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createZugferdXml(invoice: Invoice, zugferdVersion: Int = 2): String {
|
||||||
|
val exporter = ZUGFeRDExporterFromA3()
|
||||||
|
.setZUGFeRDVersion(zugferdVersion)
|
||||||
|
.setProfile("EN16931")
|
||||||
|
.setProducer("danki die geile Sau")
|
||||||
|
.setCreator(System.getProperty("user.name"))
|
||||||
|
|
||||||
|
return createXml(exporter.provider, invoice)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun createXml(provider: IXMLProvider, invoice: Invoice): String {
|
||||||
|
val transaction = mapper.mapToTransaction(invoice)
|
||||||
|
|
||||||
|
provider.generateXML(transaction)
|
||||||
|
|
||||||
return String(provider.xml, Charsets.UTF_8)
|
return String(provider.xml, Charsets.UTF_8)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,15 @@ class EInvoiceCreatorTest {
|
||||||
assertThat(result).isNotEmpty()
|
assertThat(result).isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun createZugferdXml() {
|
||||||
|
val invoice = createInvoice()
|
||||||
|
|
||||||
|
val result = underTest.createZugferdXml(invoice)
|
||||||
|
|
||||||
|
assertThat(result).isNotEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun createInvoice(
|
private fun createInvoice(
|
||||||
invoiceNumber: String = "12345",
|
invoiceNumber: String = "12345",
|
||||||
|
|
Loading…
Reference in New Issue