Class: Driver::Base::Fiscal
- Inherits:
-
Extface::Driver
- Object
- Extface::Driver
- Driver::Base::Fiscal
- Defined in:
- app/models/extface/driver/base/fiscal.rb
Defined Under Namespace
Classes: SaleItem
Constant Summary collapse
- NAME =
'Fiscal Device Name'.freeze
- GROUP =
Extface::FISCAL_DRIVER
- DEVELOPMENT =
driver is not ready for production (not passing all tests or has major bugs)
true
- RAW =
Select driver features
true
- PRINT =
responds to #push(data) and #pull
false
- FISCAL =
POS, slip printers
true
- REPORT =
cash registers, fiscal printers
false
Instance Method Summary collapse
- #add_comment(text = '') ⇒ Object
- #add_payment(value = nil, type_num = nil) ⇒ Object
-
#add_sale(sale_item) ⇒ Object
instance of Extface::Driver::Base::Fiscal::SaleItem.
- #add_total_modifier(fixed_value = nil, percent_ratio = nil) ⇒ Object
-
#autofix_unclosed_doc ⇒ Object
if applicable.
-
#cancel_doc_session ⇒ Object
repair interrupted doc.
- #close_fiscal_doc ⇒ Object
- #close_non_fiscal_doc ⇒ Object
- #fiscal_test ⇒ Object
- #fiscalize(bill, detailed = false) ⇒ Object
-
#handle(buffer) ⇒ Object
only transmit data that must be parsed by handler, CDR, report devices.
-
#non_fiscal_test ⇒ Object
tests.
-
#open_fiscal_doc(operator = '', password = '') ⇒ Object
fiscal wild session.
-
#open_non_fiscal_doc ⇒ Object
end.
-
#payed_recv_account(value = 0.00, payment_type_num = 0) ⇒ Object
other.
- #period_report_session(from, to, detailed = true) ⇒ Object
- #print ⇒ Object
-
#sale_and_pay_items_session(sale_items = [], operator = '', password = '') ⇒ Object
fiscal basket session of Extface::Driver::Base::Fiscal::SaleItem instances.
-
#total_payment ⇒ Object
auto calculated total default payment.
- #x_report_session ⇒ Object
-
#z_report_session ⇒ Object
reports.
Instance Method Details
#add_comment(text = '') ⇒ Object
46 |
# File 'app/models/extface/driver/base/fiscal.rb', line 46 def add_comment(text = '') raise_not_implemented end |
#add_payment(value = nil, type_num = nil) ⇒ Object
47 |
# File 'app/models/extface/driver/base/fiscal.rb', line 47 def add_payment(value = nil, type_num = nil) raise_not_implemented end |
#add_sale(sale_item) ⇒ Object
instance of Extface::Driver::Base::Fiscal::SaleItem
45 |
# File 'app/models/extface/driver/base/fiscal.rb', line 45 def add_sale(sale_item) raise_not_implemented end |
#add_total_modifier(fixed_value = nil, percent_ratio = nil) ⇒ Object
48 |
# File 'app/models/extface/driver/base/fiscal.rb', line 48 def add_total_modifier(fixed_value = nil, percent_ratio = nil) raise_not_implemented end |
#autofix_unclosed_doc ⇒ Object
if applicable
58 |
# File 'app/models/extface/driver/base/fiscal.rb', line 58 def autofix_unclosed_doc() nil end |
#cancel_doc_session ⇒ Object
repair interrupted doc
29 |
# File 'app/models/extface/driver/base/fiscal.rb', line 29 def cancel_doc_session() raise_not_implemented end |
#close_fiscal_doc ⇒ Object
50 |
# File 'app/models/extface/driver/base/fiscal.rb', line 50 def close_fiscal_doc() raise_not_implemented end |
#close_non_fiscal_doc ⇒ Object
41 |
# File 'app/models/extface/driver/base/fiscal.rb', line 41 def close_non_fiscal_doc() raise_not_implemented end |
#fiscal_test ⇒ Object
21 |
# File 'app/models/extface/driver/base/fiscal.rb', line 21 def fiscal_test() raise_not_implemented end |
#fiscalize(bill, detailed = false) ⇒ Object
77 78 79 80 81 82 83 84 85 86 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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'app/models/extface/driver/base/fiscal.rb', line 77 def fiscalize(bill, detailed = false) return nil unless bill.kind_of?(Billing::Bill) && bill.valid? operator_mapping = bill.find_operator_mapping_for(self) if detailed device.session("Fiscal Doc") do |s| s.notify "Fiscal Doc Start" s.autofix_unclosed_doc s.open_fiscal_doc(operator_mapping.try(:mapping), operator_mapping.try(:pwd)) s.notify "Register Sale" bill.charges.each do |charge| neto, percent_ratio = nil, nil, nil if modifier = charge.modifier neto = modifier.fixed_value percent_ratio = modifier.percent_ratio unless neto.present? end if charge.price.zero? #printing comments with zero charges (TODO check zero charges allowed?) s.add_comment charge.text else s.add_sale( SaleItem.new( price: charge.price.to_f, text1: charge.name, text2: charge.description, tax_group: charge.find_tax_group_mapping_for(self), #find tax group mapping by ratio , not nice qty: charge.qty.try(:to_f), neto: neto, percent_ratio: percent_ratio #TODO check format ) ) end end if global_modifier_value = bill.global_modifier_value s.notify "Register Global Modifier" s.add_total_modifier global_modifier_value.to_f end s.notify "Register Payment" bill.payments.each do |payment| s.add_payment payment.value.to_f, payment.find_payment_type_mapping_for(self) end s.notify "Close Fiscal Receipt" s.close_fiscal_doc s.notify "Fiscal Doc End" end else #not detailed device.session("Fiscal Doc") do |s| s.notify "Fiscal Doc Start" s.autofix_unclosed_doc s.open_fiscal_doc(operator_mapping.try(:mapping), operator_mapping.try(:pwd)) s.notify "Register Sale" total_modifier = nil # send payments sum, so modifier make no sence! think # if global_modifier_value = bill.global_modifier_value # s.notify "Register Global Modifier" # total_modifier = global_modifier_value.to_f # end s.add_sale( SaleItem.new( price: bill.payments_sum.to_f, #text1: bill.name, text1: '', tax_group: bill.charges.first.find_tax_group_mapping_for(self), #find tax group mapping by ratio , not nice neto: total_modifier ) ) # if global_modifier_value = bill.global_modifier_value # s.notify "Register Global Modifier" # s.add_total_modifier global_modifier_value.to_f # end s.notify "Register Payment" bill.payments.each do |payment| s.add_payment payment.value.to_f, payment.find_payment_type_mapping_for(self) end #s.total_payment #TODO fix payment and remove me s.notify "Close Fiscal Receipt" s.close_fiscal_doc s.notify "Fiscal Doc End" end end end |
#handle(buffer) ⇒ Object
only transmit data that must be parsed by handler, CDR, report devices
17 |
# File 'app/models/extface/driver/base/fiscal.rb', line 17 def handle(buffer) raise_not_implemented end |
#non_fiscal_test ⇒ Object
tests
20 |
# File 'app/models/extface/driver/base/fiscal.rb', line 20 def non_fiscal_test() raise_not_implemented end |
#open_fiscal_doc(operator = '', password = '') ⇒ Object
fiscal wild session
44 |
# File 'app/models/extface/driver/base/fiscal.rb', line 44 def open_fiscal_doc(operator = '', password = '') raise_not_implemented end |
#open_non_fiscal_doc ⇒ Object
end
39 |
# File 'app/models/extface/driver/base/fiscal.rb', line 39 def open_non_fiscal_doc() raise_not_implemented end |
#payed_recv_account(value = 0.00, payment_type_num = 0) ⇒ Object
other
56 |
# File 'app/models/extface/driver/base/fiscal.rb', line 56 def payed_recv_account(value = 0.00, payment_type_num = 0) raise_not_implemented end |
#period_report_session(from, to, detailed = true) ⇒ Object
26 |
# File 'app/models/extface/driver/base/fiscal.rb', line 26 def period_report_session(from, to, detailed = true) raise_not_implemented end |
#print ⇒ Object
40 |
# File 'app/models/extface/driver/base/fiscal.rb', line 40 def print() raise_not_implemented end |
#sale_and_pay_items_session(sale_items = [], operator = '', password = '') ⇒ Object
fiscal basket session of Extface::Driver::Base::Fiscal::SaleItem instances
53 |
# File 'app/models/extface/driver/base/fiscal.rb', line 53 def sale_and_pay_items_session(sale_items = [], operator = '', password = '') raise_not_implemented end |
#total_payment ⇒ Object
auto calculated total default payment
49 |
# File 'app/models/extface/driver/base/fiscal.rb', line 49 def total_payment() raise_not_implemented end |
#x_report_session ⇒ Object
25 |
# File 'app/models/extface/driver/base/fiscal.rb', line 25 def x_report_session() raise_not_implemented end |
#z_report_session ⇒ Object
reports
24 |
# File 'app/models/extface/driver/base/fiscal.rb', line 24 def z_report_session() raise_not_implemented end |