Skip to content

Allow specifying the QR-Code size in invoices#1489

Merged
nielsdrost7 merged 7 commits intoInvoicePlane:prep/v172from
mpldr-pulls:qr-size
Mar 23, 2026
Merged

Allow specifying the QR-Code size in invoices#1489
nielsdrost7 merged 7 commits intoInvoicePlane:prep/v172from
mpldr-pulls:qr-size

Conversation

@mpldr
Copy link
Copy Markdown
Collaborator

@mpldr mpldr commented Mar 22, 2026

Pull Request Checklist

Please check the following steps before submitting your PR. If any items are incomplete, consider marking it as [WIP] (Work in Progress).

Checklist

  • My code follows the code formatting guidelines.
  • I have tested my changes locally.
  • I selected the appropriate branch for this PR.
  • I have rebased my changes on top of the selected branch.
  • I included relevant documentation updates if necessary.
  • I have an accompanying issue ID for this pull request. (QR Code image on invoice layout too big in size #1376)

Description

Having the QR-Code be 10x10 cm in size is quite a bit too large for most invoices. This PR changes the size to be configurable, with the default at a much more reasonable 64 px.


Related Issue(s)

Fixes #1376 (again)


Motivation and Context

Had to edit the helper function in my deployment and thought to upstream the change.


Issue Type (Check one or more)

  • Bugfix
  • Improvement of an existing feature
  • New feature

Screenshots (If Applicable)

image image

My banking app had no issues reading the smaller QR code, please feel free to test with your own :P


Thank you for your contribution to InvoicePlane! We appreciate your time and effort.

Summary by CodeRabbit

  • New Features
    • QR code images in invoices now support customizable width sizing with a default of 64 pixels.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 22, 2026

📝 Walkthrough

Walkthrough

The invoice_qrcode helper function now accepts an optional $width parameter (default: 64) to control QR code sizing. The generated HTML <img> tag conditionally includes a width attribute only when the parameter is a positive integer, otherwise omitting it entirely.

Changes

Cohort / File(s) Summary
Invoice QR Code Helper
application/helpers/invoice_helper.php
Added optional $width parameter (default: 64) to invoice_qrcode() function with conditional width attribute rendering in the output <img> tag.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A QR code once stretched far too wide,
Now $width lets us choose with pride!
Default sixty-four, or pass what you please,
Invoice layouts adjusted with ease! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: making QR code size configurable in invoices, which directly addresses the core objective.
Linked Issues check ✅ Passed The PR successfully implements the objectives from issue #1376 by adding a configurable $width parameter with a reasonable default (64px) to reduce QR code size.
Out of Scope Changes check ✅ Passed All changes are scoped to the invoice_qrcode function's width parameter, directly addressing issue #1376 requirements with no extraneous modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Tip

Migrating from UI to YAML configuration.

Use the @coderabbitai configuration command in a PR comment to get a dump of all your UI settings in YAML format. You can then edit this YAML file and upload it to the root of your repository to configure CodeRabbit programmatically.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
application/helpers/invoice_helper.php (2)

126-128: Consider adding parameter type hints for clarity.

The coding guidelines recommend using type hints for all parameters where possible. Adding type hints would make the API contract clearer.

♻️ Suggested improvement
 /**
  * Returns a QR code for invoice payments.
  *
- * `@param` number invoice-id
- * `@param` number width
+ * `@param` int $invoice_id
+ * `@param` int $width Width in pixels (0 or negative to omit)
  */
-function invoice_qrcode($invoice_id, $width = 64): string
+function invoice_qrcode(int $invoice_id, int $width = 64): string

As per coding guidelines: "Use type hints for all parameters and return types where possible".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@application/helpers/invoice_helper.php` around lines 126 - 128, The
invoice_qrcode function lacks parameter type hints; update its signature
(function invoice_qrcode) to add appropriate types for $invoice_id and $width
(e.g., int $invoice_id, int $width = 64) while keeping the existing string
return type, and then run a quick search for usages/call sites to adjust any
places passing non-integer values or cast them as needed so the new type hints
do not break callers.

128-128: Consider increasing the default or passing a custom width in PDF templates.

The PDF template at application/views/invoice_templates/pdf/InvoicePlane.php:352 currently uses the default 64px width without customization. At 300 DPI, this translates to ~5.4mm, which may be marginal for reliable QR code scanning in print contexts. Either increase the default width or pass a larger custom value specifically for PDF templates.

Additionally, document the recommended size ranges for different output contexts (web vs. PDF).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@application/helpers/invoice_helper.php` at line 128, The invoice_qrcode
function currently defaults to a small 64px width; update it to either a larger
safer default (e.g. 128px) or keep 64px but ensure the PDF template calls
invoice_qrcode($invoice_id, $width) with an increased width (suggest 128–300px
depending on DPI), and add a short docblock above invoice_qrcode describing
recommended sizes for web (64–128px) vs PDF/print (128–300px) so template
authors know what to use; make the change by editing the invoice_qrcode
signature and its docblock and by updating the PDF template (InvoicePlane.php)
to pass a larger width if you opt to keep the smaller default.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@application/helpers/invoice_helper.php`:
- Around line 126-128: The invoice_qrcode function lacks parameter type hints;
update its signature (function invoice_qrcode) to add appropriate types for
$invoice_id and $width (e.g., int $invoice_id, int $width = 64) while keeping
the existing string return type, and then run a quick search for usages/call
sites to adjust any places passing non-integer values or cast them as needed so
the new type hints do not break callers.
- Line 128: The invoice_qrcode function currently defaults to a small 64px
width; update it to either a larger safer default (e.g. 128px) or keep 64px but
ensure the PDF template calls invoice_qrcode($invoice_id, $width) with an
increased width (suggest 128–300px depending on DPI), and add a short docblock
above invoice_qrcode describing recommended sizes for web (64–128px) vs
PDF/print (128–300px) so template authors know what to use; make the change by
editing the invoice_qrcode signature and its docblock and by updating the PDF
template (InvoicePlane.php) to pass a larger width if you opt to keep the
smaller default.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 680582af-46ac-4720-b973-f9cb8cf1c0fd

📥 Commits

Reviewing files that changed from the base of the PR and between 2bf9fc7 and 7088c9d.

📒 Files selected for processing (1)
  • application/helpers/invoice_helper.php

@mpldr
Copy link
Copy Markdown
Collaborator Author

mpldr commented Mar 22, 2026

Re: nitpicks

I wanted to do the first, but that would be a breaking change.

The second one ist really applicable. See Screenshots for Details.

@nielsdrost7 nielsdrost7 changed the base branch from develop to prep/v172 March 23, 2026 02:13
@nielsdrost7
Copy link
Copy Markdown
Contributor

@mpldr thanks for the PR, man! Merged

@nielsdrost7 nielsdrost7 merged commit f4dacd4 into InvoicePlane:prep/v172 Mar 23, 2026
1 check passed
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.

QR Code image on invoice layout too big in size

2 participants