mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-17 11:54:22 +01:00
(bug) fix_invoice_item if items.object=error
This commit is contained in:
parent
f6eeed76ef
commit
953cf46ec1
@ -1,5 +1,8 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Fix a bug: unable to run task fix_invoice_item when some invoice items are associated with errors
|
||||
- [TODO DEPLOY] `rails fablab:fix:invoice_items_in_error` THEN `rails fablab:fix_invoice_items` THEN `rails db:migrate`
|
||||
|
||||
## v5.6.5 2023 January 9
|
||||
|
||||
- Moved the buttons to create a new machine or availability to the admin section
|
||||
@ -24,7 +27,7 @@
|
||||
- Fix a bug: cryptic error message when failed to create a manager
|
||||
- Fix a bug: unable to restore accounting periods closed by a deleted admin
|
||||
- Fix a bug: unable to build an accounting archive if the operator was deleted
|
||||
- Fix a bug: unable to udpate an event category
|
||||
- Fix a bug: unable to update an event category
|
||||
|
||||
## v5.6.1 2023 January 6
|
||||
|
||||
|
@ -177,7 +177,7 @@ namespace :fablab do
|
||||
|
||||
desc '[release 4.4.3] fix duration of recurring availabilities'
|
||||
task availabilities_duration: :environment do
|
||||
Availability.select(:occurrence_id).where(is_recurrent: true).group(:occurrence_id).each do |a|
|
||||
Availability.select('occurrence_id').where(is_recurrent: true).group('occurrence_id').each do |a|
|
||||
occurrences = Availability.where(occurrence_id: a.occurrence_id)
|
||||
next unless occurrences.map(&:slot_duration).uniq.size > 1
|
||||
|
||||
@ -231,7 +231,7 @@ namespace :fablab do
|
||||
statistic_profile_ids = StatisticProfilePrepaidPack.all.map(&:statistic_profile_id).uniq
|
||||
# find the reservations that use prepaid pack by machine_ids, members and preriod
|
||||
reservations = Reservation.where(reservable_type: 'Machine', reservable_id: machine_ids, statistic_profile_id: statistic_profile_ids,
|
||||
created_at: start_date..end_date).order(statistic_profile_id: 'ASC', created_at: 'ASC')
|
||||
created_at: start_date..end_date).order(statistic_profile_id: :asc, created_at: :asc)
|
||||
infos = []
|
||||
reservations.each do |reservation|
|
||||
# find pack by pack's created_at before reservation's create_at and pack's expries_at before start_date
|
||||
@ -243,7 +243,7 @@ namespace :fablab do
|
||||
.where(statistic_profile_id: reservation.statistic_profile_id)
|
||||
.where('statistic_profile_prepaid_packs.created_at <= ?', reservation.created_at)
|
||||
.where('expires_at is NULL or expires_at > ?', start_date)
|
||||
.order(created_at: 'ASC')
|
||||
.order(created_at: :asc)
|
||||
|
||||
# passe reservation if cannot find any pack
|
||||
next if packs.empty?
|
||||
@ -279,5 +279,15 @@ namespace :fablab do
|
||||
puts i
|
||||
end
|
||||
end
|
||||
|
||||
desc '[release 5.6.6] fix invoice items in error'
|
||||
task invoice_items_in_error: :environment do
|
||||
next if InvoiceItem.where(object_type: 'Error').count.zero?
|
||||
|
||||
InvoiceItem.where(object_type: 'Error').update_all(object_id: 0) # rubocop:disable Rails/SkipsModelValidations
|
||||
|
||||
Fablab::Application.load_tasks if Rake::Task.tasks.empty?
|
||||
Rake::Task['fablab:chain:invoices_items'].invoke
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -36,13 +36,13 @@ namespace :fablab do
|
||||
puts "Operator: #{invoice.operator_profile&.user&.profile&.full_name} (#{invoice.operator_profile&.user&.email})"
|
||||
puts "Date: #{invoice.created_at}"
|
||||
puts '=============================================='
|
||||
puts "Concerned item: #{ii.id}"
|
||||
puts "Concerned item: #{ii.id} (#{ii.object_type} #{ii.object_id})"
|
||||
puts "Item subject: #{ii.description}."
|
||||
other_items.find_each do |oii|
|
||||
puts '=============================================='
|
||||
puts "Other item: #{oii.description} (#{oii.id})"
|
||||
puts "Other item object: #{oii.object_type} #{oii.object_id}"
|
||||
puts "Other item slots: #{oii.object.try(:slots)&.map { |s| "#{s.start_at} - #{s.end_at}" }}"
|
||||
puts "Other item slots: #{oii.object.try(:slots)&.map { |s| "#{s.start_at} - #{s.end_at}" }}" if oii.object_type == 'Reservation'
|
||||
print "\e[1;34m[ ? ]\e[0m Associate the item with #{oii.object_type} #{oii.object_id} ? (y/N) > "
|
||||
confirm = $stdin.gets.chomp
|
||||
if confirm == 'y'
|
||||
|
Loading…
x
Reference in New Issue
Block a user