Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Replaced juridical user section. Bugs fixed. Added validations for ad…

…min juridical options.
  • Loading branch information...
commit 8db2b78dfe2ef785bcce3de30592dc992fdd0497 1 parent 5b23adc
Pavel Belyakov authored August 17, 2011
32  app/controllers/admin/synergy_settings_controller.rb
... ...
@@ -1,25 +1,25 @@
1 1
 class Admin::SynergySettingsController < Admin::BaseController
  2
+  before_filter :load_configuration, :only => [:edit, :update]
  3
+  
2 4
   def show
3  
-    @preferences = Spree::Synergy::Config.get
4  
-  end
5  
-
6  
-  def edit
7  
-    @preferences = Spree::Synergy::Config.get
  5
+    @synergy_configuration = Spree::Synergy::Config.get
8 6
   end
9 7
   
10 8
   def update
11  
-    preferences = params[:preferences]
12  
-    
13  
-    enable_juridical = preferences[:juridical_enabled].nil? ? false : true
14  
-    enable_nds = preferences[:nds].nil? ? false : true
15  
-    preferences.update(:juridical_enabled => enable_juridical, :nds => enable_nds)    
16  
-    Spree::Synergy::Config.set(preferences)
17  
-
18 9
     contacts_preferences = params[:preferences][:contacts]    
19 10
     Spree::Config.set(contacts_preferences)
20  
-    
21  
-    respond_to do |format|
22  
-      format.html { redirect_to admin_synergy_settings_url }
  11
+
  12
+    if @synergy_configuration.update_attributes(params[:synergy_configuration])
  13
+      Spree::Synergy::Config.set
  14
+      redirect_to admin_synergy_settings_url
  15
+    else
  16
+      render 'edit'
23 17
     end
24 18
   end
25  
-end
  19
+  
  20
+  private
  21
+  
  22
+  def load_configuration
  23
+    @synergy_configuration = Spree::Synergy::Config.instance
  24
+  end
  25
+end
2  app/controllers/orders_controller_decorator.rb
@@ -8,7 +8,7 @@ def sberbank_invoice
8 8
   def juridical_invoice
9 9
     @order = Order.find_by_number(params[:id])
10 10
     @user = @order.user
11  
-    @preferences = Spree::Synergy::Config.get
  11
+    @synergy_configuration = Spree::Synergy::Config.get
12 12
     render :layout => false
13 13
   end
14 14
 end
12  app/controllers/users_controller_decorator.rb
... ...
@@ -1,7 +1,17 @@
1 1
 UsersController.class_eval do
2  
-  before_filter :check_juridical, :only => :update
  2
+  prepend_before_filter :load_object, :only => [:show, :edit, :update, :edit_status, :update_status]
  3
+  before_filter :check_juridical, :only => :update_status
3 4
   
4 5
   def check_juridical
5 6
     current_user.juridical = false unless params[:user][:juridical]
6 7
   end
  8
+  
  9
+  def update_status
  10
+    if @user.update_attributes(params[:user])
  11
+      flash.notice = I18n.t(:account_updated)
  12
+      redirect_to account_url
  13
+    else
  14
+      render 'edit_status'
  15
+    end
  16
+  end
7 17
 end
48  app/views/admin/synergy_settings/_juridical.html.erb
... ...
@@ -1,50 +1,50 @@
1 1
 <table>
2 2
   <tr>
3  
-    <td><%= t('enable_juridical') %>:</td>
4  
-    <td><%= @preferences['juridical_enabled'] ? t("yes") : t("no") %></td>
  3
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_juridical_enabled) %>:</td>
  4
+    <td><%= @synergy_configuration['juridical_enabled'] ? t("yes") : t("no") %></td>
5 5
   </tr>
6 6
   <tr>
7  
-    <td><%= t('juridical_name') %>:</td>
8  
-    <td><%= @preferences['recipient'] %></td>
  7
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_recipient) %>:</td>
  8
+    <td><%= @synergy_configuration['recipient'] %></td>
9 9
   </tr>
10 10
   <tr>
11  
-    <td><%= t('juridical_address') %>:</td>
12  
-    <td><%= @preferences['address'] %></td>
  11
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_address) %>:</td>
  12
