We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 2bfe84f + d547895 commit 4692781Copy full SHA for 4692781
1 file changed
lib/secretariat/invoice.rb
@@ -113,7 +113,12 @@ def valid?
113
@errors << "Base amount and summed tax base amount deviate: #{basis} / #{summed_tax_base_amount}"
114
return false
115
end
116
- if tax_calculation_method != :NONE
+ if tax_calculation_method == :ITEM_BASED
117
+ line_items_tax_amount = line_items.sum(&:tax_amount)
118
+ if tax_amount != line_items_tax_amount
119
+ @errors << "Tax amount #{tax_amount} and summed up item tax amounts #{line_items_tax_amount} deviate"
120
+ end
121
+ elsif tax_calculation_method != :NONE
122
taxes.each do |tax|
123
calc_tax = tax.base_amount * BigDecimal(tax.tax_percent) / BigDecimal(100)
124
calc_tax = calc_tax.round(2)
0 commit comments