view · edit · sidebar · attach · print · history

20110727-testcases-bbmb_ch-change-output-filename-xmlconv_bbmb_ch

<< | Index | >>


  1. Testcases bbmb.ch
  2. Change filename of output file in xmlconv.bbmb.ch
  3. Setup FI and DDD bbmb.ch

Goal/Estimate/Evaluation
  • Testcases bbmb.ch / 100% / 60%
  • Change output file name / 100% / 90%
Milestones
Summary
Commits
Keep in Mind

Testcases bbmb.ch

ruby test/suite.rb

  • 187 tests, 983 assertions, 12 failures, 6 errors

Memo (ruby option warning)

 -W0 warning is unshown

Note

  • The difference of failure number between the first and the second test runs is probably related to some saved data during the tests
  • but I can not find out where the data is saved

Change filename of output file in xmlconv.bbmb.ch

Email

Problem

  • File name becomes like 012_name_00005286.dat
  • This should be KD(eancode)_(uniq_id).dat like KD7601002026111_1311604387.dat

Experiment

  1. lib/xmlconv/i2/header.rb#initialize (suffix: date)
  2. lib/xmlconv/util/destination.rb#deliver_to_connection (suffix: counter)
  3. lib/conversion/bdd_i2.rb#_doc_add_delivery (prefix: KD+ean)
  4. lib/conversion/pharmacieplus_bdd.rb#_delivery_add_xml_customer (prefix: to get ean code of customer from xml)

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 = name

      ean_code = xml_delivery.attributes['ean']
      customer.add_id('ACC', ean_code) # This ean code is used for the output file name

Run

  • bin/bbmbd
  • bin/xmlconvd
  • copy input.xml to polling directory
  • wait one minute
  • check ftp server

Result

  • success

Setup FI and DDD bbmb.ch

Problem

  • There is no 'FI' and 'DDD' link in the search result by customer

Goal

  • Show 'FI' and 'DDD' link

Experiment

  • src/custom/behavior.rb
    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

  • bin/bbmbd
  • bin/admin
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

  • failed (FI and DDD link are not shown in the search result)
view · edit · sidebar · attach · print · history
Page last modified on July 27, 2011, at 04:55 PM