+    <td><%= @synergy_configuration['address'] %></td>
13 13
   </tr>
14 14
   <tr>
15  
-    <td><%= t('inn') %>:</td>
16  
-    <td><%= @preferences['inn'] %></td>
  15
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_inn) %>:</td>
  16
+    <td><%= @synergy_configuration['inn'] %></td>
17 17
   </tr>
18 18
   <tr>
19  
-    <td><%= t('kpp') %>:</td>
20  
-    <td><%= @preferences['kpp'] %></td>
  19
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_kpp) %>:</td>
  20
+    <td><%= @synergy_configuration['kpp'] %></td>
21 21
   </tr>
22 22
   <tr>
23  
-    <td><%= t('juridical_bank') %>:</td>
24  
-    <td><%= @preferences['bank'] %></td>
  23
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_bank) %>:</td>
  24
+    <td><%= @synergy_configuration['bank'] %></td>
25 25
   </tr>
26 26
   <tr>
27  
-    <td><%= t('settlement_acc') %>:</td>
28  
-    <td><%= @preferences['settlement_acc'] %></td>
  27
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_settlement_acc) %>:</td>
  28
+    <td><%= @synergy_configuration['settlement_acc'] %></td>
29 29
   </tr>
30 30
   <tr>
31  
-    <td><%= t('corr') %>:</td>
32  
-    <td><%= @preferences['corr'] %></td>
  31
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_corr) %>:</td>
  32
+    <td><%= @synergy_configuration['corr'] %></td>
33 33
   </tr>
34 34
   <tr>
35  
-    <td><%= t('bik') %>:</td>
36  
-    <td><%= @preferences['bik'] %></td>
  35
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_bik) %>:</td>
  36
+    <td><%= @synergy_configuration['bik'] %></td>
37 37
   </tr>
38 38
   <tr>
39  
-    <td><%= t('nds') %>:</td>
40  
-    <td><%= @preferences['nds'] ? t('yes') : t('no') %></td>
  39
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_nds) %>:</td>
  40
+    <td><%= @synergy_configuration['nds'] ? t(:w_nds) : t(:wo_nds) %></td>
41 41
   </tr>
42 42
   <tr>
43  
-    <td><%= t('juridical_director') %>:</td>
44  
-    <td><%= @preferences['director'] %></td>
  43
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_director) %>:</td>
  44
+    <td><%= @synergy_configuration['director'] %></td>
45 45
   </tr>
46 46
   <tr>
47  
-    <td><%= t('juridical_accountant') %>:</td>
48  
-    <td><%= @preferences['accountant'] %></td>
  47
+    <td><%= SynergyConfiguration.human_attribute_name(:preferred_accountant) %>:</td>
  48
+    <td><%= @synergy_configuration['accountant'] %></td>
49 49
   </tr>
50 50
 </table>
112  app/views/admin/synergy_settings/_juridical_fields.html.erb
... ...
@@ -1,48 +1,72 @@
1 1
 <p>
2  
-	<%= label_tag 'preferences[juridical_enabled]', t('enable_juridical') %>:
3  
-	<%= check_box_tag('preferences[juridical_enabled]', '1', @preferences['juridical_enabled']) %>
  2
+  <%= f.label :preferred_juridical_enabled %>:
  3
+  <%= f.check_box :preferred_juridical_enabled %>
4 4
 </p>
  5
+
  6
+<%= f.field_container :preferred_recipient do %>
  7
+  <%= f.label :preferred_recipient %>:<br />
  8
+  <%= f.text_field :preferred_recipient, :size => 40 %>
  9
+  <%= error_message_on :synergy_configuration, :preferred_recipient %>
  10
+<% end %>
  11
+
  12
+<%= f.field_container :preferred_address do %>
  13
+  <%= f.label :preferred_address %>:<br />
  14
+  <%= f.text_field :preferred_address, :size => 40 %>
  15
+  <%= error_message_on :synergy_configuration, :preferred_address %>
  16
+<% end %>
  17
+
  18
+<%= f.field_container :preferred_inn do %>
  19
+  <%= f.label :preferred_inn %>:<br />
  20
