class Economic::CashBookEntryProxy

Public Instance Methods

all() click to toggle source
# File lib/economic/proxies/cash_book_entry_proxy.rb, line 7
def all
  entity_hash = session.request(
    Endpoint.new.soap_action_name(CashBook, :get_entries),
    "cashBookHandle" => owner.handle.to_hash
  )

  if entity_hash != {}
    [entity_hash.values.first].flatten.each do |id_hash|
      find(id_hash)
    end
  end
  self
end
create_creditor_invoice(handles) click to toggle source

Creates a creditor invoice and returns the cash book entry. Example:

cash_book.entries.create_creditor_invoice(
  :creditor_handle       => { :number => 1 },
  :contra_account_handle => { :number => 1510 }
)
# File lib/economic/proxies/cash_book_entry_proxy.rb, line 57
def create_creditor_invoice(handles)
  create_cash_book_entry_for_handles(handles, "CreateCreditorInvoice")
end
create_creditor_payment(handles) click to toggle source

Creates a creditor payment and returns the cash book entry. Example:

cash_book.entries.create_creditor_payment(
  :creditor_handle       => { :number => 1 },
  :contra_account_handle => { :number => 1510 }
)
# File lib/economic/proxies/cash_book_entry_proxy.rb, line 47
def create_creditor_payment(handles)
  create_cash_book_entry_for_handles(handles, "CreateCreditorPayment")
end
create_debtor_payment(handles) click to toggle source

Creates a debtor payment and returns the cash book entry. Example:

cash_book.entries.create_debtor_payment(
  :debtor_handle         => { :number => 1 },
  :contra_account_handle => { :number => 1510 }
)
# File lib/economic/proxies/cash_book_entry_proxy.rb, line 37
def create_debtor_payment(handles)
  create_cash_book_entry_for_handles(handles, "CreateDebtorPayment")
end
create_finance_voucher(handles) click to toggle source

Creates a finance voucher and returns the cash book entry. Example:

cash_book.entries.create_finance_voucher(
  :account_handle        => { :number => 1010 },
  :contra_account_handle => { :number => 1011 }
)
# File lib/economic/proxies/cash_book_entry_proxy.rb, line 27
def create_finance_voucher(handles)
  create_cash_book_entry_for_handles(handles, "CreateFinanceVoucher")
end
create_manual_debtor_invoice(handles) click to toggle source

Creates a manual debtor invoice and returns the cash book entry. Example:

cash_book.entries.create_manual_debtor_invoice(
  :debtor_handle         => { :number => 1 },
  :contra_account_handle => { :number => 1510 }
)
# File lib/economic/proxies/cash_book_entry_proxy.rb, line 67
def create_manual_debtor_invoice(handles)
  create_cash_book_entry_for_handles(handles, "CreateManualDebtorInvoice")
end
set_due_date(id, date) click to toggle source
# File lib/economic/proxies/cash_book_entry_proxy.rb, line 71
def set_due_date(id, date)
  request("SetDueDate", "cashBookEntryHandle" => {
    "Id1" => owner.handle[:number], "Id2" => id
  },
                        :value => date)
end

Protected Instance Methods

create_cash_book_entry_for_handles(handles, action, _foobar = nil) click to toggle source
# File lib/economic/proxies/cash_book_entry_proxy.rb, line 80
def create_cash_book_entry_for_handles(handles, action, _foobar = nil)
  handle_name = handle_name_for_action(action)
  handle_key = Economic::Support::String.underscore(handle_name).intern

  data = {}
  data["cashBookHandle"] = {"Number" => owner.handle[:number]}
  data[handle_name] = {"Number" => handles[handle_key][:number]} if handles[handle_key]
  data["contraAccountHandle"] = {"Number" => handles[:contra_account_handle][:number]} if handles[:contra_account_handle]

  response = request(action, data)

  find(response)
end
handle_name_for_action(action_name) click to toggle source
# File lib/economic/proxies/cash_book_entry_proxy.rb, line 94
def handle_name_for_action(action_name)
  {
    "CreateFinanceVoucher" => "accountHandle",
    "CreateDebtorPayment" => "debtorHandle",
    "CreateCreditorInvoice" => "creditorHandle",
    "CreateCreditorPayment" => "creditorHandle",
    "CreateManualDebtorInvoice" => "debtorHandle",
  }[action_name]
end