diff --git a/app/admin/billing/service_types.rb b/app/admin/billing/service_types.rb index 3ca0a4258..356e184a4 100644 --- a/app/admin/billing/service_types.rb +++ b/app/admin/billing/service_types.rb @@ -16,6 +16,7 @@ filter :name filter :provisioning_class filter :force_renew + filter :ui_type index do selectable_column @@ -25,6 +26,7 @@ column :force_renew column :provisioning_class column :variables, :variables_json + column :ui_type end show do @@ -39,6 +41,7 @@ link_to resource.services.count, services_path(q: { type_id_eq: resource.id }) end + row :ui_type end end @@ -58,6 +61,7 @@ f.input :name f.input :force_renew f.input :provisioning_class, as: :select, collection: Billing::ServiceType.available_provisioning_classes, input_html: { class: :chosen } + f.input :ui_type f.input :variables_json, label: 'Variables', as: :text end f.actions diff --git a/app/models/billing/service_type.rb b/app/models/billing/service_type.rb index 2cc6a2091..780e85a2d 100644 --- a/app/models/billing/service_type.rb +++ b/app/models/billing/service_type.rb @@ -8,6 +8,7 @@ # force_renew :boolean default(FALSE), not null # name :string not null # provisioning_class :string +# ui_type :string # variables :jsonb # # Indexes diff --git a/app/resources/api/rest/customer/v1/service_resource.rb b/app/resources/api/rest/customer/v1/service_resource.rb index 8698dcbfb..0f22691ff 100644 --- a/app/resources/api/rest/customer/v1/service_resource.rb +++ b/app/resources/api/rest/customer/v1/service_resource.rb @@ -12,6 +12,7 @@ class Api::Rest::Customer::V1::ServiceResource < Api::Rest::Customer::V1::BaseRe attribute :renew_at attribute :renew_period attribute :service_type + attribute :ui_type has_one :account, class_name: 'Account', foreign_key_on: :related has_many :transactions, class_name: 'Transaction', foreign_key_on: :related @@ -31,6 +32,10 @@ def service_type _model.type.name end + def ui_type + _model.type.ui_type + end + def self.sortable_fields(_ctx = nil) %i[id name initial_price renew_price created_at renew_at renew_period] end diff --git a/config/locales/en.yml b/config/locales/en.yml index c0e01e0f0..3dbc8f964 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -122,6 +122,8 @@ en: lnp_routing_plan_lnp_rule: drop_call_on_error: "Drop call if LNP resolve failed. When disabled routing will fallback to use destination number" rewrite_call_destination: "use LRN as new call destination" + billing_service_type: + ui_type: "This field will be used in Service Resource of Customer API" attributes: diff --git a/db/migrate/20241107212537_migration_add_ui_type_field.rb b/db/migrate/20241107212537_migration_add_ui_type_field.rb new file mode 100644 index 000000000..09bb1c93f --- /dev/null +++ b/db/migrate/20241107212537_migration_add_ui_type_field.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class MigrationAddUiTypeField < ActiveRecord::Migration[7.0] + def change + add_column 'billing.service_types', :ui_type, :string + end +end diff --git a/db/structure.sql b/db/structure.sql index 5695533dd..02493d091 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -31489,7 +31489,8 @@ CREATE TABLE billing.service_types ( name character varying NOT NULL, provisioning_class character varying, variables jsonb, - force_renew boolean DEFAULT false NOT NULL + force_renew boolean DEFAULT false NOT NULL, + ui_type character varying ); @@ -41244,6 +41245,7 @@ INSERT INTO "public"."schema_migrations" (version) VALUES ('20241012124910'), ('20241015092015'), ('20241016075439'), -('20241017124729'); +('20241017124729'), +('20241107212537'); diff --git a/spec/factories/billing/service_types.rb b/spec/factories/billing/service_types.rb index 8bd04ab9b..58ac96841 100644 --- a/spec/factories/billing/service_types.rb +++ b/spec/factories/billing/service_types.rb @@ -8,6 +8,7 @@ # force_renew :boolean default(FALSE), not null # name :string not null # provisioning_class :string +# ui_type :string # variables :jsonb # # Indexes @@ -19,5 +20,6 @@ sequence(:name) { |n| "Service Type #{n}" } provisioning_class { 'Billing::Provisioning::Logging' } variables { { 'foo' => 'bar' } } + ui_type { 'phone_systems' } end end diff --git a/spec/models/billing/service_type_spec.rb b/spec/models/billing/service_type_spec.rb index fc7b1e295..1c19b282f 100644 --- a/spec/models/billing/service_type_spec.rb +++ b/spec/models/billing/service_type_spec.rb @@ -8,6 +8,7 @@ # force_renew :boolean default(FALSE), not null # name :string not null # provisioning_class :string +# ui_type :string # variables :jsonb # # Indexes