-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #166 support promotion, adjustment, tax for caculate commission…
… for payout
- Loading branch information
Showing
21 changed files
with
365 additions
and
129 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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Vpago | ||
module AdjustmentDecorator | ||
def self.prepended(base) | ||
base.enum handle_by: { unspecified: 0, store: 1, vendor: 2 }, _prefix: true | ||
|
||
base.scope :handle_by_vendor, -> { eligible.where(handle_by: :vendor) } | ||
base.scope :handle_by_store, -> { eligible.where(handle_by: :store) } | ||
|
||
base.before_save :set_handle_by | ||
|
||
def base.total | ||
sum(:amount) || 0 | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_handle_by | ||
if source.is_a?(::Spree::PromotionAction) | ||
self.handle_by = source.run_by | ||
elsif source.is_a?(::Spree::TaxRate) | ||
self.handle_by = source.tax_category.collect_by | ||
end | ||
end | ||
end | ||
end | ||
|
||
unless Spree::Adjustment.included_modules.include?(Vpago::AdjustmentDecorator) | ||
Spree::Adjustment.prepend(Vpago::AdjustmentDecorator) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Vpago | ||
module InventoryUnitDecorator | ||
def self.prepended(base) | ||
base.has_one :selected_shipping_rate, through: :shipment, class_name: 'Spree::ShippingRate' | ||
end | ||
end | ||
end | ||
|
||
unless Spree::InventoryUnit.included_modules.include?(Vpago::InventoryUnitDecorator) | ||
Spree::InventoryUnit.prepend(Vpago::InventoryUnitDecorator) | ||
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Vpago | ||
module PromotionActionDecorator | ||
def self.prepended(base) | ||
base.enum run_by: { unspecified: 0, store: 1, vendor: 2 }, _prefix: true | ||
end | ||
end | ||
end | ||
|
||
unless Spree::PromotionAction.included_modules.include?(Vpago::PromotionActionDecorator) | ||
Spree::PromotionAction.prepend(Vpago::PromotionActionDecorator) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Vpago | ||
module ShippingMethodDecorator | ||
def self.prepended(base) | ||
base.enum handle_by: { unspecified: 0, store: 1, vendor: 2 }, _prefix: true | ||
end | ||
end | ||
end | ||
|
||
unless Spree::ShippingMethod.included_modules.include?(Vpago::ShippingMethodDecorator) | ||
Spree::ShippingMethod.prepend(Vpago::ShippingMethodDecorator) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Vpago | ||
module ShippingRateDecorator | ||
def self.prepended(base) | ||
base.enum handle_by: { unspecified: 0, store: 1, vendor: 2 }, _prefix: true | ||
|
||
base.scope :handle_by_vendor, -> { where(handle_by: :vendor) } | ||
base.scope :handle_by_store, -> { where(handle_by: :store) } | ||
|
||
base.before_save :set_handle_by | ||
end | ||
|
||
private | ||
|
||
def set_handle_by | ||
self.handle_by = shipping_method.handle_by | ||
end | ||
end | ||
end | ||
|
||
unless Spree::ShippingRate.included_modules.include?(Vpago::ShippingRateDecorator) | ||
Spree::ShippingRate.prepend(Vpago::ShippingRateDecorator) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Vpago | ||
module TaxCategoryDecorator | ||
def self.prepended(base) | ||
base.enum collect_by: { unspecified: 0, store: 1, vendor: 2 }, _prefix: true | ||
end | ||
end | ||
end | ||
|
||
unless Spree::TaxCategory.included_modules.include?(Vpago::TaxCategoryDecorator) | ||
Spree::TaxCategory.prepend(Vpago::TaxCategoryDecorator) | ||
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
5 changes: 5 additions & 0 deletions
5
db/migrate/20240716032312_add_handle_by_to_spree_adjustments.rb
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddHandleByToSpreeAdjustments < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :spree_adjustments, :handle_by, :integer, null: false, default: 0, if_not_exists: true | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20240716032319_add_run_by_to_spree_promotion_actions.rb
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddRunByToSpreePromotionActions < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :spree_promotion_actions, :run_by, :integer, null: false, default: 0, if_not_exists: true | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20240716032325_add_collect_by_to_spree_tax_categories.rb
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddCollectByToSpreeTaxCategories < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :spree_tax_categories, :collect_by, :integer, null: false, default: 0, if_not_exists: true | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20240716032330_add_handle_by_to_spree_shipping_method.rb
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddHandleByToSpreeShippingMethod < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :spree_shipping_methods, :handle_by, :integer, null: false, default: 0, if_not_exists: true | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20240716032335_add_handle_by_to_spree_shipping_rates.rb
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddHandleByToSpreeShippingRates < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :spree_shipping_rates, :handle_by, :integer, null: false, default: 0, if_not_exists: true | ||
end | ||
end |
Oops, something went wrong.