repo_name
stringlengths 6
97
| path
stringlengths 3
341
| text
stringlengths 8
1.02M
|
|---|---|---|
ipublic/marketplace
|
app/models/integrations/generate_notice.rb
|
class Integrations::GenerateNotice
include Mongoid::Document
end
|
ipublic/marketplace
|
spec/factories/notices_ui_lien_notices.rb
|
<reponame>ipublic/marketplace<gh_stars>0
FactoryBot.define do
factory :notices_ui_lien_notice, class: 'Notices::UiLienNotice' do
end
end
|
ipublic/marketplace
|
app/models/parties/person_name.rb
|
<filename>app/models/parties/person_name.rb
module Parties
class PersonName
include Mongoid::Document
embedded_in :person_party,
class_name: "Parties::PersonParty"
field :first_name, type: String
field :middle_name, type: String
field :last_name, type: String
field :name_pfx, type: String
field :name_sfx, type: String
field :start_date, type: Date
field :end_date, type: Date
end
end
|
ipublic/marketplace
|
spec/factories/financial_accounts_financial_accounts.rb
|
FactoryBot.define do
factory :financial_accounts_financial_account, class: 'FinancialAccounts::FinancialAccount' do
end
end
|
ipublic/marketplace
|
app/models/integrations/get_priority_mail_receipt.rb
|
<filename>app/models/integrations/get_priority_mail_receipt.rb<gh_stars>0
class Integrations::GetPriorityMailReceipt
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/determinations/group_health_insurance_eligibility_determination.rb
|
class Determinations::GroupHealthInsuranceEligibilityDetermination
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/determinations/individual_ui_liability_determination.rb
|
<filename>app/models/determinations/individual_ui_liability_determination.rb
class Determinations::IndividualUiLiabilityDetermination
include Mongoid::Document
end
|
ipublic/marketplace
|
spec/factories/subscriptions_features.rb
|
FactoryBot.define do
factory :subscriptions_feature, class: 'Subscriptions::Feature' do
end
end
|
ipublic/marketplace
|
spec/factories/sagas_sagas.rb
|
<filename>spec/factories/sagas_sagas.rb<gh_stars>0
FactoryBot.define do
factory :sagas_saga, class: 'Sagas::Saga' do
end
end
|
ipublic/marketplace
|
app/jobs/application_job.rb
|
<reponame>ipublic/marketplace
class ApplicationJob < ActiveJob::Base
before_enqueue do |job|
puts "Before job is enqueued"
end
after_enqueue do |job|
puts "After job is enqueued"
end
before_perform do |job|
puts "Before job is performed"
end
after_perform do |job|
puts "After job is performed"
end
def sneakers_worker_process
end
def publish_amqp_exchange_id
end
def publish_anqp_routing_key
end
def reply_to_amqp_exchange_id
end
def reply_to_amqp_queue_id
end
def reply_to_amqp_routing_key
end
def reply_to_amqp_queue_ttl
end
end
|
ipublic/marketplace
|
spec/factories/dispatcher_workers_echo_workers.rb
|
<gh_stars>0
FactoryBot.define do
factory :dispatcher_workers_echo_worker, class: 'Dispatcher::Workers::EchoWorker' do
end
end
|
ipublic/marketplace
|
app/models/integrations/get_offers_in_compromise.rb
|
<gh_stars>0
class Integrations::GetOffersInCompromise
include Mongoid::Document
end
|
ipublic/marketplace
|
config/initializers/dispatcher.rb
|
require 'sneakers'
require 'sneakers/metrics/logging_metrics'
# Mongoid extension to support GlobalID
# JSON adapter for
# config.acapi.publish_amqp_events = :log # or true in production env
# config.acapi.app_id = "enroll"
# ExchangeType
# Process
# RoutingSlip - has_many Tasks
# ID
# Task
# TaskHost
# Task
# AMQP TaskHost URI format
# scheme: "amqp"
# userinfo:
# host: "main??"
# port
# registry
# path: "exchange"
# opaque:
# query:
# fragment:
# EnterpriseService
# TaskHost
# ID
# AMQP Exchange
# AMQP Message Routing Key
# ReplyTo
# Expires (TTL)
# MIME type
########################
#### Configure AMQP ####
########################
# AMQP host connection information
# Well-known Services
# Logger
# Specify AMQP Topology for Enterprise PubSub
# AMQP Exchanges this component uses to publishes events
# AMQP Queues this component uses to subscribe to events
#### Start Services ####
# Start Redis
$redis = Redis.new
# Start Bunny
# Start Sneakers Workers
# You can use Worker YAML Config File
# Specify an ENV WORKER_GROUP_CONFIG as a path to YAML file (or by convention ./config/sneaker_worker_groups.yml)
# bundle exec ruby -e "require 'sneakers/spawner';Sneakers::Spawner.spawn"
# File Stucture
# foogroup:
# classes: FooWorker
# workers: 8
# slowgroup:
# classes: SlowWorker
# workers: 2
# You can use Bunny connection to AMQP server as it's far more efficient than
# Sneakers default where each worker opens its own connection
# Sneakers.configure :connection => Bunny.new(…)
# Initialize Sneakers Workers
# include ::Sneakers::WorkerGroup
# Daemon
# :runner_config_file => nil, # A configuration file (see below)
# :metrics => nil, # A metrics provider implementation
# :daemonize => true, # Send to background
# :start_worker_delay => 0.2, # When workers do frenzy-die, randomize to avoid resource starvation
# :workers => 4, # Number of per-cpu processes to run
# :log => 'sneakers.log', # Log file
# :pid_path => 'sneakers.pid', # Pid file
# Workers
# :timeout_job_after => 5, # Maximal seconds to wait for job
# :prefetch => 10, # Grab 10 jobs together. Better speed.
# :threads => 10, # Threadpool size (good to match prefetch)
# :env => ENV['RACK_ENV'], # Environment
# :durable => true, # Is queue durable?
# :ack => true, # Must we acknowledge?
# :heartbeat => 2, # Keep a good connection with broker
# :exchange => 'sneakers', # AMQP exchange
# :hooks => {} # prefork/postfork hooks
# :start_worker_delay => 10 # Delay between thread startup
# Local (per worker)
# class ProfilingWorker
# include Sneakers::Worker
# from_queue 'downloads',
# :env => 'test',
# :durable => false,
# :ack => true,
# :threads => 50,
# :prefetch => 50,
# :timeout_job_after => 1,
# :exchange => 'dummy',
# :heartbeat => 5
# def work(msg)
# ack!
# end
# end
# opts = {
# :amqp => 'CLOUDAMQP_URL',
# :vhost => 'username',
# :exchange => 'sneakers',
# :exchange_type => :direct
# }
# Sneakers.configure(opts)
# Autoscaling
# workers 2
# before_fork do
# Sneakers::logger.info "I'm in a child process!"
# end
# after_fork do
# Sneakers::logger.info " I'm in a child process!"
# end
Sneakers.configure(
# daemonize: true,
heartbeat: 10,
log: 'log/sneakers.log',
metrics: Sneakers::Metrics::LoggingMetrics.new,
retry_exchange: 'activejob-retry',
retry_error_exchange: 'activejob-error',
retry_requeue_exchange: 'activejob-retry-requeue'
)
Sneakers.logger.level = Logger::INFO
# Start this using something like:
# WORKERS=ActiveJob::QueueAdapters::SneakersAdapter::JobWrapper rake sneakers:run
#### Configure ActiveJob ####
# Set Sneakers as ActiveJob Queue Adapter
Rails.application.config.active_job.queue_adapter = :sneakers
|
ipublic/marketplace
|
spec/factories/products_products.rb
|
FactoryBot.define do
factory :products_product, class: 'Products::Product' do
end
end
|
ipublic/marketplace
|
app/models/products/individual_health_insurance.rb
|
<filename>app/models/products/individual_health_insurance.rb
class Products::IndividualHealthInsurance
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/parties/party_relationship.rb
|
module Parties
class PartyRelationship
include Mongoid::Document
include Mongoid::Timestamps
# embedded_in :party_role,
# class_name: "Parties::PartyRole"
belongs_to :party_relationship_kind,
class_name: 'Parties::PartyRelationshipKind'
has_many :party_roles,
class_name: 'Parties::PartyRole'
# field :related_party_id, type: BSON::ObjectId
# field :party_relationship_kind_id, type: BSON::ObjectId
# Begin date for this relationship
field :start_date, type: Date, default: ->{ TimeKeeper.date_of_record }
# End date for this relationship
field :end_date, type: Date
# embeds_one :party_relationship_kind,
# class_name: "Parties::PartyRelationshipKind"
delegate :key, to: :party_relationship_kind
delegate :title, to: :party_relationship_kind
delegate :description, to: :party_relationship_kind
delegate :party_relationships, to: :party_relationship_kind
# delegate :eligibility_policy, to: :party_role_kind, allow_nil: true
# validates_presence_of :party_relationship_kind_id, :related_party_id
validate :party_role_pairing
validates_presence_of :party_relationship_kind
def is_active?
end_date.blank? || end_date > TimeKeeper.date_of_record
end
# def related_party=(new_related_party)
# if new_related_party.nil?
# write_attribute(:related_party_id, nil)
# else
# raise ArgumentError.new("expected Parties::Party") unless new_related_party.is_a? Partys::BenefitApplication
# write_attribute(:related_party_id, new_related_party._id)
# end
# @related_party = new_related_party
# end
# def related_party
# return nil if related_party_id.blank?
# return @related_party if defined? @related_party
# @related_party = benefit_sponsorship.benefit_applications_by(related_party_id)
# end
# def party_relationship_kind=(new_party_relationship_kind)
# if new_party_relationship_kind.nil?
# write_attribute(:party_relationship_kind_id, nil)
# else
# raise ArgumentError.new("expected Parties:PartyRelationshipKind") unless new_party_relationship_kind.is_a? Parties:PartyRelationshipKind
# write_attribute(:party_relationship_kind_id, new_party_relationship_kind._id)
# end
# @party_relationship_kind = new_party_relationship_kind
# end
# def party_relationship_kind
# return nil if party_relationship_kind_id.blank?
# return @party_relationship_kind if defined? @party_relationship_kind
# @party_relationship_kind = Parties:PartyRelationshipKind.find(party_relationship_kind_id)
# end
private
def party_role_pairing
errors.add(:party_roles, "must provide a specific role pair") unless party_roles.size == 2
end
end
end
|
ipublic/marketplace
|
app/models/financial_accounts/financial_transaction_kind.rb
|
<filename>app/models/financial_accounts/financial_transaction_kind.rb
class FinancialAccounts::FinancialTransactionKind
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/determinations/pfl_contribution_rate_determination.rb
|
class Determinations::PflContributionRateDetermination
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/integrations/ui_iceasa.rb
|
# ICESA Record format used by DC DOES Unemployment Insurance group
module Integrations
class UiIceasa
include Mongoid::Document
def dsl
# Record Length: 275 chars
# Deliminiators: CRLF (0D0A in hex) at end of each record - positions 276 & 277
Slither.define :simple, :by_bytes => false do |d|
d.template :address do |t|
t.field :name, length: 50, type: :string, required: true
t.field :street_address, length: 40, type: :string, required: true
t.field :city, length: 25, type: :string, required: true
t.field :state, length: 2, type: :string, required: true
end
d.template :zip_code do |t|
t.field :zip_code, length: 5, type: :string, required: true
t.field :zip_extension, length: 5, type: :string, required: false # include hyphen in position 159
end
d.template :phone do |t|
t.field :contact_phone, length: 10, type: :string, required: true
t.field :contact_phone_ext, length: 4, type: :string, required: true
end
# Record types
# Transmitter
d.transmitter do |transmitter|
transmitter.field :record_id, length: 1, type: :string, required: true, default: 'A' # constant
transmitter.field :year, length: 4, type: :integer, required: true # CCYY
transmitter.field :transmitter_fein, length: 9, type: :integer, required: true
transmitter.field :taxing_entity_code, length: 4, type: :string, required: true, default: 'UTAX' # constant
transmitter.field :spacer, length: 5
transmitter.template :address
transmitter.field :spacer, length: 13
transmitter.template :zip_code
transmitter.field :transmitter_contact, length: 30, type: :string, required: true
transmitter.field :transmitter_contact_phone, length: 10, type: :string, required: true
transmitter.field :transmitter_contact_phone_ext, length: 4, type: :string, required: true
transmitter.field :media_transmittter_auth_nbr, length: 6, type: :string, required: false
transmitter.field :c3_data, length: 1, type: :string, required: false
transmitter.field :suffix_code, length: 5, type: :string, required: false
transmitter.field :allocation_lists, length: 1, type: :string, required: false
transmitter.field :service_agent_id, length: 9, type: :string, required: false
transmitter.field :total_remittance_amount, length: 13, type: :string, required: false
transmitter.field :media_creation_date, length: 8, type: :string, required: true # MMDDYYYY
transmitter.field :spacer, length: 25
end
# Authorization
d.authorization do |authorization|
authorization.field :record_id, length: 1, type: :string, required: true, default: 'B' # constant
end
# Employer
d.employer do |employer|
employer.field :record_id, length: 1, type: :string, required: true, default: 'E' # constant
employer.field :payment_year, length: 4, type: :integer, required: true # CCYY
employer.field :fein, length: 9, type: :integer, required: true
employer.field :spacer, length: 9
employer.template :address
employer.field :spacer, length: 8
employer.template :zip_code
employer.field :spacer, length: 1
employer.field :type_of_employment, length: 1, type: :string, required: false
employer.field :blocking_factor, length: 1, type: :string, required: false
employer.field :establishment_nbr_or_coverage_group_pru, length: 1, type: :string, required: false
employer.field :taxing_entity_code, length: 4, type: :string, required: true, default: 'UTAX' # constant
employer.field :state_identifier_code, length: 2, type: :string, required: true, default: '11' # DC = 11
employer.field :state_unemployment_insurance_account_nbr, length: 15, type: :string, required: true # left justify with trailing spaces
employer.field :reporting_period, length: 2, type: :string, required: true
employer.field :no_workers_no_wages, length: 1, type: :string, required: true
employer.field :tax_type_code, length: 1, type: :string, required: false
employer.field :other_taxing_entity_code, length: 5, type: :string, required: false
employer.field :state_control_number, length: 7, type: :string, required: false
employer.field :unit_number, length: 5, type: :string, required: false
employer.field :spacer, length: 47
employer.field :foreign_indicator, length: 1, type: :string, required: true
employer.field :spacer, length: 1
employer.field :other_ein, length: 9, type: :string, required: false
employer.field :spacer, length: 9
end
# Employees
d.employees do |employee|
employee.field :record_id, length: 1, type: :string, required: true, default: 'S' # constant
employee.field :social_security_nbr, length: 1, type: :string, required: true
employee.field :last_name, length: 1, type: :string, required: true
employee.field :first_name, length: 1, type: :string, required: true
employee.field :middle_initial, length: 1, type: :string, required: true
employee.field :state_identifier_code, length: 2, type: :string, required: true, default: '11' # DC = 11
employee.field :spacer, length: 4
employee.field :state_qtr_total_gross_wages, length: 2, type: :money, required: false
employee.field :state_qtr_unemployment_insurance_total_wages, length: 2, type: :money, required: true
employee.field :state_qtr_unemployment_insurance_excess_wages, length: 2, type: :money, required: true
employee.field :state_qtr_unemployment_insurance_taxable_wages, length: 2, type: :money, required: true
employee.field :quarterly_state_disability_insurance_taxable_wages, length: 2, type: :money, required: false
employee.field :quarteraly_tip_wages, length: 2, type: :money, required: false
employee.field :nbr_of_weeks_worked, length: 2, type: :string, required: false
employee.field :nbr_of_hours_worked, length: 2, type: :string, required: false
employee.field :spacer, length: 4
employee.field :taxing_entity_code, length: 4, type: :string, required: true, default: 'UTAX' # constant
employee.field :state_unemployment_insurance_account_nbr, length: 15, type: :string, required: true
employee.field :unit_division_location_plant_code, length: 15, type: :string, required: false
employee.field :state_taxable_wages, length: 14, type: :money, required: false
employee.field :state_income_tax_withheld, length: 14, type: :money, required: false
employee.field :seasonal_indicator, length: 2, type: :string, required: false
employee.field :employee_health_insurance_code, length: 1, type: :string, required: false
employee.field :employer_health_insurance_code, length: 1, type: :string, required: false
employee.field :probationary_code, length: 1, type: :string, required: false
employee.field :officer_code, length: 1, type: :string, required: false
employee.field :wage_plan_code, length: 1, type: :string, required: false
employee.field :month_1_employment, length: 1, type: :string, required: false
employee.field :month_2_employment, length: 1, type: :string, required: false
employee.field :month_3_employment, length: 1, type: :string, required: false
employee.field :reporting_quarter_and_year, length: 6, type: :string, required: true
employee.field :date_first_employed, length: 6, type: :string, required: false
employee.field :date_of_separation, length: 6, type: :string, required: false
employee.field :spacer, length: 43
end
# Total
d.total do |total|
total.field :record_id, length: 1, type: :string, required: true, default: 'T' # constant
total.field :total_nbr_of_employees, length: 7, type: :integer, required: true
total.field :taxing_entity_code, length: 4, type: :string, required: true, default: 'UTAX' # constant
total.field :state_qtr_total_gross_wages_for_employer, length: 14, type: :money, required: true
total.field :state_qtr_unemployment_insurance_total_wages_for_employer, length: 14, type: :money, required: true
total.field :state_qtr_unemployment_insurance_excess_wages_for_employer, length: 14, type: :money, required: true
total.field :state_qtr_unemployment_insurance_taxable_wages_for_employer, length: 14, type: :money, required: true
total.field :quarteraly_tip_wages_for_employer, length: 13, type: :integer, required: false
total.field :ui_tax_rate_this_quarter, length: 6, type: :percent, required: true
total.field :state_qtr_ui_taxes_due, length: 13, type: :string, required: true
total.field :previous_quarters_underpayment, length: 11, type: :string, required: true
total.field :interest, length: 11, type: :string, required: true
total.field :penalty, length: 11, type: :string, required: true
total.field :credit_overpayment, length: 11, type: :string, required: false
total.field :employer_assesstment_rate, length: 5, type: :percent, required: false
total.field :employer_assessment_amount, length: 11, type: :string, required: true
total.field :employee_assessment_rate, length: 4, type: :string, required: false
total.field :employee_assessment_amount, length: 11, type: :string, required: false
total.field :total_remittance_amount, length: 11, type: :string, required: true
total.field :allocation_amount, length: 13, type: :string, required: false
total.field :wages_subject_to_state_income_tax, length: 14, type: :string, required: false
total.field :state_income_tax_withheld, length: 14, type: :string, required: false
total.field :month_1_employment_for_employer, length: 7, type: :integer, required: true
total.field :month_2_employment_for_employer, length: 7, type: :integer, required: true
total.field :month_3_employment_for_employer, length: 7, type: :integer, required: true
total.field :county_code, length: 3, type: :string, required: false
total.field :outside_county_employees, length: 7, type: :string, required: false
total.field :document_control_number, length: 10, type: :string, required: false
total.field :spacer, length: 8
end
# Final
d.final do |final|
final.field :record_id, length: 1, type: :string, required: true, default: 'F' # constant
end
end
end
end
end
|
ipublic/marketplace
|
spec/factories/parties_person_parties.rb
|
FactoryBot.define do
factory :parties_person_party, class: 'Parties::PersonParty' do
end
end
|
ipublic/marketplace
|
spec/factories/financial_accounts_financial_transactions.rb
|
FactoryBot.define do
factory :financial_accounts_financial_transaction, class: 'FinancialAccounts::FinancialTransaction' do
end
end
|
ipublic/marketplace
|
spec/factories/fees_administrative_fees.rb
|
FactoryBot.define do
factory :fees_administrative_fee, class: 'Fees::AdministrativeFee' do
end
end
|
ipublic/marketplace
|
app/models/subscriptions/subscribe.rb
|
<reponame>ipublic/marketplace
module Subscriptions
class Subscribe
include EventSource::Command
# Attributes to track in the event and update the model
attributes :tenant_id, :feature_id, :metadata
private
# Use #build_event to hook into event source framework
def build_event
Subscribed.new(
tenant_id: tenant_id,
feature_id: feature_id,
metadata: metadata
)
end
end
end
|
ipublic/marketplace
|
spec/factories/wages_nonexempt_wage_entries.rb
|
FactoryBot.define do
factory :wages_nonexempt_wage_entry, class: 'Wages::NonexemptWageEntry' do
end
end
|
ipublic/marketplace
|
spec/factories/taxes_paid_family_leave_taxes.rb
|
<gh_stars>0
FactoryBot.define do
factory :taxes_paid_family_leave_tax, class: 'Taxes::PaidFamilyLeaveTax' do
end
end
|
ipublic/marketplace
|
app/models/dispatcher/tasks/edi_rx_task.rb
|
class Dispatcher::Tasks::EdiRxTask
include Mongoid::Document
end
|
ipublic/marketplace
|
spec/factories/dispatcher_activities_group_terminate_activities.rb
|
FactoryBot.define do
factory :dispatcher_activities_group_terminate_activity, class: 'Dispatcher::Activities::GroupTerminateActivity' do
end
end
|
ipublic/marketplace
|
app/models/employers/employer_factory.rb
|
module Employers
class EmployerFactory
def self.call(contact_info:, employer_info:, address_info:)
employer = Parties::OrganizationParty.new(legal_name: employer_info.legal_name, fein: employer_info.fein, entity_kind: employer_info.kind.to_sym, is_foreign_entity: false)
contact = Parties::PersonParty.new(current_first_name: contact_info.first_name, current_last_name: contact_info.last_name)
employer.addresses.build address_info.attributes.except(:area_code, :number, :extension)
relationship_party = Roles::RelationshipRoleFactory.new(contact, :contact, :organization_ui_primary_contact, employer).party
if Parties::PartyRoleKind.is_valid_key?(employer_info.kind.to_sym)
role = Roles::RoleFactory.new(employer, employer_info.kind.to_sym).party_role
end
financial_account = FinancialAccounts::FinancialAccountFactory.call(employer, account_kind: :ui_financial_account, initial_liability_date: Date.parse(employer_info.date_of_first_wages))
#employee_party_role = Parties::PartyRole.new(party_role_kind: employee_party_role_kind, role_castable: employer)
#employee.add_party_role(employee_party_role)
[contact, employer, employer.party_ledger, relationship_party, role, financial_account].compact
end
def self.contact_role_kind
@employee_party_role_kind ||= Parties::PartyRoleKind.find_by!(key: :contact)
end
def self.party_relationship_kind
@employment_party_relationship_kind ||= Parties::PartyRelationshipKind.find_by!(key: :organization_ui_primary_contact)
end
end
end
|
ipublic/marketplace
|
spec/factories/fees_interest_fees.rb
|
FactoryBot.define do
factory :fees_interest_fee, class: 'Fees::InterestFee' do
end
end
|
ipublic/marketplace
|
app/models/wages/wage_report_factory.rb
|
module Wages
class WageReportFactory
attr_accessor :wage_report, :current_report
def self.call(organization_party, report_timespan, args)
new(organization_party, args).wage_report
end
def initialize
@organization_party = organization_party
@wage_report = organization_party.wage_reports.new
@wage_report_template = nil
@ui_contribution_report_determination = @organization_party.ui_contribution_report_determination_for(report_timespan)
# assign_wage_report_attributes(args)
find_wage_report_template
populate_wage_entries
end
def self.set_current_report(report)
@current_report = report
end
def self.get_current_report
@current_report
end
def self.amend(report, params)
cloned_report = report.clone
if params[:wages_wage_report][:new_wage_entry][:person_first_name].present?
add_entries(cloned_report, params)
else
wage_entry_ids = cloned_report.wage_entries.map(&:_id)
wage_entry_ids.each do |id|
if params[:wages_wage_report][:wage_entries][id.to_s]
update_clone(id,cloned_report, params[:wages_wage_report][:wage_entries][id.to_s])
end
end
end
end
def self.add_entries(report, params)
if params[:commit] == "Add Entry"
submission_kind = :original
amend_reason = "Original"
report_submission_kind = :original
else
submission_kind = :amended
amend_reason = params[:amend_reason]
report_submission_kind = :amended
end
wage_params = params[:wages_wage_report][:new_wage_entry]
gross_wages = wage_params[:state_total_gross_wages]
person = Parties::PersonParty.create!(
current_first_name: wage_params[:person_first_name],
current_last_name: wage_params[:person_last_name],
ssn: wage_params[:ssn])
report.update_attributes(submission_kind: report_submission_kind)
entry = report.wage_entries.new(submission_kind: submission_kind, submitted_at: Time.now, amend_reason: amend_reason)
entry.wage = Wages::Wage.new(
person_party_id: person.id,
timespan_id: report.timespan.id,
state_total_gross_wages: gross_wages,
state_excess_wages: Wages::Wage.new.sum_excess_wages(gross_wages),
state_taxable_wages: Wages::Wage.new.sum_taxable_wages(gross_wages),
state_total_wages: gross_wages
)
entry.save
report.save
if params[:commit] == "Add Entry"
set_current_report(report)
else
set_current_report(nil)
end
end
def self.update_clone(id,cloned_report, wage_params)
entry = cloned_report.wage_entries.find(id)
wage = entry.wage
entry.update_attributes!(
amend_reason: wage_params[:amend_reason]
)
entry.save!
wage.update_attributes!(
state_total_gross_wages: wage_params[:wage][:state_total_gross_wages] || 0
)
cloned_report.update_attributes(submission_kind: :amended,
submitted_at: Time.now.to_date,
state_total_gross_wages: cloned_report.sum_state_total_wages,
state_ui_excess_wages: cloned_report.sum_state_excess_wages,
state_ui_taxable_wages: cloned_report.sum_state_taxable_wages,
)
cloned_report.save!
end
def self.create_report_and_add_entries(params)
if @current_report
add_entries(@current_report, params)
else
party = Parties::OrganizationParty.find(params[:employer_id])
span = Timespans::Timespan.current_timespan
report = Wages::WageReport.create!(
organization_party: party,
timespan: span,
submission_kind: :original,
filing_method_kind: :manual_entry,
status: :submitted,
state_total_gross_wages: 0,
state_ui_taxable_wages: 0,
ui_total_due: 0,
submitted_at: Time.now,
state_ui_total_wages:0 ,
state_ui_excess_wages: 0,
ui_paid_amount: 0,
ui_tax_amount: 0,
ui_amount_due: 0,
total_employees: 0)
add_entries(report, params)
end
end
def assign_wage_report_attributes(args)
args.each_pair do |k, v|
@wage_report.send("#{k}=".to_sym, v)
end
end
# Any factors necessary here?
def assign_wage_report_ui_contribution_factors
end
def populate_wage_entries
# Build subclasses
clone_from_wage_report_template
end
def build_original_report_wage_entries
# Build from prior time period template or from scratch (empty)
end
def build_ammended_report_submission_kind
# Build from same time period template
end
def find_wage_report_template
same_timespan_wage_report || preceding_timespan_wage_report
end
def same_timespan_wage_report
wage_report_list = Wages::WageReports.where(organization_party: organization_party, timespan: report_timespan).order(submitted_at: desc).entries
if wage_report_list.size > 0
@wage_report.submission_kind = :ammended
@wage_report_template = wage_report_list.first
else
nil
end
end
def preceding_timespan_wage_report
wage_report_list = Wages::WageReports.where(organization_party: organization_party, timespan: report_timespan.predecessor).order(submitted_at: desc).entries
if wage_report_list.size > 0
@wage_report.submission_kind = :original
@wage_report_template = wage_report_list.first
else
nil
end
end
def clone_from_wage_report_template
end
def self.validate(wage_report)
# TODO: Add validations
true
end
end
end
|
ipublic/marketplace
|
spec/factories/products_unemployment_insurances.rb
|
<reponame>ipublic/marketplace
FactoryBot.define do
factory :products_unemployment_insurance, class: 'Products::UnemploymentInsurance' do
end
end
|
ipublic/marketplace
|
app/models/permission.rb
|
<reponame>ipublic/marketplace
class Permission
include Mongoid::Document
embeds_many :filter_tokens
field :role_name, type: String
end
|
ipublic/marketplace
|
db/seedfiles/bakery_cupcake_seed.rb
|
<gh_stars>0
puts "*"*80
puts "Populating Bakery Cupcake Data"
puts "*"*80
cupcake_count = 50_000
# cupcake_count = 50
cupcake_collection_name = "bakery_cupcakes"
cupcake_collection = Mongoid.default_client.collections.select { |col| col.name == cupcake_collection_name }
if cupcake_collection.present?
puts " Dropping existing collection: #{cupcake_collection_name}"
cupcake_collection.drop
else
puts " Initializing collection: #{cupcake_collection_name}"
end
puts " Seeding #{cupcake_count} Cupcake records"
(0..(cupcake_count - 1)).each { |count| Bakery::CupcakeFactory.call(cc_id: count).save! }
puts ""
puts "End of Cupcake seed"
puts "*"*80
|
ipublic/marketplace
|
db/seeds.rb
|
<reponame>ipublic/marketplace<filename>db/seeds.rb
puts "*"*80
puts "Purging Database and Removing Indexes"
system "rake db:mongoid:purge"
system "rake db:mongoid:remove_indexes"
puts "*"*80
puts "*"*80
puts "Start of seed data"
puts "*"*80
puts "*"*80
puts "Loading Timespans"
# (Timespans::YEAR_MINIMUM..Timespans::YEAR_MAXIMUM).map { |year| Timespans::CalendarYearTimespan.create(year) }
(1980..2030).map { |year| Timespans::CalendarYearTimespan.create(year: year) }
puts "*"*80
puts "*"*80
# Load Cupcake seed files
require File.join(File.dirname(__FILE__),'seedfiles', 'bakery_cupcake_seed')
# Load seedfiles folder files
require File.join(File.dirname(__FILE__),'seedfiles', 'party_roles_and_relationships_seed')
puts "Creating Organization Parties and Wage Reports"
# Favor more common entity types in the random selection
ENTITY_KINDS = [:s_corporation, :c_corporation, :s_corporation, :c_corporation, :s_corporation, :c_corporation, :limited_liability_corporation, :limited_liability_partnership, :non_profit_501c3, :other_non_profit, :household_employer]
legal_first_names = ["<NAME>", "Adaptas", "Integra Design", "Magna Solutions", "Omni Tech", "Affinity Investments", "Millenia Life", "Acme Widgets","Opal Banking", "Toro Capital", "IdeaCrew"]
person_first_names = ["Jane", "Nora", "Samuel","Matthew", "Caroline", "John", "Sara","Mason","Kristen", "David", "William", "Kevin", "Jessica","Mary","David", "John"]
person_last_names = ["Carter", "Farrell", "Jackson", "Adams","Klein","Lopez", "Price", "Peterson", "Derby", "Harris", "Hessen", "Golden", "Waithe","Murray","Aykroyd","Chase", "Curtin", "Williams"]
1..30.times do
Parties::PersonParty.create!(current_first_name:"#{person_first_names.sample}",current_last_name:"#{person_last_names.sample}", ssn: "#{rand(111111111...999999999)}")
end
legal_first_names.each do |name|
org = Parties::OrganizationParty.new(
entity_id: "#{rand(10000...999999)}",
fein: "#{rand(111111111...999999999)}",
entity_kind: ENTITY_KINDS.sample,
legal_name: name,
is_foreign_entity: false)
date_of_first_wages = Time.at(rand(Time.new(2015,1,1).to_i..Time.now.to_i)).to_date
contact = Parties::PersonParty.new(current_first_name: "#{person_first_names.sample}", current_last_name: "#{person_last_names.sample}")
role = Roles::RoleFactory.new(org, org.entity_kind).party_role if Parties::PartyRoleKind.is_valid_key?(org.entity_kind)
party_relationship = Roles::RelationshipRoleFactory.new(contact, :contact, :organization_ui_primary_contact, org).party
ui_financial_account = FinancialAccounts::FinancialAccountFactory.call(org, account_kind: :ui_financial_account, initial_liability_date: date_of_first_wages)
party_relationship.save!
contact.save!
ui_financial_account.save!
org.party_ledger.save!
org.save!
end
parties = Parties::OrganizationParty.all
parties.each do |party|
(0..10).each do |i|
entries = []
spans = []
3.times do
spans << Timespans::Timespan.current_quarters
end
spans = spans.flatten
1..10.times do
person = Parties::PersonParty.all.sample
gross_wages= rand(1000...30000)
entry = Wages::WageEntry.new(submission_kind: :original, submitted_at: Time.now)
wage = Wages::Wage.new(person_party_id: person.id,
state_total_gross_wages: gross_wages,
timespan_id: spans[i].id,
state_taxable_wages: Wages::Wage.new.sum_taxable_wages(gross_wages),
state_total_wages:gross_wages,
state_excess_wages: Wages::Wage.new.sum_excess_wages(gross_wages),
wage_entry: entry )
entries << entry
end
report = Wages::WageReport.create!(organization_party: party,
timespan: spans[i],
submission_kind: "#{Wages::WageReport::SUBMISSION_KINDS.sample}",
wage_entries: entries,
filing_method_kind: "#{Wages::WageReport::FILING_METHOD_KINDS.sample}",
status: :submitted,
state_total_gross_wages:"#{rand(10000...100000)}",
state_ui_taxable_wages:"#{rand(100...1000)}",
ui_total_due:"#{rand(500...1000)}",
submitted_at: Time.now,
state_ui_total_wages:"#{rand(1000...10000)}",
state_ui_excess_wages:"#{rand(100...1000)}",
ui_paid_amount:"#{rand(100...1000)}",
ui_tax_amount:"#{rand(100...400)}",
ui_amount_due:"#{rand(100...400)}",
total_employees: entries.size )
report.wage_entries.each do |entry|
entry.wage.save!
entry.save!
end
report.save!
end
end
puts "*"*80
puts "Creating sample TPAs"
first_names = ['Dave', 'Sue', 'Mike', 'Ann', 'Jim', 'Carol']
last_names = ['Adams', 'Brown', 'Collins', 'Douglas', 'Harris', 'Ingrid']
(0..5).each do |i|
person = Parties::PersonParty.create!(current_first_name:"#{first_names[i]}",current_last_name:"#{last_names[i]}", ssn: "#{rand(111111111...999999999)}")
tpa_party_role_kind = Parties::PartyRoleKind.where(key: :tpa).first
tpa_party_relationship_kind = Parties::PartyRelationshipKind.where(key: :ui_tpa_relationship).first
person.party_roles.create!(party_role_kind: tpa_party_role_kind, party_relationship_id: tpa_party_relationship_kind.id)
end
puts "Creating Roles and Keys"
roles = ['UITS Administrator', 'UITS Call Center', 'Employer', 'Third Party Administrator', 'Call Center']
keys = ['Configure Settings', 'Create/Manage Employers', 'Create/Manage TPAs', 'Audit Wage Reports', 'Manage Wage Reports', 'Create Wage Reports', 'Amend Wage Reports', 'Assign TPA', 'Manage Employer Details', 'Manage TPA Details']
roles.each do |role|
Role.create(name: role)
end
keys.each do |key|
FilterToken.create(name: key, granted: false)
end
puts "Creating Indexes"
system "rake db:mongoid:create_indexes"
puts "::: complete :::"
puts "End of Seed Data"
|
ipublic/marketplace
|
app/controllers/wage_reports_controller.rb
|
<reponame>ipublic/marketplace
class WageReportsController < ApplicationController
layout 'two_column'
before_action :authenticate_user!
def index
@organization = Parties::OrganizationParty.find(params[:employer_id])
@all_quarters = Timespans::Timespan.all_quarters
@current_quarters = Wages::WageReport.current_quarters(@organization)
@latest_timespan = Wages::WageReport.latest_timespan(@organization)
@current_timespan = Timespans::Timespan.current_timespan
@current_reports = Wages::WageReport.find_and_filter_wage_reports_by_quarter(@organization, @latest_timespan)
@report= Wages::WageReport.new
@org_reports = Wages::WageReport.find_and_filter_wage_reports(@organization)[2..5] || []
@last_year_totals = Wages::WageReport.multi_report_totals(@org_reports)
end
def new
@report = Wages::WageReport.new
@organization = Parties::OrganizationParty.find(params[:employer_id])
if params[:report] == "new"
Wages::WageReportFactory.set_current_report(nil)
end
@current_report = Wages::WageReportFactory.get_current_report
@entries = @current_report.try(:wage_entries)
end
def show
@current_report = Wages::WageReport.find(params[:id])
@organization = @current_report.organization_party
@entries = @current_report.wage_entries.compact
@entry = @current_report.wage_entries.new
@people = Parties::PersonParty.all
end
def edit
@report = Wages::WageReport.find(params[:id])
@organization = @report.organization_party
@amend_reasons = Wages::WageEntry::AMEND_REASONS
@entries = @report.wage_entries.sort{|a,b| b.wage.state_total_gross_wages - a.wage.state_total_gross_wages}
@entry = @report.wage_entries.new
@submission_kinds = Wages::WageEntry::SUBMISSION_KINDS
end
def create
@report = Wages::WageReport.new
if params[:commit] == "Add Entry"
Wages::WageReportFactory.create_report_and_add_entries(params)
end
@organization = Parties::OrganizationParty.find(params[:employer_id])
redirect_to new_employer_wage_report_path(@organization)
end
def destroy
report = Wages::WageReport.find(params[:id])
entry = report.wage_entries.find(params[:entry])
entry.destroy
redirect_to edit_wage_report_path(report)
end
def update
@report = Wages::WageReport.find(params[:id])
if params[:commit] == "Cancel" || params[:commit] == "Save"
redirect_to employer_wage_reports_path(@report.organization_party)
else
Wages::WageReportFactory.amend(@report, params)
redirect_to employer_wage_reports_path(@report.organization_party)
end
end
end
|
ipublic/marketplace
|
spec/factories/determinations_pfl_liability_determinations.rb
|
<filename>spec/factories/determinations_pfl_liability_determinations.rb
FactoryBot.define do
factory :determinations_pfl_liability_determination, class: 'Determinations::PflLiabilityDetermination' do
end
end
|
ipublic/marketplace
|
app/models/financial_accounts/financial_transaction.rb
|
<reponame>ipublic/marketplace
module FinancialAccounts
class FinancialTransaction
include Mongoid::Document
# TODO Make transaction immutable
belongs_to :financial_account,
class_name: 'FinancialAccounts::FinancialAccount'
field :title, type: String
field :memo, type: String
field :kind, type: Symbol
field :amount, type: BigDecimal, default: 0.0
field :effective_on, type: Date, default: ->{ TimeKeeper.date_of_record }
field :submitted_at, type: Time, default: ->{ TimeKeeper.datetime_of_record }
# Reference the source transaction in Ledger system
field :source_foreign_key, type: String
validates_presence_of :title, :kind, :amount, :effective_on, :submitted_at
end
end
|
ipublic/marketplace
|
spec/factories/fees_penalty_fees.rb
|
<gh_stars>0
FactoryBot.define do
factory :fees_penalty_fee, class: 'Fees::PenaltyFee' do
end
end
|
ipublic/marketplace
|
app/models/integrations/post_party_update.rb
|
<filename>app/models/integrations/post_party_update.rb<gh_stars>0
class Integrations::PostPartyUpdate
include Mongoid::Document
end
|
ipublic/marketplace
|
spec/factories/subscriptions_subscribes.rb
|
<reponame>ipublic/marketplace
FactoryBot.define do
factory :subscriptions_subscribe, class: 'Subscriptions::Subscribe' do
end
end
|
ipublic/marketplace
|
spec/factories/quanta_timespans.rb
|
<reponame>ipublic/marketplace
FactoryBot.define do
factory :quanta_timespan, class: 'Quanta::Timespan' do
end
end
|
ipublic/marketplace
|
app/models/products/group_dental_insurance.rb
|
class Products::GroupDentalInsurance
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/wages/wage_report_service.rb
|
<reponame>ipublic/marketplace
module Wages
class WageReportService
attr_reader :wage_report, :business_policy
def initialize(wage_report)
@wage_report = wage_report
end
def open_case
end
def determine_ui_contribution_rate
end
end
end
|
ipublic/marketplace
|
app/models/sagas/routing_slip.rb
|
class Sagas::RoutingSlip
attr_reader :completed_worklogs, :next_work_item
# completed_worklogs = Stack.new #worklog stack
# next_work_item = WorkItemQueue.new # work_item queue
def initialize(work_items = [])
raise ArgumentError.new "expected array" unless work_items.is_a? Array
work_items.each { |work_item| WorkItemQueue.enqueue work_item }
end
def is_completed?
next_work_item.count == 0
end
def is_in_progress?
completed_worklogs.count > 0
end
def process_next
raise StandardError.new("invalid operation") if is_completed?
current_item = WorkItemQueue.dequeue
activity = activator.new(current_item.activity_type)
begin
result = activity.do_work(current_item)
completed_worklogs.push(result) if result.present?
rescue => e
puts "#{e.class}: #{e.message}"
end
result
end
def progresss_uri
next_work_item.peek.activity_type.work_item_queue_address unless is_completed?
end
def compensation_uri
completed_worklogs.peek.activity_type.compensation_queue_address if is_in_progress?
end
def undo_last
raise StandardError.new("invalid operation") if is_in_progress?
current_item = completed_worklogs.pop
activity = current_item.activity_type.new
begin
activity.compensate(current_item)
rescue => e
puts "#{e.class}: #{e.message}"
end
end
end
|
ipublic/marketplace
|
spec/factories/dispatcher_workflows.rb
|
<filename>spec/factories/dispatcher_workflows.rb
FactoryBot.define do
factory :dispatcher_workflow, class: 'Dispatcher::Workflow' do
end
end
|
ipublic/marketplace
|
app/controllers/settings_controller.rb
|
<gh_stars>0
class SettingsController < ApplicationController
layout 'two_column'
before_action :authenticate_user!
def home
@roles = Role.all
end
def get_roles
@roles = Role.all
render json: @roles
end
def get_keys
@keys = FilterToken.all
render json: @keys
end
def get_permissions
@permissions = Permission.all
render json: @permissions
end
def create_key
@key = FilterToken.new(key_params)
if @key.save
render json: {code: 200, message: 'Key successfully created.'}
else
render json: {code: 400, message: 'Unable to process this request.'}
end
end
def create_role
@role = Role.new(role_params)
if @role.save
render json: {code: 200, message: 'Role successfully created.'}
else
render json: {code: 400, message: 'Unable to process this request.'}
end
end
def create_permissions
Permission.destroy_all
permission_params.keys.each do |key|
@permission = Permission.new(role_name:key)
permission_params[key].each do |ft|
@permission.filter_tokens.new(name:ft['name'], granted:ft['granted'])
end
if @permission.save
# Add later
end
end
render json: {code: 200, message: 'Permissions updated'}
end
def remove_role_and_permissions
permission = Permission.where(role_name: params[:data]).first
if permission && permission.filter_tokens.present?
permission.filter_tokens.destroy_all
permission.destroy
end
Role.where(name: params[:data]).first.destroy
render json: {code: 200, message: 'Role was successfully removed'}
end
private
def role_params
params.permit(:name)
end
def key_params
params.permit(:name, :granted)
end
def permission_params
params.require(:data)
end
end
|
ipublic/marketplace
|
app/models/dispatcher/activities/group_reinstate_activity.rb
|
class Dispatcher::Activities::GroupReinstateActivity
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/products/paid_family_leave.rb
|
<reponame>ipublic/marketplace<filename>app/models/products/paid_family_leave.rb
class Products::PaidFamilyLeave
include Mongoid::Document
end
|
ipublic/marketplace
|
spec/factories/determinations_pfl_contribution_rate_determinations.rb
|
<reponame>ipublic/marketplace
FactoryBot.define do
factory :determinations_pfl_contribution_rate_determination, class: 'Determinations::PflContributionRateDetermination' do
end
end
|
ipublic/marketplace
|
app/models/determinations/determination.rb
|
<filename>app/models/determinations/determination.rb
module Determinations
class Determination
include Mongoid::Document
belongs_to :effective_period
field :determined_at, type: Time
has_many :timespans,
class_name: 'TimeSpans:Timespan'
end
end
|
ipublic/marketplace
|
app/models/financial_accounts/party_ledger_account_balance.rb
|
class FinancialAccounts::PartyLedgerAccountBalance
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/wages/wage_report.rb
|
module Wages
TAXABLE_WAGES_MAXIMUM = 9_000
class WageReport
include Mongoid::Document
include Mongoid::Timestamps
SUBMISSION_KINDS = [:original, :amended, :estimated]
FILING_METHOD_KINDS = [:upload, :manual_entry, :no_wages]
STATUS_KINDS = [:processed, :submitted, :terminated]
# attr_readonly :submission_kind, :submitted_at
field :submitted_at, type: Time
field :submitted_by_id, type: BSON::ObjectId
field :user_account_id, type: BSON::ObjectId
field :status, type: Symbol
field :submission_kind, type: Symbol
field :filing_method_kind, type: Symbol
field :state_total_gross_wages, type: BigDecimal
field :state_ui_total_wages, type: BigDecimal
field :state_ui_taxable_wages, type: BigDecimal
field :state_ui_excess_wages, type: BigDecimal
field :ui_tax_amount, type: BigDecimal
field :ui_admin_fee_amount, type: BigDecimal
field :ui_interest_amount, type: BigDecimal
field :ui_penalty_amount, type: BigDecimal
field :ui_total_due, type: BigDecimal
field :ui_paid_amount, type: BigDecimal
field :ui_amount_due, type: BigDecimal
field :total_employees, type: Integer
embeds_many :wage_entries,
class_name: 'Wages::WageEntry'
# embeds_many :wages,
# class_name: 'Wages::Wage'
belongs_to :organization_party,
class_name: 'Parties::OrganizationParty'
has_many :timespans,
class_name: 'Timespans::Timespan'
validates_presence_of :organization_party, :filing_method_kind,
:submission_kind #:total_wages,
# :excess_wages, :taxable_wages
belongs_to :timespan,
class_name: 'Timespans::Timespan'
# validates_presence_of :organization_party, :timespan, :wage_entries, :filing_method_kind,
# :submission_kind, :total_wages,
# :excess_wages, :taxable_wages
index({ organization_party_id: 1, timespan_id: 1 })
index({ timespan_id: 1 })
def set_state_wages
write_attributes(sum_all_state_wages)
end
def sum_state_total_wages
wage_entries.map(&:wage).compact.reduce(0.0) do |subtotal, wage|
subtotal += wage.state_total_gross_wages || 0
end
end
def sum_state_excess_wages
if (sum_state_total_wages - 9000) < 0
0
else
sum_state_total_wages - 9000
end
end
def sum_state_taxable_wages
ee_count = wage_entries.size
total_taxable = (9000 * ee_count)
total = wage_entries.map(&:wage).compact.reduce(0.0) do |subtotal, wage|
subtotal += wage.state_taxable_wages || 0
end
if total > total_taxable
total_taxable
else
total
end
end
def ui_total_due
sum_state_total_wages - sum_state_excess_wages
end
def self.current_reports(org)
quarter = org.wage_reports.sort{|a,b| b.timespan.begin_on - a.timespan.begin_on}.first
end
def ui_paid_amount
0
end
def self.multi_report_totals(reports)
total_wages = reports.reduce(0.0) do |subtotal, total_wages|
subtotal += total_wages.sum_state_total_wages
end
total_taxable = reports.reduce(0.0) do |subtotal, total_wages|
subtotal += total_wages.sum_state_taxable_wages
end
total_excess = reports.reduce(0.0) do |subtotal, total_wages|
subtotal += total_wages.sum_state_excess_wages
end
[total_wages,total_taxable, total_excess]
end
def sum_state_ui_total_wages
sum_state_total_wages
end
# Calculate all wage values in one pass -- higher performance on large wage reports
def sum_all_state_wages
wage_entries.map do | wage_entry |
total_wages += wage_entry.state_total_gross_wages
excess_wages += wage_entry.state_qtr_total_gross_wages
taxable_wages += wage_entry.state_qtr_total_gross_wages
{ state_total_wages: total_wages, state_excess_wages: excess_wages, state_taxable_wages: taxable_wages }
end
end
def sum_employees
wage_entries.compact.uniq.size
end
def self.latest_timespan(org)
filter = self.find_and_filter_wage_reports(org)
if filter.present?
filter[0].timespan
else
[]
end
end
def self.find_and_filter_wage_reports(org)
org.wage_reports.sort{|a,b|b.timespan.begin_on - a.timespan.begin_on}
end
def self.current_quarters(org)
quarters = Timespans::Timespan.current_quarters.map(&:_id)
reports = quarters.map{|q| org.wage_reports.select{|a|a.timespan.id == q}.try(:first)}
if reports.compact.present?
reports.map(&:timespan)
else
[]
end
end
def self.find_and_filter_wage_reports_by_quarter(org, quarter)
org.wage_reports.select{|d|d.timespan.begin_on == quarter.begin_on}.sort{|a,b| b.submitted_at - a.submitted_at} if quarter.present?
end
private
def set_total_employees
write_attribute(:total_employees, sum_employees)
end
end
end
|
ipublic/marketplace
|
config/routes.rb
|
Rails.application.routes.draw do
namespace :api do
namespace :v3 do
get 'cupcakes/index'
end
end
get 'subscriptions/index'
get 'subscriptions/create'
get 'subscriptions/new'
get 'subscriptions/show'
get 'subscriptions/update'
devise_for :users
get 'pages/home'
get 'settings/home'
mount Flipper::UI.app(Flipper.instance) => '/flipper'
resources :dashboard
resources :notifications
resources :employers do
get 'get_employers'
resources :accounts, only: [:index] do
end
resources :wage_reports, shallow: true do
resources :wage_entries
end
end
resources :tpas do
get 'get_tpas'
end
# resources : do
# end
resources :settings do
post 'create_role', to: 'settings#create_role', as: 'create_role'
post 'create_key', to: 'settings#create_key', as: 'create_key'
post 'create_permissions', to: 'settings#create_permissions', as: 'create_permissions'
get 'get_roles', to: 'settings#get_roles'
get 'get_keys', to: 'settings#get_keys'
get 'get_permissions', to: 'settings#get_permissions'
delete 'remove_role_and_permissions', to: 'settings#remove_role_and_permissions'
end
root to: 'pages#home'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
ipublic/marketplace
|
app/models/notices/ui_blocked_claim_ineligible_notice.rb
|
<reponame>ipublic/marketplace
class Notices::UiBlockedClaimIneligibleNotice
include Mongoid::Document
end
|
ipublic/marketplace
|
spec/factories/timespans_timespans.rb
|
<gh_stars>0
FactoryBot.define do
factory :timespans_timespan, class: 'Timespans::Timespan' do
end
end
|
ipublic/marketplace
|
app/models/document.rb
|
<reponame>ipublic/marketplace<filename>app/models/document.rb
class Document
include Mongoid::Document
include Mongoid::Timestamps
ACCESS_RIGHTS = [:public, :pii_restricted]
TYPE_KINDS = [:collection,
:dataset,
:event,
:image,
:interactive_resource,
:service,
:software,
:sound,
:text
]
# Enable polymorphic associations
embedded_in :documentable, polymorphic: true
# Dublin Core metadata elements
field :title, type: String, default: "untitled"
# Entity responsible for making the resource - person, organization or service
# This will typically reference the site owner or system service
embeds_one :creator,
class_name: 'Parties::Party'
# Controlled vocabulary w/classification codes. Mapped to ConsumerRole::VLP_DOCUMENT_KINDS
field :subject, type: String
# May include but is not limited to: an abstract, a table of contents, a graphical representation,
# or a free-text account of the resource
field :description, type: String
# Entity responsible for making the resource available - person, organization or service
embeds_one :publisher,
class_name: 'Parties::Party'
# Entity responsible for making contributions to the resource - person, organization or service
# This will typically reference the site owner or system service
embeds_many :contributors,
class_name: 'Parties::Party'
# A point or period of time associated with an event in the lifecycle of the resource.
embeds_one :timespan,
class_name: 'Timespans::Timespan'
# Conforms to DCMI Type Vocabulary - http://dublincore.org/documents/2000/07/11/dcmi-type-vocabulary/
field :type, type: Symbol, default: :text
# Conforms to IANA mime types - http://www.iana.org/assignments/media-types/media-types.xhtml
# Common exammples
# PDF => application/pdf
# csv => text/csv
# markdown => text/markdown
# xml => text/xml
field :format, type: String, default: "application/pdf"
# An unambiguous reference to the resource - Conforms to URI
field :identifier, type: String
# A related resource from which the described resource is derived
field :source, type: String, default: "enroll_system"
# Conforms to ISO 639
field :language, type: String, default: "en"
# A related resource - a string conforming to a formal identification system
field :relation, type: String
# Spatial (e.g. "District of Columbia") or temporal (e.g. "Open Enrollment 2016") topic of the resource
field :coverage, type: String
# Conforms to ACCESS_RIGHTS above
field :rights, type: String
field :tags, type: Array, default: []
field :size, type: String
validates_presence_of :title, :creator, :publisher, :type, :format, :source, :language
validates :rights,
allow_blank: true,
inclusion: { in: ACCESS_RIGHTS, message: "%{value} is not a valid access right" }
validates :type,
allow_blank: true,
inclusion: { in: TYPE_KINDS, message: "%{value} is not a valid type" }
end
|
ipublic/marketplace
|
spec/factories/fees_premium_fees.rb
|
<filename>spec/factories/fees_premium_fees.rb
FactoryBot.define do
factory :fees_premium_fee, class: 'Fees::PremiumFee' do
end
end
|
ipublic/marketplace
|
app/models/integrations/file_lien.rb
|
class Integrations::FileLien
include Mongoid::Document
end
|
ipublic/marketplace
|
spec/factories/notices_notices.rb
|
<reponame>ipublic/marketplace
FactoryBot.define do
factory :notices_notice, class: 'Notices::Notice' do
end
end
|
ipublic/marketplace
|
spec/factories/integrations_post_party_updates.rb
|
FactoryBot.define do
factory :integrations_post_party_update, class: 'Integrations::PostPartyUpdate' do
end
end
|
ipublic/marketplace
|
spec/factories/financial_accounts_financial_transaction_kinds.rb
|
FactoryBot.define do
factory :financial_accounts_financial_transaction_kind, class: 'FinancialAccounts::FinancialTransactionKind' do
end
end
|
ipublic/marketplace
|
spec/models/roles/relationship_role_factory_spec.rb
|
require 'rails_helper'
RSpec.describe Roles::RelationshipRoleFactory, type: :model, dbclean: :after_each do
let(:band_battle_party_relationship_kind_key) { :band_battle }
let(:hero_party_role_kind_key) { :hero }
let(:evil_ex_party_role_kind_key) { :evil_ex }
let(:hero_current_first_name) { 'Scott' }
let(:hero_current_last_name) { 'Pilgrim' }
let(:evil_ex_current_first_name) { 'Matthew' }
let(:evil_ex_current_last_name) { 'Patel' }
let!(:hero_party) { Parties::PersonParty.create!(current_first_name: hero_current_first_name,
current_last_name: hero_current_last_name)
}
let!(:evil_ex_party) { Parties::PersonParty.create!(current_first_name: evil_ex_current_first_name,
current_last_name: evil_ex_current_last_name)
}
let!(:hero_party_role_kind) { Parties::PartyRoleKind.create!(key: hero_party_role_kind_key) }
let!(:bollywood_evil_ex_role_kind) { Parties::PartyRoleKind.create!(key: evil_ex_party_role_kind_key) }
let(:party_role_kinds) { [hero_party_role_kind, bollywood_evil_ex_role_kind] }
let!(:band_battle_party_relationship_kind) { Parties::PartyRelationshipKind.create!(key: band_battle_party_relationship_kind_key,
party_role_kinds: party_role_kinds)
}
describe 'Given a two or more PersonParties with no PartyRoles and database seeded with two or more PartyRoleKinds' do
it "PartyRelationshipKinds should be available" do
expect(Parties::PartyRelationshipKind.all.size).to be > 0
end
it "PersonParties should be available" do
expect(Parties::PersonParty.all.size).to be > 1
end
it "PartyRoles should be empty" do
expect(hero_party.party_roles.size).to eq 0
expect(evil_ex_party.party_roles.size).to eq 0
end
it "PartyRoleKinds should be available" do
expect(Parties::PartyRoleKind.all.size).to be > 1
end
context "and a PartyRelationship is added" do
before {
}
it "should produce a valid PartyRelationship" do
factory = Roles::RelationshipRoleFactory.new(hero_party, hero_party_role_kind_key, band_battle_party_relationship_kind_key, evil_ex_party)
new_party_relationship = factory.party_relationship
expect(new_party_relationship.party_relationship_kind).to eq band_battle_party_relationship_kind
expect(new_party_relationship.party_roles.map(&:party_role_kind)).to match_array party_role_kinds
new_party_relationship.validate
expect(new_party_relationship).to be_valid
end
it "should assign correct PartyRole for each PersonParty" do
factory = Roles::RelationshipRoleFactory.new(hero_party, hero_party_role_kind_key, band_battle_party_relationship_kind_key, evil_ex_party)
expect(factory.party.party_roles.first.party_role_kind).to eq hero_party_role_kind
expect(factory.related_party.party_roles.first.party_role_kind).to eq bollywood_evil_ex_role_kind
end
end
end
# let(:bollywood_evil_ex_role) { Parties::PartyRoleKind.create!(key: :evil_ex) }
# let(:skateboarder_evil_ex_role) { Parties::PartyRoleKind.create!(key: :evil_ex) }
# let(:vegan_evil_ex_role) { Parties::PartyRoleKind.create!(key: :evil_ex) }
# let(:exgirlfriend_evil_ex_role) { Parties::PartyRoleKind.create!(key: :evil_ex) }
# let(:twin_one_evil_ex_role) { Parties::PartyRoleKind.create!(key: :evil_ex) }
# let(:twin_two_evil_ex_role) { Parties::PartyRoleKind.create!(key: :evil_ex) }
# let(:gman_evil_ex_role) { Parties::PartyRoleKind.create!(key: :evil_ex) }
# let(:subject_party_role_kind) { Parties::PartyRoleKind.create!(key: :hero) }
# let(:object_party_role_kind) { Parties::PartyRoleKind.create!(key: :evil_ex) }
# let(:party_role_kinds) { [subject_party_role_kind, object_party_role_kind] }
# let(:dating_partners_party_relationship_kind) { Parties::PartyRelationshipKind.new(key: :dating_partners) }
# let(:party_relationhip_kinds) { [band_battle_party_relationship_kind, dating_partners_party_relationship_kind] }
end
|
ipublic/marketplace
|
config/deploy.rb
|
<reponame>ipublic/marketplace<filename>config/deploy.rb
server '172.30.0.41', port: 22, roles: [:web, :app, :db], primary: true
set :repo_url, '<EMAIL>:ipublic/marketplace.git'
set :application, 'marketplace'
set :user, 'nginx'
set :puma_threads, [4, 16]
set :puma_workers, 2
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/var/www/deployments/#{fetch(:application)}"
set :puma_bind, "unix:#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, false # Change to true if using ActiveRecord
## Defaults:
# set :scm, :git
# set :branch, :master
# set :format, :pretty
# set :log_level, :debug
# set :keep_releases, 5
## Linked Files & Directories (Default None):
set :linked_files, %w{config/master.key config/mongoid.yml}
set :linked_dirs, %w{config/environments} #bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
#puts "WARNING: HEAD is not the same as origin/master"
#puts "Run `git push` to sync changes."
#exit
end
end
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:restart'
end
end
before :starting, :check_revision
after :finishing, :compile_assets
after :finishing, :cleanup
after :finishing, :restart
end
# ps aux | grep puma # Get puma pid
# kill -s SIGUSR2 pid # Restart puma
# kill -s SIGTERM pid # Stop puma
|
ipublic/marketplace
|
spec/factories/subscriptions_tenants.rb
|
FactoryBot.define do
factory :subscriptions_tenant, class: 'Subscriptions::Tenant' do
end
end
|
ipublic/marketplace
|
spec/factories/taxes_unemployment_insurance_taxes.rb
|
FactoryBot.define do
factory :taxes_unemployment_insurance_tax, class: 'Taxes::UnemploymentInsuranceTax' do
end
end
|
ipublic/marketplace
|
spec/factories/determinations_group_ui_liability_determinations.rb
|
<filename>spec/factories/determinations_group_ui_liability_determinations.rb
FactoryBot.define do
factory :determinations_group_ui_liability_determination, class: 'Determinations::GroupUiLiabilityDetermination' do
end
end
|
ipublic/marketplace
|
spec/factories/integrations_redetermine_ui_contribution_rates.rb
|
<filename>spec/factories/integrations_redetermine_ui_contribution_rates.rb<gh_stars>0
FactoryBot.define do
factory :integrations_redetermine_ui_contribution_rate, class: 'Integrations::RedetermineUiContributionRate' do
end
end
|
ipublic/marketplace
|
app/models/financial_accounts/party_ledger.rb
|
<filename>app/models/financial_accounts/party_ledger.rb
module FinancialAccounts
class PartyLedger
include Mongoid::Document
field :total_due, type: BigDecimal
belongs_to :party,
class_name: 'Parties::Party'
has_many :financial_accounts,
class_name: 'FinancialAccounts::FinancialAccount'
has_many :party_ledger_account_balances,
class_name: 'FinancialAccounts::PartyLedgerAccountBalance'
has_many :timespans,
class_name: 'Timespans::Timespan'
delegate :party_roles, to: :party
def add_financial_account(new_financial_account)
end
end
end
|
ipublic/marketplace
|
app/jobs/generate_notice_job.rb
|
class GenerateNoticeJob < ApplicationJob
queue_as :default
# exchange_name :GenerateNotice
def perform(*args)
# Do something later
puts 'Perform a job'
Sneakers.logger.info "Hello World!"
end
end
|
ipublic/marketplace
|
spec/factories/sagas_routing_slips.rb
|
FactoryBot.define do
factory :sagas_routing_slip, class: 'Sagas::RoutingSlip' do
end
end
|
ipublic/marketplace
|
lib/marketplace.rb
|
<filename>lib/marketplace.rb
module Marketplace
# Namespaced nested exception. Wraps any underlying exception that may have
# resulted from a different failure
# For example on how to construct Exception test, see:
# https://gist.github.com/avdi/772356
class Error < StandardError
attr_reader :original
def initialize(msg, original = $!)
super(msg)
@original = original
end
end
# Pattern for raising Namespaced nested exceptions
# rescue Marketplace::Error
# raise
# rescue error
# raise Marketplace::Error.new("#{error.class}: #{error.message}", error)
end
|
ipublic/marketplace
|
config/initializers/flipper.rb
|
require 'flipper'
# require 'mongo'
require 'flipper/adapters/mongo.rb'
# host = Mongoid::Config.clients[:default][:hosts].first
# database_name = Mongoid.client(:default).database.name
# flipper_client = Mongo::Client.new([ host ], :database => database_name)
# feature_collection = flipper_client[:my_flipper_settings]
mongo_client = Mongoid.client(:default)
feature_collection = mongo_client[:flipper_settings]
# require 'flipper/adapters/mongo'
# feature_collection = class FlipperFeature; include Mongoid::Document; include Mongoid::Timestamps; end
Flipper.configure do |config|
config.default do
adapter = Flipper::Adapters::Mongo.new(feature_collection)
Flipper.new(adapter)
end
end
|
ipublic/marketplace
|
app/models/bakery/sprinkle.rb
|
<gh_stars>0
# frozen_string_literal: true
module Bakery
class Sprinkle
include Mongoid::Document
embedded_in :cupcake, class_name: 'Bakery::Cupcake'
COLOR_KINDS = %w[ red white blue yellow green pink orange purple black ].freeze
SHAPE_KINDS = %w[ star circle diamond square hexagon ].freeze
field :color
field :shape
def sample_sprinkle
write_attribute(:color, COLOR_KINDS.sample)
write_attribute(:shape, SHAPE_KINDS.sample)
self
end
end
end
|
ipublic/marketplace
|
app/models/determinations/ui_determination_service.rb
|
<filename>app/models/determinations/ui_determination_service.rb
module Determinations
class UiDeterminationService
include ActiveSupport::Configurable
attr_accessor :party
def initialize(party: nil)
@party = party
@active_role_keys = @party.active_party_role_keys
end
def initial_liability_date
#TODO get this date from Employer registration: date wages first paid
TimeKeeper.date_of_record
end
def payment_kind
# if @active_role_keys.include?(:non_profit_501c3) || @active_role_keys.include?(:other_non_profit)
# end
@active_role_keys.include?(:uits_reimbursing) ? :uits_reimbursing : :uits_contributing
end
def wage_filing_schedule
@active_role_keys.include?(:household_employer) ? :uits_annual_filer : :uits_qtr_filer
end
def administrative_rate
0.002
end
def contribution_rate
new_employer_rate = 0.027
current_rate_range = 0.016..7.0
reimbursing_employer_rate = 0.0
new_employer_rate
end
def write_off_eligibility
end
def add_ui_acccount
@ledger = build_or_find_party_ledger
title = "#{@party.legal_name}'s Unemployment Insurance Account"
initial_liability_date = TimeKeeper.date_of_record.beginning_of_quarter
@ui_account = FinancialAccounts::UiFinancialAccount.new(title: title,
initial_liability_date: initial_liability_date,
# current_payment_type: @party.,
# current_wage_filing_schedule: ,
)
end
end
end
|
ipublic/marketplace
|
spec/factories/notices_ui_contribution_rate_notices.rb
|
FactoryBot.define do
factory :notices_ui_contribution_rate_notice, class: 'Notices::UiContributionRateNotice' do
end
end
|
ipublic/marketplace
|
app/models/integrations/import_wage_report.rb
|
class Integrations::ImportWageReport
include Mongoid::Document
end
|
ipublic/marketplace
|
app/helpers/api/v3/cupcakes_helper.rb
|
<gh_stars>0
module Api::V3::CupcakesHelper
end
|
ipublic/marketplace
|
spec/factories/determinations_determinations.rb
|
FactoryBot.define do
factory :determinations_determination, class: 'Determinations::Determination' do
end
end
|
ipublic/marketplace
|
app/models/products/group_health_insurance.rb
|
<gh_stars>0
class Products::GroupHealthInsurance
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/notices/ui_contribution_rate_notice.rb
|
<reponame>ipublic/marketplace
class Notices::UiContributionRateNotice
include Mongoid::Document
end
|
ipublic/marketplace
|
app/controllers/api/v3/cupcakes_controller.rb
|
module Api::V3
class CupcakesController < ApplicationController
# before_action :bake_cupcakes
def index
@view_size = 20
@view_number ||= 1
@page_number = @view_number + 1
@offset = (@view_number * @view_size)
@cupcake_count = Bakery::Cupcake.all.size
@cupcakes = Bakery::Cupcake.all.order_by_cc_id.view_window(@offset, @view_size)
options = {}
options[is_collection: true]
options[:meta] = {
view_size: @view_size,
view_number: @view_number,
page_number: @page_number,
total: @cupcake_count
}
serializer = CupcakeSerializer.new(@cupcakes, options)
render json: serializer.serialized_json
# render json: serializer.serializable_hash
end
private
end
end
|
ipublic/marketplace
|
lib/dispatcher/sneakers_boot.rb
|
<filename>lib/dispatcher/sneakers_boot.rb<gh_stars>0
require 'sneakers'
require 'redis'
require 'json'
$redis = Redis.new
class Processor
include Sneakers::Worker
from_queue :logs
def work(msg)
err = JSON.parse(msg)
if err["type"] == "error"
$redis.incr "processor:#{err["error"]}"
end
ack!
end
end
|
ipublic/marketplace
|
app/models/employers/employer_service.rb
|
module Employers
class EmployerService
attr_accessor :factory
def initialize(attrs={})
@factory = Employers::EmployerFactory
end
def save(form)
model_attributes = form_params_to_attributes(form)
objects = factory.call(model_attributes.except(:id))
store(form, objects)
end
def form_params_to_attributes(form)
form.attributes.except(:contribution_info)
end
def store(form, objects)
objects.each do |object|
object.save!
end
end
end
end
|
ipublic/marketplace
|
app/models/eligibility_policies/eligibility_policy.rb
|
<gh_stars>0
module EligibilityPolicies
class EligibilityPolicy
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :party_relationship_kinds,
class_name: 'Parties::PartyRelationshipKind'
end
end
|
ipublic/marketplace
|
app/models/dispatcher/activities/group_terminate_activity.rb
|
<reponame>ipublic/marketplace<filename>app/models/dispatcher/activities/group_terminate_activity.rb
class Dispatcher::Activities::GroupTerminateActivity
include Mongoid::Document
end
|
ipublic/marketplace
|
spec/models/parties/party_spec.rb
|
require 'rails_helper'
RSpec.describe Parties::Party, type: :model do
it { is_expected.to be_mongoid_document }
it { is_expected.to have_timestamps }
it { is_expected.to have_fields(:party_id, :registered_on, :profile_source, :contact_method)}
it { is_expected.to embed_many(:documents)}
it { is_expected.to have_one(:party_ledger)}
it { is_expected.to have_many(:party_ledger_account_balances)}
it { is_expected.to have_many(:determinations)}
it { is_expected.to have_many(:cases)}
it { is_expected.to have_many(:notices)}
describe "A new Party model instance" do
context "with no arguments" do
subject { described_class.new }
it "should be valid" do
subject.validate
expect(subject).to be_valid
end
end
end
describe "Managing Roles and Relationships" do
context "Given a new Party model instance" do
subject { described_class.new }
it "party_roles set should be empty" do
expect(subject.party_roles.count).to eq 0
end
context "and a declarative PartyRole is added" do
let(:key) { :hero }
let(:title) { "Hero" }
let(:party_role_kind) { Parties::PartyRoleKind.create!(key: key) }
let(:party_role) { Parties::PartyRole.new(party_role_kind: party_role_kind) }
let(:scott_pilgrim_person_party) { Parties::PersonParty.new(current_first_name: 'Scott', current_last_name: 'Pilgrim') }
# before { subject.add_party_role(:happy_camper_party_role) }
it "should be findable by matching party_role_kind" do
end
it "should be valid" do
subject.validate
expect(subject).to be_valid
end
end
context "and a PartyRole with Relationship and Related Party is added" do
end
end
end
end
|
ipublic/marketplace
|
app/models/subscriptions/subscribed.rb
|
<filename>app/models/subscriptions/subscribed.rb
module Subscriptions
class Subscribed < EventSource::EventStream
data_attributes :tenant_id, :feature_id
# Use #apply to update the source model record
def apply(subscription)
subscription.tenant_id = tenant_id
subscription.feature_id = feature_id
subscription
end
end
end
|
ipublic/marketplace
|
app/models/comment.rb
|
<gh_stars>0
class Comment
include Mongoid::Document
include Mongoid::Timestamps
PRIORITY_KINDS = [:low, :normal, :high]
embedded_in :commentable, polymorphic: true
field :title, type: String
field :content, type: String
field :priority, type: String, default: :normal
field :is_high_priority, type: Boolean, default: false
field :tags, type: Array, default: []
validates :priority,
inclusion: { in: PRIORITY_KINDS, message: "%{value} is not a valid priority kind" },
allow_blank: false
def add_tag(new_tag)
tags << new_tag unless tags.include? new_tag
end
def drop_tag(old_tag)
tags - [old_tag]
end
def priority=(new_priority = :normal)
write_attribute(:priority, new_priority)
write_attribute(:is_high_priority, true) if new_priority == :high
end
end
|
ipublic/marketplace
|
app/models/financial_accounts/financial_account.rb
|
<reponame>ipublic/marketplace
module FinancialAccounts
class FinancialAccount
include Mongoid::Document
include Mongoid::Timestamps
field :title, type: String
field :opened_on, type: Date, default: ->{ TimeKeeper.date_of_record }
belongs_to :party_ledger,
class_name: 'FinancialAccounts::PartyLedger'
has_many :financial_transactions,
class_name: 'FinancialAccounts::FinancialTransaction',
autosave: true
validates_presence_of :title, :opened_on
end
end
|
ipublic/marketplace
|
spec/models/timespans/timespan_spec.rb
|
require 'rails_helper'
RSpec.describe Timespans::Timespan, type: :model, dbclean: :after_each do
let(:this_year) { Date.today.year }
let(:begin_on) { Date.new(this_year, 1, 1) }
let(:end_on) { Date.new(this_year, 12, 31) }
let(:title) { this_year.to_s }
let(:params) do
{
title: title,
begin_on: begin_on,
end_on: end_on,
}
end
context "A new Timespan instance" do
end
describe "instance methods" do
context "#between?" do
let(:before_period) { begin_on - 1.day }
let(:after_period) { end_on + 1.day }
let(:during_period) { begin_on + 1.day }
subject { described_class.new(params) }
it "before_period should be false" do
expect(subject.between?(before_period)).to eq false
end
it "after_period should be false" do
expect(subject.between?(after_period)).to eq false
end
it "during_period should be true" do
expect(subject.between?(during_period)).to eq true
end
it "begin_on should be true" do
expect(subject.between?(begin_on)).to eq true
end
it "end_on should be true" do
expect(subject.between?(end_on)).to eq true
end
end
context "#to_range" do
subject { described_class.new(params) }
it "should output to range type" do
expect(subject.to_range).to eq begin_on..end_on
end
end
end
end
|
ipublic/marketplace
|
spec/factories/integrations_assign_ui_cases.rb
|
FactoryBot.define do
factory :integrations_assign_ui_case, class: 'Integrations::AssignUiCase' do
end
end
|
ipublic/marketplace
|
spec/factories/parties_organization_parties.rb
|
<gh_stars>0
FactoryBot.define do
factory :parties_organization_party, class: 'Parties::OrganizationParty' do
end
end
|
ipublic/marketplace
|
spec/controllers/employers_controller_spec.rb
|
require 'rails_helper'
RSpec.describe EmployersController, type: :controller do
describe "POST #create" do
let(:contact_info) do
{ :first_name => 'Silky',
:last_name => 'Johnston',
:dob => '09/22/1981',
:email => '<EMAIL>',
:area_code => '202',
:number => '222-2222' }
end
let(:employer_info) do
{ :legal_name => "<NAME>",
:dba => '0234232',
:fein => '123456789',
:kind => 'C Corpation' }
#:sic_code, String
end
let(:address_info) do
{ :kind => 'primary',
:address_1 => '202 2nd St',
:address_2 => '',
:city => 'Washington',
:state => 'DC',
:zip => '20002',
:area_code => '202',
:number => '222-2222',
:extension => '' }
end
subject do
post :create, params: { contact_info: contact_info, employer_info: employer_info, address_info: address_info }
end
it 'creates a new employer' do
expect { subject }.to change { Parties::Party.all.count }.by(1)
end
end
end
|
ipublic/marketplace
|
app/models/integrations/get_financial_transaction.rb
|
<reponame>ipublic/marketplace
class Integrations::GetFinancialTransaction
include Mongoid::Document
end
|
ipublic/marketplace
|
app/models/wages/wage_entry.rb
|
<reponame>ipublic/marketplace
module Wages
class WageEntry
include Mongoid::Document
include Mongoid::Timestamps
SUBMISSION_KINDS = [:original, :amended]
AMEND_REASONS = ["Select Amendment Reason",
"Wages Reported to Another State",
"Wages Reported as Net Instead of Gross",
"Wages Reported to Wrong Quarter/Year",
"Wages Overreported",
"Wages Underreported",
"Wages Ommitted",
"Original"]
# attr_readonly :submission_kind, :submitted_at
embedded_in :wage_report,
class_name: 'Wages::WageReport'
field :submission_kind, type: Symbol, default: :original
field :amend_reason, type: String, default: "Original"
field :submitted_at, type: Time, default: ->{ Time.now }
embeds_one :wage,
class_name: 'Wages::Wage'
validates_presence_of :wage, :submitted_at
validates :submission_kind,
inclusion: { in: SUBMISSION_KINDS, message: "%{value} is not a valid submission kind" },
allow_blank: false
# after_initialize :build_wage
delegate :timespan, to: :wage_report
delegate :person_party, to: :wage
delegate :state_total_gross_wages, to: :wage
delegate :state_total_wages, to: :wage
delegate :state_excess_wages, to: :wage
delegate :state_taxable_wages, to: :wage
private
def build_wage_instance
wage.build(timespan: timespan)
end
end
end
|
ipublic/marketplace
|
spec/factories/roles_role_factories.rb
|
FactoryBot.define do
factory :roles_role_factory, class: 'Roles::RoleFactory' do
end
end
|
ipublic/marketplace
|
app/models/fees/unemployment_insurance_tax.rb
|
<gh_stars>0
class Fees::UnemploymentInsuranceTax
include Mongoid::Document
end
|
ipublic/marketplace
|
spec/factories/parties_organization_party_services.rb
|
<filename>spec/factories/parties_organization_party_services.rb
FactoryBot.define do
factory :parties_organization_party_service, class: 'Parties::OrganizationPartyService' do
end
end
|
ipublic/marketplace
|
app/models/employers/employer_form.rb
|
<reponame>ipublic/marketplace
module Employers
class AddressInfoForm
include Virtus.model
attribute :kind, String
attribute :address_1, String
attribute :address_2, String
attribute :city, String
attribute :state, String
attribute :zip, String
attribute :area_code, Integer
attribute :number, Integer
attribute :extension, Integer
end
class ContactInfoForm
include Virtus.model
attribute :first_name, String
attribute :last_name, String
attribute :dob, Date
attribute :email, String
attribute :area_code, Integer
attribute :number, Integer
end
class EmployerInfoForm
include Virtus.model
attribute :legal_name, String
attribute :dba, String
attribute :fein, String
attribute :kind, String
attribute :sic_code, String
attribute :company_type, String
attribute :successor, String
attribute :date_of_first_wages, String
end
class ContributionInfoForm
include Virtus.model
end
class EmployerForm
include Virtus.model
include ActiveModel::Model
attribute :id, String
attribute :address_info, Employers::AddressInfoForm
attribute :contact_info, Employers::ContactInfoForm
attribute :contribution_info, Employers::ContributionInfoForm
attribute :employer_info, Employers::EmployerInfoForm
def self.for_new
self.new
end
def self.for_create(params)
form = self.new(params)
#form.service.load_form_metadata(form)
form
end
def service
@service ||= EmployerService.new
end
def persist(update: false)
return false unless self.valid?
save_result, persisted_object = (update ? service.update(self) : service.save(self))
return false unless save_result
@show_page_model = persisted_object
self.id = persisted_object.id.to_s
true
end
def save
persist
end
end
end
|
ipublic/marketplace
|
app/helpers/api/v3/echo_helper.rb
|
module Api::V3::EchoHelper
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.