1

In my application I have fields like tax_1_amount, tax_2_amount, tax_3_amount, invoice_amount and total_invoice_amount. When the total invoice amount is calculated then the amount_in_words field should be automatically updated by the total amount in words. Total amount is calculated as follows:

@total_tax_amount = @invoice.tax_1_amount + @invoice.tax_2_amount + @invoice.tax_3_amount
@total_amount = @total_tax_amount + @invoice.invoice_amount

Can anyone tell me if there is any generator or any gem for that. Or what code shall I write for that.

4

2 に答える 2

1

必要がある

include ActionView::Helpers::NumberHelper

ビュー以外の場所で使用しようとしている場合。

于 2014-09-15T03:52:40.393 に答える
0

理解できたかどうかわかりませんが、このリンクを確認してください

http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_human

また

https://github.com/bcarrere/currency-in-words

于 2012-08-09T05:26:38.810 に答える