Skip to content

Validate advances are non-negative pt-saft-v1#830

Merged
samlown merged 1 commit into
mainfrom
prevent-negative-payment-amount
May 12, 2026
Merged

Validate advances are non-negative pt-saft-v1#830
samlown merged 1 commit into
mainfrom
prevent-negative-payment-amount

Conversation

@cavalle
Copy link
Copy Markdown
Contributor

@cavalle cavalle commented May 12, 2026

  • Adds rule to check that advance payment amounts on invoices are no less than 0 as required by the SAF-T spec.

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.

Copy link
Copy Markdown
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

Adds a Portugal SAF-T (pt-saft-v1) validation rule to ensure invoice advance payment amounts are non-negative, aligning invoice validation behavior with the SAF-T specification.

Changes:

  • Added a pt-saft invoice rule to validate that each advance payment amount is >= 0.
  • Updated the generated rules data (data/rules/pt-saft.json) to include the new assertion.
  • Added a unit test covering the negative-advance validation failure case.

Reviewed changes

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

File Description
data/rules/pt-saft.json Adds rule metadata for validating non-negative advance amounts on invoices.
addons/pt/saft/invoices.go Enforces num.ZeroOrPositive on payment.advances[].amount.
addons/pt/saft/invoices_test.go Adds test ensuring negative advance amounts fail validation.
CHANGELOG.md Documents the new pt-saft-v1 validation rule in Unreleased.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.39%. Comparing base (4cdd472) to head (8d6df9b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #830   +/-   ##
=======================================
  Coverage   93.39%   93.39%           
=======================================
  Files         369      369           
  Lines       20121    20124    +3     
=======================================
+ Hits        18792    18795    +3     
  Misses        888      888           
  Partials      441      441           

☔ View full report in Codecov by Sentry.
📢 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.

@cavalle cavalle marked this pull request as ready for review May 12, 2026 11:27
@cavalle cavalle requested a review from samlown May 12, 2026 11:27
@mintlify
Copy link
Copy Markdown

mintlify Bot commented May 12, 2026

Docs PR opened: invopop/gobl.docs#49

Added a validation rule entry documenting that advance payment amounts on Portuguese SAF-T invoices must not be negative.

@mintlify
Copy link
Copy Markdown

mintlify Bot commented May 12, 2026

Docs PR opened: invopop/docs.invopop.com#385

Added a Portugal entry to the May 12, 2026 changelog noting the new SAF-T validation rejecting negative advance payment amounts.

@samlown samlown merged commit 5ed4398 into main May 12, 2026
12 checks passed
@samlown samlown deleted the prevent-negative-payment-amount branch May 12, 2026 15:19
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.

3 participants