Repository navigation
feat(pos): copy invoice as image from invoice history - #401
Open
NotAbdelrahmanelsayed wants to merge 3 commits into
Open
NotAbdelrahmanelsayed wants to merge 3 commits into
NotAbdelrahmanelsayed wants to merge 3 commits into
Conversation
Adds a "Copy as Image" button next to Print / Create Return in the Invoice History dialog. The invoice is rendered from the same /printview page the Print button opens (built-in receipt for offline invoices) in a hidden iframe, rasterized with html-to-image, and written to the clipboard as PNG. When the clipboard is unavailable (http, permission denied) it downloads <invoice>.jpg instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XwETwvYEMLVxyZ79tn7czZ
Invoice rows from some list endpoints omit pos_profile, which made the image fall back to the default print format instead of the profile's. Look the profile up from the Sales Invoice when it's missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XwETwvYEMLVxyZ79tn7czZ
|
This pull request has been automatically marked as stale because it has not had recent activity for 21 days. To keep this PR open, please:
If no further activity occurs within the next 14 days, this PR will be automatically closed. |
…e-image-pr # Conflicts: # pos_next/translations/ar.csv
Contributor
Author
|
I merged current |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Copy as Image button next to Print / Create Return in the Invoice History dialog, so cashiers can paste a customer's receipt straight into WhatsApp/Telegram/email without printing.
How it works
/printviewpage the Print button opens (profile print format + letterhead, notrigger_print) in a hidden, same-origin iframe, and the.print-formatelement is rasterized withhtml-to-image. Pending offline invoices fall back to the built-in receipt (buildReceiptDocumentHTML).html-to-imagerenders through SVGforeignObject, so the browser does the text shaping. Arabic/RTL item names come out correctly, which html2canvas gets wrong.image/pnginClipboardItem. The blob promise is passed directly toClipboardItemso Safari keeps the user gesture.<invoice>.jpgis downloaded instead and an info toast says so.Changes
POS/src/utils/invoiceImage.js(new):renderInvoiceImage()andcopyInvoiceImage()POS/src/utils/printInvoice.js: exportDEFAULT_PRINT_FORMAT,buildReceiptDocumentHTMLandresolvePrintSettingsfor reuse (no behaviour change)POS/src/components/sale/InvoiceHistoryDialog.vue: new action button and handlerpos_next/translations/ar.csv: Arabic strings for the button, toasts and errorsPOS/package.json: addhtml-to-image@^1.11.13Notes for reviewers
.print-formatan A4min-height, a shadow and margins. These are stripped on the throwaway iframe node before capture, otherwise the image has a large blank area at the bottom.html-to-image'stoBlob()ignorestype/qualityand always returns PNG, so the util usestoCanvas()+canvas.toBlob(type)to produce a real JPEG for the download.Testing
Tested on a live ERPNext v15 site with an Arabic-locale POS, using Playwright:
<invoice>.jpgdownloaded (verified real JPEG) + info toast🤖 Generated with Claude Code
https://claude.ai/code/session_01XwETwvYEMLVxyZ79tn7czZ