Extracted InvoiceDetails
This commit is contained in:
parent
68b1f56cfa
commit
d8f707e5eb
|
@ -94,7 +94,7 @@ class InvoicingResource(
|
|||
|
||||
private fun createPdfFileResponse(pdfFile: java.nio.file.Path, invoice: Invoice): Response =
|
||||
Response.ok(pdfFile)
|
||||
.header("Content-Disposition", "attachment;filename=\"${invoice.invoiceDate.toString().replace('-', '.')} ${invoice.customer.name} ${invoice.invoiceNumber}.pdf\"")
|
||||
.header("Content-Disposition", "attachment;filename=\"${invoice.details.invoiceDate.toString().replace('-', '.')} ${invoice.customer.name} ${invoice.details.invoiceNumber}.pdf\"")
|
||||
.build()
|
||||
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
package net.codinux.invoicing.mapper
|
||||
|
||||
import net.codinux.invoicing.calculator.AmountsCalculator
|
||||
import net.codinux.invoicing.model.AmountAdjustments
|
||||
import net.codinux.invoicing.model.ChargeOrAllowance
|
||||
import net.codinux.invoicing.model.InvoiceItem
|
||||
import net.codinux.invoicing.model.Party
|
||||
import net.codinux.invoicing.model.*
|
||||
import org.mustangproject.*
|
||||
import org.mustangproject.BankDetails
|
||||
import org.mustangproject.Invoice
|
||||
import org.mustangproject.ZUGFeRD.IExportableTransaction
|
||||
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem
|
||||
import java.math.BigDecimal
|
||||
|
@ -19,15 +18,15 @@ open class MustangMapper(
|
|||
) {
|
||||
|
||||
open fun mapToTransaction(invoice: net.codinux.invoicing.model.Invoice): IExportableTransaction = Invoice().apply {
|
||||
this.number = invoice.invoiceNumber
|
||||
this.issueDate = map(invoice.invoiceDate)
|
||||
this.number = invoice.details.invoiceNumber
|
||||
this.issueDate = map(invoice.details.invoiceDate)
|
||||
this.sender = mapParty(invoice.supplier)
|
||||
this.recipient = mapParty(invoice.customer)
|
||||
|
||||
this.setZFItems(ArrayList(invoice.items.map { mapLineItem(it) }))
|
||||
|
||||
this.dueDate = map(invoice.dueDate)
|
||||
this.paymentTermDescription = invoice.paymentDescription
|
||||
this.dueDate = map(invoice.details.dueDate)
|
||||
this.paymentTermDescription = invoice.details.paymentDescription
|
||||
|
||||
this.referenceNumber = invoice.customerReference
|
||||
|
||||
|
@ -92,15 +91,12 @@ open class MustangMapper(
|
|||
|
||||
|
||||
open fun mapToInvoice(invoice: Invoice) = net.codinux.invoicing.model.Invoice(
|
||||
invoiceNumber = invoice.number,
|
||||
invoiceDate = map(invoice.issueDate),
|
||||
details = InvoiceDetails(invoice.number, map(invoice.issueDate), map(invoice.dueDate ?: invoice.paymentTerms?.dueDate), invoice.paymentTermDescription ?: invoice.paymentTerms?.description),
|
||||
|
||||
supplier = mapParty(invoice.sender),
|
||||
customer = mapParty(invoice.recipient),
|
||||
items = invoice.zfItems.map { mapLineItem(it) },
|
||||
|
||||
dueDate = map(invoice.dueDate ?: invoice.paymentTerms?.dueDate),
|
||||
paymentDescription = invoice.paymentTermDescription ?: invoice.paymentTerms?.description,
|
||||
|
||||
customerReference = invoice.referenceNumber,
|
||||
|
||||
amountAdjustments = mapAmountAdjustments(invoice),
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
package net.codinux.invoicing.model
|
||||
|
||||
import java.time.LocalDate
|
||||
|
||||
class Invoice(
|
||||
val invoiceNumber: String,
|
||||
val invoiceDate: LocalDate,
|
||||
val details: InvoiceDetails,
|
||||
val supplier: Party,
|
||||
val customer: Party,
|
||||
val items: List<InvoiceItem>,
|
||||
|
||||
val dueDate: LocalDate? = null,
|
||||
val paymentDescription: String? = null,
|
||||
|
||||
/**
|
||||
* Unique reference number of the customer, e.g. the Leitweg-ID required by German authorities (Behörden)
|
||||
*/
|
||||
|
@ -27,5 +21,5 @@ class Invoice(
|
|||
*/
|
||||
var totalAmounts: TotalAmounts? = null
|
||||
) {
|
||||
override fun toString() = "$invoiceDate $invoiceNumber to $customer ${totalAmounts?.duePayableAmount?.let { " (${it.toPlainString()})" } ?: ""}"
|
||||
override fun toString() = "$details to $customer ${totalAmounts?.duePayableAmount?.let { " (${it.toPlainString()})" } ?: ""}"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package net.codinux.invoicing.model
|
||||
|
||||
import java.time.LocalDate
|
||||
|
||||
class InvoiceDetails(
|
||||
val invoiceNumber: String,
|
||||
val invoiceDate: LocalDate,
|
||||
|
||||
val dueDate: LocalDate? = null,
|
||||
val paymentDescription: String? = null,
|
||||
) {
|
||||
override fun toString() = "$invoiceDate $invoiceNumber"
|
||||
}
|
|
@ -3,10 +3,7 @@ package net.codinux.invoicing
|
|||
import net.codinux.invoicing.creation.EInvoiceCreator
|
||||
import net.codinux.invoicing.email.model.EmailAccount
|
||||
import net.codinux.invoicing.email.EmailsFetcher
|
||||
import net.codinux.invoicing.model.EInvoiceXmlFormat
|
||||
import net.codinux.invoicing.model.Invoice
|
||||
import net.codinux.invoicing.model.InvoiceItem
|
||||
import net.codinux.invoicing.model.Party
|
||||
import net.codinux.invoicing.model.*
|
||||
import net.codinux.invoicing.reader.EInvoiceReader
|
||||
import net.codinux.invoicing.validation.EInvoiceValidator
|
||||
import java.io.File
|
||||
|
@ -84,8 +81,7 @@ class Demonstration {
|
|||
|
||||
|
||||
private fun createInvoice() = Invoice(
|
||||
invoiceNumber = "RE-00001",
|
||||
invoiceDate = LocalDate.now(),
|
||||
details = InvoiceDetails("RE-00001", LocalDate.now()),
|
||||
supplier = Party("codinux GmbH & Co. KG", "Fun Street 1", null, "12345", "Glückstadt"),
|
||||
customer = Party("Abzock GmbH", "Ausbeutstr.", null, "12345", "Abzockhausen"),
|
||||
items = listOf(InvoiceItem("Erbrachte Dienstleistungen", BigDecimal(170), "HUR", BigDecimal(1_000_000), BigDecimal(19))) // HUR = EN code for hour
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package net.codinux.invoicing.test
|
||||
|
||||
import net.codinux.invoicing.model.BankDetails
|
||||
import net.codinux.invoicing.model.Invoice
|
||||
import net.codinux.invoicing.model.InvoiceItem
|
||||
import net.codinux.invoicing.model.Party
|
||||
import net.codinux.invoicing.model.*
|
||||
import java.math.BigDecimal
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
@ -57,7 +54,7 @@ object DataGenerator {
|
|||
dueDate: LocalDate? = DueDate,
|
||||
paymentDescription: String? = dueDate?.let { "Zahlbar ohne Abzug bis ${DateTimeFormatter.ofPattern("dd.MM.yyyy").format(dueDate)}" },
|
||||
buyerReference: String? = null
|
||||
) = Invoice(invoiceNumber, invoiceDate, supplier, customer, items, dueDate, paymentDescription, buyerReference)
|
||||
) = Invoice(InvoiceDetails(invoiceNumber, invoiceDate, dueDate, paymentDescription), supplier, customer, items, buyerReference)
|
||||
|
||||
fun createParty(
|
||||
name: String,
|
||||
|
|
|
@ -59,8 +59,8 @@ object InvoiceAsserter {
|
|||
fun assertInvoice(invoice: Invoice?) {
|
||||
assertThat(invoice).isNotNull()
|
||||
|
||||
assertThat(invoice!!.invoiceNumber).isEqualTo(DataGenerator.InvoiceNumber)
|
||||
assertThat(invoice.invoiceDate).isEqualTo(DataGenerator.InvoiceDate)
|
||||
assertThat(invoice!!.details.invoiceNumber).isEqualTo(DataGenerator.InvoiceNumber)
|
||||
assertThat(invoice.details.invoiceDate).isEqualTo(DataGenerator.InvoiceDate)
|
||||
|
||||
assertParty(invoice.supplier, DataGenerator.SupplierName, DataGenerator.SupplierAddress, DataGenerator.SupplierPostalCode, DataGenerator.SupplierCity, DataGenerator.SupplierCountry, DataGenerator.SupplierVatId, DataGenerator.SupplierEmail, DataGenerator.SupplierPhone, DataGenerator.SupplierBankDetails)
|
||||
|
||||
|
|
Loading…
Reference in New Issue