Skip to content

Commit

Permalink
Allow native Currency.
Browse files Browse the repository at this point in the history
Fixed in LegalMonetaryTotal, InvoiceLine, Price.
  • Loading branch information
stas authored and corny committed Jun 26, 2024
1 parent 4b9ff9b commit 7a4cc8b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/xrechnung/invoice_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class InvoiceLine
member :price, type: Xrechnung::Price

def initialize(**kwargs)
kwargs[:line_extension_amount] = Currency::EUR(kwargs[:line_extension_amount])
unless kwargs[:line_extension_amount].is_a?(Currency)
kwargs[:line_extension_amount] = Currency::EUR(kwargs[:line_extension_amount])
end
super(**kwargs)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/xrechnung/legal_monetary_total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class LegalMonetaryTotal
include MemberContainer

transform_currency = ->(v) {
Currency::EUR(v)
v.is_a?(Currency) ? v : Currency::EUR(v)
}

# @!attribute line_extension_amount
Expand Down
4 changes: 3 additions & 1 deletion lib/xrechnung/price.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class Price
member :allowance_charge, type: Xrechnung::AllowanceCharge

def initialize(**kwargs)
kwargs[:price_amount] = Currency::EUR(kwargs[:price_amount])
unless kwargs[:price_amount].is_a?(Currency)
kwargs[:price_amount] = Currency::EUR(kwargs[:price_amount])
end
super(**kwargs)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/ruby/legal_monetary_total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def build_legal_monetary_total
line_extension_amount: 2580,
tax_exclusive_amount: 2580,
tax_inclusive_amount: 2877.09,
allowance_total_amount: 0,
allowance_total_amount: Xrechnung::Currency::EUR(0),
charge_total_amount: 0,
prepaid_amount: 0,
payable_rounding_amount: 0,
Expand Down

0 comments on commit 7a4cc8b

Please sign in to comment.