Add external_billing_id field on revenues_by_hub report

This commit is contained in:
François Turbelin
2024-11-28 22:01:35 +01:00
committed by Rachel Arnould
parent e37881837b
commit 6ae3c8b102
5 changed files with 37 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ module Api
:terms_and_conditions_file_name, :terms_and_conditions_updated_at,
:preferred_invoice_order_by_supplier, :preferred_product_low_stock_display,
:visible, :hide_ofn_navigation, :white_label_logo,
:white_label_logo_link
:white_label_logo_link, :external_billing_id
has_one :owner, serializer: Api::Admin::UserSerializer
has_many :users, serializer: Api::Admin::UserSerializer

View File

@@ -3198,6 +3198,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
report_header_hub_code: Hub Code
report_header_hub_id: Hub ID
report_header_hub_business_number: "Hub Business Number"
report_header_hub_external_billing_id: "Hub External Billing Id"
report_header_hub_legal_name: "Hub Legal Name"
report_header_hub_contact_name: "Hub Contact Name"
report_header_hub_email: "Hub Public Email"

View File

@@ -24,6 +24,7 @@ module Reporting
hub: proc { |orders| distributor(orders).name },
hub_id: proc { |orders| distributor(orders).id },
hub_business_number: proc { |orders| distributor(orders).abn },
hub_external_billing_id: proc { |orders| distributor(orders).external_billing_id },
hub_legal_name: proc { |orders| distributor(orders).business_address&.company },
hub_contact_name: proc { |orders| distributor(orders).contact_name },
hub_email: proc { |orders| distributor(orders).email_address },

View File

@@ -7,6 +7,31 @@ RSpec.describe Api::V0::EnterprisesController, type: :controller do
let(:enterprise) { create(:distributor_enterprise) }
context "as an admin user" do
let(:admin) { create(:user) }
let!(:enterprise) { create(:distributor_enterprise) }
before do
allow(controller).to receive(:spree_current_user) { admin }
end
describe "updating an enterprise" do
let(:enterprise_params) do
{
enterprise_id: enterprise.id,
enterprise: { external_billing_id: 'INV123456' }
}
end
it "creates a visible=hidden enterprise" do
api_post :create, enterprise_params
expect(response.status).to eq 200
expect(enterprise.reload.external_billing_id).to eq('INV123456')
end
end
end
context "as an enterprise owner" do
let(:enterprise_owner) { create(:user) }
let!(:enterprise) { create(:distributor_enterprise, owner: enterprise_owner) }

View File

@@ -73,4 +73,13 @@ RSpec.describe Api::Admin::EnterpriseSerializer do
end
end
end
context "when there is a external billing id" do
let(:enterprise) { create(:distributor_enterprise, external_billing_id: 'INV123456') }
it "includes URLs of image versions" do
serializer = Api::Admin::EnterpriseSerializer.new(enterprise)
expect(serializer.as_json[:external_billing_id]).to eq('INV123456')
end
end
end