mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
(bug) Accouning Line in duplicate
This commit is contained in:
parent
11a079b3e2
commit
e50c90b30d
@ -1,6 +1,8 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Fix a bug: unable to refresh machine/space/training calender after pay an reservation
|
||||
- Fix a bug: Accouning Line in duplicate
|
||||
- [TODO DEPLOY] `rails fablab:setup:build_accounting_lines`
|
||||
|
||||
## v6.0.7 2023 June 20
|
||||
|
||||
|
@ -269,6 +269,8 @@ GEM
|
||||
net-smtp (0.3.3)
|
||||
net-protocol
|
||||
nio4r (2.5.8)
|
||||
nokogiri (1.14.3-x86_64-darwin)
|
||||
racc (~> 1.4)
|
||||
nokogiri (1.14.3-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
oauth2 (1.4.4)
|
||||
@ -524,6 +526,7 @@ GEM
|
||||
zeitwerk (2.6.7)
|
||||
|
||||
PLATFORMS
|
||||
x86_64-darwin-20
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
|
@ -22,11 +22,19 @@ class Accounting::AccountingService
|
||||
lines = []
|
||||
processed = []
|
||||
invoices.find_each do |i|
|
||||
Rails.logger.debug { "processing invoice #{i.id}..." } unless Rails.env.test?
|
||||
lines.concat(generate_lines(i))
|
||||
processed.push(i.id)
|
||||
Rails.logger.debug { "[AccountLine] processing invoice #{i.id}..." } unless Rails.env.test?
|
||||
if i.main_item.nil?
|
||||
Rails.logger.error { "[AccountLine] invoice #{i.id} main_item is nil" } unless Rails.env.test?
|
||||
else
|
||||
lines.concat(generate_lines(i))
|
||||
processed.push(i.id)
|
||||
end
|
||||
end
|
||||
ActiveRecord::Base.transaction do
|
||||
ids = invoices.map(&:id)
|
||||
AccountingLine.where(invoice_id: ids).delete_all
|
||||
AccountingLine.create!(lines)
|
||||
end
|
||||
AccountingLine.create!(lines)
|
||||
processed
|
||||
end
|
||||
|
||||
|
@ -27,8 +27,6 @@ class AccountingWorker
|
||||
end
|
||||
|
||||
def invoices(invoices_ids)
|
||||
# clean
|
||||
AccountingLine.where(invoice_id: invoices_ids).delete_all
|
||||
# build
|
||||
service = Accounting::AccountingService.new
|
||||
invoices = Invoice.where(id: invoices_ids)
|
||||
@ -37,8 +35,6 @@ class AccountingWorker
|
||||
end
|
||||
|
||||
def all
|
||||
# clean
|
||||
AccountingLine.delete_all
|
||||
# build
|
||||
service = Accounting::AccountingService.new
|
||||
ids = service.build_from_invoices(Invoice.all)
|
||||
|
Loading…
x
Reference in New Issue
Block a user