mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(feat) clean accounting lines async before rebuilding
This commit is contained in:
parent
0ca7c8fb11
commit
b7838db648
@ -26,7 +26,6 @@ class AdvancedAccounting < ApplicationRecord
|
||||
raise TypeError "Unknown accountable_type #{accountable_type}"
|
||||
end
|
||||
ids = invoices.map(&:id)
|
||||
AccountingLine.where(invoice_id: ids).destroy_all
|
||||
AccountingWorker.perform_async(:invoices, ids)
|
||||
end
|
||||
end
|
||||
|
@ -77,7 +77,6 @@ class SettingService
|
||||
def update_accounting_line(settings)
|
||||
return unless settings.any? { |s| s.name.match(/^accounting_/) || s.name == 'advanced_accounting' }
|
||||
|
||||
AccountingLine.destroy_all
|
||||
AccountingWorker.perform_async(:all)
|
||||
end
|
||||
end
|
||||
|
@ -14,12 +14,18 @@ class AccountingWorker
|
||||
end
|
||||
|
||||
def invoices(invoices_ids)
|
||||
# clean
|
||||
AccountingLine.where(invoice_id: ids).destroy_all
|
||||
# build
|
||||
service = Accounting::AccountingService.new
|
||||
invoices = Invoice.where(id: invoices_ids)
|
||||
service.build_from_invoices(invoices)
|
||||
end
|
||||
|
||||
def all
|
||||
# clean
|
||||
AccountingLine.destroy_all
|
||||
# build
|
||||
service = Accounting::AccountingService.new
|
||||
service.build_from_invoices(Invoice.all)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user