Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vouchers part 1 #11002

Merged
merged 16 commits into from
Jun 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ def states
delegate :create_line_item_fees!, :create_order_fees!, :update_order_fees!,
:update_line_item_fees!, :recreate_all_fees!, to: :fee_handler

# Needs to happen before save_permalink is called
before_validation :set_currency
before_validation :generate_order_number, if: :new_record?
before_validation :clone_billing_address, if: :use_billing?
before_validation :ensure_customer

before_create :link_by_email
after_create :create_tax_charge!

validates :customer, presence: true, if: :require_customer?
validate :products_available_from_new_distribution, if: lambda {
distributor_id_changed? || order_cycle_id_changed?
Expand All @@ -107,16 +98,24 @@ def states
validates :order_cycle, presence: true, on: :require_distribution
validates :distributor, presence: true, on: :require_distribution

make_permalink field: :number
before_validation :set_currency
before_validation :generate_order_number, if: :new_record?
before_validation :clone_billing_address, if: :use_billing?
before_validation :ensure_customer
dacook marked this conversation as resolved.
Show resolved Hide resolved

before_create :link_by_email
before_save :update_shipping_fees!, if: :complete?
before_save :update_payment_fees!, if: :complete?

after_create :create_tax_charge!

after_save_commit DefaultAddressUpdater

make_permalink field: :number

attribute :send_cancellation_email, type: :boolean, default: true
attribute :restock_items, type: :boolean, default: true
# -- Scopes

scope :not_empty, -> {
left_outer_joins(:line_items).where.not(spree_line_items: { id: nil })
}
Expand Down