lib/money_s3/builders/prevodka.rb in money_s3-0.5.0 vs lib/money_s3/builders/prevodka.rb in money_s3-0.6.0
- old
+ new
@@ -15,294 +15,103 @@
module Builders
class Prevodka
include BaseBuilder
def builder
- root = Ox::Element.new(element_name)
-
- if attributes.key? :cislo_dokla
- element = Ox::Element.new('CisloDokla')
- element << attributes[:cislo_dokla] if attributes[:cislo_dokla]
- root << element
+ root = Ox::Element.new(name)
+ if data.respond_to? :attributes
+ data.attributes.each { |k, v| root[k] = v }
end
- if attributes.key? :zpusob_uctovani
- element = Ox::Element.new('ZpusobUctovani')
- element << attributes[:zpusob_uctovani] if attributes[:zpusob_uctovani]
- root << element
- end
+ root << build_element('CisloDokla', data[:cislo_dokla]) if data.key? :cislo_dokla
+ root << build_element('ZpusobUctovani', data[:zpusob_uctovani]) if data.key? :zpusob_uctovani
+ root << build_element('CObjednavk', data[:c_objednavk]) if data.key? :c_objednavk
+ root << build_element('KPFromOdb', data[:kp_from_odb]) if data.key? :kp_from_odb
+ root << build_element('Datum', data[:datum]) if data.key? :datum
+ root << build_element('Sleva', data[:sleva]) if data.key? :sleva
+ root << build_element('DRada', data[:d_rada]) if data.key? :d_rada
+ root << build_element('Stredisko', data[:stredisko]) if data.key? :stredisko
+ root << build_element('Zakazka', data[:zakazka]) if data.key? :zakazka
+ root << build_element('Cinnost', data[:cinnost]) if data.key? :cinnost
+ root << build_element('Popis', data[:popis]) if data.key? :popis
+ root << build_element('Vystavil', data[:vystavil]) if data.key? :vystavil
+ root << build_element('VyrizFaktu', data[:vyriz_faktu]) if data.key? :vyriz_faktu
+ root << build_element('TextPredPo', data[:text_pred_po]) if data.key? :text_pred_po
+ root << build_element('TextZaPol', data[:text_za_pol]) if data.key? :text_za_pol
+ root << build_element('Nadpis', data[:nadpis]) if data.key? :nadpis
+ root << build_element('ZkratTypuD', data[:zkrat_typu_d]) if data.key? :zkrat_typu_d
+ root << build_element('PorizCena', data[:poriz_cena]) if data.key? :poriz_cena
+ root << build_element('PopisX', data[:popis_x]) if data.key? :popis_x
+ root << build_element('Fiskal', data[:fiskal]) if data.key? :fiskal
+ root << build_element('FisDoklad', data[:fis_doklad]) if data.key? :fis_doklad
+ root << build_element('DatSkPoh', data[:dat_sk_poh]) if data.key? :dat_sk_poh
+ root << build_element('StatMOSS', data[:stat_moss]) if data.key? :stat_moss
+ root << build_element('SazbaDPH1', data[:sazba_dph1]) if data.key? :sazba_dph1
+ root << build_element('SazbaDPH2', data[:sazba_dph2]) if data.key? :sazba_dph2
+ root << build_element('PrimDoklad', data[:prim_doklad]) if data.key? :prim_doklad
+ root << build_element('VarSymbol', data[:var_symbol]) if data.key? :var_symbol
+ root << build_element('ParSymbol', data[:par_symbol]) if data.key? :par_symbol
+ root << build_element('TypTransakce', data[:typ_transakce]) if data.key? :typ_transakce
+ root << build_element('DodaciPodm', data[:dodaci_podm]) if data.key? :dodaci_podm
+ root << build_element('DruhDopravy', data[:druh_dopravy]) if data.key? :druh_dopravy
+ root << build_element('StOdeslUrc', data[:st_odesl_urc]) if data.key? :st_odesl_urc
+ root << build_element('DopravTuz', data[:doprav_tuz]) if data.key? :doprav_tuz
+ root << build_element('DopravZahr', data[:doprav_zahr]) if data.key? :doprav_zahr
+ root << build_element('DatumITS', data[:datum_its]) if data.key? :datum_its
+ root << build_element('Sleva', data[:sleva]) if data.key? :sleva
+ root << build_element('iDokladID', data[:i_doklad_id]) if data.key? :i_doklad_id
+ root << build_element('iDoklAgend', data[:i_dokl_agend]) if data.key? :i_dokl_agend
+ root << build_element('Celkem', data[:celkem]) if data.key? :celkem
- if attributes.key? :c_objednavk
- element = Ox::Element.new('CObjednavk')
- element << attributes[:c_objednavk] if attributes[:c_objednavk]
- root << element
+ if data.key? :eet
+ root << EETType.new('EET', data[:eet]).builder
end
- if attributes.key? :kp_from_odb
- element = Ox::Element.new('KPFromOdb')
- element << attributes[:kp_from_odb] if attributes[:kp_from_odb]
- root << element
+ if data.key? :valuty
+ root << Valuty.new('Valuty', data[:valuty]).builder
end
- if attributes.key? :datum
- element = Ox::Element.new('Datum')
- element << attributes[:datum] if attributes[:datum]
- root << element
+ if data.key? :dod_odb
+ root << SkDokladFirmaType.new('DodOdb', data[:dod_odb]).builder
end
- if attributes.key? :sleva
- element = Ox::Element.new('Sleva')
- element << attributes[:sleva] if attributes[:sleva]
- root << element
+ if data.key? :konec_prij
+ root << KonecPrijFirmaType.new('KonecPrij', data[:konec_prij]).builder
end
- if attributes.key? :d_rada
- element = Ox::Element.new('DRada')
- element << attributes[:d_rada] if attributes[:d_rada]
- root << element
+ if data.key? :import
+ root << Import.new('Import', data[:import]).builder
end
- if attributes.key? :stredisko
- element = Ox::Element.new('Stredisko')
- element << attributes[:stredisko] if attributes[:stredisko]
- root << element
+ if data.key? :sklad_pro_pr
+ root << SkladType.new('SkladProPr', data[:sklad_pro_pr]).builder
end
- if attributes.key? :zakazka
- element = Ox::Element.new('Zakazka')
- element << attributes[:zakazka] if attributes[:zakazka]
- root << element
+ if data.key? :moje_firma
+ root << MojeFirmaType.new('MojeFirma', data[:moje_firma]).builder
end
- if attributes.key? :cinnost
- element = Ox::Element.new('Cinnost')
- element << attributes[:cinnost] if attributes[:cinnost]
- root << element
+ if data.key? :vlajky
+ root << Vlajky.new('Vlajky', data[:vlajky]).builder
end
- if attributes.key? :popis
- element = Ox::Element.new('Popis')
- element << attributes[:popis] if attributes[:popis]
- root << element
+ if data.key? :souhrn_dph
+ root << SouhrnDPHType.new('SouhrnDPH', data[:souhrn_dph]).builder
end
- if attributes.key? :vystavil
- element = Ox::Element.new('Vystavil')
- element << attributes[:vystavil] if attributes[:vystavil]
- root << element
+ if data.key? :polozka
+ data[:polozka].each { |i| root << PolSklDoklType.new('Polozka', i).builder }
end
- if attributes.key? :vyriz_faktu
- element = Ox::Element.new('VyrizFaktu')
- element << attributes[:vyriz_faktu] if attributes[:vyriz_faktu]
- root << element
- end
-
- if attributes.key? :text_pred_po
- element = Ox::Element.new('TextPredPo')
- element << attributes[:text_pred_po] if attributes[:text_pred_po]
- root << element
- end
-
- if attributes.key? :text_za_pol
- element = Ox::Element.new('TextZaPol')
- element << attributes[:text_za_pol] if attributes[:text_za_pol]
- root << element
- end
-
- if attributes.key? :nadpis
- element = Ox::Element.new('Nadpis')
- element << attributes[:nadpis] if attributes[:nadpis]
- root << element
- end
-
- if attributes.key? :zkrat_typu_d
- element = Ox::Element.new('ZkratTypuD')
- element << attributes[:zkrat_typu_d] if attributes[:zkrat_typu_d]
- root << element
- end
-
- if attributes.key? :poriz_cena
- element = Ox::Element.new('PorizCena')
- element << attributes[:poriz_cena] if attributes[:poriz_cena]
- root << element
- end
-
- if attributes.key? :popis_x
- element = Ox::Element.new('PopisX')
- element << attributes[:popis_x] if attributes[:popis_x]
- root << element
- end
-
- if attributes.key? :fiskal
- element = Ox::Element.new('Fiskal')
- element << attributes[:fiskal] if attributes[:fiskal]
- root << element
- end
-
- if attributes.key? :fis_doklad
- element = Ox::Element.new('FisDoklad')
- element << attributes[:fis_doklad] if attributes[:fis_doklad]
- root << element
- end
-
- if attributes.key? :dat_sk_poh
- element = Ox::Element.new('DatSkPoh')
- element << attributes[:dat_sk_poh] if attributes[:dat_sk_poh]
- root << element
- end
-
- if attributes.key? :stat_moss
- element = Ox::Element.new('StatMOSS')
- element << attributes[:stat_moss] if attributes[:stat_moss]
- root << element
- end
-
- if attributes.key? :sazba_dph1
- element = Ox::Element.new('SazbaDPH1')
- element << attributes[:sazba_dph1] if attributes[:sazba_dph1]
- root << element
- end
-
- if attributes.key? :sazba_dph2
- element = Ox::Element.new('SazbaDPH2')
- element << attributes[:sazba_dph2] if attributes[:sazba_dph2]
- root << element
- end
-
- if attributes.key? :prim_doklad
- element = Ox::Element.new('PrimDoklad')
- element << attributes[:prim_doklad] if attributes[:prim_doklad]
- root << element
- end
-
- if attributes.key? :var_symbol
- element = Ox::Element.new('VarSymbol')
- element << attributes[:var_symbol] if attributes[:var_symbol]
- root << element
- end
-
- if attributes.key? :par_symbol
- element = Ox::Element.new('ParSymbol')
- element << attributes[:par_symbol] if attributes[:par_symbol]
- root << element
- end
-
- if attributes.key? :typ_transakce
- element = Ox::Element.new('TypTransakce')
- element << attributes[:typ_transakce] if attributes[:typ_transakce]
- root << element
- end
-
- if attributes.key? :dodaci_podm
- element = Ox::Element.new('DodaciPodm')
- element << attributes[:dodaci_podm] if attributes[:dodaci_podm]
- root << element
- end
-
- if attributes.key? :druh_dopravy
- element = Ox::Element.new('DruhDopravy')
- element << attributes[:druh_dopravy] if attributes[:druh_dopravy]
- root << element
- end
-
- if attributes.key? :st_odesl_urc
- element = Ox::Element.new('StOdeslUrc')
- element << attributes[:st_odesl_urc] if attributes[:st_odesl_urc]
- root << element
- end
-
- if attributes.key? :doprav_tuz
- element = Ox::Element.new('DopravTuz')
- element << attributes[:doprav_tuz] if attributes[:doprav_tuz]
- root << element
- end
-
- if attributes.key? :doprav_zahr
- element = Ox::Element.new('DopravZahr')
- element << attributes[:doprav_zahr] if attributes[:doprav_zahr]
- root << element
- end
-
- if attributes.key? :datum_its
- element = Ox::Element.new('DatumITS')
- element << attributes[:datum_its] if attributes[:datum_its]
- root << element
- end
-
- if attributes.key? :sleva
- element = Ox::Element.new('Sleva')
- element << attributes[:sleva] if attributes[:sleva]
- root << element
- end
-
- if attributes.key? :i_doklad_id
- element = Ox::Element.new('iDokladID')
- element << attributes[:i_doklad_id] if attributes[:i_doklad_id]
- root << element
- end
-
- if attributes.key? :i_dokl_agend
- element = Ox::Element.new('iDoklAgend')
- element << attributes[:i_dokl_agend] if attributes[:i_dokl_agend]
- root << element
- end
-
- if attributes.key? :celkem
- element = Ox::Element.new('Celkem')
- element << attributes[:celkem] if attributes[:celkem]
- root << element
- end
-
- if attributes.key? :eet
- root << EETType.new(attributes[:eet], 'EET').builder
- end
-
- if attributes.key? :valuty
- root << Valuty.new(attributes[:valuty], 'Valuty').builder
- end
-
- if attributes.key? :dod_odb
- root << SkDokladFirmaType.new(attributes[:dod_odb], 'DodOdb').builder
- end
-
- if attributes.key? :konec_prij
- root << KonecPrijFirmaType.new(attributes[:konec_prij], 'KonecPrij').builder
- end
-
- if attributes.key? :import
- root << Import.new(attributes[:import], 'Import').builder
- end
-
- if attributes.key? :sklad_pro_pr
- root << SkladType.new(attributes[:sklad_pro_pr], 'SkladProPr').builder
- end
-
- if attributes.key? :moje_firma
- root << MojeFirmaType.new(attributes[:moje_firma], 'MojeFirma').builder
- end
-
- if attributes.key? :vlajky
- root << Vlajky.new(attributes[:vlajky], 'Vlajky').builder
- end
-
- if attributes.key? :souhrn_dph
- root << SouhrnDPHType.new(attributes[:souhrn_dph], 'SouhrnDPH').builder
- end
-
- if attributes.key? :polozka
- attributes[:polozka].each { |i| root << PolSklDoklType.new(i, 'Polozka').builder }
- end
-
- if attributes.key? :seznam_nep_plateb
+ if data.key? :seznam_nep_plateb
element = Ox::Element.new('SeznamNepPlateb')
- attributes[:seznam_nep_plateb].each { |i| element << NepPlatbaType.new(i, 'NepPlatba').builder }
+ data[:seznam_nep_plateb].each { |i| element << NepPlatbaType.new('NepPlatba', i).builder }
root << element
end
- if attributes.key? :dokumenty
+ if data.key? :dokumenty
element = Ox::Element.new('Dokumenty')
- attributes[:dokumenty].map { |i| Ox::Element.new('Dokument') << i }.each { |i| element << i }
+ data[:dokumenty].map { |i| Ox::Element.new('Dokument') << i }.each { |i| element << i }
root << element
end
root
end
\ No newline at end of file