Skip to content

Add co-dian-item-identification and co-dian-tax-scheme extensions - #870

Closed
mrdanwa wants to merge 1 commit into
mainfrom
dian-extentions
Closed

mrdanwa wants to merge 1 commit into
mainfrom
dian-extentions

Conversation

@mrdanwa

@mrdanwa mrdanwa commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor
  • Added the co-dian-item-identification extension to carry the DIAN standard product code on line items.
  • Added the co-dian-tax-scheme extension to declare the party's tributo per DIAN table 13.2.6.2 (01 IVA / 04 INC / ZA IVA e INC / ZZ No aplica), with the Anexo Técnico v1.8 PDF as structured source.
  • Added validation rules, each verified against the DIAN habilitación environment:
    • 15: invoice code must be a positive integer (empty draft codes still pass).
    • 16: credit notes without a dian-cude stamp (91-22, sin referencia) cannot use credit code 2 (DIAN rule CBF03a).
    • 17: the period credited by a 91-22 note must stay within one calendar month (DIAN rule CAE02).
    • 18: a payment due date is required when the invoice is not fully paid (DIAN rule IA04).
    • BILL-LINE-01: line quantities must be positive (DIAN rule FAW01 rejects zero-amount lines).

Pre-Review Checklist

  • Opened this PR as a draft
  • Read the CONTRIBUTING.md guide.
  • Performed a self-review of my code.
  • Added thorough tests with at least 90% code coverage.
  • Modified or created example GOBL documents to show my changes in use, if appropriate.
  • Added links to the source of the changes in tax regimes or addons, either structured or in the comments.
  • Run go generate . to ensure that the Schemas and Regime data are up to date.
  • Reviewed and fixed all linter warnings.
  • Been obsessive with pointer nil checks to avoid panics.
  • Updated the CHANGELOG.md with an overview of my changes.
  • Marked this PR as ready for review.

And if you are part of the org:

  • Requested a review from Copilot and fixed or dismissed (with a reason) all the feedback raised.
  • Requested a review from @samlown.

@codecov

codecov Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.24561% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.90%. Comparing base (765f238) to head (b45eb8e).

Files with missing lines Patch % Lines
addons/co/dian/bill_invoices.go 98.03% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #870      +/-   ##
==========================================
+ Coverage   96.88%   96.90%   +0.01%     
==========================================
  Files         335      336       +1     
  Lines       15916    15973      +57     
==========================================
+ Hits        15421    15478      +57     
  Misses        494      494              
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI 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.

Pull request overview

Adds two new DIAN (Colombia) addon extensions to document item identification scheme and VAT regime, updates the generated addon data and changelog, and aligns the EN16931 generated rules to rely on the existing “VATEX or exemption note” validation.

Changes:

  • Add co-dian-item-identification and co-dian-regime extension definitions to the DIAN addon (Go source + generated addon JSON).
  • Update CHANGELOG.md to document the new DIAN extensions.
  • Remove the EN16931 rule that always required cef-vatex for exempt taxes (consistent with existing EN16931 logic that allows VATEX or exemption notes).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
data/rules/eu-en16931.json Removes the generated rule that forced VATEX on exempt tax combos (now relying on the existing “VATEX or exemption note” validation).
data/addons/co-dian-v2.json Adds the two new DIAN extension definitions to the generated addon data.
CHANGELOG.md Notes the two new DIAN extensions under Unreleased.
addons/co/dian/extensions.go Implements the two new DIAN extension definitions in the source addon definition list.

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

@mrdanwa
mrdanwa marked this pull request as ready for review June 18, 2026 08:36
Copilot AI review requested due to automatic review settings July 27, 2026 16:12
@mrdanwa
mrdanwa force-pushed the dian-extentions branch 2 times, most recently from 44d6e27 to 6728147 Compare July 27, 2026 16:16

Copilot AI 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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread addons/co/dian/bill_invoices.go
Comment thread addons/co/dian/bill_line.go
Comment thread addons/co/dian/bill_invoices_test.go
Copilot AI review requested due to automatic review settings July 27, 2026 16:21

Copilot AI 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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (2)

addons/co/dian/bill_invoices.go:173

  • code is an optional invoice field, but this rule relies on is.Matches treating empty strings as valid. Using rules.AssertIfPresent makes the optionality explicit and avoids accidental behavior changes if is.Matches semantics change later.
		rules.Field("code",
			rules.Assert("15", "invoice code must be a positive integer without leading zeroes",
				is.Matches(`^[1-9][0-9]*$`),
			),
		),

addons/co/dian/bill_line.go:11

  • The comment says DIAN rejects “zero-amount lines”, but the validation only checks that quantity is positive. Either adjust the comment to match the rule, or validate a computed monetary field (e.g., total) if that’s what DIAN actually requires.
		// Code 01: DIAN rule FAW01 rejects zero-amount lines, so quantities must be positive

