Class: Datanorm::Lines::V4::Product

Inherits:
Base
  • Object
show all
Defined in:
lib/datanorm/lines/v4/product.rb

Overview

Represents one line containting a product main name, quantity unit and price.

Example:

A;N;QBMK10208R;50;Brandmeldekabel rot;1;3;M;228313;2AED; ; ;
0

Satzartenkennzeichen “A”

1

Verarbeitungskennzeichen (N=Neuanlage, L=Löschung, A=Änderung, X=Artikelnummernänderung)

2

Artikelnummer

3

Textkennzeichen

4

Artikelbezeichnung 1 (Kurztextzeile 1)

5

Artikelbezeichnung 2 (Kurztextzeile 2)

6

Preiskennzeichen (see ‘Datanorm::Lines::V4::Price`)

7

Preiseinheit (0= per Mengeneinheit 1; 1=10, 2=100, 3=1000)

8

Mengeneinheit (Stk, m, lfm)

9

Preis (Wenn Hersteller die Preise mit Satzart “P” liefern, braucht hier kein Preis (0) eingetragen werden)

10

Rabattgruppe (Zur Ermittlung des Netto-Artikelpreises über die Rabattmatrix)

11

Hauptwarengruppe

12

Langtextschlüssel (Mit dem Langtextschlüssel wird ein Text aus mehreren Zeilen (Satzart T) an den Artikel gekettet.

Instance Attribute Summary

Attributes inherited from Base

#columns, #source_line_number

Instance Method Summary collapse

Methods inherited from Base

#encode, inherited, #initialize, #record_kind, #to_json

Constructor Details

This class inherits a constructor from Datanorm::Lines::Base

Instance Method Details

#as_jsonObject

rubocop:disable Metrics/MethodLength



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/datanorm/lines/v4/product.rb', line 74

def as_json # rubocop:disable Metrics/MethodLength
  {
    id:,
    text_id:,
    is_retail_price: retail_price?,
    is_wholesale_price: wholesale_price?,
    cents:,
    title:,
    quantity_unit:,
    quantity:,
    discount_group:
  }
end

#centsObject



49
50
51
# File 'lib/datanorm/lines/v4/product.rb', line 49

def cents
  columns[9].to_i
end

#discount_groupObject



70
71
72
# File 'lib/datanorm/lines/v4/product.rb', line 70

def discount_group
  ::Datanorm::Helpers::Utf8.call columns[9]
end

#idObject



33
34
35
# File 'lib/datanorm/lines/v4/product.rb', line 33

def id
  ::Datanorm::Helpers::Utf8.call columns[2]
end

#quantityObject



61
62
63
64
65
66
67
68
# File 'lib/datanorm/lines/v4/product.rb', line 61

def quantity
  case columns[7].to_i
  when 0 then 1
  when 1 then 10
  when 2 then 100
  when 3 then 1000
  end
end

#quantity_unitObject



57
58
59
# File 'lib/datanorm/lines/v4/product.rb', line 57

def quantity_unit
  ::Datanorm::Helpers::Utf8.call columns[8]
end

#retail_price?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/datanorm/lines/v4/product.rb', line 41

def retail_price?
  columns[6] == '1'
end

#text_idObject



37
38
39
# File 'lib/datanorm/lines/v4/product.rb', line 37

def text_id
  ::Datanorm::Helpers::Utf8.call columns[12]
end

#titleObject



53
54
55
# File 'lib/datanorm/lines/v4/product.rb', line 53

def title
  ::Datanorm::Helpers::Utf8.call columns[4..5].join(' ').strip
end

#to_sObject



29
30
31
# File 'lib/datanorm/lines/v4/product.rb', line 29

def to_s
  "<Product #{as_json}>"
end

#wholesale_price?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/datanorm/lines/v4/product.rb', line 45

def wholesale_price?
  columns[6] == '2'
end