source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
lib/tasks/helpers/ccms_payload_yamlizer.rb
Ruby
mit
19
main
1,664
require "nokogiri" require "yaml" class CcmsPayloadYamlizer def initialize(filename) @xml = File.read(filename) @doc = Nokogiri::XML(@xml, &:noblanks) @doc.remove_namespaces! @data = @doc.children.first @hash = {} end def run @hash[@data.name] = {} @data.children.each { |child| proce...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
lib/tasks/fixes/ap_5699.rake
Ruby
mit
19
main
3,422
namespace :fixes do desc "Fixes for AP-5699" task :ap_5699, [:mock] => :environment do |_task, args| args.with_defaults(mock: "true") mock = args[:mock].to_s.downcase.strip != "false" if mock Rails.logger.info "----------------------------------------" Rails.logger.info "MOCK run enabled." ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
lib/tasks/stats/opponents.rake
Ruby
mit
19
main
2,725
namespace :stats do desc "Stats for \"individual\" and \"organisation\" opponents" task opponents: :environment do ind_count = ApplicationMeritsTask::Individual.count org_count = ApplicationMeritsTask::Organisation.count ind_orphan_count = ApplicationMeritsTask::Individual.where.missing(:opponent).count...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
lib/tasks/provider_transfer/ptr_migrations.rake
Ruby
mit
19
main
2,900
namespace :ptr_migrations do desc "Transfer a LegalAidApplication from one Office to another" task :laa_transfer_office, %i[mock app_id office_id] => :environment do |_task, args| args.with_defaults(mock: "true") mock = args[:mock].to_s.downcase.strip != "false" laa = LegalAidApplication.find_by(id: arg...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
lib/tasks/jobs/bank_holiday_import.rake
Ruby
mit
19
main
272
namespace :job do namespace :bank_holiday_import do desc "Import bank holidays" task perform: :environment do Rails.logger.info "rake job:bank_holiday_import:perform queued at #{Time.zone.now}" BankHolidayUpdateWorker.perform_async end end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
lib/tasks/jobs/create_admin_reports.rake
Ruby
mit
19
main
251
namespace :job do namespace :admin_reports do desc "Upload admin reports" task upload: :environment do Rails.logger.info "rake job:admin_reports:upload queued at #{Time.zone.now}" ReportsUploaderJob.perform_now end end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
lib/utilities/redis_scanner.rb
Ruby
mit
19
main
2,276
require "redis" # Utility class to search for redis keys by name # ,view their values and delete them # # Basic usage: # # scanner.call(/regex-for-keynames/) # scanner.results # # Example usage: # # require_relative 'lib/utilities/redis_scanner' # # redis = Redis.new(url: Rails.configuration.x.redis.base_url) # scann...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
lib/devise/models/reauthable.rb
Ruby
mit
19
main
406
require "devise/hooks/reauthable" module Devise mattr_accessor :reauthenticate_in module Models module Reauthable extend ActiveSupport::Concern def reauthenticate? current_sign_in_at < reauthenticate_in.ago end delegate :reauthenticate_in, to: :class module ClassMethod...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
lib/devise/hooks/reauthable.rb
Ruby
mit
19
main
714
# Each time a record is retrieved from the session (:fetch) # we check whether the `current_sign_in_at` is older than the # `reauthenticate_in` value. If so, the record is logged out. # module Devise module Hooks module Reauthable Warden::Manager.after_set_user only: :fetch do |record, warden, options| ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/applicant.rb
Ruby
mit
19
main
3,850
require "uri" require "omniauth" class Applicant < ApplicationRecord devise :rememberable NINO_REGEXP = /\A[A-CEGHJ-PR-TW-Z]{1}[A-CEGHJ-NPR-TW-Z]{1}[0-9]{6}[A-DFM]{1}\z/ enum :correspondence_address_choice, { home: "home".freeze, residence: "residence".freeze, office: "office".freeze, } has_on...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/legal_aid_application_transaction_type.rb
Ruby
mit
19
main
783
class LegalAidApplicationTransactionType < ApplicationRecord belongs_to :legal_aid_application belongs_to :transaction_type scope :credits, -> { includes(:transaction_type).where(transaction_types: { operation: :credit }) } scope :debits, -> { includes(:transaction_type).where(transaction_types: { operation: :...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/address.rb
Ruby
mit
19
main
1,443
class Address < ApplicationRecord belongs_to :applicant before_save :normalize_postcode def self.from_json(json) attrs = JSON.parse(json) new(attrs.slice("address_line_one", "address_line_two", "city", "county", "postcode", "lookup_id")) end def full_address [address_line_one, address_line_two,...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/policy_disregards.rb
Ruby
mit
19
main
690
class PolicyDisregards < ApplicationRecord belongs_to :legal_aid_application DISREGARDS = %i[ england_infected_blood_support vaccine_damage_payments variant_creutzfeldt_jakob_disease criminal_injuries_compensation_scheme national_emergencies_trust we_love_manchester_emergency_fund londo...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/application_digest.rb
Ruby
mit
19
main
4,525
class ApplicationDigest < ApplicationRecord class << self def create_or_update!(legal_aid_application_id) attrs = map_attrs(legal_aid_application_id) rec = find_by(legal_aid_application_id:) rec.nil? ? create!(attrs) : rec.update!(attrs) end private def map_attrs(application_id) ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/aggregated_cash_outgoings.rb
Ruby
mit
19
main
686
class AggregatedCashOutgoings < BaseAggregatedCashTransaction def self.cash_transaction_categories %i[ rent_or_mortgage child_care maintenance_out legal_aid ].freeze end def self.operation :debits end attr_accessor :legal_aid_application_id, :none_selected...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/partner.rb
Ruby
mit
19
main
1,094
class Partner < ApplicationRecord belongs_to :legal_aid_application has_many :hmrc_responses, class_name: "HMRC::Response", as: :owner has_many :employments, as: :owner has_many :regular_transactions, as: :owner delegate :transaction_period_start_on, to: :legal_aid_application def json_for_hmrc { ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/provider.rb
Ruby
mit
19
main
1,871
class Provider < ApplicationRecord class RawInfoNotFound < StandardError; end encrypts :silas_id, deterministic: true devise :trackable, :reauthable, :timeoutable serialize :roles, coder: YAML serialize :offices, coder: YAML belongs_to :firm, optional: true belongs_to :selected_office, class_name: :Of...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/document_category.rb
Ruby
mit
19
main
373
class DocumentCategory < ApplicationRecord validates_with DocumentCategoryValidator def self.populate DocumentCategoryPopulator.call end def self.displayable_document_category_names where(display_on_evidence_upload: true).pluck(:name) + %w[uncategorised] end def self.submittable_category_names ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/bank_holiday.rb
Ruby
mit
19
main
518
class BankHoliday < ApplicationRecord serialize :dates, type: Array, coder: YAML scope :by_updated_at, -> { order(updated_at: :asc) } before_validation :populate_dates validates :dates, presence: true def self.dates instance = by_updated_at.last || create! instance.dates end def populate_dates...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/linked_application.rb
Ruby
mit
19
main
728
class LinkedApplication < ApplicationRecord belongs_to :lead_application, class_name: "LegalAidApplication", optional: true belongs_to :associated_application, class_name: "LegalAidApplication" belongs_to :target_application, class_name: "LegalAidApplication", optional: true validate :cannot_link_self valid...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/attachment.rb
Ruby
mit
19
main
555
class Attachment < ApplicationRecord belongs_to :legal_aid_application has_one_attached :document validates_with DocumentCategoryValidator DocumentCategoryValidator::VALID_DOCUMENT_TYPES.each do |named_scope| scope named_scope.to_sym, -> { where(attachment_type: named_scope) } end scope :uploadable_e...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/aggregated_cash_income.rb
Ruby
mit
19
main
538
class AggregatedCashIncome < BaseAggregatedCashTransaction def self.cash_transaction_categories %i[ benefits friends_or_family maintenance_in property_or_lodger pension ].freeze end def self.operation :credits end attr_accessor :legal_aid_application_id, ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/savings_amount.rb
Ruby
mit
19
main
463
class SavingsAmount < ApplicationRecord include Capital belongs_to :legal_aid_application def values? all_attributes.map { |attr| send(attr).present? }.any? end private def all_attributes %i[ offline_current_accounts offline_savings_accounts cash other_person_account ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/bank_account.rb
Ruby
mit
19
main
1,443
class BankAccount < ApplicationRecord belongs_to :bank_provider has_many :bank_transactions, dependent: :destroy has_one :legal_aid_application, through: :bank_provider ACCOUNT_TYPE_LABELS = { "TRANSACTION" => "Bank Current", "SAVINGS" => "Bank Savings", }.freeze scope :current, -> { where(account...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cash_transaction.rb
Ruby
mit
19
main
1,432
class CashTransaction < ApplicationRecord # The CashTransaction records the monthly amount paid or received by an applicant in cash for a particular month # for a particular TransactionType. These records always come in threes, representing each of the last three months # before an application was made. The tra...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/base_aggregated_cash_transaction.rb
Ruby
mit
19
main
6,619
# Base class for AggregatedCashIncome and AggregatedCashOutgoings. # # These classes are facades to allow three cash transaction records per Transaction Type # to be displayed on a form and validated. # class BaseAggregatedCashTransaction include ActiveModel::Model include MoneyHelper NUMBER_OF_FIELDS = 3 MONT...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/capital_disregard.rb
Ruby
mit
19
main
340
class CapitalDisregard < ApplicationRecord belongs_to :legal_aid_application def incomplete? (name == "compensation_for_personal_harm" && payment_reason.nil?) || (name == "loss_or_harm_relating_to_this_application" && payment_reason.nil?) || amount.nil? || account_name.nil? || date_rece...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/linked_application_type.rb
Ruby
mit
19
main
312
class LinkedApplicationType LinkTypeStruct = Struct.new(:code, :description) LINK_TYPES = [ LinkTypeStruct.new( code: "FC_LEAD", description: "Family", ), LinkTypeStruct.new( code: "LEGAL", description: "Legal", ), ].freeze def self.all LINK_TYPES end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/host_env.rb
Ruby
mit
19
main
609
class HostEnv def self.environment return Rails.env.to_sym unless Rails.env.production? host_env end def self.host_env ENV.fetch("HOST_ENV", nil)&.to_sym end def self.development? environment == :development end def self.test? environment == :test end def self.uat? environ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/announcement.rb
Ruby
mit
19
main
881
class Announcement < ApplicationRecord enum :display_type, { gov_uk: 0, moj: 1 } has_many :provider_dismissed_announcements, dependent: :delete_all validates :heading, presence: true, if: ->(announcement) { announcement.display_type == "gov_uk" } validates :body, presence: true, if: ->(announcement) { announc...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/scope_limitation.rb
Ruby
mit
19
main
797
class ScopeLimitation < ApplicationRecord belongs_to :proceeding enum :scope_type, { substantive: 0, emergency: 1 } scope :emergency, -> { where(scope_type: :emergency) } scope :substantive, -> { where(scope_type: :substantive) } def description if requires_additional_data_merge? description_with_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/vehicle.rb
Ruby
mit
19
main
357
class Vehicle < ApplicationRecord belongs_to :legal_aid_application def complete? [ estimated_value.present?, more_than_three_years_old.in?([true, false]), used_regularly.in?([true, false]), ].all?(true) end def cfe_civil_purchase_date more_than_three_years_old? ? 4.years.ago.to_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/setting.rb
Ruby
mit
19
main
1,394
class Setting < ApplicationRecord def self.mock_true_layer_data? setting.mock_true_layer_data? end def self.bank_transaction_filename setting.bank_transaction_filename end def self.manually_review_all_cases? setting.manually_review_all_cases end def self.allow_welsh_translation? setting...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/bank_transaction.rb
Ruby
mit
19
main
1,214
class BankTransaction < ApplicationRecord belongs_to :bank_account belongs_to :transaction_type, optional: true has_one :legal_aid_application, through: :bank_account serialize :meta_data, coder: YAML attr_accessor :previous_txn_id, :next_txn_id scope :by_type, lambda { includes(:transaction_type) ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/legal_aid_application.rb
Ruby
mit
19
main
30,362
class LegalAidApplication < ApplicationRecord include Discard::Model include Reviewable::Model include DelegatedFunctions ProceedingStruct = Struct.new(:name, :meaning, :matter_type, :category_of_law, :proceeding) SHARED_OWNERSHIP_YES_REASONS = %w[partner_or_ex_partner housing_assocation_or_landlord friend_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/firm.rb
Ruby
mit
19
main
367
class Firm < ApplicationRecord has_many :offices has_many :providers has_many :legal_aid_applications, through: :providers has_many :actor_permissions, as: :permittable has_many :permissions, through: :actor_permissions def self.search(search_term) if search_term where("name ILIKE ?", "%#{search...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/uploaded_evidence_collection.rb
Ruby
mit
19
main
1,772
class UploadedEvidenceCollection < ApplicationRecord belongs_to :legal_aid_application belongs_to :provider_uploader, class_name: "Provider", optional: true validate :all_evidence_categorised validate :all_mandatory_evidence_uploaded def original_attachments legal_aid_application.attachments.displayable...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/proceeding.rb
Ruby
mit
19
main
3,099
class Proceeding < ApplicationRecord FIRST_PROCEEDING_CASE_ID = 55_000_000 belongs_to :legal_aid_application has_one :opponents_application, class_name: "ProceedingMeritsTask::OpponentsApplication", dependent: :destroy has_one :attempts_to_settle, class_name: "ProceedingMeritsTask::AttemptsToSettle", dependen...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/employment_payment.rb
Ruby
mit
19
main
271
class EmploymentPayment < ApplicationRecord belongs_to :employment before_save :calculate_net_employment_income private def calculate_net_employment_income self.net_employment_income = (gross + benefits_in_kind + tax + national_insurance).round(2) end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/debug.rb
Ruby
mit
19
main
1,118
class Debug < ApplicationRecord # :nocov: def self.record_request(session, auth_params, callback_url, browser_details) create!( debug_type: "request", legal_aid_application_id: session[:current_application_id], session_id: session[:session_id], session: session.to_h.to_json, auth_p...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/feedback.rb
Ruby
mit
19
main
882
class Feedback < ApplicationRecord enum :satisfaction, { very_dissatisfied: 0, dissatisfied: 1, neither_dissatisfied_nor_satisfied: 2, satisfied: 3, very_satisfied: 4, } enum :difficulty, { very_difficult: 0, difficult: 1, neither_difficult_nor_easy: 2, easy: 3, very_easy:...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/scheduled_mailing.rb
Ruby
mit
19
main
2,393
class ScheduledMailing < ApplicationRecord # records an email for immediate or later delivery. Use .send_now! or .send_later! methods to schedule mails. serialize :arguments, type: Array, coder: YAML VALID_STATUSES = [ "waiting", # record has been written, but mail not yet sent by ScheduledMailingsDeliveryJ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/regular_transaction.rb
Ruby
mit
19
main
727
class RegularTransaction < ApplicationRecord FREQUENCIES = %w[weekly two_weekly four_weekly monthly three_monthly].freeze belongs_to :legal_aid_application belongs_to :transaction_type validates :amount, currency: { greater_than: 0 } validates :frequency, inclusion: { in: ->(transaction) { frequencies_for(t...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/benefit_check_result.rb
Ruby
mit
19
main
257
class BenefitCheckResult < ApplicationRecord belongs_to :legal_aid_application POSITIVE_RESULT = "yes".freeze def positive? result.to_s.downcase == POSITIVE_RESULT end def failure? result.to_s.downcase.start_with?("failure:") end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/transaction_type.rb
Ruby
mit
19
main
2,239
class TransactionType < ApplicationRecord default_scope { order(:sort_order) } # Note that names should be unique across the whole of NAMES - so both credit and debit NAMES = { credit: %i[ benefits excluded_benefits housing_benefit friends_or_family maintenance_in property...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/true_layer_bank.rb
Ruby
mit
19
main
989
# frozen_string_literal: true class TrueLayerBank < ApplicationRecord serialize :banks, type: Array, coder: YAML scope :by_updated_at, -> { order(updated_at: :asc) } before_validation :populate_banks validates :banks, presence: true MOCK_BANK = { provider_id: "mock", display_name: "Mock Bank", ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/dependant.rb
Ruby
mit
19
main
1,464
class Dependant < ApplicationRecord default_scope { order(number: :asc) } belongs_to :legal_aid_application DEFAULT_VALUES = { in_full_time_education: false, relationship: "child_relative", monthly_income: 0.0, assets_value: 0.0, }.freeze enum :relationship, { child_relative: "child_rel...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/bank_provider.rb
Ruby
mit
19
main
441
class BankProvider < ApplicationRecord belongs_to :applicant has_many :bank_account_holders, dependent: :destroy has_many :bank_accounts, dependent: :destroy has_one :main_account_holder, -> { order created_at: :desc }, class_name: "BankAccountHolder", inverse_of: :bank_provider, dependent: :destroy has_one...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/admin_user.rb
Ruby
mit
19
main
541
class AdminUser < ApplicationRecord encrypts :auth_subject_uid, deterministic: true devise( :database_authenticatable, :trackable, :lockable, authentication_keys: [:username], unlock_strategy: :time ) def self.from_omniauth(auth) # Find by auth.uid if admin has previously logged in with entra, els...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/final_hearing.rb
Ruby
mit
19
main
237
class FinalHearing < ApplicationRecord belongs_to :proceeding enum :work_type, { substantive: 0, emergency: 1 } scope :emergency, -> { where(work_type: :emergency) } scope :substantive, -> { where(work_type: :substantive) } end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/hmrc/response.rb
Ruby
mit
19
main
1,173
module HMRC class Response < ApplicationRecord self.table_name = "hmrc_responses" after_update :persist_employment_records, unless: :submission_started? USE_CASES = %w[one two].freeze belongs_to :legal_aid_application, inverse_of: :hmrc_responses belongs_to :owner, polymorphic: true validate...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/legal_framework/submission.rb
Ruby
mit
19
main
222
module LegalFramework class Submission < ApplicationRecord belongs_to :legal_aid_application has_many :submission_histories, -> { order(created_at: :asc) }, inverse_of: :submission, dependent: :destroy end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/legal_framework/serializable_merits_task.rb
Ruby
mit
19
main
989
module LegalFramework class SerializableMeritsTask attr_reader :name, :state, :dependencies def initialize(name, dependencies: []) @name = name @dependencies = dependencies @state = @dependencies.any? ? :waiting_for_dependency : :not_started end def remove_dependency(dependency_nam...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/legal_framework/serializable_merits_task_list.rb
Ruby
mit
19
main
2,863
module LegalFramework class SerializableMeritsTaskList attr_reader :tasks SAFE_SERIALIZABLE_CLASSES = [Symbol, SerializableMeritsTaskList, SerializableMeritsTask].freeze def initialize(lfa_response) @lfa_response = lfa_response @tasks = { application: [], proceedings: {} } serialize_a...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/legal_framework/merits_task_list.rb
Ruby
mit
19
main
1,641
module LegalFramework class MeritsTaskList < ApplicationRecord belongs_to :legal_aid_application def task_list @task_list ||= SerializableMeritsTaskList.new_from_serialized(serialized_data) end def mark_as_complete!(group, task) task_list.mark_as_complete!(group, task) self.seriali...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/special_children_act_state_machine.rb
Ruby
mit
19
main
1,138
class SpecialChildrenActStateMachine < NonMeansTestedStateMachine def case_add_requestor CCMS::Requestors::SpecialChildrenActCaseAddRequestor end aasm do state :merits_parental_responsibilities state :merits_parental_responsibilities_all_rejected event :provider_recording_parental_responsibiliti...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/ccms_submission_state_machine.rb
Ruby
mit
19
main
3,372
module CCMSSubmissionStateMachine extend ActiveSupport::Concern def awaiting_lead_case_submission? return false if legal_aid_application.lead_application.nil? || legal_aid_application.lead_application&.ccms_submission&.aasm_state.in?(%w[case_created completed]) true end included do include ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/binary_choice_form.rb
Ruby
mit
19
main
1,207
class BinaryChoiceForm include ActiveModel::Model validate :input_present? class << self def call(journey:, radio_buttons_input_name:, action: :show, form_params: nil, error: nil) attr_accessor radio_buttons_input_name.to_sym define_input_conditional(radio_buttons_input_name, form_params) if fo...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/non_passported_state_machine.rb
Ruby
mit
19
main
3,747
class NonPassportedStateMachine < BaseStateMachine def case_add_requestor CCMS::Requestors::NonPassportedCaseAddRequestor end aasm do state :provider_confirming_applicant_eligibility state :awaiting_applicant state :applicant_entering_means state :checking_citizen_answers state :analysing...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/cfe_submission_state_machine.rb
Ruby
mit
19
main
4,572
module CFESubmissionStateMachine extend ActiveSupport::Concern included do include AASM aasm do state :initialised, initial: true state :assessment_created state :proceeding_types_created state :applicant_created state :capitals_created state :vehicles_created sta...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/delegated_functions.rb
Ruby
mit
19
main
1,007
module DelegatedFunctions def used_delegated_functions? proceedings.any?(&:used_delegated_functions?) end def non_sca_used_delegated_functions? used_delegated_functions? && !special_children_act_proceedings? end def used_delegated_functions_on earliest_delegated_functions_date end def used_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/capital.rb
Ruby
mit
19
main
495
module Capital def positive? amount_attributes.values.any? { |v| v.present? && v.positive? } end def amount_attributes shared_attributes.except("partner_offline_current_accounts", "partner_offline_savings_accounts", "joint_offline_current_accounts", "joint_offline_savings_accounts") end def shared_a...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/passported_state_machine.rb
Ruby
mit
19
main
1,470
class PassportedStateMachine < BaseStateMachine def case_add_requestor CCMS::Requestors::CaseAddRequestor end aasm do state :provider_entering_means state :checking_passported_answers event :provider_enter_means do transitions from: %i[ applicant_details_checked ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/base_state_machine.rb
Ruby
mit
19
main
7,121
class BaseStateMachine < ApplicationRecord self.table_name = "state_machine_proxies" belongs_to :legal_aid_application delegate :non_means_tested?, to: :legal_aid_application def allow_ccms_submission? EnableCCMSSubmission.call || ENV.fetch("LOCAL_CCMS_OVERRIDE", "false") == "true" end def log_status...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/non_means_tested_state_machine.rb
Ruby
mit
19
main
743
class NonMeansTestedStateMachine < BaseStateMachine def case_add_requestor CCMS::Requestors::NonMeansTestedCaseAddRequestor end # The following methods override events that are not applicable for a # non-means-tested journey but which, nonetheless, must be responded to when calls # are made to legal_aid_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/concerns/reviewable/model.rb
Ruby
mit
19
main
1,149
module Reviewable module Model def self.included(base) base.class_eval do store :reviewed, coder: JSON end end def review_in_progress!(reviewable_name) reviewed[reviewable_name] = { status: "in_progress", at: Time.current } save! end def review_completed!(reviewab...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/submission.rb
Ruby
mit
19
main
551
module CFE class Submission < ApplicationRecord include CFESubmissionStateMachine belongs_to :legal_aid_application has_many :submission_histories, -> { order(created_at: :asc) }, inverse_of: :submission has_one :result, class_name: "BaseResult", dependent: :destroy delegate :passported?, :non_p...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/remarks.rb
Ruby
mit
19
main
1,804
module CFE class Remarks REASONS_WITHOUT_CATEGORIES = %i[residual_balance multi_benefit].freeze def initialize(hash) @hash = hash end def caseworker_review_required? @hash.present? end def review_reasons @review_reasons ||= populate_review_reasons end def review_c...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/remarked_transaction.rb
Ruby
mit
19
main
488
module CFE class RemarkedTransaction attr_reader :tx_id, :category def initialize(tx_id, category, reason) @tx_id = tx_id @category = category @reasons = [reason] end def update(tx_id, category, reason) raise ArgumentError, "Transaction Id mismatch" unless tx_id == @tx_id ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/base_result.rb
Ruby
mit
19
main
6,049
module CFE class BaseResult < ApplicationRecord belongs_to :legal_aid_application belongs_to :submission MAX_VALUE = 999_999_999_999 self.table_name = "cfe_results" def result_hash return {} if result.nil? JSON.parse(result, symbolize_names: true) end def overview re...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/remarked_transaction_collection.rb
Ruby
mit
19
main
388
module CFE class RemarkedTransactionCollection attr_reader :transactions def initialize @transactions = {} end def update(tx_id, category, reason) if @transactions.key?(tx_id) @transactions[tx_id].update(tx_id, category, reason) else @transactions[tx_id] = RemarkedT...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/v3/result.rb
Ruby
mit
19
main
7,484
module CFE module V3 class Result < CFE::BaseResult def assessment_result return nil if result_hash[:assessment].nil? result_hash[:assessment][:assessment_result] end def capital_assessment_result capital[:assessment_result] end def capital_contribution_req...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/v4/result.rb
Ruby
mit
19
main
10,584
module CFE module V4 class Result < CFE::BaseResult def assessment_result return nil if result_summary.nil? overall_result[:result] end def overall_result result_summary[:overall_result] end def result_summary result_hash[:result_summary] end ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/v6/result.rb
Ruby
mit
19
main
11,069
module CFE module V6 class Result < CFE::V4::Result def gross_income_results gross_income_proceeding_types.pluck(:result) end def disposable_income_results disposable_income_proceeding_types.pluck(:result) end def capital_proceeding_types capital_summary[:pr...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/v1/result.rb
Ruby
mit
19
main
2,049
## Do not delete: This file is no longer in use but is needed for the single ## table inheritance table cfe_results to continue to function correctly. module CFE module V1 class Result < CFE::BaseResult def assessment_result result_hash[:assessment_result] end def income_contribution_re...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/empty/result.rb
Ruby
mit
19
main
9,327
module CFE module Empty class Result < CFE::BaseResult def assessment_result return nil if result_summary.nil? overall_result[:result] end def overall_result result_summary[:overall_result] end def result_summary CFE::Empty::EmptyResult.blank_cfe_re...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/empty/empty_result.rb
Ruby
mit
19
main
6,931
module CFE module Empty class EmptyResult def self.blank_cfe_result { version: "Empty", timestamp: Time.zone.now.iso8601, success: true, result_summary: { overall_result: { result: "no_assessment", capital_contribution: ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/cfe/v2/result.rb
Ruby
mit
19
main
8,141
## Do not delete: This file is no longer in use but is needed for the single ## table inheritance table cfe_results to continue to function correctly. module CFE module V2 class Result < CFE::BaseResult def assessment_result return nil if result_hash[:assessment].nil? result_hash[:assessmen...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/ccms/opponent_id.rb
Ruby
mit
19
main
725
module CCMS # This class is used to generate the next OPPONENT serial number in the CCMS payload for # opponents and involved children. There will only ever be one such record in the table. # class OpponentId < ApplicationRecord SERIAL_ID_SEQUENCE_START = 88_000_000 before_save :prevent_multiple_recor...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/ccms/submission.rb
Ruby
mit
19
main
2,201
module CCMS class Submission < ApplicationRecord include CCMSSubmissionStateMachine belongs_to :legal_aid_application has_many :submission_documents, dependent: :destroy has_many :submission_history, dependent: :destroy # rubocop:disable Rails/RedundantPresenceValidationOnBelongsTo validates...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/proceeding_merits_task/chances_of_success.rb
Ruby
mit
19
main
1,042
module ProceedingMeritsTask class ChancesOfSuccess < ApplicationRecord belongs_to :proceeding PRETTY_SUCCESS_PROSPECTS = { likely: "Likely", marginal: "Marginal", poor: "Poor", borderline: "Borderline", not_known: "Uncertain", }.freeze SUCCESS_RANKING = { likely: ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/proceeding_merits_task/proceeding_linked_child.rb
Ruby
mit
19
main
477
module ProceedingMeritsTask class ProceedingLinkedChild < ApplicationRecord self.table_name = :proceedings_linked_children belongs_to :proceeding belongs_to :involved_child, class_name: "ApplicationMeritsTask::InvolvedChild" validate :correct_involved_child def correct_involved_child error...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/application_merits_task/opponent.rb
Ruby
mit
19
main
915
module ApplicationMeritsTask class Opponent < ApplicationRecord include CCMSOpponentIdGenerator belongs_to :opposable, polymorphic: true, dependent: :destroy belongs_to :legal_aid_application scope :individuals, -> { where(opposable_type: "ApplicationMeritsTask::Individual") } scope :organisatio...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/application_merits_task/involved_child.rb
Ruby
mit
19
main
502
module ApplicationMeritsTask class InvolvedChild < ApplicationRecord include CCMSOpponentIdGenerator belongs_to :legal_aid_application def ccms_other_party_type "PERSON" end def ccms_relationship_to_case "CHILD" end def ccms_relationship_to_client "UNKNOWN" end ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/application_merits_task/statement_of_case.rb
Ruby
mit
19
main
386
module ApplicationMeritsTask class StatementOfCase < ApplicationRecord belongs_to :legal_aid_application belongs_to :provider_uploader, class_name: "Provider", optional: true def original_attachments legal_aid_application.attachments.statement_of_case end def pdf_attachments legal_ai...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/application_merits_task/individual.rb
Ruby
mit
19
main
560
module ApplicationMeritsTask class Individual < ApplicationRecord has_one :opponent, as: :opposable, dependent: :destroy delegate :generate_ccms_opponent_id, :ccms_opponent_id, to: :opponent def ccms_other_party_type "PERSON" end def ccms_relationship_to_case "OPP" end def ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/application_merits_task/organisation.rb
Ruby
mit
19
main
535
module ApplicationMeritsTask class Organisation < ApplicationRecord has_one :opponent, as: :opposable, dependent: :destroy delegate :generate_ccms_opponent_id, :ccms_opponent_id, to: :opponent def ccms_other_party_type "ORGANISATION" end def ccms_relationship_to_case "OPP" end ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/models/citizen/access_token.rb
Ruby
mit
19
main
515
module Citizen class AccessToken < ApplicationRecord EXPIRES_AFTER_IN_DAYS = 8 self.table_name = "citizen_access_tokens" belongs_to :legal_aid_application encrypts :token, deterministic: true validates :expires_on, comparison: { greater_than: ->(_record) { Date.current } } def self.genera...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/validators/document_category_validator.rb
Ruby
mit
19
main
2,048
# This validator has three uses: # - to be a single source of truth for the valid attachment types / document category names # - to validate the attachment_type field on Attachment model # - to validate the name field on the DocumentCategory model # class DocumentCategoryValidator < ActiveModel::Validator # these nam...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/validators/currency_validator.rb
Ruby
mit
19
main
1,377
class CurrencyValidator < ActiveModel::Validations::NumericalityValidator ONLY_2_DECIMALS_PATTERN = /(\A-?[0-9]+\z)|(\A-?[0-9]*\.[0-9]{,2}\z)/ def validate_each(record, attr_name, value) clean_value = clean_numeric_value(value) super(record, attr_name, clean_value) # this requires the actual attribute symb...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/validators/date_time_validator.rb
Ruby
mit
19
main
1,090
# this takes care of validating datetime fields before rails gets there and # messes everything up. it should preserve the local time zone from the user input # this goes in the model # validates :attribute_name, date_time: true # or # validates :attribute_name, date_time: ->(field) { object.send(field).present? }...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/validators/date_validator.rb
Ruby
mit
19
main
1,961
class DateValidator < ActiveModel::EachValidator DEFAULT_FORMAT = "%Y-%m-%d".freeze DEFAULT_EARLIEST_DATE = "1900-01-01".freeze def validate_each(record, attribute, value) value = parse_date(value, options[:format]) if value.is_a?(String) return unless valid_date?(record, attribute, value) validate_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/validators/presence_partner_optional_validator.rb
Ruby
mit
19
main
295
class PresencePartnerOptionalValidator < ActiveModel::Validations::PresenceValidator def validate_each(record, attr_name, value) key_name = record.send(options[:partner_labels]) ? :blank_with_partner : :blank record.errors.add(attr_name, key_name, **options) if value.blank? end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/validators/numericality_partner_optional_validator.rb
Ruby
mit
19
main
1,045
class NumericalityPartnerOptionalValidator < ActiveModel::Validations::NumericalityValidator def validate_each(record, attr_name, value) clean_value = clean_numeric_value(value) super(record, attr_name, clean_value) # this requires the actual attribute symbol, e.g. :cash replace_error_with_partner(record...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/builders/cash_transaction_json_builder.rb
Ruby
mit
19
main
378
class CashTransactionJsonBuilder < BaseJsonBuilder def as_json { id:, legal_aid_application_id:, amount:, transaction_date:, created_at:, updated_at:, month_number:, transaction_type_id:, transaction_type: TransactionTypeJsonBuilder.build(transaction_type).as_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/builders/legal_aid_application_json_builder.rb
Ruby
mit
19
main
6,164
class LegalAidApplicationJsonBuilder < BaseJsonBuilder def as_json { id:, application_ref:, created_at:, updated_at:, applicant_id:, has_offline_accounts:, open_banking_consent:, open_banking_consent_choice_at:, own_home:, property_value:, shared_o...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/builders/transaction_type_json_builder.rb
Ruby
mit
19
main
245
class TransactionTypeJsonBuilder < BaseJsonBuilder def as_json { id:, name:, operation:, created_at:, updated_at:, sort_order:, archived_at:, other_income:, parent_id:, } end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/builders/linked_application_json_builder.rb
Ruby
mit
19
main
274
class LinkedApplicationJsonBuilder < BaseJsonBuilder def as_json { id:, associated_application_id:, lead_application_id:, link_type_code:, target_application_id:, confirm_link:, created_at:, updated_at:, } end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/builders/employment_json_builder.rb
Ruby
mit
19
main
321
class EmploymentJsonBuilder < BaseJsonBuilder def as_json { id:, legal_aid_application_id:, owner_type:, owner_id:, name:, created_at:, updated_at:, employment_payments: employment_payments.map { |ep| EmploymentPaymentJsonBuilder.build(ep).as_json }, } end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/builders/schedule_json_builder.rb
Ruby
mit
19
main
345
class ScheduleJsonBuilder < BaseJsonBuilder def as_json { id:, office_id:, area_of_law:, category_of_law:, authorisation_status:, status:, start_date:, end_date:, cancelled:, license_indicator:, devolved_power_status:, created_at:, upda...