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