Sha256: 4344bbc7cbd2f62aa845cc223f7448e2264005007e82d97d5be15a4ee5543985

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module AmoCRM::Entities
  # Пример:
  # https://support.moysklad.ru/hc/ru/articles/203402923-Пример-загрузки-заказа-покупателя-через-REST-API
  #
  class CustomerOrder < Base
    include CommonObject
    include XmlFix

    tag 'customerOrder'

    attribute :created,     Time
    attribute :createdBy,   String

    attribute :stateUuid, String

    attribute :reservedSum,     Float

    attribute :sourceStoreUuid, String
    attribute :sourceAccountUuid, String
    attribute :sourceAgentUuid, String

    attribute :targetAgentUuid, String
    attribute :targetAccountUuid, String

    attribute :applicable,      Boolean
    attribute :moment,          Time

    attribute :payerVat,        Boolean

    attribute :consignmentUuid, String

    attribute :rate,            Float

    attribute :vatIncluded,     Boolean
    attribute :name,            String

    element   :sum,             AmoCRM::Entities::Price, tag: :sum

    element   :deleted,         Time

    has_many  :customerOrderPosition, AmoCRM::Entities::CustomerOrderPosition

    def state universe
      cache :customer_order_states, universe do
        fail "No stateUuid in CustomerOrder #{uuid}" unless stateUuid
        workflow = universe.workflows.findWhere name: 'CustomerOrder'
        workflow.states.find { |s| s.uuid == stateUuid }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amo_crm-0.2.2 lib/amo_crm/entities/customer_order.rb