Merge pull request #53 from internetee/110946256-vat_missing

110946256-logic_fix
This commit is contained in:
teadur 2016-01-04 12:52:58 +02:00
commit d3eae94593

View file

@ -17,8 +17,7 @@ class Invoice < ActiveRecord::Base
validates :invoice_type, :due_date, :currency, :seller_name, validates :invoice_type, :due_date, :currency, :seller_name,
:seller_iban, :buyer_name, :invoice_items, :vat_prc, presence: true :seller_iban, :buyer_name, :invoice_items, :vat_prc, presence: true
before_create :set_invoice_number before_create :set_invoice_number, :check_vat
before_create :check_vat
def set_invoice_number def set_invoice_number
last_no = Invoice.order(number: :desc).where('number IS NOT NULL').limit(1).pluck(:number).first last_no = Invoice.order(number: :desc).where('number IS NOT NULL').limit(1).pluck(:number).first
@ -37,7 +36,7 @@ class Invoice < ActiveRecord::Base
end end
def check_vat def check_vat
if buyer.country_code = 'EE' && buyer.vat_no.present? if buyer.country_code != 'EE' && buyer.vat_no.present?
self.vat_prc = 0 self.vat_prc = 0
end end
end end