Class: Bisac::POALineItem
- Inherits:
-
Object
- Object
- Bisac::POALineItem
- Includes:
- Utils
- Defined in:
- lib/bisac/poa_line_item.rb
Overview
represents a single line on the purchase order ack
Instance Attribute Summary collapse
-
#discount ⇒ Object
Returns the value of attribute discount.
-
#isbn ⇒ Object
Returns the value of attribute isbn.
-
#line_item_number ⇒ Object
Returns the value of attribute line_item_number.
-
#list_nett_indicator ⇒ Object
Returns the value of attribute list_nett_indicator.
-
#nett_price ⇒ Object
Returns the value of attribute nett_price.
-
#order_qty ⇒ Object
Returns the value of attribute order_qty.
-
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
-
#shippable_qty ⇒ Object
Returns the value of attribute shippable_qty.
-
#special_price ⇒ Object
Returns the value of attribute special_price.
-
#status ⇒ Object
Returns the value of attribute status.
-
#supplier_poa_number ⇒ Object
Returns the value of attribute supplier_poa_number.
-
#unit_price ⇒ Object
Returns the value of attribute unit_price.
-
#warehouse_status ⇒ Object
Returns the value of attribute warehouse_status.
Class Method Summary collapse
-
.load_from_string(data) ⇒ Object
returns a new Bisac::POLineItem object using the data passed in as a string refer to the bisac spec for the expected format of the string.
Instance Method Summary collapse
- #isbn10 ⇒ Object
-
#isbn? ⇒ Boolean
is the isbn for this product valid?.
- #status_text ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#discount ⇒ Object
Returns the value of attribute discount.
12 13 14 |
# File 'lib/bisac/poa_line_item.rb', line 12 def discount @discount end |
#isbn ⇒ Object
Returns the value of attribute isbn.
14 15 16 |
# File 'lib/bisac/poa_line_item.rb', line 14 def isbn @isbn end |
#line_item_number ⇒ Object
Returns the value of attribute line_item_number.
11 12 13 |
# File 'lib/bisac/poa_line_item.rb', line 11 def line_item_number @line_item_number end |
#list_nett_indicator ⇒ Object
Returns the value of attribute list_nett_indicator.
12 13 14 |
# File 'lib/bisac/poa_line_item.rb', line 12 def list_nett_indicator @list_nett_indicator end |
#nett_price ⇒ Object
Returns the value of attribute nett_price.
11 12 13 |
# File 'lib/bisac/poa_line_item.rb', line 11 def nett_price @nett_price end |
#order_qty ⇒ Object
Returns the value of attribute order_qty.
11 12 13 |
# File 'lib/bisac/poa_line_item.rb', line 11 def order_qty @order_qty end |
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
10 11 12 |
# File 'lib/bisac/poa_line_item.rb', line 10 def sequence_number @sequence_number end |
#shippable_qty ⇒ Object
Returns the value of attribute shippable_qty.
13 14 15 |
# File 'lib/bisac/poa_line_item.rb', line 13 def shippable_qty @shippable_qty end |
#special_price ⇒ Object
Returns the value of attribute special_price.
12 13 14 |
# File 'lib/bisac/poa_line_item.rb', line 12 def special_price @special_price end |
#status ⇒ Object
Returns the value of attribute status.
13 14 15 |
# File 'lib/bisac/poa_line_item.rb', line 13 def status @status end |
#supplier_poa_number ⇒ Object
Returns the value of attribute supplier_poa_number.
10 11 12 |
# File 'lib/bisac/poa_line_item.rb', line 10 def supplier_poa_number @supplier_poa_number end |
#unit_price ⇒ Object
Returns the value of attribute unit_price.
11 12 13 |
# File 'lib/bisac/poa_line_item.rb', line 11 def unit_price @unit_price end |
#warehouse_status ⇒ Object
Returns the value of attribute warehouse_status.
13 14 15 |
# File 'lib/bisac/poa_line_item.rb', line 13 def warehouse_status @warehouse_status end |
Class Method Details
.load_from_string(data) ⇒ Object
returns a new Bisac::POLineItem object using the data passed in as a string refer to the bisac spec for the expected format of the string
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bisac/poa_line_item.rb', line 18 def self.load_from_string(data) data = data.to_s.ljust(93) raise ArgumentError, "POA Line Items must start with '40'" unless data[0,2] == "40" item = POALineItem.new item.sequence_number = data[2,5].to_i item.supplier_poa_number = data[7,13].strip item.line_item_number = data[20,10].strip # prefer the 13 digit ISBN if it exists (it's a non-standard, Pacstream extension) # fallback to the ISBN10 item.isbn = data[80,13].strip item.isbn = data[30,10].strip if item.isbn.nil? item.order_qty = data[40,5].to_i item.unit_price = BigDecimal.new(data[45,8]) / 100 item.nett_price = BigDecimal.new(data[53,9]) / 100 item.list_nett_indicator = data[62,1] item.special_price = data[63,1] item.discount = BigDecimal.new(data[63,1]) / 100 item.shippable_qty = data[69,5].to_i item.status = data[74,2].to_i item.warehouse_status = data[76,2].to_i return item end |
Instance Method Details
#isbn10 ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/bisac/poa_line_item.rb', line 60 def isbn10 if isbn? && @isbn[0,3] == "978" ISBN10.complete(@isbn[3,9]) else @isbn end end |
#isbn? ⇒ Boolean
is the isbn for this product valid?
56 57 58 |
# File 'lib/bisac/poa_line_item.rb', line 56 def isbn? EAN13.valid?(@isbn || "") end |
#status_text ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/bisac/poa_line_item.rb', line 87 def status_text case self.status when 1 then "Accepted: Title Shipped As Ordered" when 2 then "Accepted: Substitute Title Shipped As Ordered" when 3 then "Cancelled: Future Publication" when 4 then "Cancelled: Future Publication" # date available when 5 then "Backordered: Future Publication" when 6 then "Cancelled: Out of Stock" when 7 then "Backordered: Out of Stock" when 8 then "Cancelled: Out of Print" when 9 then "Partial Ship: Cancel Rest" when 10 then "Partial Ship: Backorder Rest" when 11 then "Cancelled: HB Out of Print, PB Available" when 12 then "Cancelled: PB Out of Print, HB Available" when 13 then "Cancelled: Out of Print, Alt. Edition Available" when 14 then "Backordered: Subtitute Title on BO." when 15 then "Cancelled: No Rights" when 16 then "Cancelled: Not our Publication" when 17 then "Accepted: Free Book" when 18 then "Cancelled: BO Expired" when 19 then "Cancelled: Subscription Only" when 20 then "Cancelled: Not Carried" when 21 then "Cancelled: Not Carried" when 22 then "Cancelled: Import Title" when 23 then "Cancelled: Not Available for Wholesale" when 24 then "Cancelled: Kits Not Available" when 25 then "Cancelled: Not Available" when 26 then "Cancelled: New Price From Publisher" when 27 then "Cancelled: ISBN Not Recognised" when 28 then "Cancelled: Out of Print" when 29 then "Backordered: At Customers Request" else "UNKNOWN" end end |
#to_s ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bisac/poa_line_item.rb', line 68 def to_s line = " " * 93 line[0,2] = "40" # line type line[2,5] = @sequence_number.to_s.rjust(5,"0") # line counter line[7,13] = pad_trunc(@supplier_poa_number, 13) line[20,10] = rpad_trunc(@line_item_number, 10, "0") line[30,10] = pad_trunc(isbn10, 10) line[40,5] = rpad_trunc(@order_qty, 5, "0") line[45,8] = rpad_trunc(@unit_price.to_i, 8, "0") line[53,9] = rpad_trunc(@nett_price.to_i, 9, "0") line[62,1] = pad_trunc(@list_nett_indicator, 1) line[63,1] = rpad_trunc(@special_price, 1, "0") line[64,5] = rpad_trunc(@discount.to_i, 5, "0") line[69,5] = rpad_trunc(@shippable_qty, 5, "0") line[74,2] = rpad_trunc(@status, 2, "0") line[80,13] = pad_trunc(isbn, 13) line end |