require 'ordoro/record/base'

module Ordoro
  module Record
    class PurchaseOrder < Base

      attribute :status
      attribute :shipping_method
      attribute :items, Array[Ordoro::Record::PurchaseOrderLineItem]
      attribute :po_id, String
      attribute :company_id, Integer
      attribute :warehouse, String
      attribute :supplier, Ordoro::Record::Supplier
      attribute :sent, DateTime
      attribute :instructions, String
    end
  end
end

require 'ordoro/record/base'

module Ordoro
  module Record
    class PurchaseOrder < Base

      attribute :status, String, readonly: true
      attribute :shipping_method, String
      attribute :items, Array[Ordoro::Record::PurchaseOrderLineItem], readonly: true
      attribute :po_id, String, writable_on: :create
      attribute :company_id, Integer, readonly: true
      attribute :warehouse, Integer
      attribute :supplier, Ordoro::Record::Supplier, readonly: true
      attribute :sent, DateTime
      attribute :instructions, String

      def initialize(attributes={})
        self.po_id = attributes.delete('id_token')
        super(attributes)
      end

      def persisted?
        po_id
      end
    end
  end
end

Allow POs to be marked as sent
Allow POs to be marked as sent
