Skip to content

Commit

Permalink
Feat: make validation optional to allow other VAT calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
zealot128 committed Nov 26, 2024
1 parent a8c87ff commit 74b3749
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/secretariat/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ def namespaces(version: 1)
)
end

def to_xml(version: 1)
def to_xml(version: 1, validate: true)
if version < 1 || version > 2
raise 'Unsupported Document Version'
end

unless valid?
if validate && !valid?
raise ValidationError.new("Invoice is invalid", errors)
end

Expand Down Expand Up @@ -147,7 +147,7 @@ def to_xml(version: 1)

if version == 2
line_items.each_with_index do |item, i|
item.to_xml(xml, i + 1, version: version) # one indexed
item.to_xml(xml, i + 1, version: version, validate: validate) # one indexed
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/secretariat/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def tax_category_code(version: 2)
TAX_CATEGORY_CODES[tax_category] || 'S'
end

def to_xml(xml, line_item_index, version: 2)
if !valid?
def to_xml(xml, line_item_index, version: 2, validate: true)
if validate && !valid?
pp errors
raise ValidationError.new("LineItem #{line_item_index} is invalid", errors)
end
Expand Down

0 comments on commit 74b3749

Please sign in to comment.