Sha256: 87a99f761a0273951d565e89338ba2d08a7e553dee973a811dd56fb7c2f3a785
Contents?: true
Size: 945 Bytes
Versions: 4
Compression:
Stored size: 945 Bytes
Contents
module Comee module Core class PurchaseOrder < ApplicationRecord before_save :total_price belongs_to :supplier has_many :purchase_order_items validates :po_number, presence: true, uniqueness: true validates :order_date, :delivery_address, :status, :delivery_date, presence: true enum status: { draft: 0, submitted: 1, approved: 2, confirmed: 3, canceled: 4 } def total_price items = PurchaseOrderItem.where(purchase_order_id: id) self.total_price = items.sum(&:total_price) end def self.ransackable_attributes(_auth_object = nil) %w[ id supplier_id unit_id order_date status delivery_address delivery_date ] end def self.ransackable_associations(_auth_object = nil) %w[supplier unit] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems