Sha256: c28ed82c31cd1c6dd5b949bba7edfadbdf2c9184807dbf03bc80521621a7a12f
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
module Skr # Is a record of an inventory receipt # A {PurchaseOrder} can have one or more of them class PoReceipt < Skr::Model has_visible_id has_sku_loc_lines has_gl_transaction belongs_to :purchase_order, export: true belongs_to :vendor, export: true belongs_to :location, export: true has_one :gl_transaction, :as=>:source has_many :lines, :class_name=>'Skr::PorLine', export: { writable: true }, inverse_of: :po_receipt validates :freight, numericality: true validates :purchase_order, :location, presence: true before_create :record_freight, if: ->{ freight.nonzero? } after_create :logit def purchase_order=(po) super self.location ||= purchase_order.location self.vendor = purchase_order.vendor end private def record_freight GlTransaction.current.add_posting( amount: self.freight, debit: GlAccount.default_for( :inventory_receipts_clearing ), credit: vendor.gl_freight_account ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stockor-0.5.0 | lib/skr/models/po_receipt.rb |
stockor-0.4.0 | lib/skr/models/po_receipt.rb |