Skip to content

Add invoicing period (BG-14) and invoice line period (BG-26) - #12

Open
alexbabintsev wants to merge 1 commit into
codebarista-de:masterfrom
alexbabintsev:invoicing-period
Open

alexbabintsev wants to merge 1 commit into
codebarista-de:masterfrom
alexbabintsev:invoicing-period

Conversation

@alexbabintsev

Copy link
Copy Markdown

Closes #11.

Adds the invoicing period (BG-14) and the invoice line period (BG-26), so an XRechnung for services or subscriptions can state the period of supply and no longer gets KoSIT's BR-DE-TMP-32 warning.

  • New model class InvoicingPeriod with startDate (BT-73 / BT-134) and endDate (BT-74 / BT-135), used by Invoice.invoicingPeriod(...) and Item.invoiceLinePeriod(...), in the same builder style as the other model classes.
  • CIIXMLEInvoiceWriter writes ram:BillingSpecifiedPeriod in ApplicableHeaderTradeSettlement after the ram:ApplicableTradeTax elements, and in SpecifiedLineTradeSettlement after the line's ram:ApplicableTradeTax, as the CII schema orders them. Only the dates that are set are written; a period with neither date is left out, so no empty element appears.
  • New scenario order_with_invoicing_period (the PayPal order with a November 2024 period on the invoice and on its line), for XRECHNUNG and EN16931_CORE, plus two null-safety tests.

Checked: ./gradlew test passes (69 tests, Java 17). Both expected files of the new scenario pass the XRechnung 3.0.2 and EN 16931 CII Schematron without findings.

I left the version number and the changelog to you. BT-72 without a deliver-to party, the third point in the issue, is not part of this PR.

@embewee embewee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR and the detailed issue, we appreciate your contribution! (I've added a contributing note to the README to make clear that PRs are welcome.)
Sorry, another PR was merged in the meantime and now conflicts with this one. Could you rebase onto master? The implementation looks good, I added some comments to address prior to merging

* If the period is given, at least one of the two dates must be set (BR-CO-19, BR-CO-20), and the end date must not
* be before the start date (BR-29, BR-30).
*/
public class InvoicingPeriod {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BGs have different names, we should reflect this here. Suggested name: InvoicingOrInvoiceLinePeriod. The actual property names in Invoice and Item can remain unchanged.

Element specifiedSettlement = builder.createElement(NS_RAM, "SpecifiedLineTradeSettlement");
tradeLineItem.appendChild(specifiedSettlement);
specifiedSettlement.appendChild(createTax(builder, lineItem.getVat()));
if (hasDate(lineItem.getInvoiceLinePeriod())) { // BG-26

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (hasDate(lineItem.getInvoiceLinePeriod())) { // BG-26
if (lineItem.getInvoiceLinePeriod() != null) { // BG-26

If the element shall not be written, the value must be set to null. That's how it's already done in other parts of the code

for (Vat totalVat : invoice.getVatTotals()) {
tradeSettlement.appendChild(createTax(builder, totalVat));
}
if (hasDate(invoice.getInvoicingPeriod())) { // BG-14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (hasDate(invoice.getInvoicingPeriod())) { // BG-14
if (lineItem.getInvoiceLinePeriod() != null) { // BG-14

Comment on lines +556 to +559
private static boolean hasDate(InvoicingPeriod period) {
return period != null && (period.getStartDate() != null || period.getEndDate() != null);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static boolean hasDate(InvoicingPeriod period) {
return period != null && (period.getStartDate() != null || period.getEndDate() != null);
}

Comment on lines +52 to +63
"deliveryInfo": {
"name": "Frida Fehlerfinder",
"deliveryAddress": {
"addressLineOne": "Problemstraße",
"addressLineTwo": null,
"addressLineThree": null,
"city": "Fehlstadt",
"zipCode": "10004",
"countryIsoCode": "DE"
},
"actualDeliveryDate": null
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"deliveryInfo": {
"name": "Frida Fehlerfinder",
"deliveryAddress": {
"addressLineOne": "Problemstraße",
"addressLineTwo": null,
"addressLineThree": null,
"city": "Fehlstadt",
"zipCode": "10004",
"countryIsoCode": "DE"
},
"actualDeliveryDate": null
},
"deliveryInfo": null,

We should test that the period alone satisfies the business rule

"quantity": 13,
"unitCode": "XPP",
"itemTotalNetAmount": 8193.28,
"name": "Hauptprodukt mit erweiterten Preisen",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"name": "Hauptprodukt mit erweiterten Preisen",
"name": "Subscription",

nit

Comment on lines +115 to +122
"charges": [
{
"netAmount": 0.00,
"vatCategory": "S",
"vatRate": 19,
"reason": "Versandkosten"
}
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"charges": [
{
"netAmount": 0.00,
"vatCategory": "S",
"vatRate": 19,
"reason": "Versandkosten"
}
]
"charges": []

nit: subscription has no shipping costs

"meansType": "68",
"meansText": null,
"remittanceInfo": null,
"paymentTerms": "Die Ware bleibt, bis zur vollständigen Bezahlung, unser Eigentum.\nLeistungsdatum entspricht Rechnungsdatum",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"paymentTerms": "Die Ware bleibt, bis zur vollständigen Bezahlung, unser Eigentum.\nLeistungsdatum entspricht Rechnungsdatum",
"paymentTerms": "Zahlbar innerhalb von 14 Tagen ohne Abzug.",

nit: "Leistungsdatum entspricht Rechnungsdatum" doesn't fit an invoice that has a service period

@alexbabintsev

Copy link
Copy Markdown
Author

Thanks for the review! Rebased onto master and addressed the comments:

  • renamed the class to InvoicingOrInvoiceLinePeriod (property names in Invoice and Item unchanged)
  • removed hasDate(): BG-14 and BG-26 are written when the property is not null, as elsewhere (for BG-14 I used invoice.getInvoicingPeriod() != null, the suggestion had lineItem.getInvoiceLinePeriod())
  • the scenario has no delivery info now, so the period alone covers the rule; item renamed to "Subscription", no shipping charge, payment terms that fit a service period
  • expected XMLs regenerated; all 71 tests pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support the invoicing period (BG-14) and invoice line period (BG-26)

2 participants