mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
fix chain_record methods
This commit is contained in:
parent
ae7a939cba
commit
811d7288e7
@ -218,6 +218,7 @@ class Invoice < ActiveRecord::Base
|
|||||||
|
|
||||||
def chain_record
|
def chain_record
|
||||||
self.footprint = compute_footprint
|
self.footprint = compute_footprint
|
||||||
|
save!
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_footprint
|
def check_footprint
|
||||||
|
@ -8,6 +8,7 @@ class InvoiceItem < ActiveRecord::Base
|
|||||||
|
|
||||||
def chain_record
|
def chain_record
|
||||||
self.footprint = compute_footprint
|
self.footprint = compute_footprint
|
||||||
|
save!
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_footprint
|
def check_footprint
|
||||||
|
@ -6,20 +6,14 @@ namespace :fablab do
|
|||||||
task chain_invoices_records: :environment do
|
task chain_invoices_records: :environment do
|
||||||
raise "Footprints were already generated, won't regenerate" if Invoice.where.not(footprint: nil).count.positive?
|
raise "Footprints were already generated, won't regenerate" if Invoice.where.not(footprint: nil).count.positive?
|
||||||
|
|
||||||
Invoice.order(:created_at).all.each do |i|
|
Invoice.order(:created_at).all.each(&:chain_record)
|
||||||
i.chain_record
|
|
||||||
i.save!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'assign all footprints to existing InvoiceItem records'
|
desc 'assign all footprints to existing InvoiceItem records'
|
||||||
task chain_invoices_items_records: :environment do
|
task chain_invoices_items_records: :environment do
|
||||||
raise "Footprints were already generated, won't regenerate" if InvoiceItem.where.not(footprint: nil).count.positive?
|
raise "Footprints were already generated, won't regenerate" if InvoiceItem.where.not(footprint: nil).count.positive?
|
||||||
|
|
||||||
InvoiceItem.order(:created_at).all.each do |i|
|
InvoiceItem.order(:created_at).all.each(&:chain_record)
|
||||||
i.chain_record
|
|
||||||
i.save!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'assign environment value to all invoices'
|
desc 'assign environment value to all invoices'
|
||||||
|
Loading…
Reference in New Issue
Block a user