Module: YDIM::Html::State::AjaxInvoiceMethods
Instance Method Summary collapse
- #ajax_invoices(model = @model) ⇒ Object
- #ajax_status ⇒ Object
- #currency_convert(invoices) ⇒ Object
- #sort_invoices(invoices) ⇒ Object
Instance Method Details
#ajax_invoices(model = @model) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ydim/html/state/invoices.rb', line 15 def ajax_invoices(model=@model) keys = [:payment_received, :unique_id, :deleted] input = user_input(keys, [:unique_id]) id = input.delete(:unique_id).to_i if(!error? && !input.empty? && (invoice = @session.invoice(id))) input.each { |key, val| invoice.send("#{key}=", val) } invoice.odba_store model.delete_if { |info| info.unique_id == id } end AjaxInvoices.new(@session, model) end |
#ajax_status ⇒ Object
28 29 30 |
# File 'lib/ydim/html/state/invoices.rb', line 28 def ajax_status AjaxInvoices.new(@session, load_invoices) end |
#currency_convert(invoices) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ydim/html/state/invoices.rb', line 31 def currency_convert(invoices) currency = Html.config.currency converter = @session.currency_converter invoices.each { |inv| if(icur = inv.currency) inv.total_netto = converter.convert(inv.total_netto, icur, currency) inv.total_brutto = converter.convert(inv.total_brutto, icur, currency) end inv.currency = currency } end |
#sort_invoices(invoices) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/ydim/html/state/invoices.rb', line 42 def sort_invoices(invoices) null_date = Date.new(9999) invoices.sort_by { |inv| [null_date - (inv.date || null_date), inv.description.to_s] } end |