Class: MoneyS3::Utils::Receipts

Inherits:
Object
  • Object
show all
Defined in:
lib/money_s3/utils/receipts.rb

Constant Summary collapse

TRANSACTION_TYPES =
[:credit, :debit]

Instance Method Summary collapse

Instance Method Details

#to_xml(raw) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/money_s3/utils/receipts.rb', line 6

def to_xml(raw)
  receipts = raw.map do |item|
    data = {
      dat_uc_pr: item[:date].to_s,
      dat_vyst: item[:date].to_s,
      dat_plat: item[:date].to_s,
      dat_upl_dph: item[:date].to_s,
      popis: item[:description],
      dat_pln: item[:date].to_s,
      celkem: item[:amount].abs.to_s,
      pokl: item[:my_petty_cash_id],
      souhrn_dph: {
        zaklad0: item[:amount].abs.to_s
      },
      pr_kont: item[:transaction_rule],
      cleneni: item[:transaction_vat_rule],
      d_rada: item[:series]
    }

    if item[:amount].negative?
      data.merge({ vydej: '1' })
    else
      data.merge({ vydej: '0' })
    end
  end

  money_data = { seznam_pok_dokl: receipts }
  MoneyS3.build(money_data)
end