mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Update available/unallocated calculations
This commit is contained in:
@@ -2,7 +2,7 @@ require 'open_food_network/reports/bulk_coop_report'
|
||||
|
||||
module OpenFoodNetwork::Reports
|
||||
class BulkCoopAllocationReport < BulkCoopReport
|
||||
header "Customer", "Product", "Unit Size", "Variant", "Weight", "Sum Total", "Sum Max Total", "Total Allocated", "Remainder"
|
||||
header "Customer", "Product", "Unit Size", "Variant", "Weight", "Sum Total", "Sum Max Total", "Total Available", "Unallocated"
|
||||
|
||||
organise do
|
||||
group { |li| li.variant.product }
|
||||
@@ -16,8 +16,8 @@ module OpenFoodNetwork::Reports
|
||||
column { |lis| "" }
|
||||
column { |lis| total_amount(lis) }
|
||||
column { |lis| total_max_quantity_amount(lis) }
|
||||
column { |lis| ( (lis.first.variant.product.group_buy_unit_size || 0).zero? ? 0 : ( lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } / lis.first.variant.product.group_buy_unit_size ) ).floor * (lis.first.variant.product.group_buy_unit_size || 0) }
|
||||
column { |lis| lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } - ( ( (lis.first.variant.product.group_buy_unit_size || 0).zero? ? 0 : ( lis.sum { |li| ( [li.max_quantity || 0, li.quantity || 0].max ) * (li.variant.weight || 0) } / lis.first.variant.product.group_buy_unit_size ) ).floor * (lis.first.variant.product.group_buy_unit_size || 0) ) }
|
||||
column { |lis| total_available(lis) }
|
||||
column { |lis| remainder(lis) }
|
||||
end
|
||||
|
||||
organise do
|
||||
|
||||
Reference in New Issue
Block a user