JIPE$Default Dimension - client = TinyTds::Client.new(username: 'test', password: '@Chatenois!2017', host: '40.89.153.193', appname: "SQL4PS" , port: 1534, database: "JIPE") -#comptes = client.execute("SELECT TOP 5000000 * FROM dbo.[JIPE$General Posting Setup]") -#comptes.cancel - odd = true -dimensions = client.execute("SELECT TOP 400000 * FROM dbo.[JIPE$Dimension Value]") -dimensions_results = [] -dimensions.each do |d| -dimensions_results << d -dimensions.cancel %div %table.table %tr %td Famille produits %td Nom famille %td Account %td Account 4PS %td Zone -dimensions.each do |d| -if true #or d["Code"].split(".").size == 2 and (d["Code"].split(".")[1].size == 2 or d["Code"].split(".")[1].size == 3) %tr %td{:colspan => 5}=#debug c -if odd == true -odd =false -else -odd = true -comptes = client.execute("SELECT TOP 5000000 * FROM dbo.[JIPE$General Posting Setup] WHERE [Gen_ Prod_ Posting Group] = '#{d["Code"]}'") -r = [] -comptes.each do |c| %tr -if false %td=debug c -r << [ c["Purch_ Account"], c["Purch_ Account 4PS"], c["Sales Account"], c["Gen_ Bus_ Posting Group"]] if c["Purch_ Account"] != "" or c["Purch_ Account 4PS"] != "" or c["Sales Account"] != "" -r.uniq.each do |s| %tr{:style => ("font-weight:bold !important;" if odd == true)} %td =d["Code"] %td =d["Name"] %td =s[0] %td =s[1] %td =s[2] %td -if s[1].to_s != "" =c = s[1] -else =c = s[0] -if !SComptaAccount.where(code:d["Code"],zone:s[3]).first -SComptaAccount.create(code:d["Code"], name:d["Name"], i_account:s[0], i_account_ps:s[1], i_sale_account:s[2], zone:s[3], purchase_account:c, sale_account:s[2]) -comptes.cancel -if false -if r.count > 0 %hr %p=params[:table] %p= r.count %table.table.table-striped %tr -ic = 0 -r.each do |row| -ic += 1 -if ic == 1 -row.each do |k,v| %th =k -r.each do |row| %tr -row.each do |k,v| %td -if v.class == String =v.encode("UTF-8", :invalid => :replace, :undef => :replace) -else =v -r.cancel