Created
June 30, 2010 17:09
-
-
Save byped/458953 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def apply_adjustments | |
adjustments = self.class.adjustments_to_apply[self.status.name.methodize.to_sym] || [] | |
return if adjustments.empty? | |
total_adjustment = adjustments.inject(0.0){ |total,adjust| total + adjust.apply_to(self).to_f } | |
return if total_adjustment == 0.0 | |
case self.status.name.methodize.to_sym | |
when :shipping_ready, :pending | |
self.estimated_total = ('%.2f' % (self.estimated_total + total_adjustment)).to_f if self.estimated_value | |
when :awaiting_confirmation, :accepted | |
self.payout_total = ('%.2f' % (self.inspected_value + total_adjustment)).to_f if self.inspected_value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment