Slots
Product Definitions
-
credits
1 credits = 1 job_offer (no permanent) || 1 event
-
permanent credits
1 permanent credits = 1 permanent job_offer
-
slots
1 slot = 1 space available for 1 year for a job_offer
Data model
Credits::Slot
# Return all slots for a company
for_company(company)
# Return slot for a job_offer
for_job_offer(job_offer)
Credits::SlotPack
# 2 pack types
# - JobSlotPack
# - InternshipSlotPack
# 2 states
# - active
# - expired
# available_capacity is computed by diffing
# slot max capacity minus already active job_offers on this slot
def available_capacity
capacity - slot_ids.size
end
Company Configuration
payment_types
It's a bitwise value
- :credits = 1
- :slots = 2
- :credits_permanent = 4
payment_types = [:credits, :slots] == 3
Company Configuration
payment_types
- #payment_type?(:credits)
- #any_payment_types?(:credits, :slots)
- #all_payment_types?(:credits, :slots)
- #any_payment_types?(:credits, :slots) { |p| visible(user, p) }
- #add_payment_type(:credits)
- #remove_payment_type(:credits)
- #payment_type == [:slots]
- #payment_type_value == 3
- ::PAYMENT_TYPES_MAPPING
- #with_any_payment_types(:credits, :slots) # scope
- #with_all_payment_types(:credits, :slots) # scope
Technical Definitions
-
payable
= creditable || slotable
-
slotable
object with payment_types and slot_packs association
-
creditable
object with payment_types and wallet association
-
resource
object with credits_value
Credits::Payment Service
Credits::PaymentBalance
Mixin
# return proper payment_types balance depending on attributes :
# - payable
# - resource
balance()
# return proper payment_type balance depending on params :
# - payable
# - resource
balance_for(resource_type, *payment_types)
credits_balance_for(resource_type)
slots_balance_for(resource_type)
############# Example
balance(:job, [:slots, :credits])
# (return Mash)
# => { total: 2, credits: 1, slots: 2, selected_payment: :slots }
balance(:job, [:credits])
# (return Mash)
# => { credits: 1, selected_payment: :credits }
Reporting
Slots
By Charly Poly
Slots
- 1,671