Skip to content

added all EN16931 invoice types to UBL writer#846

Merged
stephanstapel merged 1 commit intomasterfrom
ubl-invoice-types
Dec 13, 2025
Merged

added all EN16931 invoice types to UBL writer#846
stephanstapel merged 1 commit intomasterfrom
ubl-invoice-types

Conversation

@stephanstapel
Copy link
Owner

Summary

Added all EN16931 invoice types to UBL writer

Checklist

  • Code follows repo Coding Instructions
  • Public APIs documented (XML)
  • Unit tests added/updated
  • No blocking async (.Result / GetAwaiter().GetResult())
  • CancellationToken respected
  • Analyzers clean (dotnet build no warnings as errors)
  • dotnet format --verify-no-changes passes

Breaking changes?

  • No
  • Yes (explain impact & migration)

Copilot AI review requested due to automatic review settings December 13, 2025 20:30
@stephanstapel stephanstapel merged commit 98e9c43 into master Dec 13, 2025
6 checks passed
@stephanstapel stephanstapel deleted the ubl-invoice-types branch December 13, 2025 20:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the invoice type classification logic in the UBL writer to support all EN16931 invoice types. The previous implementation only handled three invoice types (Invoice, Correction, and CreditNote) and threw exceptions for all others. The new implementation comprehensively classifies all 13 credit note types defined in the EN16931 standard.

  • Replaced hardcoded if-else chain with a dedicated _IsInvoiceAccordingToEn16931 method using a switch statement
  • Added support for 12 additional credit note types that were previously unsupported
  • Changed error handling behavior from throwing NotImplementedException to treating unknown types as invoices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1143 to +1164
private bool _IsInvoiceAccordingToEn16931(InvoiceType type)
{
switch (type)
{
case InvoiceType.CreditNoteRelatedToGoodsOrServices:
case InvoiceType.CreditNoteRelatedToFinancialAdjustments:
case InvoiceType.SelfBilledCreditNote:
case InvoiceType.ConsolidatedCreditNoteGoodsAndServices:
case InvoiceType.CreditNoteForPriceVariation:
case InvoiceType.DelcredereCreditNote:
case InvoiceType.CreditNote:
case InvoiceType.FactoredCreditNote:
case InvoiceType.OcrPaymentCreditNote:
case InvoiceType.ReversalOfCredit:
case InvoiceType.SelfBilledFactoredCreditNote:
case InvoiceType.PrepaymentCreditNoteCorrected:
case InvoiceType.ForwardersCreditNote:
return false;
default:
return true;
}
} // !_IsInvoiceAccordingToEn16931()
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

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

The _IsInvoiceAccordingToEn16931 method has comprehensive coverage of EN16931 credit note types. However, there's no test coverage for this new functionality. The PR checklist indicates "Unit tests added/updated" is not checked. Consider adding tests that verify:

  1. All credit note invoice types return false
  2. All invoice types return true
  3. Edge cases with new invoice types that may be added in the future are handled correctly by the default case

This is especially important since the old code would throw NotImplementedException for unsupported types, but the new code silently treats them as invoices via the default case, which is a behavioral change.

Copilot uses AI. Check for mistakes.
Comment on lines +1161 to +1162
default:
return true;
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

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

The default case returns true for all invoice types not explicitly listed as credit notes. While this approach works for current EN16931 types, it changes the behavior from the previous implementation which threw NotImplementedException for unrecognized types. Consider adding a comment documenting that:

  1. All EN16931 invoice types are covered by this method
  2. The default case assumes new types will be invoices unless explicitly added to the credit note list

This will help future maintainers understand the design decision and remember to update this method when new credit note types are added to the InvoiceType enum.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

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.

1 participant