From 09adc8f6905b13dfe6bab0557f5ce72a8b41cfe2 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Mon, 25 Jul 2022 14:33:17 +0200 Subject: [PATCH] In Enterprise Fees Summary report, SUM column should be numeric + update specs as well --- .../reports/enterprise_fee_summary/scope.rb | 2 +- .../enterprise_fee_summary_report_spec.rb | 74 +++++++++---------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/reporting/reports/enterprise_fee_summary/scope.rb b/lib/reporting/reports/enterprise_fee_summary/scope.rb index 86a165ad08..023fc36f7a 100644 --- a/lib/reporting/reports/enterprise_fee_summary/scope.rb +++ b/lib/reporting/reports/enterprise_fee_summary/scope.rb @@ -366,7 +366,7 @@ module Reporting chain_to_scope do select( <<-JOIN_STRING.strip_heredoc - SUM(spree_adjustments.amount)::TEXT AS total_amount, + SUM(spree_adjustments.amount)::NUMERIC AS total_amount, spree_payment_methods.name AS payment_method_name, spree_shipping_methods.name AS shipping_method_name, hubs.name AS hub_name, diff --git a/spec/lib/reports/enterprise_fee_summary/enterprise_fee_summary_report_spec.rb b/spec/lib/reports/enterprise_fee_summary/enterprise_fee_summary_report_spec.rb index 0487954d33..007667eb80 100644 --- a/spec/lib/reports/enterprise_fee_summary/enterprise_fee_summary_report_spec.rb +++ b/spec/lib/reports/enterprise_fee_summary/enterprise_fee_summary_report_spec.rb @@ -116,37 +116,37 @@ describe Reporting::Reports::EnterpriseFeeSummary::Base do expected_result = [ ["Admin", "Sample Coordinator", "Coordinator Fee 1", "Another Customer", - "Coordinator", "All", "Sample Coordinator Tax", "512.00"], + "Coordinator", "All", "Sample Coordinator Tax", 512], ["Admin", "Sample Coordinator", "Coordinator Fee 1", "Sample Customer", - "Coordinator", "All", "Sample Coordinator Tax", "1024.00"], + "Coordinator", "All", "Sample Coordinator Tax", 1024], ["Admin", "Sample Distributor", "Distributor Fee 1", "Another Customer", - "Outgoing", "Sample Distributor", "Sample Distributor Tax", "4.00"], + "Outgoing", "Sample Distributor", "Sample Distributor Tax", 4], ["Admin", "Sample Distributor", "Distributor Fee 1", "Sample Customer", - "Outgoing", "Sample Distributor", "Sample Distributor Tax", "8.00"], + "Outgoing", "Sample Distributor", "Sample Distributor Tax", 8], ["Payment Transaction", "Sample Distributor", "Sample Payment Method", "Another Customer", - nil, nil, nil, "2.00"], + nil, nil, nil, 2], ["Payment Transaction", "Sample Distributor", "Sample Payment Method", "Sample Customer", - nil, nil, nil, "4.00"], + nil, nil, nil, 4], ["Sales", "Sample Coordinator", "Coordinator Fee 2", "Another Customer", - "Coordinator", "All", "Various", "1024.00"], + "Coordinator", "All", "Various", 1024], ["Sales", "Sample Coordinator", "Coordinator Fee 2", "Sample Customer", - "Coordinator", "All", "Various", "2048.00"], + "Coordinator", "All", "Various", 2048], ["Sales", "Sample Distributor", "Distributor Fee 2", "Another Customer", - "Outgoing", "Sample Distributor", "Sample Product Tax", "8.00"], + "Outgoing", "Sample Distributor", "Sample Product Tax", 8], ["Sales", "Sample Distributor", "Distributor Fee 2", "Sample Customer", - "Outgoing", "Sample Distributor", "Sample Product Tax", "16.00"], + "Outgoing", "Sample Distributor", "Sample Product Tax", 16], ["Sales", "Sample Producer", "Producer Fee 1", "Another Customer", - "Incoming", "Sample Producer", "Sample Producer Tax", "64.00"], + "Incoming", "Sample Producer", "Sample Producer Tax", 64], ["Sales", "Sample Producer", "Producer Fee 1", "Sample Customer", - "Incoming", "Sample Producer", "Sample Producer Tax", "128.00"], + "Incoming", "Sample Producer", "Sample Producer Tax", 128], ["Sales", "Sample Producer", "Producer Fee 2", "Another Customer", - "Incoming", "Sample Producer", "Sample Product Tax", "128.00"], + "Incoming", "Sample Producer", "Sample Product Tax", 128], ["Sales", "Sample Producer", "Producer Fee 2", "Sample Customer", - "Incoming", "Sample Producer", "Sample Product Tax", "256.00"], + "Incoming", "Sample Producer", "Sample Product Tax", 256], ["Shipment", "Sample Distributor", "Sample Shipping Method", "Another Customer", - nil, nil, "Platform Rate", "1.00"], + nil, nil, "Platform Rate", 1], ["Shipment", "Sample Distributor", "Sample Shipping Method", "Sample Customer", - nil, nil, "Platform Rate", "2.00"] + nil, nil, "Platform Rate", 2] ] expected_result.each_with_index do |expected_attributes, row_index| @@ -173,7 +173,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::Base do expected_result = [ ["Shipment", "Sample Distributor", "Sample Shipping Method", "Sample Customer", - nil, nil, "Platform Rate", "1.00"] + nil, nil, "Platform Rate", 1] ] expected_result.each_with_index do |expected_attributes, row_index| @@ -208,9 +208,9 @@ describe Reporting::Reports::EnterpriseFeeSummary::Base do expected_result = [ ["Payment Transaction", "Sample Distributor", "Sample Payment Method", "Sample Customer", - nil, nil, nil, "2.00"], + nil, nil, nil, 2], ["Shipment", "Sample Distributor", "Sample Shipping Method", "Sample Customer", - nil, nil, "Platform Rate", "1.00"] + nil, nil, "Platform Rate", 1] ] expected_result.each_with_index do |expected_attributes, row_index| @@ -233,7 +233,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::Base do expected_result = [ ["Shipment", "Sample Distributor", "Sample Shipping Method", "Sample Customer", - nil, nil, "Platform Rate", "1.00"] + nil, nil, "Platform Rate", 1] ] expected_result.each_with_index do |expected_attributes, row_index| @@ -280,17 +280,17 @@ describe Reporting::Reports::EnterpriseFeeSummary::Base do expected_result = [ ["Admin", "Sample Coordinator", "Sample Coordinator Fee", "Sample Customer", - "Incoming", "Sample Producer", "Sample Coordinator Tax", "512.00"], + "Incoming", "Sample Producer", "Sample Coordinator Tax", 512], ["Admin", "Sample Coordinator", "Sample Coordinator Fee", "Sample Customer", - "Outgoing", "Sample Distributor", "Sample Coordinator Tax", "512.00"], + "Outgoing", "Sample Distributor", "Sample Coordinator Tax", 512], ["Admin", "Sample Distributor", "Sample Distributor Fee", "Sample Customer", - "Incoming", "Sample Producer", "Sample Distributor Tax", "4.00"], + "Incoming", "Sample Producer", "Sample Distributor Tax", 4], ["Payment Transaction", "Sample Distributor", "Sample Payment Method", "Sample Customer", - nil, nil, nil, "2.00"], + nil, nil, nil, 2], ["Sales", "Sample Producer", "Sample Producer Fee", "Sample Customer", - "Outgoing", "Sample Distributor", "Sample Producer Tax", "64.00"], + "Outgoing", "Sample Distributor", "Sample Producer Tax", 64], ["Shipment", "Sample Distributor", "Sample Shipping Method", "Sample Customer", - nil, nil, "Platform Rate", "1.00"] + nil, nil, "Platform Rate", 1] ] expected_result.each_with_index do |expected_attributes, row_index| @@ -361,27 +361,27 @@ describe Reporting::Reports::EnterpriseFeeSummary::Base do expected_result = [ ["Admin", "Sample Coordinator", "Coordinator Fee A", "Sample Customer", - "Coordinator", "All", "Coordinator Tax A", "15.00"], + "Coordinator", "All", "Coordinator Tax A", 15], ["Admin", "Sample Coordinator", "Coordinator Fee A", "Sample Customer", - "Incoming", entire_orders_text, "Coordinator Tax A", "15.00"], + "Incoming", entire_orders_text, "Coordinator Tax A", 15], ["Admin", "Sample Coordinator", "Coordinator Fee A", "Sample Customer", - "Outgoing", entire_orders_text, "Coordinator Tax A", "15.00"], + "Outgoing", entire_orders_text, "Coordinator Tax A", 15], ["Admin", "Sample Coordinator", "Coordinator Fee B", "Sample Customer", - "Coordinator", "All", various_tax_categories_text, "20.00"], + "Coordinator", "All", various_tax_categories_text, 20], ["Admin", "Sample Coordinator", "Coordinator Fee C", "Sample Customer", - "Coordinator", "All", nil, "25.00"], + "Coordinator", "All", nil, 25], ["Admin", "Sample Distributor", "Distributor Fee A", "Sample Customer", - "Incoming", entire_orders_text, various_tax_categories_text, "30.00"], + "Incoming", entire_orders_text, various_tax_categories_text, 30], ["Admin", "Sample Distributor", "Distributor Fee A", "Sample Customer", - "Outgoing", entire_orders_text, various_tax_categories_text, "30.00"], + "Outgoing", entire_orders_text, various_tax_categories_text, 30], ["Payment Transaction", "Sample Distributor", "Sample Payment Method", "Sample Customer", - nil, nil, nil, "2.00"], + nil, nil, nil, 2], ["Sales", "Sample Producer", "Producer Fee A", "Sample Customer", - "Incoming", entire_orders_text, "Producer Tax A", "10.00"], + "Incoming", entire_orders_text, "Producer Tax A", 10], ["Sales", "Sample Producer", "Producer Fee A", "Sample Customer", - "Outgoing", entire_orders_text, "Producer Tax A", "10.00"], + "Outgoing", entire_orders_text, "Producer Tax A", 10], ["Shipment", "Sample Distributor", "Sample Shipping Method", "Sample Customer", - nil, nil, "Platform Rate", "1.00"] + nil, nil, "Platform Rate", 1] ] expected_result.each_with_index do |expected_attributes, row_index|