view · edit · sidebar · attach · print · history

20110722-update-new-user-stock-format-bbmb_ch

<< | Index | >>


  1. Confirm the problem
  2. Check code
  3. Fix encoding problem
  4. Fix password problem
  5. Fix update user (overwrite Kundennr)
  6. Fix missing product

Goal/Estimate/Evaluation
  • Change user privilege / 90% / 90%
Milestones
  • Confirm the problem
  • Check code
Summary
Commits
ToDo Tomorrow
  • 207 product
  • set all the group as 'Apo'
    • search all the groups from ywsarti
    • set all the goups in ywsbezber
    • hard coding to update the group name 'Apo' for all the customers
  • Probably update_users in bbmbapp.rb should be updated with values = {:group_short => 'Apo'}, check this tomorrow
  • fix update_stock (more smartly)

Confirm the problem

Email

Goal

  • All the customer (hospital user) can see all the product (remove user privilege)

Some users can see products but some users cannot see products

  • test1@ywesee.com
  • test3@ywesee.com

Check code

Experiment

  • If I change 'Bezugsgruppe', I can search products

Note

  • 'Bezugsgruppe' is refered to as 'short_group' in the source code
  • All the 'BEzugsgruppe' is listed in 'ywsbezber'

suspend

Fix encoding problem

Example

Patch file

Result

Note

  • The encoding is NOT 'UTF-8', but 'ISO-8859-1'
  • I modifiy the file with UTF-8 first, then convert it into ISO-8859-1 by the following script
  • Convert file: Attach:convert.rb.20110725.txt

Fix password problem

Problem

  • Customer's password is reset after the updating of customers with the new file format

Confirm

  • Load the current customer data
 masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ rm *.*
 masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ cp ~/work/mnemonic_local_update_all_kund_bak/*.* .
  • Run bin/bbmbd
  • Set a new pasword of a customer who is listed in the new customer file
  • Confirm the login with the customer user
  • Replace the new customer ids
 masa@masa ~/ywesee/bbmb.ch $ bin/admin
 ch.bbmb.globopharm> replace_customer_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_user_ids.csv'
 -> 169
  • Confirm the login with the customer user
  • Update the customer data with the new customer file format
 masa@masa ~/ywesee/bbmb.ch $ bin/admin
 ch.bbmb.globopharm> update
  • Confirm the failure of logging in with the customer user

Resolved

  • The encoding of Customer.csv was not 'ISO-8859-1'
  • I re-downloaded the Customer.csv from the actual server and put it on the test server
  • Then it works (even after the updating the same password is available)

Fix update user (overwrite Kundennr)

Note

  • The current update process cannot overwrite email address
  • Email address is used as ID of customer, rather than 'Kundennr' (customer_id).
  • There can be same customer_id users, but cannot be the same email address users
  • Namely, email address is unique in the bbmb.ch to identify an user

Problem

  • When the update_user runs, sometimes :e_duplicate_email error happens
  • because some users have already email address and a new id user does not have email address.

Solution

  • Search all the users and update customer_id (Kundennr) if the user's email is the same to the one in the new customer file
  • (Update replace_customer_ids method)

Scripts

Note

  • There is one email address duplicated in Customers.csv

Experiment

 users.filter('email@ywesee.com').values[0].value(:customer_id)

Experiment (src/util/bbmbapp.rb)

  def overwrite_customer_ids_by_email(email_file = nil)
    return 'set the path to the new customer email file' unless email_file

    count = 0
    File.readlines(email_file).each do |line|
      ids = line.chomp.split(/;/)
      alloga_id = ids[0]
      ean_code  = ids[1]
      email     = ids[2]
      if user = users.filter(email).values[0]
        updates = {:customer_id => alloga_id, :customer_ean13 => ean_code}
        save_user(user, updates, user.modifier)
        count += 1
      end
    end
    count
  end
  def replace_customer_ids_gag_to_alloga(map_file = nil)
    return 'set the path to the mapping file' unless map_file
    count = 0
    File.readlines(map_file).each do |line|
      ids = line.chomp.split(/;/)
      gag_id    = ids[0]
      ean_code  = ids[1]
      alloga_id = ids[2]
      if users.filter(alloga_id).values.select{|u| !u.email.to_s.empty?}.empty? \
      and (user = users.filter(gag_id).values[0] and user.value(:customer_id) == gag_id)
        updates = {:customer_id => alloga_id, :customer_ean13 => ean_code}
        save_user(user, updates, user.modifier)
        count += 1
      end
    end
    count
  end

Note (Key points)

  • If there is already email address then the customer id is overwritten by the new customer id (overwrite_customer_ids_by_email)
  • If an user id is already overwritten by the overwrite_customer_ids_by_email method, the user is not overwritten by replace_customer_ids_gag_to_alloga method
  • I deleted one user whose email address is duplicated from Customer.csv

Run

  • bin/bbmbd
  • bin/admin
masa@masa ~/ywesee/bbmb.ch $ bin/admin
ch.bbmb.globopharm> overwrite_customer_ids_by_email '/home/masa/work/new_data/new_customer_id_ean_email.dat'
-> 27
ch.bbmb.globopharm> replace_customer_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_user_ids.csv'
-> 123
ch.bbmb.globopharm> update
-> 

Result (Console Log)

BbmbApp::update - updating admin@ywesee.com
update: update_stock
update_stock done
update: update_users
update_users done

Fix missing product

Problem

  • The new product, 81000207 (ean), is not shown

Run

masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ rm *.*
masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ cp ~/work/mnemonic_local_update_all_kund_bak/*.* .
masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ cd ../..
masa@masa ~/ywesee/bbmb.ch $ bin/admin
ch.bbmb.globopharm> overwrite_customer_ids_by_email '/home/masa/work/new_data/new_customer_id_ean_email.dat'
-> 27
ch.bbmb.globopharm> replace_customer_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_user_ids.csv'
-> 123
ch.bbmb.globopharm> replace_article_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_stock_ids.csv'
-> 284
ch.bbmb.globopharm> update
-> 

Result

Note

  • but actually 81000207 is written in Items.csv

Experiment (ywsbezber, ywskunbez)

masa@masa ~/ywesee/bbmb.ch $ bin/admin
ch.bbmb.globopharm> overwrite_customer_ids_by_email '/home/masa/work/new_data/new_customer_id_ean_email.dat'
-> 27
ch.bbmb.globopharm> replace_customer_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_user_ids.csv'
-> 123
ch.bbmb.globopharm> replace_article_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_stock_ids.csv'
-> 284
ch.bbmb.globopharm> update
-> 
  • Change 'Bezugsgruppe' as 'Apo' (because setting the group_access 'Apo' in ywsbezber)

Result (Console log)

BbmbApp::update - updating admin@ywesee.com
update: update_stock
update_stock done
update: update_users
update_users done
update: update_group_access
update_group_access done

Result

Note (Key point)

  • ywsbezber
 "Apo";"INDIV";"";yes
view · edit · sidebar · attach · print · history
Page last modified on July 26, 2011, at 07:23 AM