mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Create adjustment metadata when creating adjustment
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user