mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 12:08:27 +02:00
Add support for PG interval field in DirectoInvoice sending
This commit is contained in:
parent
838522b81a
commit
4554975fad
2 changed files with 7 additions and 7 deletions
|
@ -40,8 +40,8 @@ module Registrar::BookKeeping
|
|||
|
||||
def fetch_invoice_lines(activity, lines)
|
||||
price = load_price(activity)
|
||||
if price.duration.include? 'year'
|
||||
price.duration.to_i.times do |duration|
|
||||
if price.duration.in_years.to_i >= 1
|
||||
price.duration.in_years.to_i.times do |duration|
|
||||
lines << new_monthly_invoice_line(activity: activity, duration: duration + 1).as_json
|
||||
end
|
||||
else
|
||||
|
@ -67,9 +67,9 @@ module Registrar::BookKeeping
|
|||
end
|
||||
|
||||
def finalize_invoice_line(line, price:, activity:, duration:)
|
||||
yearly = price.duration.include?('year')
|
||||
yearly = price.duration.in_years.to_i >= 1
|
||||
|
||||
line['price'] = yearly ? (price.price.amount / price.duration.to_i) : price.price.amount
|
||||
line['price'] = yearly ? (price.price.amount / price.duration.in_years.to_i) : price.price.amount
|
||||
line['description'] = description_in_language(price: price, yearly: yearly)
|
||||
|
||||
if duration.present?
|
||||
|
@ -90,7 +90,7 @@ module Registrar::BookKeeping
|
|||
locale_string = "registrar.invoice_#{timeframe_string}_product_description"
|
||||
|
||||
I18n.with_locale(language == 'en' ? 'en' : 'et') do
|
||||
I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.to_i)
|
||||
I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.in_years.to_i)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
def test_multi_year_purchases_have_duration_assigned
|
||||
activity = account_activities(:one)
|
||||
price = billing_prices(:create_one_year)
|
||||
price.update(duration: '3 years')
|
||||
price.update(duration: 3.years)
|
||||
activity.update(activity_type: 'create', price: price)
|
||||
|
||||
response = <<-XML
|
||||
|
@ -157,7 +157,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
|||
|
||||
activity = account_activities(:one)
|
||||
price = billing_prices(:create_one_year)
|
||||
price.update(duration: '3 years')
|
||||
price.update(duration: 3.years)
|
||||
activity.update(activity_type: 'create', price: price)
|
||||
|
||||
# Creating account activity for second action
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue