foodsoft/app/models/article_price.rb
Philipp Rothmann fb2b4d8a8a chore: rubocop
chore: fix api test conventions

chore: rubocop -A spec/

chore: more rubocop -A

fix failing test

rubocop fixes

removes helper methods that are in my opinion dead code

more rubocop fixes

rubocop -a --auto-gen-config
2023-06-09 17:35:05 +02:00

31 lines
1,018 B
Ruby

class ArticlePrice < ApplicationRecord
include LocalizeInput
include PriceCalculation
# @!attribute price
# @return [Number] Net price
# @see Article#price
# @!attribute tax
# @return [Number] VAT percentage
# @see Article#tax
# @!attribute deposit
# @return [Number] Deposit
# @see Article#deposit
# @!attribute unit_quantity
# @return [Number] Number of units in wholesale package (box).
# @see Article#unit
# @see Article#unit_quantity
# @!attribute article
# @return [Article] Article this price is about.
belongs_to :article
# @!attribute order_articles
# @return [Array<OrderArticle>] Order articles this price is associated with.
has_many :order_articles
localize_input_of :price, :tax, :deposit
validates :price, :tax, :deposit, :unit_quantity, presence: true
validates :price, numericality: { greater_than_or_equal_to: 0 }
validates :unit_quantity, numericality: { greater_than: 0 }
validates :deposit, :tax, numericality: true
end