* VRFS-3670 - affiliate rate usage
This commit is contained in:
parent
9dbcdb2436
commit
27328a7c65
|
|
@ -2,6 +2,8 @@
|
||||||
<%= f.semantic_errors *f.object.errors.keys %>
|
<%= f.semantic_errors *f.object.errors.keys %>
|
||||||
<%= f.inputs do %>
|
<%= f.inputs do %>
|
||||||
<%= f.input(:partner_name, :input_html => {:maxlength => 128}) %>
|
<%= f.input(:partner_name, :input_html => {:maxlength => 128}) %>
|
||||||
|
<%= f.input(:entity_type, :as => :select, :collection => AffiliatePartner::ENTITY_TYPES) %>
|
||||||
|
<%= f.input(:rate) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= f.actions %>
|
<%= f.actions %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -306,4 +306,5 @@ jam_track_slug.sql
|
||||||
mixdown.sql
|
mixdown.sql
|
||||||
aac_master.sql
|
aac_master.sql
|
||||||
video_recording.sql
|
video_recording.sql
|
||||||
web_playable_jamtracks.sql
|
web_playable_jamtracks.sql
|
||||||
|
affiliate_partner_rate.sql
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE affiliate_partners ADD COLUMN rate NUMERIC(8,2) DEFAULT 0.10;
|
||||||
|
|
@ -9,7 +9,7 @@ class JamRuby::AffiliatePartner < ActiveRecord::Base
|
||||||
has_many :months, :class_name => 'JamRuby::AffiliateMonthlyPayment', foreign_key: :affiliate_partner_id, inverse_of: :affiliate_partner
|
has_many :months, :class_name => 'JamRuby::AffiliateMonthlyPayment', foreign_key: :affiliate_partner_id, inverse_of: :affiliate_partner
|
||||||
has_many :traffic_totals, :class_name => 'JamRuby::AffiliateTrafficTotal', foreign_key: :affiliate_partner_id, inverse_of: :affiliate_partner
|
has_many :traffic_totals, :class_name => 'JamRuby::AffiliateTrafficTotal', foreign_key: :affiliate_partner_id, inverse_of: :affiliate_partner
|
||||||
has_many :visits, :class_name => 'JamRuby::AffiliateReferralVisit', foreign_key: :affiliate_partner_id, inverse_of: :affiliate_partner
|
has_many :visits, :class_name => 'JamRuby::AffiliateReferralVisit', foreign_key: :affiliate_partner_id, inverse_of: :affiliate_partner
|
||||||
attr_accessible :partner_name, :partner_code, :partner_user_id
|
attr_accessible :partner_name, :partner_code, :partner_user_id, :entity_type, :rate, as: :admin
|
||||||
|
|
||||||
ENTITY_TYPES = %w{ Individual Sole\ Proprietor Limited\ Liability\ Company\ (LLC) Partnership Trust/Estate S\ Corporation C\ Corporation Other }
|
ENTITY_TYPES = %w{ Individual Sole\ Proprietor Limited\ Liability\ Company\ (LLC) Partnership Trust/Estate S\ Corporation C\ Corporation Other }
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@ class JamRuby::AffiliatePartner < ActiveRecord::Base
|
||||||
product_info = shopping_cart.product_info
|
product_info = shopping_cart.product_info
|
||||||
# subtract the total quantity from the freebie quantity, to see how much we should attribute to them
|
# subtract the total quantity from the freebie quantity, to see how much we should attribute to them
|
||||||
real_quantity = product_info[:quantity].to_i - product_info[:marked_for_redeem].to_i
|
real_quantity = product_info[:quantity].to_i - product_info[:marked_for_redeem].to_i
|
||||||
{fee_in_cents: real_quantity * 20}
|
{fee_in_cents: (1.99 * 100 * real_quantity * rate).round}
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,15 @@ describe AffiliatePartner do
|
||||||
user.should_attribute_sale?(shopping_cart).should eq({fee_in_cents:20})
|
user.should_attribute_sale?(shopping_cart).should eq({fee_in_cents:20})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "user with an affiliate relationship (with a custom rate) buying a jamtrack" do
|
||||||
|
user.affiliate_referral = partner
|
||||||
|
user.save!
|
||||||
|
partner.rate = 0.25
|
||||||
|
partner.save!
|
||||||
|
shopping_cart = ShoppingCart.create user, jam_track, 1, false
|
||||||
|
user.should_attribute_sale?(shopping_cart).should eq({fee_in_cents:50})
|
||||||
|
end
|
||||||
|
|
||||||
it "user with an affiliate relationship redeeming a jamtrack" do
|
it "user with an affiliate relationship redeeming a jamtrack" do
|
||||||
user.affiliate_referral = partner
|
user.affiliate_referral = partner
|
||||||
user.save!
|
user.save!
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue