Skip to content

fix: include payable amount when zero and respect generateOnZero flag#12

Merged
SimonLoir merged 2 commits into
mainfrom
fix-zero-payable-amount
May 13, 2026
Merged

fix: include payable amount when zero and respect generateOnZero flag#12
SimonLoir merged 2 commits into
mainfrom
fix-zero-payable-amount

Conversation

@SimonLoir

Copy link
Copy Markdown
Member

This commit addresses an issue where zero payable amounts were not included correctly and ensures other zero amounts are omitted when the generateOnZero flag is set to false.

@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Rate limit exceeded

@SimonLoir has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 56 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ff2a58ed-0dce-44ec-a8bd-4774b5049c7f

📥 Commits

Reviewing files that changed from the base of the PR and between 95ccb1d and cbb712b.

📒 Files selected for processing (1)
  • package.json
📝 Walkthrough

Walkthrough

The PR updates monetary XML generation in Peppol UBL documents to correctly emit PayableAmount when its value is 0, while preserving the existing behavior of omitting null or undefined amounts. A new type-guard helper distinguishes these cases, and tests validate the behavior for both invoices and credit notes.

Changes

PayableAmount zero-value handling

Layer / File(s) Summary
Type guard and amount generation logic
src/helpers/isNullish.ts, src/builder/DocumentBuilder.ts
isNullish type guard is introduced to check for null or undefined. DocumentBuilder imports it, extends __buildAmount with an optional generateOnZero parameter to allow zero-value emission, and updates __buildMonetaryTotal to pass the flag when building PayableAmount.
Test validation for invoice and credit note
tests/builder-invoice.test.ts, tests/builder-creditnote.test.ts
Two test cases per document type validate that PayableAmount is always included with 0.00 when zero, and that other zero-valued monetary fields are omitted when generateOnZero is false.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PixelDrive/peppol-toolkit#10: Both PRs modify __buildMonetaryTotal and __buildAmount logic in DocumentBuilder to change how cbc:PayableAmount is emitted for zero values.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: ensuring payable amounts are included when zero while respecting the generateOnZero flag for other amounts.
Description check ✅ Passed The description directly relates to the changeset by explaining the fix for zero payable amounts and the generateOnZero flag behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-zero-payable-amount

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/helpers/isNullish.ts`:
- Around line 1-2: The isNullish function currently types its parameter as any;
change the parameter type to unknown to improve type safety while preserving the
type guard signature (export const isNullish = (value: unknown): value is null |
undefined => ...). Update the parameter type in the isNullish function
definition and keep the existing null/undefined checks so the runtime behavior
and the type predicate remain unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 704a6b34-3541-4aa5-8ba9-18960f0be3ce

📥 Commits

Reviewing files that changed from the base of the PR and between 9ae7ba1 and 95ccb1d.

📒 Files selected for processing (4)
  • src/builder/DocumentBuilder.ts
  • src/helpers/isNullish.ts
  • tests/builder-creditnote.test.ts
  • tests/builder-invoice.test.ts

Comment thread src/helpers/isNullish.ts
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high

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

Results:
1 new issue

Category Results
BestPractice 1 high

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@SimonLoir SimonLoir merged commit 1ea26b7 into main May 13, 2026
3 of 4 checks passed
@SimonLoir SimonLoir deleted the fix-zero-payable-amount branch May 13, 2026 22:47
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