Sha256: 1ac8457d3c7d5b2a65ff5a70b707f3a0aa550cdee1e9a3d3aabe2bfefe78f707
Contents?: true
Size: 1.34 KB
Versions: 7
Compression:
Stored size: 1.34 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 attributes_for_gl_transaction { location: location, source: self, description: "PO RECPT #{self.visible_id}" } end def logit end 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
7 entries across 7 versions & 2 rubygems