Renamed totalAmounts to totals and added articleNumber to InvoiceItem
This commit is contained in:
parent
e76a130a75
commit
ad23dc3fc3
|
@ -32,7 +32,7 @@ val fetchResult = emailsFetcher.fetchAllEmails(EmailAccount(
|
||||||
))
|
))
|
||||||
|
|
||||||
fetchResult.emails.forEach { email ->
|
fetchResult.emails.forEach { email ->
|
||||||
println("${email.sender}: ${email.attachments.firstNotNullOfOrNull { it.invoice }?.totalAmounts?.duePayableAmount}")
|
println("${email.sender}: ${email.attachments.firstNotNullOfOrNull { it.invoice }?.totals?.duePayableAmount}")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ open class MustangMapper(
|
||||||
adjustments.allowances.forEach { this.addAllowance(mapAllowance(it)) }
|
adjustments.allowances.forEach { this.addAllowance(mapAllowance(it)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoice.totalAmounts == null) {
|
if (invoice.totals == null) {
|
||||||
invoice.totalAmounts = calculator.calculateTotalAmounts(this)
|
invoice.totals = calculator.calculateTotalAmounts(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,10 @@ open class MustangMapper(
|
||||||
|
|
||||||
open fun mapLineItem(item: InvoiceItem): IZUGFeRDExportableItem = Item(
|
open fun mapLineItem(item: InvoiceItem): IZUGFeRDExportableItem = Item(
|
||||||
// description has to be an empty string if not set
|
// description has to be an empty string if not set
|
||||||
Product(item.name, item.description ?: "", item.unit, item.vatRate), item.unitPrice, item.quantity
|
Product(item.name, item.description ?: "", item.unit, item.vatRate).apply {
|
||||||
|
this.sellerAssignedID = item.articleNumber // TODO: what is the articleNumber? sellerAssignedId, globalId, ...?
|
||||||
|
},
|
||||||
|
item.unitPrice, item.quantity
|
||||||
).apply {
|
).apply {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,7 +104,7 @@ open class MustangMapper(
|
||||||
|
|
||||||
amountAdjustments = mapAmountAdjustments(invoice),
|
amountAdjustments = mapAmountAdjustments(invoice),
|
||||||
|
|
||||||
totalAmounts = calculator.calculateTotalAmounts(invoice)
|
totals = calculator.calculateTotalAmounts(invoice)
|
||||||
)
|
)
|
||||||
|
|
||||||
open fun mapParty(party: TradeParty) = Party(
|
open fun mapParty(party: TradeParty) = Party(
|
||||||
|
@ -111,7 +114,7 @@ open class MustangMapper(
|
||||||
)
|
)
|
||||||
|
|
||||||
open fun mapLineItem(item: IZUGFeRDExportableItem) = InvoiceItem(
|
open fun mapLineItem(item: IZUGFeRDExportableItem) = InvoiceItem(
|
||||||
item.product.name, item.quantity, item.product.unit, item.price, item.product.vatPercent, item.product.description.takeUnless { it.isBlank() }
|
item.product.name, item.quantity, item.product.unit, item.price, item.product.vatPercent, item.product.sellerAssignedID, item.product.description.takeUnless { it.isBlank() }
|
||||||
)
|
)
|
||||||
|
|
||||||
protected open fun mapAmountAdjustments(invoice: Invoice): AmountAdjustments? {
|
protected open fun mapAmountAdjustments(invoice: Invoice): AmountAdjustments? {
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Invoice(
|
||||||
* For outgoing invoices: You don't have to calculate them, we do this for you. This ensures that all total amounts
|
* For outgoing invoices: You don't have to calculate them, we do this for you. This ensures that all total amounts
|
||||||
* are in accordance to other data of the invoice like the invoice item amounts and amount adjustments.
|
* are in accordance to other data of the invoice like the invoice item amounts and amount adjustments.
|
||||||
*/
|
*/
|
||||||
var totalAmounts: TotalAmounts? = null
|
var totals: TotalAmounts? = null
|
||||||
) {
|
) {
|
||||||
override fun toString() = "$details to $customer ${totalAmounts?.duePayableAmount?.let { " (${it.toPlainString()})" } ?: ""}"
|
override fun toString() = "$details to $customer ${totals?.duePayableAmount?.let { " (${it.toPlainString()})" } ?: ""}"
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ class InvoiceItem(
|
||||||
val unit: String,
|
val unit: String,
|
||||||
val unitPrice: BigDecimal,
|
val unitPrice: BigDecimal,
|
||||||
val vatRate: BigDecimal,
|
val vatRate: BigDecimal,
|
||||||
|
val articleNumber: String? = null,
|
||||||
val description: String? = null,
|
val description: String? = null,
|
||||||
) {
|
) {
|
||||||
override fun toString() = "$name, $quantity x $unitPrice, $vatRate %"
|
override fun toString() = "$name, $quantity x $unitPrice, $vatRate %"
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Demonstration {
|
||||||
))
|
))
|
||||||
|
|
||||||
fetchResult.emails.forEach { email ->
|
fetchResult.emails.forEach { email ->
|
||||||
println("${email.sender}: ${email.attachments.firstNotNullOfOrNull { it.invoice }?.totalAmounts?.duePayableAmount}")
|
println("${email.sender}: ${email.attachments.firstNotNullOfOrNull { it.invoice }?.totals?.duePayableAmount}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.codinux.invoicing.test
|
package net.codinux.invoicing.test
|
||||||
|
|
||||||
|
import net.codinux.invoicing.calculator.AmountsCalculator
|
||||||
import net.codinux.invoicing.model.*
|
import net.codinux.invoicing.model.*
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
@ -21,7 +22,7 @@ object DataGenerator {
|
||||||
const val SupplierEmail = "working-class-hero@rock.me"
|
const val SupplierEmail = "working-class-hero@rock.me"
|
||||||
const val SupplierPhone = "+4917012345678"
|
const val SupplierPhone = "+4917012345678"
|
||||||
val SupplierFax: String? = null
|
val SupplierFax: String? = null
|
||||||
val SupplierBankDetails = BankDetails("DE00123456780987654321", "ABZODEFFXXX", "Manuela Musterfrau")
|
val SupplierBankDetails = BankDetails("DE00123456780987654321", "ABZODEFFXXX", "Manuela Musterfrau", "Abzock-Bank")
|
||||||
|
|
||||||
const val CustomerName = "Untertänigster Leistungsempfänger"
|
const val CustomerName = "Untertänigster Leistungsempfänger"
|
||||||
const val CustomerAddress = "Party Street 1"
|
const val CustomerAddress = "Party Street 1"
|
||||||
|
@ -40,6 +41,7 @@ object DataGenerator {
|
||||||
const val ItemUnit = "HUR" // EN code for 'hour'
|
const val ItemUnit = "HUR" // EN code for 'hour'
|
||||||
val ItemUnitPrice = BigDecimal(99)
|
val ItemUnitPrice = BigDecimal(99)
|
||||||
val ItemVatRate = BigDecimal(19)
|
val ItemVatRate = BigDecimal(19)
|
||||||
|
val ItemArticleNumber: String? = null
|
||||||
val ItemDescription: String? = null
|
val ItemDescription: String? = null
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,8 +55,9 @@ object DataGenerator {
|
||||||
items: List<InvoiceItem> = listOf(createItem()),
|
items: List<InvoiceItem> = 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)}" },
|
||||||
buyerReference: String? = null
|
) = Invoice(InvoiceDetails(invoiceNumber, invoiceDate, dueDate, paymentDescription), supplier, customer, items).apply {
|
||||||
) = Invoice(InvoiceDetails(invoiceNumber, invoiceDate, dueDate, paymentDescription), supplier, customer, items, buyerReference)
|
this.totals = AmountsCalculator().calculateTotalAmounts(this)
|
||||||
|
}
|
||||||
|
|
||||||
fun createParty(
|
fun createParty(
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -77,7 +80,8 @@ object DataGenerator {
|
||||||
unit: String = ItemUnit,
|
unit: String = ItemUnit,
|
||||||
unitPrice: BigDecimal = ItemUnitPrice,
|
unitPrice: BigDecimal = ItemUnitPrice,
|
||||||
vatRate: BigDecimal = ItemVatRate,
|
vatRate: BigDecimal = ItemVatRate,
|
||||||
|
articleNumber: String? = ItemArticleNumber,
|
||||||
description: String? = ItemDescription,
|
description: String? = ItemDescription,
|
||||||
) = InvoiceItem(name, quantity, unit, unitPrice, vatRate, description)
|
) = InvoiceItem(name, quantity, unit, unitPrice, vatRate, articleNumber, description)
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue