Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added validate for order. fixed locales and update version

  • Loading branch information...
commit 483cfdcfda218aebd37db0a5ece8a36343368e0c 1 parent 98caaa7
@damianogiacomello damianogiacomello authored
View
2  app/models/spree/address_decorator.rb
@@ -2,7 +2,7 @@
attr_accessible :tax_id_number, :vat_number
validates_format_of :tax_id_number, :with => /^[A-Z]{6}[A-Z0-9]{2}[A-Z][A-Z0-9]{2}[A-Z][A-Z0-9]{3}[A-Z]$/i, :if => :fiscal_code_present?
- validates :vat_number, :length => {:maximum => 11}, :if => Proc.new {|a| !a.vat_number.blank? }
+ validates :vat_number, :length => {:minimum => 10}, :if => Proc.new {|a| !a.vat_number.blank? }
validates :tax_id_number, :length => {:in => 11..16}, :if => :fiscal_code_present?
def empty?
View
9 app/models/spree/order_decorator.rb
@@ -0,0 +1,9 @@
+Spree::Order.class_eval do
+ validate :has_valid_bill_address
+
+ def has_valid_bill_address
+ return unless :address == state_name.to_sym
+ return unless bill_address && bill_address.valid?
+ errors.add(:base, :no_valid_bill_address) if !bill_address.empty? && (bill_address.vat_number.blank? && bill_address.tax_id_number.blank?)
+ end
+end
View
8 app/views/spree/shared/_user_form.html.erb
@@ -102,10 +102,6 @@
<%= bill_form.text_field :alternative_phone %>
</p>
<% end %>
- <p class="field" id="fiscal-code">
- <%= bill_form.label :fiscal_code, t(:fiscal_code) %><br />
- <%= bill_form.text_field :fiscal_code%>
- </p>
</div>
<% end %>
</fieldset>
@@ -188,10 +184,6 @@
<%= ship_form.text_field :alternative_phone %>
</p>
<% end %>
- <p class="field" id="fiscal-code">
- <%= ship_form.label :fiscal_code, t(:fiscal_code) %><br />
- <%= ship_form.text_field :fiscal_code %>
- </p>
</div>
<% end %>
</fieldset>
View
66 config/locales/it.yml
@@ -6,33 +6,39 @@ it:
tax_id_number: "Codice Fiscale"
vat_number: "P. IVA"
activerecord:
- attributes:
- spree/address:
- tax_id_number: "Codice Fiscale"
- vat_number: "P. IVA"
- spree/order/bill_address:
- tax_id_number: "Codice Fiscale"
- vat_number: "P. IVA"
- spree/order/ship_address:
- tax_id_number: "Codice Fiscale"
- vat_number: "P. IVA"
- spree/user/bill_address:
- address1: "Indirizzo"
- city: "Citta`"
- firstname: "Nome"
- lastname: "Cognome"
- phone: "Telefono"
- state: "Stato/Provincia"
- zipcode: "CAP"
- tax_id_number: "Codice Fiscale"
- vat_number: "P. IVA"
- spree/user/ship_address:
- address1: "Indirizzo"
- city: "Citta`"
- firstname: "Nome"
- lastname: "Cognome"
- phone: "Telefono"
- state: "Stato/Provincia"
- zipcode: "CAP"
- tax_id_number: "Codice Fiscale"
- vat_number: "P. IVA"
+ errors:
+ models:
+ spree/order:
+ attributes:
+ base:
+ no_valid_bill_address: "Indirizzo di Fatturazione errato. P.IVA o Cod. Fiscale errati."
+ attributes:
+ spree/address:
+ tax_id_number: "Codice Fiscale"
+ vat_number: "P. IVA"
+ spree/order/bill_address:
+ tax_id_number: "Codice Fiscale"
+ vat_number: "P. IVA"
+ spree/order/ship_address:
+ tax_id_number: "Codice Fiscale"
+ vat_number: "P. IVA"
+ spree/user/bill_address:
+ address1: "Indirizzo"
+ city: "Citta`"
+ firstname: "Nome"
+ lastname: "Cognome"
+ phone: "Telefono"
+ state: "Stato/Provincia"
+ zipcode: "CAP"
+ tax_id_number: "Codice Fiscale"
+ vat_number: "P. IVA"
+ spree/user/ship_address:
+ address1: "Indirizzo"
+ city: "Citta`"
+ firstname: "Nome"
+ lastname: "Cognome"
+ phone: "Telefono"
+ state: "Stato/Provincia"
+ zipcode: "CAP"
+ tax_id_number: "Codice Fiscale"
+ vat_number: "P. IVA"
View
2  spree_address_book.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_address_book'
- s.version = '1.1.0'
+ s.version = '1.1.1'
s.summary = 'Manage address for User'
s.required_ruby_version = '>= 1.8.7'
Please sign in to comment.
Something went wrong with that request. Please try again.