extface 0.4.6a → 0.4.6b

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6a5e92df95302c771ddb50d19300c437e18b089
4
- data.tar.gz: d371929e63c4779cf028f6464d03266fc5e00e7f
3
+ metadata.gz: 559dd9a69d057d63eec58689df5acdeac89dc0b3
4
+ data.tar.gz: 42ab44a0dc85ab3c5c8bb730f3d5fd1ca8fedb9d
5
5
  SHA512:
6
- metadata.gz: 213e8d580c1e35bf442b3c49c3f4251cf7e0d47843beccc245254ef2705445931adea025c0589390e72c800a61d1c3b854a60166521f3d6142753a6ab0ee1861
7
- data.tar.gz: fe4b57ffe2d57fc16f6e2958543fa43bcbaba43fc333c170d60d1d9a2ec0c13e4b827d61fb4bdec45b279cfc8ed3332ed84ee134a9bf540ed3474bda8ed65e7b
6
+ metadata.gz: 22c93ea7ddc98b9c7b860b0bc071672bd4175de73a9bc1e915a455369c05aa38ba691923b7bcb61cb4b5c27aa11be64667bdad52b153466b9e1f575ac109142e
7
+ data.tar.gz: 1e173f3c7e95fb9993d5514590acc3f4c0b4cfe0181a737ca0abd6b331e7a39eb5d719c0d3dfb92c135a22476e4786f4dbfc084bb9b678f619ba8f56ab4c45b1
@@ -119,17 +119,24 @@ 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
122
127
  s.add_sale(
123
128
  SaleItem.new(
124
129
  price: bill.payments_sum.to_f,
125
- text1: bill.name,
130
+ #text1: bill.name,
131
+ text1: '',
126
132
  tax_group: bill.charges.first.find_tax_group_mapping_for(self), #find tax group mapping by ratio , not nice
133
+ neto: total_modifier
127
134
  )
128
135
  )
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
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
133
140
  s.notify "Register Payment"
134
141
  bill.payments.each do |payment|
135
142
  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 nak_messages > INVALID_FRAME_RETRIES
227
+ if invalid_frames > 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 << "$#{neto}" unless item.neto.blank?
259
+ data << "$#{'%.2f' % item.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 & 0x02).zero?
286
+ errors.add :base, "Syntax Error" unless (status[0].ord & 0x01).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?
@@ -10,7 +10,8 @@ module Extface
10
10
  include Extface::Driver::Datecs::CommandsV1
11
11
 
12
12
  def handle(buffer)
13
- if i = buffer.index(/[\x03\x16\x15]/) # find position of frame possible delimiter
13
+ #if i = buffer.index(/[\x03\x16\x15]/) # find position of frame possible delimiter
14
+ if i = buffer.index("\x03") || buffer.index("\x16") || buffer.index("\x15")
14
15
  rpush buffer[0..i] # this will make data available for #pull(timeout) method
15
16
  return i+1 # return number of bytes processed
16
17
  end
@@ -165,7 +166,7 @@ module Extface
165
166
  end
166
167
  elsif !resp.ack?
167
168
  invalid_frames += 1
168
- if nak_messages > INVALID_FRAME_RETRIES
169
+ if invalid_frames > INVALID_FRAME_RETRIES
169
170
  errors.add :base, "#{INVALID_FRAME_RETRIES} Broken Packets Received. Abort!"
170
171
  break
171
172
  end
@@ -211,7 +212,7 @@ module Extface
211
212
  errors.add :base, "Fiscal Device General Error" unless (status_0 & 0x20).zero?
212
213
  errors.add :base, "Invalid Command" unless (status_0 & 0x02).zero?
213
214
  errors.add :base, "Date & Time Not Set" unless (status_0 & 0x04).zero?
214
- errors.add :base, "Syntax Error" unless (status_0 & 0x02).zero?
215
+ errors.add :base, "Syntax Error" unless (status_0 & 0x01).zero?
215
216
  status_1 = status[1].ord
216
217
  errors.add :base, "Unpermitted Command In This Mode" unless (status_1 & 0x02).zero?
217
218
  errors.add :base, "Field Overflow" unless (status_1 & 0x01).zero?
@@ -230,7 +231,7 @@ module Extface
230
231
  include ActiveModel::Validations
231
232
  attr_reader :frame, :len, :seq, :cmd, :data, :status, :bcc
232
233
 
233
- validates_presence_of :frame, unless: :unpacked?
234
+ validates_presence_of :frame#, unless: :unpacked?
234
235
  validate :bcc_validation
235
236
  validate :len_validation
236
237
 
@@ -252,6 +253,19 @@ module Extface
252
253
  def nak?; !!@nak; end #should retry command with same seq
253
254
 
254
255
  private
256
+ def build_sale_data(item)
257
+ "".tap() do |data|
258
+ data << item.text1 unless item.text1.blank?
259
+ data << "\x0a#{text2}" unless item.text2.blank?
260
+ data << "\t"
261
+ data << TAX_GROUPS_MAP[item.tax_group || 2]
262
+ data << ("%.2f" % item.price)
263
+ data << "*#{item.qty.to_s}" unless item.qty.blank?
264
+ data << ",#{item.percent}" unless item.percent.blank?
265
+ data << "$#{'%.2f' % item.neto}" unless item.neto.blank?
266
+ end
267
+ end
268
+
255
269
  def unpacked? # is it packed or unpacked message?
256
270
  @ack || @nak
257
271
  end
@@ -1,3 +1,3 @@
1
1
  module Extface
2
- VERSION = "0.4.6a"
2
+ VERSION = "0.4.6b"
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.6a
4
+ version: 0.4.6b
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-06-10 00:00:00.000000000 Z
11
+ date: 2015-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails