File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,12 +121,12 @@ def valid?
121121 @errors = [ ]
122122 tax = BigDecimal ( tax_amount )
123123 basis = BigDecimal ( basis_amount )
124- summed_tax_amount = taxes . sum ( &:tax_amount )
124+ summed_tax_amount = taxes . sum ( &:tax_amount ) . round ( 2 )
125125 if tax != summed_tax_amount
126126 @errors << "Tax amount and summed tax amounts deviate: #{ tax_amount } / #{ summed_tax_amount } "
127127 return false
128128 end
129- summed_tax_base_amount = taxes . sum ( &:base_amount )
129+ summed_tax_base_amount = taxes . sum ( &:base_amount ) . round ( 2 )
130130 if basis != summed_tax_base_amount
131131 @errors << "Base amount and summed tax base amount deviate: #{ basis } / #{ summed_tax_base_amount } "
132132 return false
Original file line number Diff line number Diff line change @@ -791,5 +791,20 @@ def test_invoice_object_extensions
791791 assert_match ( /<ram:PaymentReference>#{ invoice . payment_reference } <\/ ram:PaymentReference>/ , xml )
792792 assert_match ( %r{<ram:DefinedTradeContact>\s *<ram:PersonName>Max Mustermann</ram:PersonName>\s *</ram:DefinedTradeContact>} , xml )
793793 end
794+
795+ def test_invoice_with_quantity_causing_sub_cent_amounts
796+ invoice = make_de_invoice
797+ invoice . tax_calculation_method = :ITEM_BASED
798+ invoice . line_items . first . net_amount = BigDecimal ( '10.12' )
799+ invoice . line_items . first . billed_quantity = BigDecimal ( '0.1' )
800+ invoice . line_items . first . charge_amount = BigDecimal ( '1.01' )
801+ invoice . line_items . first . tax_amount = BigDecimal ( '0.19' )
802+ invoice . basis_amount = BigDecimal ( '1.01' ) # 1.012 rounded
803+ invoice . tax_amount = BigDecimal ( '0.19' )
804+ invoice . grand_total_amount = BigDecimal ( '1.2' )
805+
806+ invoice . valid?
807+ assert_equal [ ] , invoice . errors
808+ end
794809 end
795810end
You can’t perform that action at this time.
0 commit comments