@@ -306,12 +306,16 @@ def modify_overdue_config
306306 options [ :api_key ] = current_tenant . api_key
307307 options [ :api_secret ] = current_tenant . api_secret
308308
309- view_form_model = params . require ( :kill_bill_client_model_overdue ) . permit! . to_h . compact_blank
309+ view_form_model = params [ :kill_bill_client_model_overdue ] & .permit! & .to_h & .compact_blank || { }
310310 view_form_model [ 'states' ] = view_form_model [ 'states' ] . values if view_form_model [ 'states' ] . present?
311-
312- overdue = Kaui ::Overdue . from_overdue_form_model ( view_form_model )
313- Kaui ::Overdue . upload_tenant_overdue_config_json ( overdue . to_json , options [ :username ] , nil , comment , options )
314- redirect_to admin_tenant_path ( current_tenant . id , active_tab : 'OverdueShow' ) , notice : I18n . t ( 'flashes.notices.overdue_added_successfully' )
311+ if view_form_model [ 'states' ] . blank?
312+ Kaui ::AdminTenant . delete_tenant_user_key_value ( 'OVERDUE_CONFIG' , options [ :username ] , nil , comment , options )
313+ redirect_to admin_tenant_path ( current_tenant . id , active_tab : 'OverdueShow' ) , notice : I18n . t ( 'flashes.notices.overdue_updated_successfully' )
314+ else
315+ overdue = Kaui ::Overdue . from_overdue_form_model ( view_form_model )
316+ Kaui ::Overdue . upload_tenant_overdue_config_json ( overdue . to_json , options [ :username ] , nil , comment , options )
317+ redirect_to admin_tenant_path ( current_tenant . id , active_tab : 'OverdueShow' ) , notice : I18n . t ( 'flashes.notices.overdue_added_successfully' )
318+ end
315319 end
316320
317321 def upload_overdue_config
0 commit comments