mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(bug) unable to generate statistic
This commit is contained in:
parent
5e621b0615
commit
a5c73b64c7
@ -4,6 +4,8 @@
|
||||
|
||||
- Fix a bug: for project categories, if there is no category : do not show categories panel in show view, do not show categories input field in edit view
|
||||
- Fix a bug: unable to update status to paid for latest payment schedule item
|
||||
- Fix a bug: unable to generate statistic
|
||||
- [TODO DEPLOY] `rails fablab:maintenance:regenerate_statistics[2014,1]`
|
||||
|
||||
## v6.0.13 2023 August 28
|
||||
|
||||
|
@ -50,6 +50,8 @@ class Statistics::FetcherService
|
||||
.eager_load(:slots, :slots_reservations, :invoice_items, :reservation_context, statistic_profile: [:group])
|
||||
.find_each do |r|
|
||||
next unless r.reservable
|
||||
next unless r.original_invoice
|
||||
next if r.slots.empty?
|
||||
|
||||
profile = r.statistic_profile
|
||||
result = { date: r.created_at.to_date,
|
||||
@ -61,8 +63,7 @@ class Statistics::FetcherService
|
||||
nb_hours: (r.slots.map(&:duration).map(&:to_i).reduce(:+) / 3600.0).to_f,
|
||||
ca: calcul_ca(r.original_invoice),
|
||||
reservation_context_id: r.reservation_context_id,
|
||||
coupon: r.original_invoice.coupon&.code
|
||||
}.merge(user_info(profile))
|
||||
coupon: r.original_invoice.coupon&.code }.merge(user_info(profile))
|
||||
yield result
|
||||
end
|
||||
end
|
||||
@ -77,6 +78,8 @@ class Statistics::FetcherService
|
||||
.eager_load(:slots, :slots_reservations, :invoice_items, :reservation_context, statistic_profile: [:group])
|
||||
.find_each do |r|
|
||||
next unless r.reservable
|
||||
next unless r.original_invoice
|
||||
next if r.slots.empty?
|
||||
|
||||
profile = r.statistic_profile
|
||||
result = { date: r.created_at.to_date,
|
||||
@ -88,8 +91,7 @@ class Statistics::FetcherService
|
||||
nb_hours: (r.slots.map(&:duration).map(&:to_i).reduce(:+) / 3600.0).to_f,
|
||||
ca: calcul_ca(r.original_invoice),
|
||||
reservation_context_id: r.reservation_context_id,
|
||||
coupon: r.original_invoice.coupon&.code
|
||||
}.merge(user_info(profile))
|
||||
coupon: r.original_invoice.coupon&.code }.merge(user_info(profile))
|
||||
yield result
|
||||
end
|
||||
end
|
||||
@ -104,6 +106,7 @@ class Statistics::FetcherService
|
||||
.eager_load(:slots, :slots_reservations, :invoice_items, :reservation_context, statistic_profile: [:group])
|
||||
.find_each do |r|
|
||||
next unless r.reservable
|
||||
next unless r.original_invoice
|
||||
|
||||
profile = r.statistic_profile
|
||||
slot = r.slots.first
|
||||
@ -116,8 +119,7 @@ class Statistics::FetcherService
|
||||
nb_hours: difference_in_hours(slot.start_at, slot.end_at),
|
||||
ca: calcul_ca(r.original_invoice),
|
||||
reservation_context_id: r.reservation_context_id,
|
||||
coupon: r.original_invoice&.coupon&.code
|
||||
}.merge(user_info(profile))
|
||||
coupon: r.original_invoice&.coupon&.code }.merge(user_info(profile))
|
||||
yield result
|
||||
end
|
||||
end
|
||||
@ -161,6 +163,7 @@ class Statistics::FetcherService
|
||||
.eager_load(:slots, :invoice_items, statistic_profile: [:group])
|
||||
.find_each do |r|
|
||||
next unless r.reservable
|
||||
next unless r.statistic_profile
|
||||
|
||||
reservations_ca_list.push(
|
||||
{ date: r.created_at.to_date, ca: calcul_ca(r.original_invoice) || 0 }.merge(user_info(r.statistic_profile))
|
||||
@ -171,6 +174,8 @@ class Statistics::FetcherService
|
||||
.find_each do |i|
|
||||
# the following line is a workaround for issue #196
|
||||
profile = i.statistic_profile || i.main_item.object&.wallet&.user&.statistic_profile
|
||||
next unless profile
|
||||
|
||||
avoirs_ca_list.push({ date: i.created_at.to_date, ca: calcul_avoir_ca(i) || 0 }.merge(user_info(profile)))
|
||||
end
|
||||
reservations_ca_list.concat(subscriptions_ca_list).concat(avoirs_ca_list).each do |e|
|
||||
@ -221,6 +226,8 @@ class Statistics::FetcherService
|
||||
.where('order_activities.created_at >= :start_date AND order_activities.created_at <= :end_date', options)
|
||||
.group('orders.id')
|
||||
.find_each do |o|
|
||||
next unless o.invoice
|
||||
|
||||
result = { date: o.created_at.to_date, ca: calcul_ca(o.invoice), coupon: o.invoice.coupon&.code }
|
||||
.merge(user_info(o.statistic_profile))
|
||||
.merge(store_order_info(o))
|
||||
|
Loading…
x
Reference in New Issue
Block a user