<< | Index | >>
ruby test/suite.rb
Memo (ruby option warning)
-W0 warning is unshown
Note
Problem
Experiment
1. lib/xmlconv/i2/header.rb#initialize (suffix: date)
def initialize(recipient_id = 'EPIN_PL')
@recipient_id = recipient_id
@prefix = @recipient_id
time = Time.now
#msec = sprintf('%03i', (time.to_f * 1000).to_i % 100)
#@transaction_id = time.strftime("YmdHM#{msec}")
@transaction_id = time.strftime("YmdHM")
end
2. lib/xmlconv/util/destination.rb#deliver_to_connection (suffix: counter)
def deliver_to_connection(connection, delivery, idx=nil)
if(delivery.is_a?(Array))
delivery.each_with_index { |part, idx|
deliver_to_connection(connection, part, idx)
}
else
fh = Tempfile.new('xmlconv')
fh.puts(delivery)
fh.flush
target = delivery.filename
if(idx)
#target = sprintf("%03i_%s", idx, target)
target.gsub!(/\.dat/, "%03i.dat" % idx)
end
if(@tmp)
tmp = File.join(@tmp.path, target)
connection.puttextfile(fh.path, tmp)
connection.rename(tmp, target)
else
connection.puttextfile(fh.path, target)
end
fh.close!
@status = :ftp_ok
end
end
3. lib/conversion/bdd_i2.rb#_doc_add_delivery (prefix: KD + ean code)
def _doc_add_delivery(doc, delivery, sender_id='YWESEE') order = I2::Order.new order.sender_id = sender_id # customer_id is in reality the delivery_id assigned by the # customer - the slight confusion is due to automatic naming#transaction_id = delivery.customer_id
#order.ade_id = order.delivery_id = transaction_id
#doc.header.transaction_id = sprintf(transaction_id.to_s.rjust(8, '0'))
order.add_date(I2::Date.from_date(::Date.today, :order, :order)) if(bsr = delivery.bsr) order.interface = bsr.interface || '61' if(customer = bsr.customer) _order_add_party(order, customer) end end if(customer = delivery.customer) _order_add_customer(order, customer)#prefix = customer.name.to_s
prefix = 'KD' + customer.acc_id.to_s#prefix.gsub!(/\s+/, '_')
#prefix.gsub!(/[^a-z0-9_]/i, '')
#if(prefix.empty?)
# prefix = 'ohne_namen
'#end
...
4. lib/conversion/pharmacieplus_bdd.rb#_delivery_add_xml_customer (prefix: to get ean code of customer from xml)
def _delivery_add_xml_customer(delivery, xml_delivery) customer = Model::Party.new customer.role = 'Customer' _customer_add_party(customer, '1075', 'BillTo') ship_to = _customer_add_party(customer, _latin1(xml_delivery.attributes['ean']), 'ShipTo') if(xml_header = REXML::XPath.first(xml_delivery, 'livraison')) name = Model::Name.new # Pharmacieplus delivers the Pharmacy-Name in 'last-name', and the name # of the contact person in 'other-name' - we need to juggle the pieces # around a bit. (see also _party_add_xml_address) =begin if(xml_name = REXML::XPath.first(xml_header, 'last-name')) name.last = _latin1(xml_name.text) end if(xml_name = REXML::XPath.first(xml_header, 'first-name')) name.first = _latin1(xml_name.text) end =end if(xml_name = REXML::XPath.first(xml_header, 'other-name')) name.text = _latin1(xml_name.text) end customer.name = nameean_code = xml_delivery.attributes['ean']
customer.add_id('ACC', ean_code) # This ean code is used for the output file name
Run
Result
Problem
Goal
Experiment
UPDATES = [ :update_stock, #:update_suppliers, :update_users, #:update_user_access, :update_group_access, #:update_user_article_prices, #:update_user_article_discounts, #:update_user_group_discounts, #:update_user_volume_prices, #:update_stock_atc, #:update_sl, :update_atc_classes, :update_fachinfos, ]
Run
masa@masa ~/ywesee/bbmb.ch $ bin/admin ch.bbmb.globopharm> update
Console log
update: update_stock update_stock done update: update_users update_users done update: update_group_access update_group_access done update: update_atc_classes update_atc_classes done update: update_fachinfos update_fachinfos done
Result