Issue PDF: bold the last 8 of 17-character VINs

Matches the on-screen VIN: 17-character VINs show the last 8 in bold
(what dealerships ask for), older or short VINs plain. Uses
redmine_qbo's HTML values in the PDF grid when available; with an older
redmine_qbo the last 8 are set apart with a space as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
Claude committed 2026-10-29 20:21:07 -04:00
1 parent 129a9f668c
commit a0789bd495
1 file changed
+14 -4
+14 -4
View File
@@ -20,17 +20,27 @@ module Vehicles
def pdf_left(context={})
output = []
output << [l(:field_vehicles), context[:issue].vehicle ? context[:issue].vehicle.to_s : nil]
output << [l(:field_vin), context[:issue].vehicle ? pdf_vin(context[:issue].vehicle.vin) : nil]
output << pdf_vin_row(context[:issue].vehicle&.vin)
output << [l(:field_notes), context[:issue].vehicle ? context[:issue].vehicle.notes : nil]
return output
end
private
# 17-character VINs are split before the last 8 (what dealerships ask for); others stay whole
def pdf_vin(vin)
# Same as on screen: 17-character VINs with the last 8 in bold (what dealerships ask for when
# ordering parts), older or short VINs plain. Bold needs redmine_qbo's HTML values in its PDF grid;
# with an older redmine_qbo the last 8 are set apart with a space instead.
def pdf_vin_row(vin)
vin = vin.to_s
vin.length == 17 ? "#{vin[0, 9]} #{vin[9, 8]}" : vin
return [l(:field_vin), nil] if vin.empty?
return [l(:field_vin), vin] unless vin.length == 17
first, last = ERB::Util.h(vin[0, 9]), ERB::Util.h(vin[9, 8])
if defined?(RedmineQbo::Patches::PdfPatch::PDF_HTML_VALUES)
[l(:field_vin), vin, { html: "#{first}<b>#{last}</b>" }]
else
[l(:field_vin), "#{vin[0, 9]} #{vin[9, 8]}"]
end
end
end