diff --git a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mapper/MustangMapper.kt b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mapper/MustangMapper.kt index d4959ce..25322ff 100644 --- a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mapper/MustangMapper.kt +++ b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mapper/MustangMapper.kt @@ -2,11 +2,7 @@ package net.codinux.invoicing.mapper import net.codinux.invoicing.model.LineItem import net.codinux.invoicing.model.Party -import org.mustangproject.Contact -import org.mustangproject.Invoice -import org.mustangproject.Item -import org.mustangproject.Product -import org.mustangproject.TradeParty +import org.mustangproject.* import org.mustangproject.ZUGFeRD.IExportableTransaction import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem import java.time.Instant @@ -34,13 +30,19 @@ class MustangMapper { party.name, party.street, party.postalCode, party.city, party.countryIsoCode ).apply { this.taxID = party.vatId - // TODO: ID? // TODO: description? this.email = party.email this.setContact(Contact(party.contactName, party.phone, party.email).apply { this.fax = party.fax }) + + party.bankDetails?.let { + this.addBankDetails(BankDetails(it.accountNumber, it.bankCode).apply { + accountName = it.accountHolderName + // TODO: there's currently no field for financialInstitutionName in Zugferd model even though it exists on CII and UBL + }) + } } fun mapLineItem(item: LineItem): IZUGFeRDExportableItem = Item( diff --git a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/model/BankDetails.kt b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/model/BankDetails.kt new file mode 100644 index 0000000..eaeeea9 --- /dev/null +++ b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/model/BankDetails.kt @@ -0,0 +1,17 @@ +package net.codinux.invoicing.model + +class BankDetails( + /** + * In the EU / SEPA area the IBAN + */ + val accountNumber: String, + /** + * In the EU / SEPA area the BIC. Optional for countries like Germany + */ + val bankCode: String? = null, + + val accountHolderName: String? = null, + val financialInstitutionName: String? = null +) { + override fun toString() = "${accountHolderName ?: financialInstitutionName ?: ""} ${bankCode ?: ""} $accountHolderName" +} \ No newline at end of file diff --git a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/model/Party.kt b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/model/Party.kt index 856065f..0b5c64c 100644 --- a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/model/Party.kt +++ b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/model/Party.kt @@ -18,9 +18,12 @@ class Party( // actually there can be multiple contacts in eInvoice data model, all containing an email, phone, fax and contact name val email: String? = null, - var phone: String? = null, - var fax: String? = null, - var contactName: String? = null, + val phone: String? = null, + val fax: String? = null, + val contactName: String? = null, + + // actually there can be multiple bankDetails in eInvoice data model + val bankDetails: BankDetails? = null, ) { override fun toString() = "$name, $city" } \ No newline at end of file diff --git a/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/test/DataGenerator.kt b/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/test/DataGenerator.kt index c2d114f..d422546 100644 --- a/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/test/DataGenerator.kt +++ b/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/test/DataGenerator.kt @@ -1,5 +1,6 @@ package net.codinux.invoicing.test +import net.codinux.invoicing.model.BankDetails import net.codinux.invoicing.model.Invoice import net.codinux.invoicing.model.LineItem import net.codinux.invoicing.model.Party @@ -21,6 +22,9 @@ object DataGenerator { const val SenderVatId = "DE12345678" const val SenderEmail = "working-class-hero@rock.me" const val SenderPhone = "+4917012345678" + const val SenderAccountId = "DE00123456780987654321" + const val SenderBankCode = "12345678" + const val SenderAccountHolderName = "Manuela Musterfrau" const val RecipientName = "Untertänigster Leistungsempfänger" const val RecipientStreet = "Party Street 1" @@ -42,7 +46,8 @@ object DataGenerator { fun createInvoice( invoiceNumber: String = InvoiceNumber, 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)), recipient: Party = createParty(RecipientName, RecipientStreet, RecipientPostalCode, RecipientCity, RecipientCountry, RecipientVatId, RecipientEmail, RecipientPhone), items: List = listOf(createItem()), dueDate: LocalDate? = DueDate, @@ -60,8 +65,9 @@ object DataGenerator { email: String? = SenderEmail, phone: String? = SenderPhone, fax: String? = null, - contactName: String? = null - ) = Party(name, streetName, postalCode, city, country, vatId, email, phone, fax, contactName) + contactName: String? = null, + bankDetails: BankDetails? = null + ) = Party(name, streetName, postalCode, city, country, vatId, email, phone, fax, contactName, bankDetails) fun createItem( name: String = ItemName,