Sha256: d8dae57ef1debb5ab09ef874ac63022da7f3b5e12f0a3721dfffb1444356f132
Contents?: true
Size: 1.63 KB
Versions: 12
Compression:
Stored size: 1.63 KB
Contents
module Comee module Core class SalesOrderItem < ApplicationRecord before_save :calculate_total_price enum processing_status: {unprocessed: 0, partially_processed: 1, fully_processed: 2} belongs_to :sales_order belongs_to :customer_order_item belongs_to :product belongs_to :unit belongs_to :source, class_name: "Comee::Core::FulfillmentCenter", optional: true belongs_to :purchase_order_item, optional: true has_many :shipment_items validates :customer_item_no, :customer_item_description, :delivery_date, :processing_status, presence: true validates :quantity, :price, presence: true, numericality: {greater_than: 0} validates :quantity_delivered, :quantity_canceled, numericality: {greater_than_or_equal_to: 0} delegate(:po_number, to: :purchase_order_item, prefix: false, allow_nil: true) def calculate_total_price self.total_price = price * quantity end def quantity_remaining quantity - (quantity_delivered + quantity_canceled) end def self.ransackable_attributes(_auth_object = nil) %w[ id customer_item_no customer_item_description customer_order_item_id delivery_date eb_number handover_date lead_time product_id sales_order_id purchase_order_item_id source_id unit_id processing_status ] end def self.ransackable_associations(_auth_object = nil) %w[customer_order_item product sales_order purchase_order_item source unit] end end end end
Version data entries
12 entries across 12 versions & 1 rubygems