app/models/extface/driver/datecs/fp550.rb in extface-0.4.6f vs app/models/extface/driver/datecs/fp550.rb in extface-0.4.6g

- old
+ new

@@ -228,10 +228,22 @@ errors.add :base, "Unpermitted Command In This Mode" unless (status_1 & 0x02).zero? errors.add :base, "Field Overflow" unless (status_1 & 0x01).zero? end private + def build_sale_data(item) + "".tap() do |data| + data << item.text1 unless item.text1.blank? + data << "\x0a#{text2}" unless item.text2.blank? + data << "\t" + data << TAX_GROUPS_MAP[item.tax_group || 2] + data << ("%.2f" % item.price) + data << "*#{item.qty.to_s}" unless item.qty.blank? + data << ",#{item.percent}" unless item.percent.blank? + data << "$#{'%.2f' % item.neto}" unless item.neto.blank? + end + end def sequence_number @seq ||= 0x1f @seq += 1 @seq = 0x1f if @seq == 0x7f @@ -262,21 +274,9 @@ def ack?; !!@ack; end #should wait, response is yet to come def nak?; !!@nak; end #should retry command with same seq private - def build_sale_data(item) - "".tap() do |data| - data << item.text1 unless item.text1.blank? - data << "\x0a#{text2}" unless item.text2.blank? - data << "\t" - data << TAX_GROUPS_MAP[item.tax_group || 2] - data << ("%.2f" % item.price) - data << "*#{item.qty.to_s}" unless item.qty.blank? - data << ",#{item.percent}" unless item.percent.blank? - data << "$#{'%.2f' % item.neto}" unless item.neto.blank? - end - end def unpacked? # is it packed or unpacked message? @ack || @nak end \ No newline at end of file