Skip to content

Update invoice and credit note schemas to follow PEPPOL BIS Invoice 3 specification#9

Merged
SimonLoir merged 7 commits intomainfrom
copilot/update-invoice-credit-notes
Apr 1, 2026
Merged

Update invoice and credit note schemas to follow PEPPOL BIS Invoice 3 specification#9
SimonLoir merged 7 commits intomainfrom
copilot/update-invoice-credit-notes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

  • Analyze current schemas vs OpenPEPPOL specification
  • Run existing tests to establish baseline (170/170 pass, 1 pre-existing failure)
  • Fix InvoicePeriodSchema - make descriptionCode optional (spec: 0..1)
  • Create Delivery schema (spec: cac:Delivery 0..1)
  • Create AllowanceCharge schema (document-level 0..n and line-level 0..n)
  • Create AdditionalDocumentReference schema (spec: 0..n)
  • Update Invoice schema - add missing fields (orderReference, billingReference, document references, delivery, allowanceCharge, projectReference)
  • Update CreditNote schema - inherit new fields from Invoice, omit projectReference per credit note spec
  • Update Line schema - add commodityClassification, line allowanceCharge, price baseQuantity, price allowanceCharge, update standardItemIdentification and additionalItemProperties
  • Update PaymentMeans schema - add paymentDueDate for credit notes
  • Update DocumentBuilder to handle new fields
  • Update DocumentParser to handle new fields
  • Update data files (basic-invoice.ts, basic-creditNote.ts) for schema changes
  • Update common/index.ts exports
  • Run tests - all 170 pass (1 pre-existing CJS build failure)
  • Self-review: fix __bool helper wiring, fix this-binding bug in builder line methods

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 1, 2026

Not up to standards ⛔

🔴 Issues 11 high

Alerts:
⚠ 11 issues (≤ 0 issues of at least minor severity)

Results:
11 new issues

Category Results
ErrorProne 11 high

View in Codacy

🟢 Metrics 8 complexity . -6 duplication

Metric Results
Complexity 8
Duplication -6

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

Copilot AI and others added 3 commits April 1, 2026 13:43
Agent-Logs-Url: https://github.com/PixelDrive/peppol-toolkit/sessions/66585be7-f643-4ca2-bff8-823420d86af2

Co-authored-by: SimonLoir <17649337+SimonLoir@users.noreply.github.com>
- Fix InvoicePeriodSchema: make descriptionCode optional (0..1)
- Create Delivery schema (cac:Delivery 0..1)
- Create AllowanceCharge schemas (document-level and line-level)
- Create AdditionalDocumentReference schema
- Update Invoice: add orderReference, billingReference, document references,
  delivery, allowanceCharge, projectReference
- Update CreditNote: inherit new Invoice fields, remove projectReference
- Update Line: add commodityClassification, lineAllowanceCharge,
  baseQuantity, priceAllowanceCharge, update standardItemIdentification
  and additionalItemProperties to match spec structure
- Update PaymentMeans: add paymentDueDate
- Update DocumentBuilder: handle all new fields
- Update DocumentParser: handle all new fields
- Update data files and tests for schema changes

Agent-Logs-Url: https://github.com/PixelDrive/peppol-toolkit/sessions/66585be7-f643-4ca2-bff8-823420d86af2

Co-authored-by: SimonLoir <17649337+SimonLoir@users.noreply.github.com>
Copilot AI changed the title [WIP] Update invoice and credit notes to follow specifications Update invoice and credit note schemas to follow PEPPOL BIS Invoice 3 specification Apr 1, 2026
Copilot AI requested a review from SimonLoir April 1, 2026 14:25
@SimonLoir
Copy link
Copy Markdown
Member

@copilot review

…ne methods

- Replace inline boolean expressions with __bool() helper in parser
- Fix __buildInvoiceLine/_buildCreditNoteLine losing `this` context
  when passed as .map() callbacks and using DocumentBuilder.prototype
- Call __buildLineItem directly with arrow functions to preserve `this`
- Remove now-unused wrapper methods

Agent-Logs-Url: https://github.com/PixelDrive/peppol-toolkit/sessions/b68d20b9-7ae6-4674-b8a6-f82e74b3eb83

Co-authored-by: SimonLoir <17649337+SimonLoir@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 1, 2026

@copilot review

Self-review found and fixed two bugs in 093527b:

  1. this-binding bug in builder__buildInvoiceLine and _buildCreditNoteLine were passed as bare .map() callbacks (losing this) and internally called DocumentBuilder.prototype.__buildLineItem(...) (also wrong this). This would crash at runtime when a line has allowanceCharge set, since __buildLineItem calls this.__buildLineAllowanceCharge(). Fixed by calling this.__buildLineItem(line, tag) directly via arrow functions.

  2. __bool helper unused — The helper was added but the two inline boolean expressions were never updated. Now wired in both __parseAllowanceCharges and __parseLineItem.

@SimonLoir SimonLoir marked this pull request as ready for review April 1, 2026 16:24
@SimonLoir SimonLoir merged commit 18816a6 into main Apr 1, 2026
2 of 3 checks passed
@SimonLoir SimonLoir deleted the copilot/update-invoice-credit-notes branch April 1, 2026 16:26
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.

2 participants