+  <%= f.text_field :preferred_inn, :maxlength => 10 %>
  21
+  <%= error_message_on :synergy_configuration, :preferred_inn %>
  22
+<% end %>
  23
+
  24
+<%= f.field_container :preferred_kpp do %>
  25
+  <%= f.label :preferred_kpp %>:<br />
  26
+  <%= f.text_field :preferred_kpp, :maxlength => 9 %>
  27
+  <%= error_message_on :synergy_configuration, :preferred_kpp %>
  28
+<% end %>
  29
+
  30
+<%= f.field_container :preferred_bank do %>
  31
+  <%= f.label :preferred_bank %>:<br />
  32
+  <%= f.text_field :preferred_bank, :size => 40 %>
  33
+  <%= error_message_on :synergy_configuration, :preferred_bank %>
  34
+<% end %>
  35
+
  36
+<%= f.field_container :preferred_settlement_acc do %>
  37
+  <%= f.label :preferred_settlement_acc %>:<br />
  38
+  <%= f.text_field :preferred_settlement_acc, :maxlength => 20, :size => 25 %>
  39
+  <%= error_message_on :synergy_configuration, :preferred_settlement_acc %>
  40
+<% end %>
  41
+
  42
+<%= f.field_container :preferred_corr do %>
  43
+  <%= f.label :preferred_corr %>:<br />
  44
+  <%= f.text_field :preferred_corr, :maxlength => 20, :size => 25 %>
  45
+  <%= error_message_on :synergy_configuration, :preferred_corr %>
  46
+<% end %>
  47
+
  48
+<%= f.field_container :preferred_bik do %>
  49
+  <%= f.label :preferred_bik %>:<br />
  50
+  <%= f.text_field :preferred_bik, :maxlength => 9 %>
  51
+  <%= error_message_on :synergy_configuration, :preferred_bik %>
  52
+<% end %>
  53
+
5 54
 <p>
6  
-<%= label_tag 'preferences[recipient]', t('juridical_name') %>:<br />
7  
-<%= text_field_tag('preferences[recipient]', @preferences['recipient'])%>
  55
+  <%= f.label :preferred_nds %>:<br />
  56
+  <%= f.radio_button :preferred_nds, false %>
  57
+  <%= t(:wo_nds) %>&nbsp;
  58
+  <%= f.radio_button :preferred_nds, true %>
  59
+  <%= t(:w_nds) %>
8 60
 </p>
9  
-<p>
10  
-<%= label_tag 'preferences[address]', t('juridical_address') %>:<br />
11  
-<%= text_field_tag('preferences[address]', @preferences['address'])%>
12  
-</p>
13  
-<p>
14  
-<%= label_tag 'preferences[inn]', t('inn') %>:<br />
15  
-<%= text_field_tag('preferences[inn]', @preferences['inn'])%>
16  
-</p>
17  
-<p>
18  
-<%= label_tag 'preferences[kpp]', t('kpp') %>:<br />
19  
-<%= text_field_tag('preferences[kpp]', @preferences['kpp'])%>
20  
-</p>
21  
-<p>
22  
-<%= label_tag 'preferences[bank]', t('juridical_bank') %>:<br />
23  
-<%= text_field_tag('preferences[bank]', @preferences['bank'])%>
24  
-</p>
25  
-<p>
26  
-<%= label_tag 'preferences[settlement_acc]', t('settlement_acc') %>:<br />
27  
-<%= text_field_tag('preferences[settlement_acc]', @preferences['settlement_acc'])%>
28  
-</p>
29  
-<p>
30  
-<%= label_tag 'preferences[corr]', t('corr') %>:<br />
31  
-<%= text_field_tag('preferences[corr]', @preferences['corr'])%>
32  
-</p>
33  
-<p>
34  
-<%= label_tag 'preferences[bik]', t('bik') %>:<br />
35  
-<%= text_field_tag('preferences[bik]', @preferences['bik'])%>
36  
-</p>
37  
-<p>
38  
-<%= check_box_tag('preferences[nds]', true, @preferences['nds'])%>
39  
-<%= label_tag 'preferences[nds]', t('nds') %>
40  
-</p>
41  
-<p>
42  
-<%= label_tag 'preferences[director]', t('juridical_director') %>:<br />
43  
-<%= text_field_tag('preferences[director]', @preferences['director'])%>
44  
-</p>
45  
-<p>
46  
-<%= label_tag 'preferences[accountant]', t('juridical_accountant') %>:<br />
47  
-<%= text_field_tag('preferences[accountant]', @preferences['accountant'])%>
48  
-</p>
  61
+
  62
+<%= f.field_container :preferred_director do %>
  63
+  <%= f.label :preferred_director %>:<br />
  64
+  <%= f.text_field :preferred_director %>
  65
+  <%= error_message_on :synergy_configuration, :preferred_director %>
  66
+<% end %>
  67
+
  68
+<%= f.field_container :preferred_accountant do %>
  69
+  <%= f.label :preferred_accountant %>:<br />
  70
+  <%= f.text_field :preferred_accountant %>
  71
+  <%= error_message_on :synergy_configuration, :preferred_accountant %>
  72
+<% end %>
10  app/views/admin/synergy_settings/edit.html.erb
@@ -2,13 +2,15 @@
2 2
 
3 3
 <h1><%= t('synergy_settings') %></h1>
4 4
 
5  
-<%= form_tag(admin_synergy_settings_path, :method => :put) do %>
6  
-  <h2><%= t('juridical_settings') %></h2>
7  
-  <%= render 'juridical_fields' %>
  5
+<%= render "shared/error_messages", :target => @synergy_configuration %>
8 6
 
9  
-  <h2><%= t('contacts_settings') %></h2>
  7
+<%= form_for @synergy_configuration, :url => admin_synergy_settings_path, :method => :put do |f| %>
  8
+  <h2><%= t(:contacts_settings) %></h2>
10 9
   <%= render 'contacts_fields' %>
11 10
 
  11
+  <h2><%= t(:juridical_settings) %></h2>
  12
+  <%= render 'juridical_fields', :f => f %>
  13
+
12 14
   <p class="form-buttons">
13 15
     <%= button t('update') %>
14 16
     <%= t("or") %> <%= link_to t("cancel"), admin_synergy_settings_url %>
11  app/views/admin/synergy_settings/show.html.erb
... ...
@@ -1,11 +1,12 @@
1 1
 <%= render :partial => 'admin/shared/configuration_menu' %>
2 2
 
3  
-<h1><%= t('synergy_settings') %></h1>
  3
+<h1><%= t(:synergy_settings) %></h1>
4 4
 
5  
-<h2><%= t('juridical_settings') %></h2>
  5
+<h2><%= t(:contacts_settings) %></h2>
  6
+<%= render 'contacts' %>
  7
+
  8
+<h2><%= t(:juridical_settings) %></h2>
6 9
 <%= render 'juridical' %>
7 10
 
8  
-<h2><%= t('contacts_settings') %></h2>
9  
-<%= render 'contacts' %>
10 11
 
11  
-<p><%= link_to_with_icon 'edit', t('edit'), edit_admin_synergy_settings_path %></p>
  12
+<p><%= link_to_with_icon 'edit', t(:edit), edit_admin_synergy_settings_path %></p>
16  app/views/orders/juridical_invoice.html.erb
... ...
@@ -1,6 +1,6 @@
1 1
 <html>
2 2
 <head>
3  
-<title>СЧЕТ</title>
  3
+<title>СЧЕТ № <%= @order.number %> от <%= @order.updated_at.strftime("%d.%m.%Y") %></title>
4 4
 <style type="text/css">
5 5
 p {
6 6
 font-family: Times New Roman; 
@@ -20,10 +20,10 @@ color: #FF0000;
20 20
 <table border="0" cellpadding="0" cellspacing="10" width="640">
21 21
       <tr>
22 22
         <td valign="top"><strong>Поставщик:</strong></td>
23  
-        <td><strong><%= @preferences['recipient'] %></strong><br />
24  
-        Банковские реквизиты:<br />Расчетный счет: <%= @preferences['settlement_acc'] %><br /><%= @preferences['bank'] %>,<br />БИК: <%= @preferences['bik'] %><br />к/с: <%= @preferences['corr'] %><br />
25  
-        ИНН:&nbsp;<%= @preferences['inn'] %><br />
26  
-		КПП:&nbsp;<%= @preferences['kpp'] %></td>
  23
+        <td><strong><%= @synergy_configuration['recipient'] %></strong><br />
  24
+        Банковские реквизиты:<br />Расчетный счет: <%= @synergy_configuration['settlement_acc'] %><br /><%= @synergy_configuration['bank'] %>,<br />БИК: <%= @synergy_configuration['bik'] %><br />к/с: <%= @synergy_configuration['corr'] %><br />
  25
+        ИНН:&nbsp;<%= @synergy_configuration['inn'] %><br />
  26
+		КПП:&nbsp;<%= @synergy_configuration['kpp'] %></td>
27 27
       </tr>
28 28
       <tr>
29 29
         <td valign="top"><strong>Плательщик:</strong></td>
@@ -64,14 +64,14 @@ color: #FF0000;
64 64
             <td colspan="3" width="80%" align="right">ИТОГО:&nbsp;</td>
65 65
             <td align="right" style="white-space:nowrap;"><%= number_to_currency @order.total %></td>
66 66
           </tr>
67  
-          <% if @preferences['nds'] %>
  67
+          <% if @synergy_configuration['nds'] %>
68 68
             <tr>
69 69
               <td colspan="3" width="80%" align="right">В том числе НДС 18%</td>
70 70
               <td align="right" style="white-space:nowrap;"><%= "%.2f" % ((@order.total / 118.0) * 18) %> руб.</td>
71 71
             </tr>
72 72
           <% else %>
73 73
             <tr>
74  
-              <td colspan="2" width="80%" align="right"><span style="color:red; font-weight:bold;">Без налога (НДС)</td>
  74
+              <td colspan="3" width="80%" align="right">Без налога (НДС)</td>
75 75
               <td align="right" style="white-space:nowrap;">&ndash;</td>
76 76
             </tr>
77 77
           <% end %>
@@ -90,7 +90,7 @@ color: #FF0000;
90 90
       <tr>
91 91
         <td valign="top" width="50%"><br /><br /><br />Руководитель<br /><br /><br /><br /><br />Главный&nbsp;бухгалтер</td>
92 92
         <td valign="top"><img src="/images/invoice_stamp.jpg" width="310" height="210" alt="" /></td>
93  
-        <td valign="top" width="50%" style="white-space:nowrap"><br /><br /><br /><%= @preferences['director'] %><br /><br /><br /><br /><br /><%= @preferences['accountant'] %></td>
  93
+        <td valign="top" width="50%" style="white-space:nowrap"><br /><br /><br /><%= @synergy_configuration['director'] %><br /><br /><br /><br /><br /><%= @synergy_configuration['accountant'] %></td>
94 94
       </tr>
95 95
 </table>
96 96
 </div>
2  app/views/orders/show.html.erb
@@ -15,6 +15,6 @@
15 15
     <%= link_to t('print_sberbank_invoice'), orders_sberbank_invoice_path %>
16 16
   <% end %>
17 17
   <% if @order.payment_method.is_a?(PaymentMethod::JuridicalInvoice) %>
18  
-    <%= link_to t('print_juridical_invoice'), orders_juridical_invoice_path %>
  18
+    <%= link_to t('print_juridical_invoice'), orders_juridical_invoice_path, :target => "_blank" %>
19 19
   <% end %>
20 20
 </div>
45  app/views/shared/_juridical_user_fields.html.erb
... ...
@@ -1,45 +0,0 @@
1  
-<% if (["edit", "update"].include?(controller.action_name)) && Spree::Synergy::Config[:juridical_enabled] %>
2  
-  <p>
3  
-    <%= check_box_tag "user[juridical]", true, @user.juridical?, :onclick => "$('#user_juridical_data').toggle();" %>
4  
-    <%= label_tag "user_juridical", User.human_attribute_name('juridical') %>
5  
-  </p>
6  
-
7  
-  <div id="user_juridical_data" style="display: <%= @user.juridical? ? "block" : "none" %>;">
8  
-    <p>
9  
-      <%= label_tag "user_recipient", User.human_attribute_name('recipient') %><br />
10  
-      <%= text_field_tag "user[recipient]", @user.recipient %>
11  
-    </p>
12  
-    <p>
13  
-      <%= label_tag "user_juridical_address", User.human_attribute_name('juridical_address') %><br />
14  
-      <%= text_field_tag "user[juridical_address]", @user.juridical_address %>
15  
-    </p>
16  
-    <p>
17  
-      <%= label_tag "user_inn", User.human_attribute_name('inn') %><br />
18  
-      <%= text_field_tag "user[inn]", @user.inn %>
19  
-    </p>
20  
-    <p>
21  
-      <%= label_tag "user_kpp", User.human_attribute_name('kpp') %><br />
22  
-      <%= text_field_tag "user[kpp]", @user.kpp %>
23  
-    </p>
24  
-    <p>
25  
-      <%= label_tag "user_recipient_bank", User.human_attribute_name('recipient_bank') %><br />
26  
-      <%= text_field_tag "user[recipient_bank]", @user.recipient_bank %>
27  
-    </p>
28  
-    <p>
29  
-      <%= label_tag "user_settlement_acc", User.human_attribute_name('settlement_acc') %><br />
30  
-      <%= text_field_tag "user[settlement_acc]", @user.settlement_acc %>
31  
-    </p>
32  
-    <p>
33  
-      <%= label_tag "user_corr", User.human_attribute_name('corr') %><br />
34  
-      <%= text_field_tag "user[corr]", @user.corr %>
35  
-    </p>
36  
-    <p>
37  
-      <%= label_tag "user_bik", User.human_attribute_name('bik') %><br />
38  
-      <%= text_field_tag "user[bik]", @user.bik %>
39  
-    </p>
40  
-    <p>
41  
-      <%= check_box_tag "user[nds]", true, @user.nds %>
42  
-      <%= label_tag "user_nds", User.human_attribute_name('nds') %><br />
43  
-    </p>
44  
-  </div>
45  
-<% end %>
10  app/views/users/_status.html.erb
... ...
@@ -0,0 +1,10 @@
  1
+<% if Spree::Synergy::Config[:juridical_enabled] %>
  2
+  <table>
  3
+    <tr>
  4
+      <td><%= t(:account_status) %>:</td>
  5
+      <td><%= current_user.juridical? ? t(:juridical) : t(:physical) %></td>
  6
+    </tr>
  7
+  </table>
  8
+
  9
+  <p><%= link_to t(:change), edit_status_account_path %></p>
  10
+<% end %>
46  app/views/users/_status_form.html.erb
... ...
@@ -0,0 +1,46 @@
  1
+<p>
  2
+  <%= check_box_tag "user[juridical]", true, @user.juridical?, :onclick => "$('#user_juridical_data').toggle();" %>
  3
+  <%= label_tag "user_juridical", User.human_attribute_name('juridical') %>
  4
+</p>
  5
+
  6
+<div id="user_juridical_data" style="display: <%= @user.juridical? ? "block" : "none" %>;">
  7
+  <p>
  8
+    <%= label_tag "user_recipient", User.human_attribute_name('recipient') %><br />
  9
+    <%= text_field_tag "user[recipient]", @user.recipient %>
  10
+  </p>
  11
+  <p>
  12
+    <%= label_tag "user_juridical_address", User.human_attribute_name('juridical_address') %><br />
  13
+    <%= text_field_tag "user[juridical_address]", @user.juridical_address %>
  14
+  </p>
  15
+  <p>
  16
+    <%= label_tag "user_inn", User.human_attribute_name('inn') %><br />
  17
+    <%= text_field_tag "user[inn]", @user.inn, :maxlength => 10 %>
  18
+  </p>
  19
+  <p>
  20
+    <%= label_tag "user_kpp", User.human_attribute_name('kpp') %><br />
  21
+    <%= text_field_tag "user[kpp]", @user.kpp, :maxlength => 9 %>
  22
+  </p>
  23
+  <p>
  24
+    <%= label_tag "user_recipient_bank", User.human_attribute_name('recipient_bank') %><br />
  25
+    <%= text_field_tag "user[recipient_bank]", @user.recipient_bank %>
  26
+  </p>
  27
+  <p>
  28
+    <%= label_tag "user_settlement_acc", User.human_attribute_name('settlement_acc') %><br />
  29
+    <%= text_field_tag "user[settlement_acc]", @user.settlement_acc, :maxlength => 20 %>
  30
+  </p>
  31
+  <p>
  32
+    <%= label_tag "user_corr", User.human_attribute_name('corr') %><br />
  33
+    <%= text_field_tag "user[corr]", @user.corr, :maxlength => 20 %>
  34
+  </p>
  35
+  <p>
  36
+    <%= label_tag "user_bik", User.human_attribute_name('bik') %><br />
  37
+    <%= text_field_tag "user[bik]", @user.bik, :maxlength => 9 %>
  38
+  </p>
  39
+  <p>
  40
+    <%= label_tag "user_nds", User.human_attribute_name('nds') %>:<br />
  41
+    <%= radio_button_tag "user[nds]", false, !@user.nds %>
  42
+    <%= label_tag 'user[nds]', User.human_attribute_name('wo_nds') %>&nbsp;
  43
+    <%= radio_button_tag "user[nds]", true, @user.nds %>
  44
+    <%= label_tag 'user[nds]', User.human_attribute_name('w_nds') %>
  45
+  </p>
  46
+</div>
11  app/views/users/edit_status.html.erb
... ...
@@ -0,0 +1,11 @@
  1
+<%= render "shared/error_messages", :target => @user %>
  2
+
  3
+<h1><%= t(:edit_account_status) %></h1>
  4
+
  5
+<% if Spree::Synergy::Config[:juridical_enabled] %>
  6
+  <%= form_for(@user, :url => update_status_account_path, :html => { :method => :put }) do |f| %>
  7
+    <%= render 'status_form', :f => f %>
  8
+  
  9
+    <p><%= submit_tag t(:update) %></p>
  10
+  <% end %>
  11
+<% end %>
36  config/locales/ru.yml
@@ -33,7 +33,22 @@ ru:
33 33
         settlement_acc: "Расч. сч."
34 34
         corr: "Корр. сч."
35 35
         bik: "БИК"
36  
-        nds: "Настройки НДС (с НДС/без НДС)"
  36
+        nds: "Настройки НДС"
  37
+        w_nds: "НДС 18%"
  38
+        wo_nds: "без НДС"
  39
+      synergy_configuration:
  40
+        preferred_juridical_enabled: "Принимать заказы от юридических лиц"
  41
+        preferred_recipient: "Наименование организации"
  42
+        preferred_address: "Адрес организации"
  43
+        preferred_inn: "ИНН"
  44
+        preferred_kpp: "КПП"
  45
+        preferred_bank: "Банк получатель"
  46
+        preferred_settlement_acc: "Расч. сч."
  47
+        preferred_corr: "Корр.сч."
  48
+        preferred_bik: "БИК"
  49
+        preferred_nds: "Настройки НДС"
  50
+        preferred_director: "ФИО руководителя"
  51
+        preferred_accountant: "ФИО главного бухгалтера"
37 52
     models: 
38 53
       address: 
39 54
         one: "Адрес"
@@ -146,18 +161,19 @@ ru:
146 161
 
147 162
   juridical_settings: "Настройки юридического лица"
148 163
   juridical_description: "Автоматизация работы с юридическими лицами"
149  
-  enable_juridical: "Принимать заказы от юридических лиц"
150  
-  juridical_director: "ФИО руководителя"
151  
-  juridical_accountant: "ФИО главбуха"
152  
-  juridical_name: "Наименование организации"
153  
-  juridical_address: "Адрес организации"
154  
-  juridical_bank: "Банк получатель"
155  
-  nds: "Настройки НДС (с НДС/без НДС)"
  164
+
  165
+  w_nds: "НДС 18%"
  166
+  wo_nds: "без НДС"
156 167
   juridical_invoice: "Счет для юридических лиц"
157  
-  print_juridical_invoice: "Распечатать квитанцию на оплату"
  168
+  print_juridical_invoice: "Распечатать счет на оплату"
158 169
   juridical_info: "Юридическая информация"
159 170
   juridical_disabled: "На текущий момент работа с юридическими лицами отключена, попробуйте сделать заказ позже."
160  
-  
  171
+
161 172
   contacts_settings: "Контактная информация"
162 173
   store_email: "E-mail магазина"
163 174
   store_phone: "Телефон магазина"
  175
+
  176
+  account_status: "Статус аккаунта"
  177
+  edit_account_status: "Редактирование статуса аккаунта"
  178
+  juridical: "юридическое лицо"
  179
+  physical: "физическое лицо"
9  config/routes.rb
@@ -7,6 +7,13 @@
7 7
   namespace :admin do
8 8
     resource :synergy_settings, :only => [:show, :edit, :update]
9 9
   end
10  
-  match "/orders/:id/juridical_invoice" => "orders#juridical_invoice", :as => :orders_juridical_invoice
  10
+  
11 11
   match "/admin/orders/:id/juridical_info" => "admin/orders#juridical_info", :as => :orders_juridical_info
  12
+  match "/orders/:id/juridical_invoice" => "orders#juridical_invoice", :as => :orders_juridical_invoice
  13
+  
  14
+  resource :account, :controller => "users" do
  15
+    get :edit_status
  16
+    put :update_status
  17
+  end
  18
+  
12 19
 end
2  db/migrate/20110803100246_add_fields_to_users.rb
@@ -24,4 +24,4 @@ def self.down
24 24
     remove_column :users, :juridical_address
25 25
     remove_column :users, :recipient
26 26
   end
27  
-end
  27
+end
11  db/migrate/20110818091541_change_user_juridical_fields.rb
... ...
@@ -0,0 +1,11 @@
  1
+class ChangeUserJuridicalFields < ActiveRecord::Migration
  2
+  def self.up
  3
+    change_column :users, :inn, :string
  4
+    change_column :users, :kpp, :string
  5
+  end
  6
+
  7
+  def self.down
  8
+    change_column :users, :kpp, :integer
  9
+    change_column :users, :inn, :integer
  10
+  end
  11
+end
2  lib/spree/synergy/config.rb
@@ -3,7 +3,7 @@ module Synergy
3 3
     class Config
4 4
       include Singleton
5 5
       include PreferenceAccess
6  
-
  6
+      
7 7
       class << self
8 8
         def instance
9 9
           return nil unless ActiveRecord::Base.connection.tables.include?('configurations')
5  lib/synergy_configuration.rb
... ...
@@ -1,4 +1,9 @@
1 1
 class SynergyConfiguration < Configuration
  2
+  validates :preferred_recipient, :preferred_address, :preferred_inn, :preferred_kpp, :preferred_bank, :preferred_settlement_acc, :preferred_corr, :preferred_bik, :preferred_nds, :preferred_director, :preferred_accountant, :presence => true, :on => :update
  3
+  validates :preferred_inn, :numericality => true, :length => { :is => 10 }, :on => :update
  4
+  validates :preferred_kpp, :preferred_bik, :numericality => true, :length => { :is => 9 }, :on => :update
  5
+  validates :preferred_settlement_acc, :preferred_corr, :numericality => true, :length => { :is => 20 }, :on => :update
  6
+  
2 7
   preference :juridical_enabled, :boolean, :default => false
3 8
   preference :recipient, :string
4 9
   preference :address, :string
4  lib/synergy_hooks.rb
@@ -12,8 +12,6 @@ class SecointHooks < Spree::ThemeSupport::HookListener
12 12
     )
13 13
   end
14 14
   
15  
-  insert_after :signup_below_password_fields, 'shared/juridical_user_fields'
16  
-
17 15
   insert_after :admin_configurations_menu do
18 16
     %(<tr>
19 17
       <td><%= link_to t("synergy_settings"), admin_synergy_settings_path %></td>
@@ -26,4 +24,6 @@ class SecointHooks < Spree::ThemeSupport::HookListener
26 24
   end
27 25
   
28 26
   insert_after :admin_order_tabs, 'admin/orders/juridical_tabs'
  27
+  
  28
+  insert_after :account_summary, 'users/status'
29 29
 end

0 notes on commit 8db2b78

Please sign in to comment.
Something went wrong with that request. Please try again.