Create adjustment metadata when creating adjustment

This commit is contained in:
Rohan Mitchell
2013-08-12 10:00:10 +10:00
parent 149d48ff5a
commit 14268b7be0
2 changed files with 13 additions and 2 deletions

View File

@@ -25,7 +25,8 @@ class ProductDistribution < ActiveRecord::Base
end
def create_adjustment_for(line_item)
enterprise_fee.create_adjustment(adjustment_label_for(line_item), line_item.order, line_item, true)
a = enterprise_fee.create_adjustment(adjustment_label_for(line_item), line_item.order, line_item, true)
AdjustmentMetadata.create! adjustment: a, enterprise: enterprise_fee.enterprise, fee_name: enterprise_fee.name, fee_type: enterprise_fee.fee_type, enterprise_role: 'distributor'
end
def clear_all_enterprise_fee_adjustments_for(line_item)

View File

@@ -57,7 +57,11 @@ describe ProductDistribution do
adjustment.amount.should == 1.23
# And it should have some associated metadata
pending 'Needs metadata spec'
md = adjustment.metadata
md.enterprise.should == distributor
md.fee_name.should == enterprise_fee.name
md.fee_type.should == enterprise_fee.fee_type
md.enterprise_role.should == 'distributor'
end
end
@@ -152,6 +156,12 @@ describe ProductDistribution do
adjustment.source.should == line_item
adjustment.originator.should == pd.enterprise_fee
adjustment.should be_mandatory
md = adjustment.metadata
md.enterprise.should == pd.distributor
md.fee_name.should == pd.enterprise_fee.name
md.fee_type.should == pd.enterprise_fee.fee_type
md.enterprise_role.should == 'distributor'
end
end