extface 0.4.6k → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ede5b88e7959cc6c14c2a2b7eaa1ece5ed393e5b
4
- data.tar.gz: 313d55aae1f2178e4c0e4d7aa5b54ef171846fd8
3
+ metadata.gz: 86eeadecf20a2ea8daa39cb2ba6ebdbe73a34412
4
+ data.tar.gz: 382850d445c1c6b67deea928c4721f3c64010603
5
5
  SHA512:
6
- metadata.gz: 4684b142a6421b87b1156638862b140670c65d9f9d0bc9574e5c784afe1b3be11b03c9c209fde52827292a5455ae43ebde7581b01e18dbcde84caf458b4ff92b
7
- data.tar.gz: 726b94534299b4be2c7cc7ffe02fec9b220f1ba54774e7105a14ed06c8300b9147e5566d721e87c466a1882aaef37ca7bd2ac7380ef3002a5d901c264a421c0d
6
+ metadata.gz: a106262ddd387f6952e355fbf55dad497171295d7c02f9c0701c829d3bd26e0db74829663df377fb7a429b489265f96c254d8e30485b4afec9fe322f5cecba6e
7
+ data.tar.gz: a1fb0ba140eb33919fcf1119004df102335e66d101820b2d9f340af7eb43a9e5a3e795990b6e78e16e6781a117bb097b3a8dd847cf205427cd5f6d60284ead55
@@ -119,24 +119,17 @@ module Extface
119
119
  s.notify "Fiscal Doc Start"
120
120
  s.open_fiscal_doc(operator_mapping.try(:mapping), operator_mapping.try(:pwd))
121
121
  s.notify "Register Sale"
122
- total_modifier = nil
123
- # if global_modifier_value = bill.global_modifier_value
124
- # s.notify "Register Global Modifier"
125
- # total_modifier = global_modifier_value.to_f
126
- # end
127
122
  s.add_sale(
128
123
  SaleItem.new(
129
124
  price: bill.payments_sum.to_f,
130
- #text1: bill.name,
131
- text1: '',
125
+ text1: bill.name,
132
126
  tax_group: bill.charges.first.find_tax_group_mapping_for(self), #find tax group mapping by ratio , not nice
133
- neto: total_modifier
134
127
  )
135
128
  )
136
- # if global_modifier_value = bill.global_modifier_value
137
- # s.notify "Register Global Modifier"
138
- # s.add_total_modifier global_modifier_value.to_f
139
- # end
129
+ if global_modifier_value = bill.global_modifier_value
130
+ s.notify "Register Global Modifier"
131
+ s.add_total_modifier global_modifier_value.to_f
132
+ end
140
133
  s.notify "Register Payment"
141
134
  bill.payments.each do |payment|
142
135
  s.add_payment payment.value.to_f, payment.find_payment_type_mapping_for(self)
@@ -224,7 +224,7 @@ module Extface
224
224
  end
225
225
  elsif !resp.ack?
226
226
  invalid_frames += 1
227
- if invalid_frames > INVALID_FRAME_RETRIES
227
+ if nak_messages > INVALID_FRAME_RETRIES
228
228
  errors.add :base, "#{INVALID_FRAME_RETRIES} Broken Packets Received. Abort!"
229
229
  break
230
230
  end
@@ -256,7 +256,7 @@ module Extface
256
256
  data << ("%.2f" % item.price)
257
257
  data << "*#{item.qty.to_s}" unless item.qty.blank?
258
258
  data << ",#{item.percent}" unless item.percent.blank?
259
- data << "$#{'%.2f' % item.neto}" unless item.neto.blank?
259
+ data << "$#{neto}" unless item.neto.blank?
260
260
  end
261
261
  end
262
262
 
@@ -283,7 +283,7 @@ module Extface
283
283
  errors.add :base, "Fiscal Device General Error" unless (status[0].ord & 0x20).zero?
284
284
  errors.add :base, "Invalid Command" unless (status[0].ord & 0x02).zero?
285
285
  errors.add :base, "Date & Time Not Set" unless (status[0].ord & 0x04).zero?
286
- errors.add :base, "Syntax Error" unless (status[0].ord & 0x01).zero?
286
+ errors.add :base, "Syntax Error" unless (status[0].ord & 0x02).zero?
287
287
 
288
288
  errors.add :base, "Wrong Password" unless (status[1].ord & 0x40).zero?
289
289
  errors.add :base, "Cutter Error" unless (status[1].ord & 0x20).zero?
@@ -6,31 +6,11 @@ module Extface
6
6
  INVALID_FRAME_RETRIES = 6 #count (bad length, bad checksum)
7
7
  ACKS_MAX_WAIT = 60 #count / nothing is forever
8
8
  NAKS_MAX_COUNT = 3 #count
