Extracted SenderBankDetails, corrected format for German Vat-IDs

This commit is contained in:
dankito 2024-11-15 00:35:09 +01:00
parent c94b9f8ece
commit f96885ca42
2 changed files with 17 additions and 17 deletions

View File

@ -63,7 +63,7 @@ class EInvoiceCreatorTest {
assertParty(asserter, receiverXPath, DataGenerator.RecipientName, DataGenerator.RecipientStreet, DataGenerator.RecipientPostalCode, DataGenerator.RecipientCity, DataGenerator.RecipientVatId, DataGenerator.RecipientEmail, DataGenerator.RecipientPhone) assertParty(asserter, receiverXPath, DataGenerator.RecipientName, DataGenerator.RecipientStreet, DataGenerator.RecipientPostalCode, DataGenerator.RecipientCity, DataGenerator.RecipientVatId, DataGenerator.RecipientEmail, DataGenerator.RecipientPhone)
val lineItemXPath = "//rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem" val lineItemXPath = "//rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem"
assertLineItem(asserter, lineItemXPath, DataGenerator.ItemName, DataGenerator.ItemUnit, DataGenerator.ItemQuantity, DataGenerator.ItemPrice, DataGenerator.ItemVat, DataGenerator.ItemDescription) assertLineItem(asserter, lineItemXPath, DataGenerator.ItemName, DataGenerator.ItemUnit, DataGenerator.ItemQuantity, DataGenerator.ItemPrice, DataGenerator.ItemVatPercentage, DataGenerator.ItemDescription)
} }
private fun assertParty(asserter: XPathAsserter, partyXPath: String, name: String, street: String, postalCode: String, city: String, vatId: String, email: String, phone: String) { private fun assertParty(asserter: XPathAsserter, partyXPath: String, name: String, street: String, postalCode: String, city: String, vatId: String, email: String, phone: String) {
@ -80,14 +80,14 @@ class EInvoiceCreatorTest {
asserter.xpathHasValue("$partyXPath/ram:DefinedTradeContact/ram:TelephoneUniversalCommunication/ram:CompleteNumber", phone) asserter.xpathHasValue("$partyXPath/ram:DefinedTradeContact/ram:TelephoneUniversalCommunication/ram:CompleteNumber", phone)
} }
private fun assertLineItem(asserter: XPathAsserter, partyXPath: String, name: String, unit: String, quantity: BigDecimal, price: BigDecimal, vatPercentage: BigDecimal, description: String?) { private fun assertLineItem(asserter: XPathAsserter, itemXPath: String, name: String, unit: String, quantity: BigDecimal, price: BigDecimal, vatPercentage: BigDecimal, description: String?) {
asserter.xpathHasValue("$partyXPath/ram:SpecifiedTradeProduct/ram:Name", name) asserter.xpathHasValue("$itemXPath/ram:SpecifiedTradeProduct/ram:Name", name)
asserter.xpathHasValue("$partyXPath/ram:SpecifiedLineTradeDelivery/ram:BilledQuantity/@unitCode", unit) asserter.xpathHasValue("$itemXPath/ram:SpecifiedLineTradeDelivery/ram:BilledQuantity/@unitCode", unit)
asserter.xpathHasValue("$partyXPath/ram:SpecifiedLineTradeDelivery/ram:BilledQuantity", quantity, 4) asserter.xpathHasValue("$itemXPath/ram:SpecifiedLineTradeDelivery/ram:BilledQuantity", quantity, 4)
asserter.xpathHasValue("$partyXPath/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount", price, 2) asserter.xpathHasValue("$itemXPath/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount", price, 2)
asserter.xpathHasValue("$partyXPath/ram:SpecifiedLineTradeSettlement/ram:ApplicableTradeTax/ram:RateApplicablePercent", vatPercentage, 2) asserter.xpathHasValue("$itemXPath/ram:SpecifiedLineTradeSettlement/ram:ApplicableTradeTax/ram:RateApplicablePercent", vatPercentage, 2)
// asserter.xpathHasValue("$partyXPath/ram:URIUniversalCommunication/ram:URIID", description) // asserter.xpathHasValue("$partyXPath/ram:URIUniversalCommunication/ram:URIID", description)
} }

View File

@ -19,27 +19,26 @@ object DataGenerator {
const val SenderPostalCode = "12345" const val SenderPostalCode = "12345"
const val SenderCity = "Glückstadt" const val SenderCity = "Glückstadt"
const val SenderCountry = "DE" const val SenderCountry = "DE"
const val SenderVatId = "DE12345678" const val SenderVatId = "DE123456789"
const val SenderEmail = "working-class-hero@rock.me" const val SenderEmail = "working-class-hero@rock.me"
const val SenderPhone = "+4917012345678" const val SenderPhone = "+4917012345678"
const val SenderAccountId = "DE00123456780987654321" val SenderBankDetails = BankDetails("DE00123456780987654321", "ABZODEFFXXX", "Manuela Musterfrau")
const val SenderBankCode = "12345678"
const val SenderAccountHolderName = "Manuela Musterfrau"
const val RecipientName = "Untertänigster Leistungsempfänger" const val RecipientName = "Untertänigster Leistungsempfänger"
const val RecipientStreet = "Party Street 1" const val RecipientStreet = "Party Street 1"
const val RecipientPostalCode = SenderPostalCode const val RecipientPostalCode = SenderPostalCode
const val RecipientCity = SenderCity const val RecipientCity = SenderCity
const val RecipientCountry = "DE" const val RecipientCountry = "DE"
const val RecipientVatId = "DE87654321" const val RecipientVatId = "DE987654321"
const val RecipientEmail = "exploiter@your.boss" const val RecipientEmail = "exploiter@your.boss"
const val RecipientPhone = "+4912345678" const val RecipientPhone = "+491234567890"
val RecipientBankDetails: BankDetails? = null
const val ItemName = "Erbrachte Dienstleistungen" const val ItemName = "Erbrachte Dienstleistungen"
const val ItemUnit = "HUR" // EN code for 'hour' const val ItemUnit = "HUR" // EN code for 'hour'
val ItemQuantity = BigDecimal(1) val ItemQuantity = BigDecimal(1)
val ItemPrice = BigDecimal(99) val ItemPrice = BigDecimal(99)
val ItemVat = BigDecimal(0.19) val ItemVatPercentage = BigDecimal(19)
val ItemDescription: String? = null val ItemDescription: String? = null
@ -47,8 +46,9 @@ object DataGenerator {
invoiceNumber: String = InvoiceNumber, invoiceNumber: String = InvoiceNumber,
invoicingDate: LocalDate = InvoicingDate, invoicingDate: LocalDate = InvoicingDate,
sender: Party = createParty(SenderName, SenderStreet, SenderPostalCode, SenderCity, SenderCountry, SenderVatId, SenderEmail, SenderPhone, sender: Party = createParty(SenderName, SenderStreet, SenderPostalCode, SenderCity, SenderCountry, SenderVatId, SenderEmail, SenderPhone,
bankDetails = BankDetails(SenderAccountId, SenderBankCode, SenderAccountHolderName)), bankDetails = SenderBankDetails),
recipient: Party = createParty(RecipientName, RecipientStreet, RecipientPostalCode, RecipientCity, RecipientCountry, RecipientVatId, RecipientEmail, RecipientPhone), recipient: Party = createParty(RecipientName, RecipientStreet, RecipientPostalCode, RecipientCity, RecipientCountry, RecipientVatId, RecipientEmail, RecipientPhone,
bankDetails = RecipientBankDetails),
items: List<LineItem> = listOf(createItem()), items: List<LineItem> = listOf(createItem()),
dueDate: LocalDate? = DueDate, dueDate: LocalDate? = DueDate,
paymentDescription: String? = dueDate?.let { "Zahlbar ohne Abzug bis ${DateTimeFormatter.ofPattern("dd.MM.yyyy").format(dueDate)}" }, paymentDescription: String? = dueDate?.let { "Zahlbar ohne Abzug bis ${DateTimeFormatter.ofPattern("dd.MM.yyyy").format(dueDate)}" },
@ -74,7 +74,7 @@ object DataGenerator {
unit: String = ItemUnit, unit: String = ItemUnit,
quantity: BigDecimal = ItemQuantity, quantity: BigDecimal = ItemQuantity,
price: BigDecimal = ItemPrice, price: BigDecimal = ItemPrice,
vatPercentage: BigDecimal = ItemVat, vatPercentage: BigDecimal = ItemVatPercentage,
description: String? = ItemDescription, description: String? = ItemDescription,
) = LineItem(name, unit, quantity, price, vatPercentage, description) ) = LineItem(name, unit, quantity, price, vatPercentage, description)