File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ def valid?
7474 gross_price = BigDecimal ( gross_amount )
7575 charge_price = BigDecimal ( charge_amount )
7676 tax = BigDecimal ( tax_amount )
77- unit_price = net_price * BigDecimal ( billed_quantity . abs )
77+ unit_price = ( net_price * BigDecimal ( billed_quantity . abs ) ) . round ( 2 )
7878
7979 if charge_price != unit_price
8080 @errors << "charge price and gross price times quantity deviate: #{ charge_price } / #{ unit_price } "
Original file line number Diff line number Diff line change @@ -793,18 +793,27 @@ def test_invoice_object_extensions
793793 end
794794
795795 def test_invoice_with_quantity_causing_sub_cent_amounts
796+ errors = [ ]
797+
796798 invoice = make_de_invoice
797799 invoice . tax_calculation_method = :ITEM_BASED
798800 invoice . line_items . first . net_amount = BigDecimal ( '10.12' )
801+ invoice . line_items . first . gross_amount = BigDecimal ( '10.12' )
802+ invoice . line_items . first . discount_amount = BigDecimal ( '0' )
799803 invoice . line_items . first . billed_quantity = BigDecimal ( '0.1' )
800804 invoice . line_items . first . charge_amount = BigDecimal ( '1.01' )
801805 invoice . line_items . first . tax_amount = BigDecimal ( '0.19' )
802806 invoice . basis_amount = BigDecimal ( '1.01' ) # 1.012 rounded
803807 invoice . tax_amount = BigDecimal ( '0.19' )
804808 invoice . grand_total_amount = BigDecimal ( '1.2' )
805809
806- invoice . valid?
807- assert_equal [ ] , invoice . errors
810+ begin
811+ invoice . to_xml ( version : 2 )
812+ rescue ValidationError => e
813+ errors = e . errors
814+ pp e . errors
815+ end
816+ assert_equal [ ] , errors
808817 end
809818 end
810819end
You can’t perform that action at this time.
0 commit comments