Class: MediServ::API::Batch

Inherits:
Struct
  • Object
show all
Defined in:
lib/mediserv/api/types.rb

Instance Method Summary collapse

Methods included from Format

#fmt_amount, #fmt_date, #fmt_string, #fmt_time

Instance Method Details

#anzahl_rechnungenObject

Anzahl Rechnungen



279
280
281
# File 'lib/mediserv/api/types.rb', line 279

def anzahl_rechnungen
  rechnungen.length
end

#stringify_keys(h) ⇒ Object



351
352
353
354
355
356
# File 'lib/mediserv/api/types.rb', line 351

def stringify_keys(h)
  h.reduce({}) do |h, (k,v)|
    v = stringify_keys(v) if v.kind_of?(Hash)
    h.merge({k.to_s => v})
  end
end

#to_hObject



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/mediserv/api/types.rb', line 328

def to_h
  h = {
    Allgemein: allgemein.to_h.merge({
      Total: total,
      TotalPkt: total_pkt,
      TotalLeis: total_leis,
      TotalMed: total_med,
      TotalLabor: total_labor,
      TotalDiverse: total_diverse,
      TotalRabatt: total_rabatt,
      TotalVz: total_vz,
      TotalNetto: total_netto,
      Datum: fmt_date(created_at),
      Zeit: fmt_time(created_at),
      AnzRech: anzahl_rechnungen,
    }),
  }
  rechnungen.each.with_index(1) do |r,i|
    h["R#{i}"] = r.to_h
  end
  stringify_keys h
end

#totalObject

Gesamtsumme Total (ist auch die Summe von TotalLeis + TotalMed + TotalLabor + TotalDiverse + TotalRabatt)



319
320
321
# File 'lib/mediserv/api/types.rb', line 319

def total
  total_leis + total_med + total_labor + total_diverse + total_rabatt
end

#total_diverseObject

Gesamtsumme Diverse Positionen



304
305
306
# File 'lib/mediserv/api/types.rb', line 304

def total_diverse
  rechnungen.map(&:total_diverse).reduce(0.0, :+)
end

#total_laborObject

Gesamtsumme aller Laborkosten



299
300
301
# File 'lib/mediserv/api/types.rb', line 299

def total_labor
  rechnungen.map(&:total_labor).reduce(0.0, :+)
end

#total_leisObject

Gesamtsumme aller Leistungen



289
290
291
# File 'lib/mediserv/api/types.rb', line 289

def total_leis
  rechnungen.map(&:total_leis).reduce(0.0, :+)
end

#total_medObject

Gesamtsumme aller Medikamente



294
295
296
# File 'lib/mediserv/api/types.rb', line 294

def total_med
  rechnungen.map(&:total_med).reduce(0.0, :+)
end

#total_nettoObject

Nettosumme (Total – Vorauszahlung)



324
325
326
# File 'lib/mediserv/api/types.rb', line 324

def total_netto
  total - total_vz
end

#total_pktObject

Gesamtsumme Taxpunkte



284
285
286
# File 'lib/mediserv/api/types.rb', line 284

def total_pkt
  rechnungen.map(&:total_punkte).reduce(0.0, :+)
end

#total_rabattObject

Gesamtsumme Rabatte



309
310
311
# File 'lib/mediserv/api/types.rb', line 309

def total_rabatt
  rechnungen.map(&:total_rabatt).reduce(0.0, :+)
end

#total_vzObject

Gesamtsumme der abgezogenen Vorauszahlungen



314
315
316
# File 'lib/mediserv/api/types.rb', line 314

def total_vz
  rechnungen.map(&:total_vz).reduce(0.0, :+)
end