-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Denis I
committed
Jun 28, 2015
1 parent
324dec8
commit e461024
Showing
2 changed files
with
27 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
Spree::LineItem.class_eval do | ||
after_save :update_core_charges | ||
before_destroy :destroy_core_charges | ||
|
||
def calculate_core_charge | ||
return unless product.core_amount | ||
self.quantity * product.core_amount | ||
end | ||
end | ||
|
||
def compute_amount o | ||
calculate_core_charge | ||
end | ||
|
||
def core_charge | ||
order.adjustments.find{|adj| adj.source_id == id} | ||
end | ||
|
||
def update_core_charges | ||
core_charge and core_charge.update! | ||
end | ||
|
||
def destroy_core_charges | ||
core_charge and core_charge.destroy | ||
end | ||
|
||
end |
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