Added BankDetails

This commit is contained in:
dankito 2024-11-14 20:49:23 +01:00
parent cd86300d36
commit fb5cce224f
4 changed files with 40 additions and 12 deletions

View File

@ -2,11 +2,7 @@ package net.codinux.invoicing.mapper
import net.codinux.invoicing.model.LineItem import net.codinux.invoicing.model.LineItem
import net.codinux.invoicing.model.Party import net.codinux.invoicing.model.Party
import org.mustangproject.Contact import org.mustangproject.*
import org.mustangproject.Invoice
import org.mustangproject.Item
import org.mustangproject.Product
import org.mustangproject.TradeParty
import org.mustangproject.ZUGFeRD.IExportableTransaction import org.mustangproject.ZUGFeRD.IExportableTransaction
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem
import java.time.Instant import java.time.Instant
@ -34,13 +30,19 @@ class MustangMapper {
party.name, party.street, party.postalCode, party.city, party.countryIsoCode party.name, party.street, party.postalCode, party.city, party.countryIsoCode
).apply { ).apply {
this.taxID = party.vatId this.taxID = party.vatId
// TODO: ID?
// TODO: description? // TODO: description?
this.email = party.email this.email = party.email
this.setContact(Contact(party.contactName, party.phone, party.email).apply { this.setContact(Contact(party.contactName, party.phone, party.email).apply {
this.fax = party.fax 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( fun mapLineItem(item: LineItem): IZUGFeRDExportableItem = Item(

View File

@ -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"
}

View File

@ -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 // actually there can be multiple contacts in eInvoice data model, all containing an email, phone, fax and contact name
val email: String? = null, val email: String? = null,
var phone: String? = null, val phone: String? = null,
var fax: String? = null, val fax: String? = null,
var contactName: 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" override fun toString() = "$name, $city"
} }

View File

@ -1,5 +1,6 @@
package net.codinux.invoicing.test package net.codinux.invoicing.test
import net.codinux.invoicing.model.BankDetails
import net.codinux.invoicing.model.Invoice import net.codinux.invoicing.model.Invoice
import net.codinux.invoicing.model.LineItem import net.codinux.invoicing.model.LineItem
import net.codinux.invoicing.model.Party import net.codinux.invoicing.model.Party
@ -21,6 +22,9 @@ object DataGenerator {
const val SenderVatId = "DE12345678" const val SenderVatId = "DE12345678"
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"
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"
@ -42,7 +46,8 @@ object DataGenerator {
fun createInvoice( fun createInvoice(
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)),
recipient: Party = createParty(RecipientName, RecipientStreet, RecipientPostalCode, RecipientCity, RecipientCountry, RecipientVatId, RecipientEmail, RecipientPhone), recipient: Party = createParty(RecipientName, RecipientStreet, RecipientPostalCode, RecipientCity, RecipientCountry, RecipientVatId, RecipientEmail, RecipientPhone),
items: List<LineItem> = listOf(createItem()), items: List<LineItem> = listOf(createItem()),
dueDate: LocalDate? = DueDate, dueDate: LocalDate? = DueDate,
@ -60,8 +65,9 @@ object DataGenerator {
email: String? = SenderEmail, email: String? = SenderEmail,
phone: String? = SenderPhone, phone: String? = SenderPhone,
fax: String? = null, fax: String? = null,
contactName: String? = null contactName: String? = null,
) = Party(name, streetName, postalCode, city, country, vatId, email, phone, fax, contactName) bankDetails: BankDetails? = null
) = Party(name, streetName, postalCode, city, country, vatId, email, phone, fax, contactName, bankDetails)
fun createItem( fun createItem(
name: String = ItemName, name: String = ItemName,