Skip to content

Commit

Permalink
fix: scor ref
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosteiner committed Jan 7, 2025
1 parent e91b2c7 commit ecb9a95
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/models/payment_infos/qr_bill.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,27 @@ def scor_ref
end

def qrr_ref
RefBuilders::InvoicePayment.with_checksum(invoice.payment_ref).rjust(27, '0')
@qrr_ref ||= RefBuilders::InvoicePayment.with_checksum(invoice.payment_ref).rjust(27, '0')
end

def scor_ref?
ref_type == :SCOR
end

def qrr_ref?
ref_type == :QRR
end

def ref
ref_type == :SCOR ? scor_ref : qrr_ref
scor_ref? ? scor_ref : qrr_ref
end

def formatted_ref
[ref[..1], ref[2..].chars.in_groups_of(5).map(&:join)].join(' ')
if scor_ref?
ref.chars.in_groups_of(4).map(&:join).join(' ')
else
[ref[..1], ref[2..].chars.in_groups_of(5).map(&:join)].join(' ')
end
end

def qrcode
Expand Down

0 comments on commit ecb9a95

Please sign in to comment.