export sage
This commit is contained in:
parent
de61331e22
commit
4a077a836b
@ -10,6 +10,72 @@ class Admin::ProductOrdersController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def export2
|
||||||
|
@product_orders = ProductOrder.where(:completed_finish => true).order("created_at DESC")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
format.csv {
|
||||||
|
|
||||||
|
@file = ""
|
||||||
|
|
||||||
|
elements = {
|
||||||
|
|
||||||
|
"N°Pièce" => "product_order.bl_number",
|
||||||
|
|
||||||
|
"Date" => "product_order.created_at",
|
||||||
|
"Type document" => "product_order.sage_type_doc",
|
||||||
|
"Tiers" => "product_order.sage_tiers",
|
||||||
|
"Référence article" => "sage_reference",
|
||||||
|
"Quantité" => "qty",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"Type prix" => "product_order.sage_type_prix",
|
||||||
|
"Prix unitaire" => "archived_product.price_ht",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
headers = []
|
||||||
|
attributes = []
|
||||||
|
|
||||||
|
elements.each do |key, value|
|
||||||
|
headers << key
|
||||||
|
attributes << value
|
||||||
|
end
|
||||||
|
|
||||||
|
@csv = CSV.generate(:headers => true, :col_sep => ";") do |csv|
|
||||||
|
csv << headers
|
||||||
|
|
||||||
|
@product_orders.all.each do |product_order|
|
||||||
|
product_order.product_order_products.each do |product_order_product|
|
||||||
|
csv << attributes.map{ |attr| eval("product_order_product."+attr.to_s) }
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
send_data @csv.encode('iso-8859-1', :undef => :replace, :replace => ''), :filename => "export-#{Date.today.to_s.to_slug}.csv", :type => 'text/csv; charset=iso-8859-1; header=present' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def export
|
def export
|
||||||
@product_orders = ProductOrder.where(:completed_finish => true).order("created_at DESC")
|
@product_orders = ProductOrder.where(:completed_finish => true).order("created_at DESC")
|
||||||
|
|
||||||
@ -33,7 +99,7 @@ class Admin::ProductOrdersController < ApplicationController
|
|||||||
"created_at" => "created_at",
|
"created_at" => "created_at",
|
||||||
|
|
||||||
|
|
||||||
"fact_organisation" => "particular_bill.firstname",
|
"fact_organisation" => "particular_bill.organisation",
|
||||||
"fact_prenom" => "particular_bill.firstname",
|
"fact_prenom" => "particular_bill.firstname",
|
||||||
"fact_nom" => "particular_bill.name",
|
"fact_nom" => "particular_bill.name",
|
||||||
"fact_adresse" => "particular_bill.address_2",
|
"fact_adresse" => "particular_bill.address_2",
|
||||||
@ -43,7 +109,7 @@ class Admin::ProductOrdersController < ApplicationController
|
|||||||
"fact_pays" => "particular_bill.country",
|
"fact_pays" => "particular_bill.country",
|
||||||
"fact_tel" => "particular_bill.tel",
|
"fact_tel" => "particular_bill.tel",
|
||||||
|
|
||||||
"livr_organisation" => "particular_send.firstname",
|
"livr_organisation" => "particular_send.organisation",
|
||||||
"livr_prenom" => "particular_send.firstname",
|
"livr_prenom" => "particular_send.firstname",
|
||||||
"livr_nom" => "particular_send.name",
|
"livr_nom" => "particular_send.name",
|
||||||
"livr_adresse" => "particular_send.address_2",
|
"livr_adresse" => "particular_send.address_2",
|
||||||
|
@ -31,6 +31,18 @@ class ProductOrder < ActiveRecord::Base
|
|||||||
attr_accessor :force_fdp_validation, :force_payment, :force_cgv_validation
|
attr_accessor :force_fdp_validation, :force_payment, :force_cgv_validation
|
||||||
|
|
||||||
|
|
||||||
|
def sage_tiers
|
||||||
|
"tiers"
|
||||||
|
end
|
||||||
|
|
||||||
|
def sage_type_prix
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
|
def sage_type_doc
|
||||||
|
1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def prodons_country
|
def prodons_country
|
||||||
countr = particular_bill.country
|
countr = particular_bill.country
|
||||||
|
@ -11,6 +11,12 @@ class ProductOrderProduct < ActiveRecord::Base
|
|||||||
belongs_to :archived_product_size, class_name: "ProductSize"
|
belongs_to :archived_product_size, class_name: "ProductSize"
|
||||||
belongs_to :archived_product_option, class_name: "ProductOption"
|
belongs_to :archived_product_option, class_name: "ProductOption"
|
||||||
|
|
||||||
|
|
||||||
|
def sage_reference
|
||||||
|
if self.product
|
||||||
|
self.product.sage_reference
|
||||||
|
end
|
||||||
|
end
|
||||||
def tva
|
def tva
|
||||||
20.0
|
20.0
|
||||||
end
|
end
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
%hr
|
%hr
|
||||||
%h3 Tailles possibles :
|
%h3 Tailles possibles :
|
||||||
=form.input :product_sizes, :collection => ProductSize.where("archived is null").order(:position).all, :as => :check_boxes, :label => "Tailles"
|
=form.input :product_sizes, :collection => ProductSize.where("archived is null").order(:position).all, :as => :check_boxes, :label => "Tailles"
|
||||||
|
|
||||||
|
=form.input :sage_reference, :label => "Référence sage :"
|
||||||
|
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
|
@ -313,6 +313,7 @@ Rails.application.routes.draw do
|
|||||||
resources :product_orders do
|
resources :product_orders do
|
||||||
collection do
|
collection do
|
||||||
get :export
|
get :export
|
||||||
|
get :export2
|
||||||
end
|
end
|
||||||
member do
|
member do
|
||||||
get :ship
|
get :ship
|
||||||
|
6
db/migrate/20171220122439_add_sage_to_products.rb
Normal file
6
db/migrate/20171220122439_add_sage_to_products.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class AddSageToProducts < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :products, :sage_reference, :string
|
||||||
|
add_column :products, :sage_tiers, :string
|
||||||
|
end
|
||||||
|
end
|
14
db/schema.rb
14
db/schema.rb
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20171022211011) do
|
ActiveRecord::Schema.define(version: 20171220122439) do
|
||||||
|
|
||||||
create_table "accepted_offers", force: :cascade do |t|
|
create_table "accepted_offers", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
@ -877,17 +877,19 @@ ActiveRecord::Schema.define(version: 20171022211011) do
|
|||||||
add_index "product_stocks", ["product_id"], name: "index_product_stocks_on_product_id", using: :btree
|
add_index "product_stocks", ["product_id"], name: "index_product_stocks_on_product_id", using: :btree
|
||||||
|
|
||||||
create_table "products", force: :cascade do |t|
|
create_table "products", force: :cascade do |t|
|
||||||
t.decimal "price_ht", precision: 10, scale: 2
|
t.decimal "price_ht", precision: 10, scale: 2
|
||||||
t.decimal "price_reduced_ht", precision: 10, scale: 2
|
t.decimal "price_reduced_ht", precision: 10, scale: 2
|
||||||
t.boolean "enabled", limit: 1
|
t.boolean "enabled", limit: 1
|
||||||
t.integer "default_image_id", limit: 4
|
t.integer "default_image_id", limit: 4
|
||||||
t.integer "position", limit: 4
|
t.integer "position", limit: 4
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "product_category_id", limit: 4
|
t.integer "product_category_id", limit: 4
|
||||||
t.integer "product_collection_id", limit: 4
|
t.integer "product_collection_id", limit: 4
|
||||||
t.boolean "archived", limit: 1, default: false
|
t.boolean "archived", limit: 1, default: false
|
||||||
t.integer "reseaux_id", limit: 4
|
t.integer "reseaux_id", limit: 4
|
||||||
|
t.string "sage_reference", limit: 255
|
||||||
|
t.string "sage_tiers", limit: 255
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "products", ["product_category_id"], name: "index_products_on_product_category_id", using: :btree
|
add_index "products", ["product_category_id"], name: "index_products_on_product_category_id", using: :btree
|
||||||
|
Loading…
x
Reference in New Issue
Block a user