Skip to content

Commit

Permalink
Reorder tax exemption status, make percent optional
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipp authored and corny committed Dec 17, 2024
1 parent c4467a0 commit 88bd0b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions lib/xrechnung/tax_category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TaxCategory

# @!attribute percent
# @return [BigDecimal]
member :percent, type: BigDecimal, transform_value: ->(v) { BigDecimal(v, 0) }
member :percent, type: BigDecimal, transform_value: ->(v) { v.nil? ? nil : BigDecimal(v, 0) }

# @!attribute tax_scheme_id
# @return [String]
Expand All @@ -41,15 +41,16 @@ class TaxCategory
def to_xml(xml, root_tag_name: :TaxCategory)
xml.cac root_tag_name do
xml.cbc :ID, id
xml.cbc :Percent, format("%.2f", percent)
xml.cac :TaxScheme do
xml.cbc :ID, tax_scheme_id
end
xml.cbc :Percent, format("%.2f", percent) unless percent.nil?

unless tax_exemption_reason_code.nil?
xml.cbc :TaxExemptionReasonCode, tax_exemption_reason_code
xml.cbc :TaxExemptionReason, tax_exemption_reason
end

xml.cac :TaxScheme do
xml.cbc :ID, tax_scheme_id
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/scraps/tax_category.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<cac:TaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>16.00</cbc:Percent>
<cbc:TaxExemptionReasonCode>VATEX-EU-S</cbc:TaxExemptionReasonCode>
<cbc:TaxExemptionReason>Exempt</cbc:TaxExemptionReason>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
<cbc:TaxExemptionReasonCode>VATEX-EU-S</cbc:TaxExemptionReasonCode>
<cbc:TaxExemptionReason>Exempt</cbc:TaxExemptionReason>
</cac:TaxCategory>

0 comments on commit 88bd0b6

Please sign in to comment.