process payment fields
This commit is contained in:
@@ -22,6 +22,12 @@ module Submissions
|
||||
VERIFIED_TEXT = 'Verified'
|
||||
UNVERIFIED_TEXT = 'Unverified'
|
||||
|
||||
CURRENCY_SYMBOLS = {
|
||||
'USD' => '$',
|
||||
'EUR' => '€',
|
||||
'GBP' => '£'
|
||||
}.freeze
|
||||
|
||||
module_function
|
||||
|
||||
# rubocop:disable Metrics
|
||||
@@ -200,7 +206,15 @@ module Submissions
|
||||
|
||||
composer.image(io, width:, height:, margin: [0, 0, 10, 0])
|
||||
composer.formatted_text_box([{ text: '' }])
|
||||
elsif field['type'] == 'file'
|
||||
elsif field['type'].in?(%w[file payment])
|
||||
if field['type'] == 'payment'
|
||||
unit = CURRENCY_SYMBOLS[field['preferences']['currency']]
|
||||
|
||||
price = ApplicationController.helpers.number_to_currency(field['preferences']['price'], unit:)
|
||||
|
||||
composer.formatted_text_box([{ text: "Paid #{price}\n" }], padding: [0, 0, 10, 0])
|
||||
end
|
||||
|
||||
composer.formatted_text_box(
|
||||
Array.wrap(value).map do |uuid|
|
||||
attachment = submitter.attachments.find { |a| a.uuid == uuid }
|
||||
|
||||
@@ -85,7 +85,7 @@ module Submissions
|
||||
width: image.width * scale,
|
||||
height: image.height * scale
|
||||
)
|
||||
when 'file'
|
||||
when 'file', 'payment'
|
||||
items = Array.wrap(value).each_with_object([]) do |uuid, acc|
|
||||
attachment = submitter.attachments.find { |a| a.uuid == uuid }
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ module Submitters
|
||||
def replace_default_variables(value, attrs, template, with_time: false)
|
||||
return if value.blank?
|
||||
|
||||
value.gsub(VARIABLE_REGEXP) do |e|
|
||||
value.to_s.gsub(VARIABLE_REGEXP) do |e|
|
||||
case key = ::Regexp.last_match(1)
|
||||
when 'time'
|
||||
if with_time
|
||||
|
||||
Reference in New Issue
Block a user