Skip to content
Browse files

FIX: Fixed epic bug which caused invoice number incrementation after …

…every modify to the invoice (including adding payment)

Signed-off-by: Tommaso Visconti <tommaso.visconti@gmail.com>
  • Loading branch information...
1 parent c7ccd5c commit c73199ce9e5624dce7e697f4b824a4cb77abe4d6 @tommyblue tommyblue committed Apr 2, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 app/models/invoice.rb
View
4 app/models/invoice.rb
@@ -8,11 +8,11 @@ class Invoice < ActiveRecord::Base
validates_presence_of :date, :customer, :consolidated_tax
- before_save do
+ before_create do
self.number = self.customer.user.options.where(:name => 'NEXT_INVOICE_NUMBER').first.value.to_i
end
- after_save do
+ after_create do
opt = self.customer.user.options.where(:name => 'NEXT_INVOICE_NUMBER').first
opt.value = opt.value.to_i + 1
opt.save!

0 comments on commit c73199c

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