opensteam 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +53 -0
- data/README.rdoc +19 -10
- data/generators/opensteam/opensteam_generator.rb +27 -3
- data/generators/opensteam/templates/app/controllers/admin/configurations_controller.rb +85 -0
- data/generators/opensteam/templates/app/controllers/admin/inventories_controller.rb +1 -1
- data/generators/opensteam/templates/app/controllers/admin/invoices_controller.rb +35 -4
- data/generators/opensteam/templates/app/controllers/admin/orders_controller.rb +5 -4
- data/generators/opensteam/templates/app/controllers/admin/shipments_controller.rb +6 -3
- data/generators/opensteam/templates/app/controllers/admin/shipping_rate_groups_controller.rb +76 -0
- data/generators/opensteam/templates/app/controllers/admin/tax_groups_controller.rb +124 -0
- data/generators/opensteam/templates/app/controllers/admin/tax_rules_controller.rb +19 -0
- data/generators/opensteam/templates/app/controllers/admin/tax_zones_controller.rb +118 -0
- data/generators/opensteam/templates/app/controllers/admin/users_controller.rb +1 -1
- data/generators/opensteam/templates/app/controllers/admin_controller.rb +20 -0
- data/generators/opensteam/templates/app/controllers/carts_controller.rb +118 -0
- data/generators/opensteam/templates/app/controllers/checkout_controller.rb +119 -79
- data/generators/opensteam/templates/app/controllers/profile_controller.rb +2 -4
- data/generators/opensteam/templates/app/controllers/searches_controller.rb +1 -1
- data/generators/opensteam/templates/app/controllers/user_sessions_controller.rb +2 -1
- data/generators/opensteam/templates/app/controllers/users_controller.rb +10 -3
- data/generators/opensteam/templates/app/helpers/admin_helper.rb +15 -1
- data/generators/opensteam/templates/app/helpers/checkout_helper.rb +38 -0
- data/generators/opensteam/templates/app/helpers/webshop_helper.rb +6 -1
- data/generators/opensteam/templates/app/models/zone.rb +18 -0
- data/generators/opensteam/templates/app/views/admin/_menu.html.erb +18 -0
- data/generators/opensteam/templates/app/views/admin/catalog.html.erb +2 -3
- data/generators/opensteam/templates/app/views/admin/configurations/edit.html.erb +20 -0
- data/generators/opensteam/templates/app/views/admin/configurations/index.html.erb +22 -0
- data/generators/opensteam/templates/app/views/admin/configurations/new.html.erb +19 -0
- data/generators/opensteam/templates/app/views/admin/configurations/show.html.erb +13 -0
- data/generators/opensteam/templates/app/views/admin/filters/_filter.html.erb +1 -1
- data/generators/opensteam/templates/app/views/admin/index.html.erb +0 -19
- data/generators/opensteam/templates/app/views/admin/inventories/edit.html.erb +10 -6
- data/generators/opensteam/templates/app/views/admin/inventories/new.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/inventories/show.html.erb +10 -6
- data/generators/opensteam/templates/app/views/admin/invoices/_invoice.html.erb +1 -0
- data/generators/opensteam/templates/app/views/admin/invoices/_invoice_fields.html.erb +52 -0
- data/generators/opensteam/templates/app/views/admin/invoices/new.html.erb +9 -37
- data/generators/opensteam/templates/app/views/admin/invoices/show.html.erb +10 -36
- data/generators/opensteam/templates/app/views/admin/invoices/show.pdf.prawn +59 -0
- data/generators/opensteam/templates/app/views/admin/order_config.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/order_items/_item_entry.html.erb +9 -0
- data/generators/opensteam/templates/app/views/admin/order_items/_items_table.html.erb +16 -0
- data/generators/opensteam/templates/app/views/admin/orders/_order.html.erb +9 -9
- data/generators/opensteam/templates/app/views/admin/orders/_orders.html.erb +1 -1
- data/generators/opensteam/templates/app/views/admin/orders/show.html.erb +25 -9
- data/generators/opensteam/templates/app/views/admin/payment_types.html.erb +27 -0
- data/generators/opensteam/templates/app/views/admin/payments/_credit_card_payment.html.erb +26 -0
- data/generators/opensteam/templates/app/views/admin/payments/_credit_card_payment_info.html.erb +15 -0
- data/generators/opensteam/templates/app/views/admin/payments/_direct_debit_payment.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/shipments/new.html.erb +45 -30
- data/generators/opensteam/templates/app/views/admin/shipments/show.html.erb +3 -3
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/_payment_addition.html.erb +12 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/_rate.html.erb +16 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/edit.html.erb +63 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/index.html.erb +28 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/new.html.erb +60 -0
- data/generators/opensteam/templates/app/views/admin/shipping_rate_groups/show.html.erb +13 -0
- data/generators/opensteam/templates/app/views/admin/system.html.erb +5 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/_attributes.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/_tax_groups.html.erb +17 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/_tax_groups_row.html.erb +12 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/_tax_rule.html.erb +14 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/edit.html.erb +26 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/index.html.erb +8 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/new.html.erb +27 -0
- data/generators/opensteam/templates/app/views/admin/tax_groups/show.html.erb +28 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/_attributes.html.erb +18 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/_tax_zone_row.html.erb +13 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/_tax_zones.html.erb +11 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/edit.html.erb +16 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/index.html.erb +16 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/new.html.erb +14 -0
- data/generators/opensteam/templates/app/views/admin/tax_zones/show.html.erb +15 -0
- data/generators/opensteam/templates/app/views/admin/users.html.erb +0 -1
- data/generators/opensteam/templates/app/views/admin/users/show.html.erb +10 -0
- data/generators/opensteam/templates/app/views/administration_mailer/order_customer.erb +1 -1
- data/generators/opensteam/templates/app/views/carts/_cart.html.erb +7 -0
- data/generators/opensteam/templates/app/views/carts/_cart_content.html.erb +45 -0
- data/generators/opensteam/templates/app/views/carts/create.rjs +3 -0
- data/generators/opensteam/templates/app/views/{cart → carts}/index.html.erb +0 -0
- data/generators/opensteam/templates/app/views/carts/update.rjs +11 -0
- data/generators/opensteam/templates/app/views/checkout/_address.html.erb +42 -0
- data/generators/opensteam/templates/app/views/checkout/_customer.html.erb +31 -0
- data/generators/opensteam/templates/app/views/checkout/_edit_checkout.html.erb +42 -0
- data/generators/opensteam/templates/app/views/checkout/_new_checkout.html.erb +44 -0
- data/generators/opensteam/templates/app/views/checkout/_shipping_buttons.html.erb +8 -0
- data/generators/opensteam/templates/app/views/checkout/edit.html.erb +7 -0
- data/generators/opensteam/templates/app/views/checkout/new.html.erb +11 -0
- data/generators/opensteam/templates/app/views/checkout/outro.html.erb +1 -4
- data/generators/opensteam/templates/app/views/checkout/show.html.erb +63 -0
- data/generators/opensteam/templates/app/views/common/_header_admin.html.erb +5 -0
- data/generators/opensteam/templates/app/views/layouts/admin.html.erb +28 -12
- data/generators/opensteam/templates/app/views/layouts/profile.html.erb +2 -2
- data/generators/opensteam/templates/app/views/layouts/webshop.html.erb +5 -4
- data/generators/opensteam/templates/app/views/payment/_advance_payment_payment.html.erb +1 -0
- data/generators/opensteam/templates/app/views/payment/_credit_card_payment.html.erb +37 -0
- data/generators/opensteam/templates/app/views/payment/_credit_card_payment_confirmation.html.erb +20 -0
- data/generators/opensteam/templates/app/views/payment/_direct_debit_payment.html.erb +5 -0
- data/generators/opensteam/templates/app/views/payment/_direct_debit_payment_confirmation.html.erb +5 -0
- data/generators/opensteam/templates/app/views/profile/index.html.erb +1 -1
- data/generators/opensteam/templates/app/views/profile/infos/edit.html.erb +20 -12
- data/generators/opensteam/templates/app/views/profile/infos/edit_password.html.erb +16 -12
- data/generators/opensteam/templates/app/views/profile/orders/_order.html.erb +1 -1
- data/generators/opensteam/templates/app/views/profile/orders/show.html.erb +10 -7
- data/generators/opensteam/templates/app/views/webshop/_inventory_content.html.erb +1 -0
- data/generators/opensteam/templates/app/views/webshop/show.html.erb +3 -1
- data/generators/opensteam/templates/config/initializers/init_states.rb +13 -24
- data/generators/opensteam/templates/config/initializers/opensteam.rb +41 -0
- data/generators/opensteam/templates/config/initializers/opensteam_model_tables.rb +49 -10
- data/generators/opensteam/templates/config/initializers/opensteam_security.rb +8 -0
- data/generators/opensteam/templates/config/initializers/payment_process.rb +37 -0
- data/generators/opensteam/templates/db/migrate/20080609095723_create_addresses.rb +8 -2
- data/generators/opensteam/templates/db/migrate/20080609095726_create_inventories.rb +6 -3
- data/generators/opensteam/templates/db/migrate/20080609095728_create_order_items.rb +12 -1
- data/generators/opensteam/templates/db/migrate/20080609095729_create_orders.rb +8 -12
- data/generators/opensteam/templates/db/migrate/20080609095730_create_payment_types.rb +2 -0
- data/generators/opensteam/templates/db/migrate/20080714131513_create_invoices.rb +2 -1
- data/generators/opensteam/templates/db/migrate/20080714131650_create_shipments.rb +3 -1
- data/generators/opensteam/templates/db/migrate/20080808075247_create_containers.rb +30 -0
- data/generators/opensteam/templates/db/migrate/20080808083011_create_container_items.rb +25 -0
- data/generators/opensteam/templates/db/migrate/20080812102727_create_tax_zones.rb +16 -0
- data/generators/opensteam/templates/db/migrate/20080812102858_create_tax_rules.rb +15 -0
- data/generators/opensteam/templates/db/migrate/20080812102956_create_tax_groups.rb +14 -0
- data/generators/opensteam/templates/db/migrate/20080831181436_create_configurations.rb +15 -0
- data/generators/opensteam/templates/db/migrate/20080903131506_create_payments.rb +22 -0
- data/generators/opensteam/templates/db/migrate/20080904133625_create_payment_transactions.rb +24 -0
- data/generators/opensteam/templates/db/migrate/20080916102341_create_zones.rb +19 -0
- data/generators/opensteam/templates/db/migrate/20080916134340_create_region_shipping_rates.rb +18 -0
- data/generators/opensteam/templates/db/migrate/20080916134523_create_shipping_rate_groups.rb +18 -0
- data/generators/opensteam/templates/db/migrate/20080916135226_create_shipping_payment_additions.rb +20 -0
- data/generators/opensteam/templates/db/migrate/20080916135228_init_opensteam_config.rb +60 -0
- data/generators/opensteam/templates/public/images/opensteam_black.jpg +0 -0
- data/generators/opensteam/templates/public/images/pdf.png +0 -0
- data/generators/opensteam/templates/public/images/shader.png +0 -0
- data/generators/opensteam/templates/public/index.html +1 -0
- data/generators/opensteam/templates/public/javascripts/opensteam.js +21 -21
- data/generators/opensteam/templates/public/stylesheets/opensteam_admin.css +291 -0
- data/generators/opensteam/templates/public/stylesheets/opensteam_white.css +47 -11
- data/generators/opensteam/templates/tasks/opensteam.rake +2 -12
- data/generators/opensteam/templates/test/fixtures/addresses.yml +26 -0
- data/generators/opensteam/templates/test/fixtures/configurations.yml +29 -0
- data/generators/opensteam/templates/test/fixtures/inventories.yml +32 -15
- data/generators/opensteam/templates/test/fixtures/profiles.yml +21 -0
- data/generators/opensteam/templates/test/fixtures/region_shipping_rates.yml +33 -0
- data/generators/opensteam/templates/test/fixtures/shipping_payment_additions.yml +91 -0
- data/generators/opensteam/templates/test/fixtures/shipping_rate_groups.yml +25 -0
- data/generators/opensteam/templates/test/fixtures/tax_groups.yml +13 -0
- data/generators/opensteam/templates/test/fixtures/tax_rules.yml +29 -0
- data/generators/opensteam/templates/test/fixtures/tax_zones.yml +33 -0
- data/generators/opensteam/templates/test/fixtures/users.yml +26 -0
- data/generators/opensteam/templates/test/fixtures/zones.yml +2707 -0
- data/generators/opensteam/templates/test/functional/carts_controller_test.rb +103 -0
- data/generators/opensteam/templates/test/test_helper.rb +38 -0
- data/generators/opensteam/templates/test/unit/container_test.rb +71 -0
- data/generators/opensteam/templates/test/unit/order_test.rb +93 -0
- data/generators/opensteam/templates/test/unit/payment_test.rb +220 -0
- data/generators/opensteam/templates/test/unit/product_test.rb +158 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/.gitignore +3 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/MIT-LICENSE +20 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/README +12 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/Rakefile +22 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/init.rb +6 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/lib/prawnto.rb +13 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/lib/prawnto/action_controller.rb +47 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/lib/prawnto/template_handler/base.rb +75 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/lib/prawnto/template_handler/raw.rb +54 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/tasks/prawnto_tasks.rake +4 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/test/action_controller_test.rb +36 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/test/base_template_handler_test.rb +58 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/test/raw_template_handler_test.rb +163 -0
- data/generators/opensteam/templates/vendor/plugins/prawnto/test/template_handler_test_mocks.rb +83 -0
- data/generators/opensteam_product/templates/views/admin/_attributes.html.erb +8 -3
- data/generators/opensteam_product/templates/views/admin/_inventories.html.erb +2 -0
- data/lib/opensteam.rb +0 -1
- data/lib/opensteam/base.rb +2 -1
- data/lib/opensteam/checkout.rb +3 -12
- data/lib/opensteam/config.rb +50 -2
- data/lib/opensteam/container.rb +196 -0
- data/lib/opensteam/extension_base.rb +19 -1
- data/lib/opensteam/finder.rb +1 -1
- data/lib/opensteam/helpers/config_table_helper.rb +18 -6
- data/lib/opensteam/initializer.rb +24 -4
- data/lib/opensteam/inventory_base.rb +6 -1
- data/lib/opensteam/invoice_base.rb +12 -13
- data/lib/opensteam/money.rb +230 -0
- data/lib/opensteam/order_base.rb +122 -48
- data/lib/opensteam/payment.rb +225 -0
- data/lib/opensteam/payment/advance_payment.rb +34 -0
- data/lib/opensteam/payment/credit_card_payment.rb +217 -0
- data/lib/opensteam/payment/direct_debit_payment.rb +53 -0
- data/lib/opensteam/product_base.rb +48 -12
- data/lib/opensteam/security.rb +54 -0
- data/lib/opensteam/shipment_base.rb +214 -6
- data/lib/opensteam/shopping_cart.rb +20 -300
- data/lib/opensteam/state_logic.rb +5 -3
- data/lib/opensteam/state_machine.rb +8 -3
- data/lib/opensteam/user_base.rb +48 -6
- data/lib/opensteam/version.rb +1 -1
- metadata +122 -16
- data/generators/opensteam/templates/app/controllers/cart_controller.rb +0 -94
- data/generators/opensteam/templates/app/views/admin/orders/_event.html.erb +0 -5
- data/generators/opensteam/templates/app/views/admin/orders/_order_item.html.erb +0 -10
- data/generators/opensteam/templates/app/views/cart/_cart.html.erb +0 -8
- data/generators/opensteam/templates/app/views/cart/_cart_content.html.erb +0 -20
- data/generators/opensteam/templates/app/views/cart/update.rjs +0 -1
- data/generators/opensteam/templates/app/views/checkout/payment.html.erb +0 -8
- data/generators/opensteam/templates/app/views/checkout/shipping.html.erb +0 -45
- data/generators/opensteam/templates/app/views/checkout/show_cart.html.erb +0 -13
- data/generators/opensteam/templates/app/views/checkout/update_cart_content.rjs +0 -2
- data/generators/opensteam/templates/app/views/profile/orders/_order_item.html.erb +0 -10
- data/generators/opensteam/templates/db/migrate/20080609095725_create_dummy_users.rb +0 -21
- data/lib/opensteam/cart_base.rb +0 -227
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
class Admin::TaxGroupsController < AdminController
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
before_filter :set_sort_column
|
|
5
|
+
|
|
6
|
+
def index
|
|
7
|
+
@tax_groups = ProductTaxGroup.find( :all, :include => [:tax_zones, :inventories ] )
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# @tax_groups = apply_filter( "TaxGroup" )
|
|
11
|
+
#
|
|
12
|
+
# @tax_groups = ( @tax_groups || TaxGroup ).order_by( @sort_column.order )
|
|
13
|
+
#
|
|
14
|
+
# if params[:sort]
|
|
15
|
+
# @tax_groups.reverse! if session[:tax_group]
|
|
16
|
+
# session[:tax_group] = session[:tax_group] ? false : true
|
|
17
|
+
# end
|
|
18
|
+
|
|
19
|
+
respond_to do |format|
|
|
20
|
+
format.html
|
|
21
|
+
format.xml { render :xml => @tax_groups.to_xml( :root => "tax_groups") }
|
|
22
|
+
format.js { render :partial => "admin/tax_groups/tax_groups_row", :collection => @tax_groups}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def new
|
|
29
|
+
@tax_group = Opensteam::Money::Tax::ProductTaxGroup.new
|
|
30
|
+
@tax_zones = Opensteam::Money::Tax::TaxZone.all
|
|
31
|
+
|
|
32
|
+
@tax_rules = @tax_group.tax_rules.build
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def create
|
|
41
|
+
@tax_group = Opensteam::Money::Tax::ProductTaxGroup.new( params[:tax_group] )
|
|
42
|
+
@tax_zones = Opensteam::Money::Tax::TaxZone.all.to_h2 { |a| a.country }
|
|
43
|
+
|
|
44
|
+
respond_to do |format|
|
|
45
|
+
if @tax_group.save
|
|
46
|
+
flash[:notice] = "TaxGroup successfully created!"
|
|
47
|
+
format.html { redirect_to :action => :index }
|
|
48
|
+
format.xml { render :xml => @tax_group.to_xml( :root => "tax_group" ), :status => :created, :location => @tax_zone }
|
|
49
|
+
else
|
|
50
|
+
format.html { render :action => :new }
|
|
51
|
+
format.xml { render :xml => @tax_group.errors, :status => :unprocessable_entity }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def show
|
|
59
|
+
@tax_group = Opensteam::Money::Tax::TaxGroup.find( params[:id], :include => :tax_rules )
|
|
60
|
+
|
|
61
|
+
respond_to do |format|
|
|
62
|
+
format.html
|
|
63
|
+
format.xml { render :xml => @tax_group.to_xml( :root => "tax_group" ) }
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def edit
|
|
69
|
+
@tax_group = Opensteam::Money::Tax::TaxGroup.find( params[:id] )
|
|
70
|
+
@tax_zones = Opensteam::Money::Tax::TaxZone.all
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def update
|
|
75
|
+
@tax_group = Opensteam::Money::Tax::ProductTaxGroup.find( params[:id] )
|
|
76
|
+
@tax_zones = Opensteam::Money::Tax::TaxZone.all
|
|
77
|
+
|
|
78
|
+
params[:tax_group][:existing_tax_rule_attributes] ||= {}
|
|
79
|
+
|
|
80
|
+
respond_to do |format|
|
|
81
|
+
if @tax_group.update_attributes( params[:tax_group] )
|
|
82
|
+
flash[:notice] = "TaxGroup successfully created!"
|
|
83
|
+
format.html { redirect_to admin_tax_group_path( @tax_group ) }
|
|
84
|
+
format.xml { render :xml => @tax_group.to_xml( :root => "tax_group" ), :status => :created, :location => @tax_zone }
|
|
85
|
+
else
|
|
86
|
+
format.html { render :action => :edit }
|
|
87
|
+
format.xml { render :xml => @tax_group.errors, :status => :unprocessable_entity }
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def destroy
|
|
96
|
+
@tax_group = Opensteam::Money::Tax::TaxGroup.find( params[:id] )
|
|
97
|
+
|
|
98
|
+
respond_to do |format|
|
|
99
|
+
unless @tax_group.inventories.empty?
|
|
100
|
+
flash[:error] = "Cannot delete TaxGroup '#{@tax_group.name}'. Remove Product Associations first."
|
|
101
|
+
format.html { redirect_to :action => :index }
|
|
102
|
+
else
|
|
103
|
+
@tax_group.destroy
|
|
104
|
+
format.html { redirect_to :action => :index }
|
|
105
|
+
format.xml { head :ok }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
private
|
|
117
|
+
def set_sort_column
|
|
118
|
+
id = params[:sort] || "id"
|
|
119
|
+
@sort_column = TaxGroup.osteam_configtable.columns.find { |s| s.id.to_s == id }
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Admin::TaxRulesController < AdminController
|
|
2
|
+
|
|
3
|
+
def index
|
|
4
|
+
@inventories = Inventory.find( :all, :include => :product )
|
|
5
|
+
@product_tax_groups = ProductTaxGroup.find( :all, :include => :tax_zones )
|
|
6
|
+
@tax_zones = TaxZone.all.to_h2 { |a| a.country }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_tax_rule
|
|
11
|
+
@inventory = Inventory.find( params[:inventory] )
|
|
12
|
+
render :text => @inventory.tax_group.name.to_s
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
class Admin::TaxZonesController < AdminController
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
before_filter :set_sort_column
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# def filter
|
|
8
|
+
# save_filter( "TaxZone" )
|
|
9
|
+
# # @tax_zones = apply_filter( "TaxZone" )
|
|
10
|
+
# redirect_to :action => :index
|
|
11
|
+
# end
|
|
12
|
+
#
|
|
13
|
+
|
|
14
|
+
def index
|
|
15
|
+
# save_filter( "TaxZone" ) if request.post?
|
|
16
|
+
@tax_zones = apply_filter( "TaxZone" )
|
|
17
|
+
|
|
18
|
+
@tax_zones = ( @tax_zones || TaxZone ).order_by( @sort_column.order )
|
|
19
|
+
|
|
20
|
+
if params[:sort]
|
|
21
|
+
@tax_zones.reverse! if session[:tax_zones]
|
|
22
|
+
session[:tax_zones] = session[:tax_zones] ? false : true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
respond_to do |format|
|
|
27
|
+
format.html
|
|
28
|
+
format.xml { render :xml => @tax_zones.to_xml( :root => "tax_zones") }
|
|
29
|
+
format.js { render :partial => "admin/tax_zones/tax_zone_row", :collection => @tax_zones }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def new
|
|
37
|
+
@tax_zone = Opensteam::Money::Tax::TaxZone.new
|
|
38
|
+
@countries = CountryCodes.countries_for_select "name"
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def create
|
|
44
|
+
@tax_zone = Opensteam::Money::Tax::TaxZone.new( params[:tax_zone] )
|
|
45
|
+
|
|
46
|
+
respond_to do |format|
|
|
47
|
+
|
|
48
|
+
if @tax_zone.save
|
|
49
|
+
flash[:notice] = "TaxZone was successfully created!"
|
|
50
|
+
format.html { redirect_to :action => 'index' }
|
|
51
|
+
format.xml { render :xml => @tax_zone.to_xml( :root => "tax_zone" ), :status => :creates, :location => @tax_zone }
|
|
52
|
+
else
|
|
53
|
+
format.html { render :action => 'new' }
|
|
54
|
+
format.xml { render :xml => @tax_zone.errors, :status => :unprocessable_entity }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def show
|
|
62
|
+
@tax_zone = Opensteam::Money::Tax::TaxZone.find( params[:id] )
|
|
63
|
+
|
|
64
|
+
respond_to do |format|
|
|
65
|
+
format.html
|
|
66
|
+
format.xml { render :xml => @tax_zone.to_xml( :root => "tax_zone" ) }
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def edit
|
|
73
|
+
@tax_zone = Opensteam::Money::Tax::TaxZone.find( params[:id] )
|
|
74
|
+
@countries = CountryCodes.countries_for_select "name"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def update
|
|
80
|
+
@tax_zone = Opensteam::Money::Tax::TaxZone.find( params[:id] )
|
|
81
|
+
|
|
82
|
+
respond_to do |format|
|
|
83
|
+
if @tax_zone.update_attributes( params[:tax_zone] )
|
|
84
|
+
flash[:notice] = "TaxZone was sucessfully updated!"
|
|
85
|
+
format.html { redirect_to( admin_tax_zone_path( @tax_zone ) ) }
|
|
86
|
+
format.xml { head :ok }
|
|
87
|
+
else
|
|
88
|
+
format.html { render :action => 'edit' }
|
|
89
|
+
format.xml { render :xml => @tax_zone.errors, :status => :unprocessable_entity }
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def destroy
|
|
97
|
+
@tax_zone = Opensteam::Tax::TaxZone.find( params[:id] )
|
|
98
|
+
@tax_zone.destroy
|
|
99
|
+
|
|
100
|
+
respond_to do |format|
|
|
101
|
+
format.html { redirect_to( admin_tax_zones_path ) }
|
|
102
|
+
format.xml { head :ok }
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
private
|
|
111
|
+
def set_sort_column
|
|
112
|
+
id = params[:sort] || "id"
|
|
113
|
+
@sort_column = TaxZone.osteam_configtable.columns.find { |s| s.id.to_s == id }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
end
|
|
@@ -92,7 +92,7 @@ class Admin::UsersController < AdminController
|
|
|
92
92
|
|
|
93
93
|
if ret
|
|
94
94
|
flash[:notice] = "User succesfully created"
|
|
95
|
-
format.html { redirect_to
|
|
95
|
+
format.html { redirect_to admin_user_path( @user ) }
|
|
96
96
|
format.xml
|
|
97
97
|
else
|
|
98
98
|
format.html { render :action => "new" }
|
|
@@ -32,6 +32,26 @@ class AdminController < ApplicationController
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
def filter
|
|
36
|
+
self.class.name =~ /^Admin::(.+)Controller$/
|
|
37
|
+
model = $1
|
|
38
|
+
save_filter( model.singularize )
|
|
39
|
+
redirect_to :action => :index
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def payment_types
|
|
45
|
+
@payment_types = Opensteam::Payment::Types.all
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def toggle_payment_type
|
|
50
|
+
Opensteam::Payment::Types.find( params[:id] ).toggle!
|
|
51
|
+
redirect_to :action => :payment_types
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
|
|
35
55
|
private
|
|
36
56
|
def authorized?
|
|
37
57
|
unless logged_in? && is_admin?
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
## TEMPLATE ##
|
|
2
|
+
class CartsController < ApplicationController
|
|
3
|
+
|
|
4
|
+
layout "<%= file_name %>"
|
|
5
|
+
|
|
6
|
+
before_filter :get_cart
|
|
7
|
+
|
|
8
|
+
before_filter :check_availability, :only => [:create]
|
|
9
|
+
before_filter :check_storage, :only => [:update]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def check_availability
|
|
14
|
+
if Inventory.find( params[:id] ).is_available?
|
|
15
|
+
return true
|
|
16
|
+
else
|
|
17
|
+
render :update do |page| page.alert( "This Item is current not available!" ) end
|
|
18
|
+
return false
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def check_storage
|
|
23
|
+
if params[:incr]
|
|
24
|
+
if ( @cart[ params[:id] ].quantity + 1 ) <= @cart[ params[:id].to_i ].item.storage
|
|
25
|
+
return true
|
|
26
|
+
else
|
|
27
|
+
render :update do |page| page.alert( "Sorry, there are only #{@cart[ params[:id] ].item.storage} items available!") end
|
|
28
|
+
return false
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def index
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def create
|
|
42
|
+
@inventory = Inventory.find( params[:id] )
|
|
43
|
+
@cart.push( @inventory )
|
|
44
|
+
|
|
45
|
+
respond_to do |format|
|
|
46
|
+
format.html { redirect_to :action => 'index' }
|
|
47
|
+
format.js
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def show
|
|
53
|
+
@inventory = @cart[ params[:id] ].item
|
|
54
|
+
@product = @inventory.product
|
|
55
|
+
@product.selected_inventory = @inventory
|
|
56
|
+
@properties = @inventory.properties.to_h2 { |x| x.class.to_s.tableize }
|
|
57
|
+
|
|
58
|
+
@inventory = [ @inventory ] # TODO: change webshop/show template ...
|
|
59
|
+
|
|
60
|
+
@cart_details = true
|
|
61
|
+
|
|
62
|
+
render :template => "<%= file_name %>/show"
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def destroy
|
|
68
|
+
if params[:id]
|
|
69
|
+
@cart[ params[:id].to_i ].destroy
|
|
70
|
+
@cart.reload
|
|
71
|
+
else
|
|
72
|
+
wipe_cart
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
respond_to do |format|
|
|
77
|
+
format.html { redirect_to :action => 'index' }
|
|
78
|
+
format.js { render :template => "carts/create.rjs" }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def update
|
|
85
|
+
if params[:id]
|
|
86
|
+
@cart[ params[:id].to_i ].incr if params[:incr]
|
|
87
|
+
@cart[ params[:id].to_i ].decr if params[:decr]
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
if params[:quantity]
|
|
91
|
+
@cart.update_attributes( :set_quantity => Hash[ params[:quantity] ] )
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
@cart.reload
|
|
95
|
+
|
|
96
|
+
respond_to do |format|
|
|
97
|
+
format.html { redirect_to :action => 'index', :controller => '<%= file_name %>' }
|
|
98
|
+
format.js
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
private
|
|
105
|
+
def get_cart
|
|
106
|
+
session[:cart] ||= Cart.create.id
|
|
107
|
+
@cart = Cart.find( session[:cart] )
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def wipe_cart
|
|
111
|
+
session[:cart] = nil
|
|
112
|
+
get_cart
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
end
|
|
@@ -11,9 +11,26 @@ class CheckoutController < ApplicationController
|
|
|
11
11
|
layout "<%= file_name %>"
|
|
12
12
|
include Opensteam::Checkout
|
|
13
13
|
include Opensteam::ShoppingCart
|
|
14
|
+
before_filter :check_admin
|
|
15
|
+
before_filter :set_instance_vars
|
|
14
16
|
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def shipping_types
|
|
21
|
+
locals = { :country => params[:order][:shipping_address][:country] }
|
|
22
|
+
locals[:payment_type] = params[:order][:payment_type] if params[:order][:payment_type]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
render :update do |page|
|
|
26
|
+
for st in Opensteam::ShipmentBase::RegionShippingRate.all.collect(&:shipping_method ).uniq
|
|
27
|
+
page.replace_html "shipping_type_rate_#{st.underscore}", @cart.calculate_shipping_rate(
|
|
28
|
+
locals.update( :shipping_method => st ) )
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
# render :partial => "shipping_buttons", :locals => locals , :layout => false, :object => @cart
|
|
32
|
+
end
|
|
33
|
+
|
|
17
34
|
|
|
18
35
|
# initialize checkout-flow
|
|
19
36
|
#
|
|
@@ -24,106 +41,129 @@ class CheckoutController < ApplicationController
|
|
|
24
41
|
end
|
|
25
42
|
end
|
|
26
43
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# dummy page
|
|
31
|
-
def intro
|
|
32
|
-
@cart = get_cart
|
|
33
|
-
order = Opensteam::OrderBase::Order.create
|
|
34
|
-
session[:active_order] = order.id
|
|
35
|
-
if logged_in?
|
|
36
|
-
redirect_to :action => :place_order
|
|
37
|
-
return
|
|
38
|
-
end
|
|
39
|
-
session[:return_to] = url_for :controller => 'checkout', :action => 'show_cart'
|
|
40
|
-
|
|
44
|
+
|
|
45
|
+
def intro
|
|
46
|
+
redirect_to :action => :new
|
|
41
47
|
end
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
session[:cart] = nil
|
|
51
|
-
@cart = get_cart
|
|
52
|
-
session[:active_order] = nil
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def new
|
|
51
|
+
@order = Opensteam::OrderBase::Order.new
|
|
52
|
+
|
|
53
|
+
respond_to do |format|
|
|
54
|
+
format.html
|
|
55
|
+
end
|
|
53
56
|
end
|
|
54
57
|
|
|
55
58
|
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# [POST] + [GET]
|
|
60
|
-
def shipping
|
|
61
|
-
@order = Opensteam::OrderBase::Order.find( session[:active_order] )
|
|
62
|
-
@cart = get_cart
|
|
63
|
-
|
|
60
|
+
def create
|
|
61
|
+
@order = Opensteam::OrderBase::Order.new( params[:order] )
|
|
64
62
|
|
|
63
|
+
@customer = logged_in? ? current_user : Opensteam::UserBase::User.new_or_existing_guest( params[:guest_customer] )
|
|
64
|
+
@order.real_customer = @customer
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
@shipping_address = Opensteam::UserBase::Address.new
|
|
68
|
-
@payment_address = Opensteam::UserBase::Address.new
|
|
69
|
-
|
|
70
|
-
#saving the form
|
|
71
|
-
if request.post?
|
|
66
|
+
respond_to do |format|
|
|
72
67
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
render :action => :shipping
|
|
77
|
-
end
|
|
78
|
-
params[:order].delete :customer
|
|
79
|
-
@order.real_customer = @customer
|
|
80
|
-
end
|
|
68
|
+
ret = @order.valid?
|
|
69
|
+
@payment = Opensteam::Payment::Base[ @order.payment_type ].new( params[:payment_fields] ) if @order.payment_type
|
|
70
|
+
ret2 = @payment.valid? if @order.payment_type
|
|
81
71
|
|
|
82
|
-
if
|
|
83
|
-
@order.
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
if ret && ret2
|
|
73
|
+
@order.save
|
|
74
|
+
@order.copy_items_from @cart
|
|
75
|
+
@order.update_price_and_tax!
|
|
76
|
+
@order.set_shipping_rate!
|
|
77
|
+
@order.save
|
|
86
78
|
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
session[:active_order] = @order.id
|
|
80
|
+
format.html { render :action => :show }
|
|
89
81
|
else
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
@shipping_address = @order.shipping_address
|
|
93
|
-
render :action => :shipping
|
|
82
|
+
flash[:error] = "could not save order"
|
|
83
|
+
format.html { render :action => :new }
|
|
94
84
|
end
|
|
95
|
-
|
|
96
85
|
end
|
|
97
|
-
|
|
86
|
+
|
|
98
87
|
end
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
# show the shopping cart again
|
|
105
|
-
def show_cart
|
|
106
|
-
@cart = get_cart
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def show
|
|
91
|
+
@order = Opensteam::OrderBase::Order.find( session[:active_order],
|
|
92
|
+
:include => [ :shipping_address, :payment_address, :items, :customer ] )
|
|
107
93
|
end
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
# place order
|
|
111
|
-
# [POST]
|
|
112
|
-
#
|
|
94
|
+
|
|
113
95
|
def place_order
|
|
114
|
-
# if request.post?
|
|
115
|
-
|
|
116
96
|
@order = Opensteam::OrderBase::Order.find( session[:active_order] )
|
|
117
|
-
@order.
|
|
97
|
+
@order.customer.addresses << [ @order.shipping_address, @order.payment_address ]
|
|
98
|
+
@order.payments.build_payment( params[:payment] )
|
|
118
99
|
@order.save
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
100
|
+
|
|
101
|
+
@order.state = :pending
|
|
102
|
+
|
|
103
|
+
clear_cart
|
|
104
|
+
redirect_to :action => :outro
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def edit
|
|
110
|
+
@order = Opensteam::OrderBase::Order.find( session[:active_order],
|
|
111
|
+
:include => [ :shipping_address, :payment_address, :customer ] )
|
|
112
|
+
|
|
113
|
+
@customer = @order.customer
|
|
123
114
|
end
|
|
124
115
|
|
|
116
|
+
|
|
117
|
+
def update
|
|
118
|
+
@order = Opensteam::OrderBase::Order.find( session[:active_order] )
|
|
119
|
+
@customer = @order.customer
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
respond_to do |format|
|
|
123
|
+
|
|
124
|
+
ret = @order.update_attributes( params[:order] )
|
|
125
|
+
@payment = Opensteam::Payment::Base[ @order.payment_type ].new( params[:payment_fields] ) if ret
|
|
126
|
+
|
|
127
|
+
if ret && @payment.valid?
|
|
128
|
+
|
|
129
|
+
@order.update_price_and_tax!
|
|
130
|
+
@order.set_shipping_rate!
|
|
131
|
+
@order.save
|
|
132
|
+
|
|
133
|
+
session[:active_order] = @order.id
|
|
134
|
+
format.html { render :action => :show }
|
|
135
|
+
else
|
|
136
|
+
flash[:error] = "Error: Could not update order"
|
|
137
|
+
format.html { render :action => :edit }
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def outro
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
125
154
|
private
|
|
126
155
|
|
|
156
|
+
|
|
157
|
+
def set_instance_vars
|
|
158
|
+
#@order = Opensteam::OrderBase::Order.find( session[:active_order] )
|
|
159
|
+
@countries = Zone.all.collect(&:country_name).sort
|
|
160
|
+
# @countries = CountryCodes.countries_for_select("name").sort
|
|
161
|
+
@customer = logged_in? ? current_user : Opensteam::UserBase::User.new
|
|
162
|
+
@addresses = @customer.addresses
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
127
167
|
def check_admin
|
|
128
168
|
if( logged_in? && is_admin? )
|
|
129
169
|
flash[:error] = "Checkout not allowed for Admin User #{current_user.email}"
|