Comment thread addons/co/dian/bill_invoices.go
Comment thread addons/co/dian/bill_invoices.go
Comment thread addons/co/dian/bill_line.go
Copilot AI review requested due to automatic review settings July 27, 2026 16:29

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

addons/co/dian/bill_invoices.go:172

  • This rule relies on is.Matches treating an empty string as valid, so invoice codes can be blank (as your tests cover). The assertion message currently reads like it always requires a positive integer; consider clarifying that the constraint applies only when a code is provided.
		// Code 15: DIAN numbering requires plain positive integers
		rules.Field("code",
			rules.Assert("15", "invoice code must be a positive integer without leading zeroes",
				is.Matches(`^[1-9][0-9]*$`),
			),

Comment thread addons/co/dian/bill_invoices.go
Comment thread addons/co/dian/bill_invoices.go Outdated
Comment thread data/rules/co-dian.json
Comment thread addons/co/dian/bill_invoices.go Outdated
Copilot AI review requested due to automatic review settings July 27, 2026 16:40

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

addons/co/dian/bill_line.go:11

  • The comment says this rule targets “zero-amount lines”, but the validation enforces only that quantity is positive (it doesn’t cover other ways a line amount could be zero). To avoid misleading future readers, reword the comment to match the actual constraint being enforced.
		// Code 01: DIAN rule FAW01 rejects zero-amount lines, so quantities must be positive

Copilot AI review requested due to automatic review settings July 27, 2026 16:46

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread addons/co/dian/bill_invoices.go
Copilot AI review requested due to automatic review settings July 27, 2026 16:53

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

addons/co/dian/bill_invoices.go:173

  • The invoice code format rule (15) applies to all DIAN invoices, including proforma (which is explicitly allowed by rule 01). If proforma documents are intended to behave like drafts, this will incorrectly reject common non-numeric proforma codes (e.g. PROF-001). Consider scoping rule 15 to standard, credit-note, and debit-note (or explicitly excluding proforma) to match the other DIAN-specific constraints (e.g. rule 18 already skips proformas).
		// Code 15: DIAN numbering requires plain positive integers
		rules.Field("code",
			rules.Assert("15", "invoice code must be a positive integer without leading zeroes",
				is.Matches(`^[1-9][0-9]*$`),
			),
		),

addons/co/dian/bill_line.go:13

  • The comment says DIAN rejects “zero-amount lines”, but the rule only enforces a positive quantity. Since org.Item.Price can be zero, a line can still have a zero amount even with a positive quantity. Either adjust the comment to reflect what’s actually validated, or extend validation to check the calculated line amount instead.
		// Code 01: DIAN rule FAW01 rejects zero-amount lines, so quantities must be positive
		rules.Field("quantity",
			rules.Assert("01", "must be greater than 0", num.Positive),

Comment thread CHANGELOG.md Outdated
Copilot AI review requested due to automatic review settings July 27, 2026 17:00

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

addons/co/dian/bill_invoices.go:172

  • is.Matches intentionally returns true for empty strings, so this assertion currently allows an empty invoice code even though the description says it must be a positive integer. If the intent is “validate format only when present” (as the tests suggest), make that explicit with rules.AssertIfPresent and update the message accordingly so we don’t rely on the surprising “empty matches” behavior of is.Matches.
		// Code 15: DIAN numbering requires plain positive integers
		rules.Field("code",
			rules.Assert("15", "invoice code must be a positive integer without leading zeroes",
				is.Matches(`^[1-9][0-9]*$`),
			),

addons/co/dian/bill_invoices.go:258

  • invoiceCreditSaleHasDueDate treats any non-nil dd.Date as a valid due date. A non-nil but zero-value date (e.g. &cal.Date{}) would satisfy this rule even though it effectively carries no due date.
	for _, dd := range inv.Payment.Terms.DueDates {
		if dd != nil && dd.Date != nil {
			return true
		}

@mrdanwa mrdanwa changed the title Add co-dian-item-identification and co-dian-regime extensions Add co-dian-item-identification and co-dian-tax-scheme extensions Sep 17, 2026
@mrdanwa
mrdanwa force-pushed the dian-extentions branch 2 times, most recently from d7351c4 to d5a719d Compare September 17, 2026 14:06
- co-dian-item-identification: product-coding standard for a line item's
  code (001 UNSPSC, 010 GTIN, 020 customs tariff, 999 taxpayer's own
  standard), for UBL StandardItemIdentification/ID@schemeID.
- co-dian-tax-scheme: the tributo the party is responsible for, per DIAN
  Anexo Tecnico v1.8 table 13.2.6.2 (01 IVA, 04 INC, ZA IVA e INC,
  ZZ No aplica), for the UBL PartyTaxScheme/TaxScheme group.
- Invoice rules 15-18: plain positive integer code, credit-note
  restrictions when the preceding document lacks a dian-cude stamp
  (no concept 2, period within one calendar month), and payment due
  date required on credit sales (DIAN rule IA04).
- Line rule 01: quantity must be positive (DIAN rule FAW01).
- Regenerate data/addons/co-dian-v2.json.
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