9
-
10
- TAX_GROUPS_MAP = {
11
- 1 => "\xc0",
12
- 2 => "\xc1",
13
- 3 => "\xc2",
14
- 4 => "\xc3",
15
- 5 => "\xc4",
16
- 6 => "\xc5",
17
- 7 => "\xc6",
18
- 8 => "\xc7"
19
- }
20
-
21
- PAYMENT_TYPE_MAP = {
22
- 1 => "P",
23
- 2 => "N",
24
- 3 => "C",
25
- 4 => "D",
26
- 5 => "B"
27
- }
28
9
 
29
10
  include Extface::Driver::Datecs::CommandsV1
30
11
 
31
12
  def handle(buffer)
32
- #if i = buffer.index(/[\x03\x16\x15]/) # find position of frame possible delimiter
33
- if i = buffer.index("\x03") || buffer.index("\x16") || buffer.index("\x15")
13
+ if i = buffer.index(/[\x03\x16\x15]/) # find position of frame possible delimiter
34
14
  rpush buffer[0..i] # this will make data available for #pull(timeout) method
35
15
  return i+1 # return number of bytes processed
36
16
  end
@@ -97,8 +77,8 @@ module Extface
97
77
  end
98
78
 
99
79
  #fiscal
100
- def open_fiscal_doc(operator = "1", password = "000000")
101
- fsend Sales::START_FISCAL_DOC, "#{operator.presence || "1"},#{password.presence || "000000"},00001"
80
+ def open_fiscal_doc(operator = "1", password = "1")
81
+ fsend Sales::START_FISCAL_DOC, "#{operator.presence || "1"},#{password.presence || "1"},00001"
102
82
  @fiscal_session = true
103
83
  end
104
84
 
@@ -152,7 +132,7 @@ module Extface
152
132
  def cancel_doc_session
153
133
  device.session("Doc cancel") do |s|
154
134
  s.notify "Doc Cancel Start"
155
- s.fsend Sales::CANCEL_FISCAL_DOC
135
+ s.fsend Sales::CANCEL_DOC
156
136
  s.paper_cut
157
137
  s.notify "Doc Cancel End"
158
138
  end
@@ -185,7 +165,7 @@ module Extface
185
165
  end
186
166
  elsif !resp.ack?
187
167
  invalid_frames += 1
188
- if invalid_frames > INVALID_FRAME_RETRIES
168
+ if nak_messages > INVALID_FRAME_RETRIES
189
169
  errors.add :base, "#{INVALID_FRAME_RETRIES} Broken Packets Received. Abort!"
190
170
  break
191
171
  end
@@ -231,25 +211,11 @@ module Extface
231
211
  errors.add :base, "Fiscal Device General Error" unless (status_0 & 0x20).zero?
232
212
  errors.add :base, "Invalid Command" unless (status_0 & 0x02).zero?
233
213
  errors.add :base, "Date & Time Not Set" unless (status_0 & 0x04).zero?
234
- errors.add :base, "Syntax Error" unless (status_0 & 0x01).zero?
214
+ errors.add :base, "Syntax Error" unless (status_0 & 0x02).zero?
235
215
  status_1 = status[1].ord
236
- errors.add :base, "Unpermitted Command In This Mode" unless (status_1 & 0x02).zero?
237
- errors.add :base, "Field Overflow" unless (status_1 & 0x01).zero?
238
216
  end
239
217
 
240
218
  private
241
- def build_sale_data(item)
242
- "".tap() do |data|
243
- data << item.text1 unless item.text1.blank?
244
- data << "\x0a#{text2}" unless item.text2.blank?
245
- data << "\t"
246
- data << TAX_GROUPS_MAP[item.tax_group || 2]
247
- data << ("%.2f" % item.price)
248
- data << "*#{item.qty.to_s}" unless item.qty.blank?
249
- data << ",#{item.percent}" unless item.percent.blank?
250
- data << ",;#{'%.2f' % item.neto}" unless item.neto.blank?
251
- end
252
- end
253
219
 
254
220
  def sequence_number
255
221
  @seq ||= 0x1f
@@ -262,7 +228,7 @@ module Extface
262
228
  include ActiveModel::Validations
263
229
  attr_reader :frame, :len, :seq, :cmd, :data, :status, :bcc
264
230
 
265
- validates_presence_of :frame#, unless: :unpacked?
231
+ validates_presence_of :frame, unless: :unpacked?
266
232
  validate :bcc_validation
267
233
  validate :len_validation
268
234
 
@@ -284,7 +250,6 @@ module Extface
284
250
  def nak?; !!@nak; end #should retry command with same seq
285
251
 
286
252
  private
287
-
288
253
  def unpacked? # is it packed or unpacked message?
289
254
  @ack || @nak
290
255
  end
@@ -1,3 +1,3 @@
1
1
  module Extface
2
- VERSION = "0.4.6k"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6k
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Vangelov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-02 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -242,9 +242,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
242
242
  version: '0'
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  requirements:
245
- - - ">"
245
+ - - ">="
246
246
  - !ruby/object:Gem::Version
247
- version: 1.3.1
247
+ version: '0'
248
248
  requirements: []
249
249
  rubyforge_project:
250
250
  rubygems_version: 2.4.6