mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
Fix Style/HashSyntax
This commit is contained in:
@@ -4,7 +4,7 @@ module TaxHelper
|
||||
def display_taxes(taxable, display_zero: true)
|
||||
if !taxable.included_tax_total.zero?
|
||||
amount = Spree::Money.new(taxable.included_tax_total, currency: taxable.currency)
|
||||
I18n.t(:tax_amount_included, amount: amount)
|
||||
I18n.t(:tax_amount_included, amount:)
|
||||
elsif !taxable.additional_tax_total.zero?
|
||||
Spree::Money.new(taxable.additional_tax_total, currency: taxable.currency)
|
||||
elsif display_zero
|
||||
|
||||
@@ -26,7 +26,7 @@ class ReportJob < ApplicationJob
|
||||
def email_result(user, blob)
|
||||
ReportMailer.with(
|
||||
to: user.email,
|
||||
blob: blob,
|
||||
blob:,
|
||||
).report_ready.deliver_later
|
||||
end
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class WebhookDeliveryJob < ApplicationJob
|
||||
body = {
|
||||
id: job_id,
|
||||
at: Time.zone.now.to_s,
|
||||
event: event,
|
||||
event:,
|
||||
data: payload,
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class JsonApiSchema
|
||||
attributes: {
|
||||
type: :object,
|
||||
properties: attributes,
|
||||
required: required
|
||||
required:
|
||||
},
|
||||
relationships: {
|
||||
type: :object,
|
||||
|
||||
@@ -12,7 +12,7 @@ class EnterpriseMailer < ApplicationMailer
|
||||
enterprise: @enterprise.name,
|
||||
sitename: Spree::Config[:site_name])
|
||||
mail(to: enterprise.contact.email,
|
||||
subject: subject)
|
||||
subject:)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ class EnterpriseMailer < ApplicationMailer
|
||||
I18n.with_locale valid_locale(@enterprise.owner) do
|
||||
subject = t('enterprise_mailer.invite_manager.subject', enterprise: @enterprise.name)
|
||||
mail(to: user.email,
|
||||
subject: subject)
|
||||
subject:)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class PaymentMailer < ApplicationMailer
|
||||
subject = I18n.t('spree.payment_mailer.authorize_payment.subject',
|
||||
distributor: @payment.order.distributor.name)
|
||||
I18n.with_locale valid_locale(@payment.order.user) do
|
||||
mail(to: payment.order.email, subject: subject)
|
||||
mail(to: payment.order.email, subject:)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ class PaymentMailer < ApplicationMailer
|
||||
order: @payment.order)
|
||||
I18n.with_locale valid_locale(shop_owner) do
|
||||
mail(to: shop_owner.email,
|
||||
subject: subject)
|
||||
subject:)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ class ProducerMailer < ApplicationMailer
|
||||
|
||||
mail(
|
||||
to: @producer.contact.email,
|
||||
subject: subject,
|
||||
subject:,
|
||||
reply_to: @coordinator.contact.email,
|
||||
cc: @coordinator.contact.email
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ module Spree
|
||||
I18n.with_locale valid_locale(@order.distributor.owner) do
|
||||
subject = I18n.t('spree.order_mailer.cancel_email_for_shop.subject')
|
||||
mail(to: @order.distributor.contact.email,
|
||||
subject: subject)
|
||||
subject:)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ module Spree
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend)
|
||||
mail(to: @order.email,
|
||||
subject: subject,
|
||||
subject:,
|
||||
reply_to: @order.distributor.contact.email)
|
||||
end
|
||||
end
|
||||
@@ -42,7 +42,7 @@ module Spree
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend)
|
||||
mail(to: @order.distributor.contact.email,
|
||||
subject: subject)
|
||||
subject:)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ module Spree
|
||||
@shipment = shipment.respond_to?(:id) ? shipment : Spree::Shipment.find(shipment)
|
||||
@delivery = delivery
|
||||
subject = base_subject
|
||||
mail(to: @shipment.order.email, subject: subject)
|
||||
mail(to: @shipment.order.email, subject:)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -5,7 +5,7 @@ module Spree
|
||||
def test_email(user)
|
||||
recipient = user.respond_to?(:id) ? user : Spree::User.find(user)
|
||||
subject = "#{Spree::Config[:site_name]} #{t('spree.test_mailer.test_email.subject')}"
|
||||
mail(to: recipient.email, subject: subject)
|
||||
mail(to: recipient.email, subject:)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ module Spree
|
||||
"#{I18n.t('spree.user_mailer.reset_password_instructions.subject')}"
|
||||
|
||||
I18n.with_locale valid_locale(user) do
|
||||
mail(to: user.email, subject: subject)
|
||||
mail(to: user.email, subject:)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ module Spree
|
||||
I18n.with_locale valid_locale(@user) do
|
||||
subject = t('spree.user_mailer.confirmation_instructions.subject')
|
||||
mail(to: confirmation_email_address,
|
||||
subject: subject)
|
||||
subject:)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class SubscriptionMailer < ApplicationMailer
|
||||
confirm_email_subject = t('spree.order_mailer.confirm_email.subject')
|
||||
subject = "#{Spree::Config[:site_name]} #{confirm_email_subject} ##{order.number}"
|
||||
mail(to: order.email,
|
||||
subject: subject,
|
||||
subject:,
|
||||
reply_to: order.distributor.contact.email)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,19 +17,19 @@ class ColumnPreference < ApplicationRecord
|
||||
} }
|
||||
|
||||
def self.for(user, action_name)
|
||||
stored_preferences = where(user_id: user.id, action_name: action_name)
|
||||
stored_preferences = where(user_id: user.id, action_name:)
|
||||
default_preferences = __send__("#{action_name}_columns")
|
||||
filter(default_preferences, user, action_name)
|
||||
default_preferences.each_with_object([]) do |(column_name, default_attributes), preferences|
|
||||
stored_preference = stored_preferences.find_by(column_name: column_name)
|
||||
stored_preference = stored_preferences.find_by(column_name:)
|
||||
if stored_preference
|
||||
stored_preference.assign_attributes(default_attributes.select{ |k, _v|
|
||||
stored_preference[k].nil?
|
||||
} )
|
||||
preferences << stored_preference
|
||||
else
|
||||
attributes = default_attributes.merge(user_id: user.id, action_name: action_name,
|
||||
column_name: column_name)
|
||||
attributes = default_attributes.merge(user_id: user.id, action_name:,
|
||||
column_name:)
|
||||
preferences << ColumnPreference.new(attributes)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,13 +45,13 @@ module CalculatedAdjustments
|
||||
return if amount.zero? && !mandatory
|
||||
|
||||
adjustment_attributes = {
|
||||
amount: amount,
|
||||
amount:,
|
||||
originator: self,
|
||||
order: order_object_for(adjustable),
|
||||
label: label,
|
||||
mandatory: mandatory,
|
||||
state: state,
|
||||
tax_category: tax_category
|
||||
label:,
|
||||
mandatory:,
|
||||
state:,
|
||||
tax_category:
|
||||
}
|
||||
|
||||
if adjustable.respond_to?(:adjustments)
|
||||
|
||||
@@ -42,7 +42,7 @@ module OrderShipment
|
||||
|
||||
shipment = shipments.first
|
||||
|
||||
shipping_rate = shipment.shipping_rates.find_by(shipping_method_id: shipping_method_id)
|
||||
shipping_rate = shipment.shipping_rates.find_by(shipping_method_id:)
|
||||
return unless shipping_rate
|
||||
|
||||
shipment.selected_shipping_rate_id = shipping_rate.id
|
||||
|
||||
@@ -122,7 +122,7 @@ module VariantStock
|
||||
# This is the original Spree::StockLocation#move,
|
||||
# except that we raise an error if the stock item is missing,
|
||||
# because, unlike Spree, we should always have exactly one stock item per variant.
|
||||
stock_item.stock_movements.create!(quantity: quantity, originator: originator)
|
||||
stock_item.stock_movements.create!(quantity:, originator:)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -39,7 +39,7 @@ class Customer < ApplicationRecord
|
||||
|
||||
scope :of, ->(enterprise) { where(enterprise_id: enterprise) }
|
||||
scope :managed_by, ->(user) {
|
||||
user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none
|
||||
user&.persisted? ? where(user:).or(of(Enterprise.managed_by(user))) : none
|
||||
}
|
||||
scope :created_manually, -> { where(created_manually: true) }
|
||||
scope :visible, -> { where(id: Spree::Order.complete.select(:customer_id)).or(created_manually) }
|
||||
@@ -61,7 +61,7 @@ class Customer < ApplicationRecord
|
||||
end
|
||||
|
||||
def associate_user
|
||||
self.user = user || Spree::User.find_by(email: email)
|
||||
self.user = user || Spree::User.find_by(email:)
|
||||
end
|
||||
|
||||
def update_orders_and_delete_canceled_subscriptions
|
||||
|
||||
@@ -476,8 +476,8 @@ class Enterprise < ApplicationRecord
|
||||
end
|
||||
|
||||
def name_is_unique
|
||||
dups = Enterprise.where(name: name)
|
||||
dups = dups.where.not(id: id) unless new_record?
|
||||
dups = Enterprise.where(name:)
|
||||
dups = dups.where.not(id:) unless new_record?
|
||||
|
||||
errors.add :name, I18n.t(:enterprise_name_error, email: dups.first.owner.email) if dups.any?
|
||||
end
|
||||
@@ -581,7 +581,7 @@ class Enterprise < ApplicationRecord
|
||||
# We avoid an infinite loop and don't need to touch the whole distributor tree.
|
||||
def touch_distributors
|
||||
Enterprise.distributing_products(supplied_products.select(:id)).
|
||||
where.not(enterprises: { id: id }).
|
||||
where.not(enterprises: { id: }).
|
||||
update_all(updated_at: Time.zone.now)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -76,7 +76,7 @@ class EnterpriseRelationship < ApplicationRecord
|
||||
permissions.destroy_all
|
||||
else
|
||||
permissions.where.not(name: perms).destroy_all
|
||||
perms.map { |name| permissions.find_or_initialize_by name: name }
|
||||
perms.map { |name| permissions.find_or_initialize_by name: }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class Exchange < ApplicationRecord
|
||||
return unless variant_ids.any?
|
||||
|
||||
ExchangeVariant.insert_all( # rubocop:disable Rails/SkipsModelValidations
|
||||
variant_ids.map{ |variant_id| { variant_id: variant_id, exchange_id: exchange_id } }
|
||||
variant_ids.map{ |variant_id| { variant_id:, exchange_id: } }
|
||||
)
|
||||
end
|
||||
|
||||
@@ -127,7 +127,7 @@ class Exchange < ApplicationRecord
|
||||
|
||||
ExchangeVariant.where(variant_id: variant_ids).
|
||||
joins(:exchange).
|
||||
where(exchanges: { order_cycle: order_cycle, incoming: false }).
|
||||
where(exchanges: { order_cycle:, incoming: false }).
|
||||
delete_all
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class ExchangeVariant < ApplicationRecord
|
||||
def delete_related_outgoing_variants
|
||||
return unless exchange.incoming?
|
||||
|
||||
ExchangeVariant.where(variant_id: variant_id).
|
||||
ExchangeVariant.where(variant_id:).
|
||||
joins(:exchange).
|
||||
where(exchanges: { order_cycle: exchange.order_cycle, incoming: false }).
|
||||
delete_all
|
||||
|
||||
@@ -116,19 +116,19 @@ class Invoice
|
||||
end
|
||||
|
||||
def display_outstanding_balance
|
||||
Spree::Money.new(new_outstanding_balance, currency: currency)
|
||||
Spree::Money.new(new_outstanding_balance, currency:)
|
||||
end
|
||||
|
||||
def display_checkout_tax_total
|
||||
Spree::Money.new(total_tax, currency: currency)
|
||||
Spree::Money.new(total_tax, currency:)
|
||||
end
|
||||
|
||||
def display_checkout_total_less_tax
|
||||
Spree::Money.new(total - total_tax, currency: currency)
|
||||
Spree::Money.new(total - total_tax, currency:)
|
||||
end
|
||||
|
||||
def display_total
|
||||
Spree::Money.new(total, currency: currency)
|
||||
Spree::Money.new(total, currency:)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,17 +10,17 @@ class Invoice
|
||||
invoice_update_attributes :label
|
||||
|
||||
def display_amount
|
||||
Spree::Money.new(amount, currency: currency)
|
||||
Spree::Money.new(amount, currency:)
|
||||
end
|
||||
|
||||
def display_taxes(display_zero: false)
|
||||
if included_tax_total.positive?
|
||||
amount = Spree::Money.new(included_tax_total, currency: currency)
|
||||
I18n.t(:tax_amount_included, amount: amount)
|
||||
amount = Spree::Money.new(included_tax_total, currency:)
|
||||
I18n.t(:tax_amount_included, amount:)
|
||||
elsif additional_tax_total.positive?
|
||||
Spree::Money.new(additional_tax_total, currency: currency)
|
||||
Spree::Money.new(additional_tax_total, currency:)
|
||||
elsif display_zero
|
||||
Spree::Money.new(0.00, currency: currency)
|
||||
Spree::Money.new(0.00, currency:)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,20 +12,20 @@ class Invoice
|
||||
delegate :name_to_display, :options_text, to: :variant
|
||||
|
||||
def display_amount_with_adjustments
|
||||
Spree::Money.new((price_with_adjustments * quantity), currency: currency)
|
||||
Spree::Money.new((price_with_adjustments * quantity), currency:)
|
||||
end
|
||||
|
||||
def single_display_amount_with_adjustments
|
||||
Spree::Money.new(price_with_adjustments, currency: currency)
|
||||
Spree::Money.new(price_with_adjustments, currency:)
|
||||
end
|
||||
|
||||
def display_line_items_taxes(display_zero: true)
|
||||
if included_tax.positive?
|
||||
Spree::Money.new( included_tax, currency: currency)
|
||||
Spree::Money.new( included_tax, currency:)
|
||||
elsif added_tax.positive?
|
||||
Spree::Money.new( added_tax, currency: currency)
|
||||
Spree::Money.new( added_tax, currency:)
|
||||
elsif display_zero
|
||||
Spree::Money.new(0.00, currency: currency)
|
||||
Spree::Money.new(0.00, currency:)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ class Invoice
|
||||
end
|
||||
|
||||
def display_amount
|
||||
Spree::Money.new(amount, currency: currency)
|
||||
Spree::Money.new(amount, currency:)
|
||||
end
|
||||
|
||||
def payment_method_name
|
||||
|
||||
@@ -15,7 +15,7 @@ class ProducerProperty < ApplicationRecord
|
||||
def property_name=(name)
|
||||
return if name.blank?
|
||||
|
||||
self.property = Spree::Property.find_by(name: name) ||
|
||||
Spree::Property.create(name: name, presentation: name)
|
||||
self.property = Spree::Property.find_by(name:) ||
|
||||
Spree::Property.create(name:, presentation: name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -468,12 +468,12 @@ module ProductImport
|
||||
end
|
||||
|
||||
def mark_as_not_updatable(entry, attribute)
|
||||
mark_as_invalid(entry, attribute: attribute,
|
||||
mark_as_invalid(entry, attribute:,
|
||||
error: I18n.t("admin.product_import.model.not_updatable"))
|
||||
end
|
||||
|
||||
def mark_as_values_must_be_same(entry, attribute)
|
||||
mark_as_invalid(entry, attribute: attribute,
|
||||
mark_as_invalid(entry, attribute:,
|
||||
error: I18n.t("admin.product_import.model.values_must_be_same"))
|
||||
end
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def import_results
|
||||
{ entries: entries_json, reset_counts: reset_counts }
|
||||
{ entries: entries_json, reset_counts: }
|
||||
end
|
||||
|
||||
def save_results
|
||||
@@ -151,7 +151,7 @@ module ProductImport
|
||||
inventory_updated: inventory_updated_count,
|
||||
products_reset: products_reset_count,
|
||||
},
|
||||
updated_ids: updated_ids,
|
||||
updated_ids:,
|
||||
errors: errors.full_messages
|
||||
}
|
||||
end
|
||||
@@ -255,9 +255,9 @@ module ProductImport
|
||||
# build_entries and buils_all_entries
|
||||
def add_malformed_csv_error(error_message)
|
||||
unless errors.added?(:importer, I18n.t('admin.product_import.model.malformed_csv',
|
||||
error_message: error_message))
|
||||
error_message:))
|
||||
errors.add(:importer, I18n.t('admin.product_import.model.malformed_csv',
|
||||
error_message: error_message))
|
||||
error_message:))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class ReportBlob < ActiveStorage::Blob
|
||||
# before we know anything about the report file. It enables us to use the
|
||||
# same blob in the controller to read the result.
|
||||
create_before_direct_upload!(
|
||||
filename: filename,
|
||||
filename:,
|
||||
byte_size: 0,
|
||||
checksum: "0",
|
||||
content_type: content_type(filename),
|
||||
|
||||
@@ -86,13 +86,13 @@ module Spree
|
||||
def active_merchant_hash
|
||||
{
|
||||
name: full_name,
|
||||
address1: address1,
|
||||
address2: address2,
|
||||
city: city,
|
||||
address1:,
|
||||
address2:,
|
||||
city:,
|
||||
state: state_text,
|
||||
zip: zipcode,
|
||||
country: country.try(:iso),
|
||||
phone: phone
|
||||
phone:
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user