From 074d59031ce9505ccc3ae0bc7133c83e3cfe2eb2 Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 4 Jan 2016 12:33:46 +0200 Subject: [PATCH] 110946256-logic_fix --- app/models/invoice.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/invoice.rb b/app/models/invoice.rb index aaddbd77b..2f54e2287 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -17,8 +17,7 @@ class Invoice < ActiveRecord::Base validates :invoice_type, :due_date, :currency, :seller_name, :seller_iban, :buyer_name, :invoice_items, :vat_prc, presence: true - before_create :set_invoice_number - before_create :check_vat + before_create :set_invoice_number, :check_vat def set_invoice_number 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 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 end end